Re: [U-Boot] [RFC 1/1] efi_loader: fix building of helloworld.efi on x86_64

On 09/12/2017 05:00 AM, Bin Meng wrote:
Hi Heinrich,
On Sun, Sep 10, 2017 at 4:55 PM, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
Variable EFI_LDS is set based on CONFIG_EFI_STUB_64BIT. It influences which lds script is used for compiling helloworld.efi. This results in building helloworld.efi failing on x86_64 if CONFIG_EFI_STUB_64BIT is not set. CONFIG_EFI_STUB_64BIT is only visible if EFI_STUB is selected. We should be able to compile a 64bit helloworld.efi irrespective of EFI_STUB.
With the patch the bitness of the efi build is taken from the architecture choice.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
For proper testing https://lists.denx.de/pipermail/u-boot/2017-September/305184.html must be fixed.
So I send this as RFC.
Sorry I missed this. This does not go to the U-Boot ML. Did you intend to keep the discussion among us?
CC: U-Boot Mailing List u-boot@lists.denx.de
Alex, do you remember why CONFIG_EFI_STUB_64BIT was introduced in the first place.
The CONFIG_EFI_STUB_64BIT was introduced to support booting from a 64-bit EFI BIOS.
Would you ever use a stub with a different bitness than U-Boot?
Yes, for example U-Boot x86 32-bit to boot a 64-bit EFI payload.
My understanding is that the EFI stub is used if U-Boot is loaded as an EFI application.
It has nothing to do with the EFI application or driver loaded by U-boot's bootefi command, which I assume you reference as "to boot a 64-bit EFI payload".
A stub with different bitness than U-Boot would be needed if we wanted to load 64 bit U-Boot as a 32 bit EFI application or a 32 bit U-Boot as a 64 bit EFI application. Is this required in any scenario?
Regards
Heinrich
Regards
Heinrich
arch/x86/config.mk | 12 ++++++------ lib/efi/Kconfig | 18 ------------------ 2 files changed, 6 insertions(+), 24 deletions(-)
diff --git a/arch/x86/config.mk b/arch/x86/config.mk index fe8639aef6..a87dd33837 100644 --- a/arch/x86/config.mk +++ b/arch/x86/config.mk @@ -93,16 +93,16 @@ endif
ifneq ($(CONFIG_EFI_STUB)$(CONFIG_CMD_BOOTEFI_HELLO_COMPILE)$(CONFIG_CMD_SELFTEST_COMPILE),)
-ifneq ($(CONFIG_EFI_STUB_64BIT),) -EFI_LDS := elf_x86_64_efi.lds -EFI_CRT0 := crt0_x86_64_efi.o -EFI_RELOC := reloc_x86_64_efi.o -EFI_TARGET := --target=efi-app-ia32 -else +ifeq ($(IS_32BIT),y) EFI_LDS := elf_ia32_efi.lds EFI_CRT0 := crt0_ia32_efi.o EFI_RELOC := reloc_ia32_efi.o EFI_TARGET := --target=efi-app-x86_64 +else +EFI_LDS := elf_x86_64_efi.lds +EFI_CRT0 := crt0_x86_64_efi.o +EFI_RELOC := reloc_x86_64_efi.o +EFI_TARGET := --target=efi-app-ia32 endif
endif diff --git a/lib/efi/Kconfig b/lib/efi/Kconfig index 919e314a0c..8c0bc2a529 100644 --- a/lib/efi/Kconfig +++ b/lib/efi/Kconfig @@ -34,21 +34,3 @@ config EFI_RAM_SIZE use. U-Boot allocates this from EFI on start-up (along with a few other smaller amounts) and it can never be increased after that. It is used as the RAM size in with U-Boot.
-choice
prompt "EFI 32/64-bit selection"
depends on EFI_STUB
help
EFI does not support mixing 32-bit and 64-bit modes. This is a
significant problem because it means that you must build a stub with
the correct type for EFI to load it correctly. If you are using
32-bit EFI, select 32-bit here, else select 64-bit. Failure to do
this may produce no error message - it just won't start!
-config EFI_STUB_32BIT
bool "Produce a stub for running with 32-bit EFI"
-config EFI_STUB_64BIT
bool "Produce a stub for running with 64-bit EFI"
-endchoice
Regards, Bin

