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

Heinrich Schuchardt xypron.glpk at gmx.de
Tue Sep 12 08:18:29 UTC 2017


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 at 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 at 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 at 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
> 



More information about the U-Boot mailing list