Re: [v2 PATCH 1/5] efi: Move arm-stub to a common file

From: Heinrich Schuchardt
Date: Sat Apr 25 2020 - 05:48:14 EST


On 4/21/20 9:19 PM, Palmer Dabbelt wrote:
> On Mon, 13 Apr 2020 14:29:03 PDT (-0700), Atish Patra wrote:
>> Most of the arm-stub code is written in an architecture independent
>> manner.
>> As a result, RISC-V can reuse most of the arm-stub code.
>>
>> Rename the arm-stub.c to efi-stub.c so that ARM, ARM64 and RISC-V can
>> use it.
>> This patch doesn't introduce any functional changes.
>>
>> Signed-off-by: Atish Patra <atish.patra@xxxxxxx>

The code being moved has some problems:

The ARM stub ignores the return value of efi_setup_gop().

drivers/firmware/efi/libstub/arm-stub.c and
drivers/firmware/efi/libstub/x86-stub.c both call LocateHandle() before
calling efi_setup_gop(). I think this should be moved to efi_setup_gop().

I guess the issues can be addressed in some follow up patch.

Best regards

Heinrich

>
> We'll need a bunch of Acked-bys for these, but I'm happy to take this in my
> tree.
>
>> ---
>> Âarch/arm/KconfigÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ |Â 2 +-
>> Âarch/arm64/KconfigÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ |Â 2 +-
>> Âdrivers/firmware/efi/KconfigÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ |Â 4 ++--
>> Âdrivers/firmware/efi/libstub/MakefileÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ | 12 ++++++------
>> Â.../firmware/efi/libstub/{arm-stub.c => efi-stub.c}Â |Â 0
>> Â5 files changed, 10 insertions(+), 10 deletions(-)
>> Ârename drivers/firmware/efi/libstub/{arm-stub.c => efi-stub.c} (100%)
>>
>> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
>> index 66a04f6f4775..165987aa5bcd 100644
>> --- a/arch/arm/Kconfig
>> +++ b/arch/arm/Kconfig
>> @@ -1954,7 +1954,7 @@ config EFI
>> ÂÂÂÂ select UCS2_STRING
>> ÂÂÂÂ select EFI_PARAMS_FROM_FDT
>> ÂÂÂÂ select EFI_STUB
>> -ÂÂÂ select EFI_ARMSTUB
>> +ÂÂÂ select EFI_GENERIC_STUB
>> ÂÂÂÂ select EFI_RUNTIME_WRAPPERS
>> ÂÂÂÂ ---help---
>> ÂÂÂÂÂÂ This option provides support for runtime services provided
>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>> index 40fb05d96c60..32d818c5ccda 100644
>> --- a/arch/arm64/Kconfig
>> +++ b/arch/arm64/Kconfig
>> @@ -1785,7 +1785,7 @@ config EFI
>> ÂÂÂÂ select EFI_PARAMS_FROM_FDT
>> ÂÂÂÂ select EFI_RUNTIME_WRAPPERS
>> ÂÂÂÂ select EFI_STUB
>> -ÂÂÂ select EFI_ARMSTUB
>> +ÂÂÂ select EFI_GENERIC_STUB
>> ÂÂÂÂ default y
>> ÂÂÂÂ help
>> ÂÂÂÂÂÂ This option provides support for runtime services provided
>> diff --git a/drivers/firmware/efi/Kconfig b/drivers/firmware/efi/Kconfig
>> index 613828d3f106..2a2b2b96a1dc 100644
>> --- a/drivers/firmware/efi/Kconfig
>> +++ b/drivers/firmware/efi/Kconfig
>> @@ -106,12 +106,12 @@ config EFI_PARAMS_FROM_FDT
>> Âconfig EFI_RUNTIME_WRAPPERS
>> ÂÂÂÂ bool
>>
>> -config EFI_ARMSTUB
>> +config EFI_GENERIC_STUB
>> ÂÂÂÂ bool
>>
>> Âconfig EFI_ARMSTUB_DTB_LOADER
>> ÂÂÂÂ bool "Enable the DTB loader"
>> -ÂÂÂ depends on EFI_ARMSTUB
>> +ÂÂÂ depends on EFI_GENERIC_STUB
>> ÂÂÂÂ default y
>> ÂÂÂÂ help
>> ÂÂÂÂÂÂ Select this config option to add support for the dtb= command
>> diff --git a/drivers/firmware/efi/libstub/Makefile
>> b/drivers/firmware/efi/libstub/Makefile
>> index 094eabdecfe6..d590504541f6 100644
>> --- a/drivers/firmware/efi/libstub/Makefile
>> +++ b/drivers/firmware/efi/libstub/Makefile
>> @@ -23,7 +23,7 @@ cflags-$(CONFIG_ARM)ÂÂÂÂÂÂÂ := $(subst
>> $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \
>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ -fno-builtin -fpic \
>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ $(call cc-option,-mno-single-pic-base)
>>
>> -cflags-$(CONFIG_EFI_ARMSTUB)ÂÂÂ += -I$(srctree)/scripts/dtc/libfdt
>> +cflags-$(CONFIG_EFI_GENERIC_STUB)ÂÂÂ += -I$(srctree)/scripts/dtc/libfdt
>>
>> ÂKBUILD_CFLAGSÂÂÂÂÂÂÂÂÂÂÂ := $(cflags-y) -DDISABLE_BRANCH_PROFILING \
>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ -include
>> $(srctree)/drivers/firmware/efi/libstub/hidden.h \
>> @@ -45,13 +45,13 @@ lib-yÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ := efi-stub-helper.o gop.o
>> secureboot.o tpm.o \
>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ skip_spaces.o lib-cmdline.o lib-ctype.o
>>
>> Â# include the stub's generic dependencies from lib/ when building for
>> ARM/arm64
>> -arm-deps-y := fdt_rw.c fdt_ro.c fdt_wip.c fdt.c fdt_empty_tree.c
>> fdt_sw.c
>> +efi-deps-y := fdt_rw.c fdt_ro.c fdt_wip.c fdt.c fdt_empty_tree.c
>> fdt_sw.c
>>
>> Â$(obj)/lib-%.o: $(srctree)/lib/%.c FORCE
>> ÂÂÂÂ $(call if_changed_rule,cc_o_c)
>>
>> -lib-$(CONFIG_EFI_ARMSTUB)ÂÂÂ += arm-stub.o fdt.o string.o \
>> -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ $(patsubst %.c,lib-%.o,$(arm-deps-y))
>> +lib-$(CONFIG_EFI_GENERIC_STUB)ÂÂÂÂÂÂÂ += efi-stub.o fdt.o string.o \
>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ $(patsubst %.c,lib-%.o,$(efi-deps-y))
>>
>> Âlib-$(CONFIG_ARM)ÂÂÂÂÂÂÂ += arm32-stub.o
>> Âlib-$(CONFIG_ARM64)ÂÂÂÂÂÂÂ += arm64-stub.o
>> @@ -73,8 +73,8 @@ CFLAGS_arm64-stub.oÂÂÂÂÂÂÂ :=
>> -DTEXT_OFFSET=$(TEXT_OFFSET)
>> Â# a verification pass to see if any absolute relocations exist in any
>> of the
>> Â# object files.
>> Â#
>> -extra-$(CONFIG_EFI_ARMSTUB)ÂÂÂ := $(lib-y)
>> -lib-$(CONFIG_EFI_ARMSTUB)ÂÂÂ := $(patsubst %.o,%.stub.o,$(lib-y))
>> +extra-$(CONFIG_EFI_GENERIC_STUB)ÂÂÂ := $(lib-y)
>> +lib-$(CONFIG_EFI_GENERIC_STUB)ÂÂÂ := $(patsubst %.o,%.stub.o,$(lib-y))
>>
>> ÂSTUBCOPY_FLAGS-$(CONFIG_ARM64)ÂÂÂ += --prefix-alloc-sections=.init \
>> ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ --prefix-symbols=__efistub_
>> diff --git a/drivers/firmware/efi/libstub/arm-stub.c
>> b/drivers/firmware/efi/libstub/efi-stub.c
>> similarity index 100%
>> rename from drivers/firmware/efi/libstub/arm-stub.c
>> rename to drivers/firmware/efi/libstub/efi-stub.c
>
> Reviewed-by: Palmer Dabbelt <palmerdabbelt@xxxxxxxxxx>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>