On 12.09.17 10:18, Heinrich Schuchardt wrote:
On 09/12/2017 05:00 AM, Bin Meng wrote:
Hi Heinrich,
On Sun, Sep 10, 2017 at 4:55 PM, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
Variable EFI_LDS is set based on CONFIG_EFI_STUB_64BIT. It influences which lds script is used for compiling helloworld.efi. This results in building helloworld.efi failing on x86_64 if CONFIG_EFI_STUB_64BIT is not set. CONFIG_EFI_STUB_64BIT is only visible if EFI_STUB is selected. We should be able to compile a 64bit helloworld.efi irrespective of EFI_STUB.
With the patch the bitness of the efi build is taken from the architecture choice.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
For proper testing https://lists.denx.de/pipermail/u-boot/2017-September/305184.html must be fixed.
So I send this as RFC.
Sorry I missed this. This does not go to the U-Boot ML. Did you intend to keep the discussion among us?
CC: U-Boot Mailing List u-boot@lists.denx.de
Alex, do you remember why CONFIG_EFI_STUB_64BIT was introduced in the first place.
The CONFIG_EFI_STUB_64BIT was introduced to support booting from a 64-bit EFI BIOS.
Would you ever use a stub with a different bitness than U-Boot?
Yes, for example U-Boot x86 32-bit to boot a 64-bit EFI payload.
My understanding is that the EFI stub is used if U-Boot is loaded as an EFI application.
It has nothing to do with the EFI application or driver loaded by U-boot's bootefi command, which I assume you reference as "to boot a 64-bit EFI payload".
A stub with different bitness than U-Boot would be needed if we wanted to load 64 bit U-Boot as a 32 bit EFI application or a 32 bit U-Boot as a 64 bit EFI application. Is this required in any scenario?
That's what Bin just explained, no? Running U-Boot on x86 as 32bit binary was/is quite common, but usually you're running on a 64bit UEFI implementation.
Or you want to run 64-bit U-Boot on an older Mac which only has 32bit UEFI...
Alex

Hi Heinrich,
On Tue, Sep 12, 2017 at 4:18 PM, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
On 09/12/2017 05:00 AM, Bin Meng wrote:
Hi Heinrich,
On Sun, Sep 10, 2017 at 4:55 PM, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
Variable EFI_LDS is set based on CONFIG_EFI_STUB_64BIT. It influences which lds script is used for compiling helloworld.efi. This results in building helloworld.efi failing on x86_64 if CONFIG_EFI_STUB_64BIT is not set. CONFIG_EFI_STUB_64BIT is only visible if EFI_STUB is selected. We should be able to compile a 64bit helloworld.efi irrespective of EFI_STUB.
With the patch the bitness of the efi build is taken from the architecture choice.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
For proper testing https://lists.denx.de/pipermail/u-boot/2017-September/305184.html must be fixed.
So I send this as RFC.
Sorry I missed this. This does not go to the U-Boot ML. Did you intend to keep the discussion among us?
CC: U-Boot Mailing List u-boot@lists.denx.de
Alex, do you remember why CONFIG_EFI_STUB_64BIT was introduced in the first place.
The CONFIG_EFI_STUB_64BIT was introduced to support booting from a 64-bit EFI BIOS.
Would you ever use a stub with a different bitness than U-Boot?
Yes, for example U-Boot x86 32-bit to boot a 64-bit EFI payload.
My understanding is that the EFI stub is used if U-Boot is loaded as an EFI application.
Maybe there is some confusion. I was referring to the EFI payload as documented in doc/README.efi. Are you referring to the same EFI application in that doc?
It has nothing to do with the EFI application or driver loaded by U-boot's bootefi command, which I assume you reference as "to boot a 64-bit EFI payload".
A stub with different bitness than U-Boot would be needed if we wanted to load 64 bit U-Boot as a 32 bit EFI application or a 32 bit U-Boot as a 64 bit EFI application. Is this required in any scenario?
Regards, Bin

On 09/12/2017 03:24 PM, Bin Meng wrote:
Hi Heinrich,
On Tue, Sep 12, 2017 at 4:18 PM, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
On 09/12/2017 05:00 AM, Bin Meng wrote:
Hi Heinrich,
On Sun, Sep 10, 2017 at 4:55 PM, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
Variable EFI_LDS is set based on CONFIG_EFI_STUB_64BIT. It influences which lds script is used for compiling helloworld.efi. This results in building helloworld.efi failing on x86_64 if CONFIG_EFI_STUB_64BIT is not set. CONFIG_EFI_STUB_64BIT is only visible if EFI_STUB is selected. We should be able to compile a 64bit helloworld.efi irrespective of EFI_STUB.
With the patch the bitness of the efi build is taken from the architecture choice.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
For proper testing https://lists.denx.de/pipermail/u-boot/2017-September/305184.html must be fixed.
So I send this as RFC.
Sorry I missed this. This does not go to the U-Boot ML. Did you intend to keep the discussion among us?
CC: U-Boot Mailing List u-boot@lists.denx.de
Alex, do you remember why CONFIG_EFI_STUB_64BIT was introduced in the first place.
The CONFIG_EFI_STUB_64BIT was introduced to support booting from a 64-bit EFI BIOS.
Would you ever use a stub with a different bitness than U-Boot?
Yes, for example U-Boot x86 32-bit to boot a 64-bit EFI payload.
My understanding is that the EFI stub is used if U-Boot is loaded as an EFI application.
Maybe there is some confusion. I was referring to the EFI payload as documented in doc/README.efi. Are you referring to the same EFI application in that doc?
Ok, "U-Boot on EFI".
So I guess we have to separate the $LDS_EFI used for the stub from the one used for helloworld.efi.
It has nothing to do with the EFI application or driver loaded by U-boot's bootefi command, which I assume you reference as "to boot a 64-bit EFI payload".
A stub with different bitness than U-Boot would be needed if we wanted to load 64 bit U-Boot as a 32 bit EFI application or a 32 bit U-Boot as a 64 bit EFI application. Is this required in any scenario?
Regards, Bin
participants (3)
-
Alexander Graf
-
Bin Meng
-
Heinrich Schuchardt