diff mbox series

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

Message ID 20200413212907.29244-2-atish.patra@wdc.com (mailing list archive)
State New, archived
Headers show
Series Add UEFI support for RISC-V | expand

Commit Message

Atish Patra April 13, 2020, 9:29 p.m. UTC
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@wdc.com>
---
 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%)

Comments

Palmer Dabbelt April 21, 2020, 7:19 p.m. UTC | #1
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@wdc.com>

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@google.com>
Heinrich Schuchardt April 25, 2020, 9:47 a.m. UTC | #2
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@wdc.com>

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@google.com>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
Ard Biesheuvel April 25, 2020, 9:54 a.m. UTC | #3
On Sat, 25 Apr 2020 at 11:48, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> 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@wdc.com>
>
> 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.
>

Yes, I suppose this could be improved a bit, so patches welcome, as usual :-)
But I don't think it has any bearing on a patch that renames the file.
diff mbox series

Patch

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