x86: efi: payload: Various fixes
cover x86: efi: payload: Various fixes
This series includes 3 patches that were previously sent to ML but not applied, along with some new patches with various fixes on efi x86 payload support.
For [01: efi.h: Do not use config options] and [02: x86: Change __kernel_size_t conditionals to use compiler provided defines], the changes are mainly adding some comments to describe the changes in more details.
This series is available at u-boot-x86/efi2-working for testing.
Alexander Graf (1):
efi.h: Do not use config options
Bin Meng (5):
x86: Change __kernel_size_t conditionals to use compiler provided
defines
efi: stub: Move the use_uart assignment immediately after
exit_boot_services() call
x86: efi-x86_payload: Enable PRE_CONSOLE_BUFFER
x86: efi: payload: Count in conventional memory above 4GB in DRAM bank
cmd: efi: Fix wrong memory descriptor end address
arch/x86/cpu/efi/payload.c | 3 +-- arch/x86/include/asm/posix_types.h | 3 ++- cmd/efi.c | 2 +- configs/efi-x86_payload32_defconfig | 2 ++ configs/efi-x86_payload64_defconfig | 2 ++ include/efi.h | 24 +++++++++++------------- lib/efi/Makefile | 4 ++-- lib/efi/efi_stub.c | 6 +++--- 8 files changed, 24 insertions(+), 22 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/6 efi.h: Do not use config options
From: Alexander Graf <[email protected]>
Currently efi.h determines a few bits of its environment according to config options. This falls apart with the efi stub support which may result in efi.h getting pulled into the stub as well as real U-Boot code. In that case, one may be 32bit while the other one is 64bit.
This patch changes the conditionals to use compiler provided defines instead. That way we always adhere to the build environment we're in and the definitions adjust automatically.
---
include/efi.h | 24 +++++++++++------------- lib/efi/Makefile | 4 ++-- 2 files changed, 13 insertions(+), 15 deletions(-)
include/efi.h +11 -13
@@ -19,12 +19,19 @@#include <linux/string.h> #include <linux/types.h> -#if CONFIG_EFI_STUB_64BIT || (!defined(CONFIG_EFI_STUB ) && defined(__x86_64__)) -/* EFI uses the Microsoft ABI which is not the default for GCC */ +/* +* EFI on x86_64 uses the Microsoft ABI which is not the default for GCC. +* +* There are two scenarios for EFI on x86_64: building a 64-bit EFI stub +* codes (CONFIG_EFI_STUB_64BIT) and building a 64-bit U-Boot (CONFIG_X86_64). +* Either needs to be properly built with the '-m64' compiler flag, and hence +* it is enough to only check the compiler provided define __x86_64__ here. +*/ +#ifdef __x86_64__#define EFIAPI __attribute__((ms_abi))#else #define EFIAPI asmlinkage -#endif +#endif /* __x86_64__ */ struct efi_device_path ;
@@ -32,16 +39,7 @@ typedef struct {u8 b[16 ]; } efi_guid_t; -#define EFI_BITS_PER_LONG BITS_PER_LONG - -/* -* With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64. EFI_STUB is set -* in lib/efi/Makefile, when building the stub. -*/ -#if defined(CONFIG_EFI_STUB_64BIT ) && defined(EFI_STUB ) -#undef EFI_BITS_PER_LONG -#define EFI_BITS_PER_LONG 64 -#endif +#define EFI_BITS_PER_LONG (sizeof(long) * 8)/* Bit mask for EFI status code with error */ #define EFI_ERROR_MASK (1UL << (EFI_BITS_PER_LONG - 1))
lib/efi/Makefile +2 -2
@@ -7,11 +7,11 @@ obj-$(CONFIG_EFI_STUB) += efi_info.o CFLAGS_REMOVE_efi_stub.o := -mregparm=3 \ $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32) -CFLAGS_efi_stub.o := -fpic -fshort-wchar -DEFI_STUB \ +CFLAGS_efi_stub.o := -fpic -fshort-wchar \ $(if $(CONFIG_EFI_STUB_64BIT),-m64) CFLAGS_REMOVE_efi.o := -mregparm=3 \ $(if $(CONFIG_EFI_STUB_64BIT),-march=i386 -m32) -CFLAGS_efi.o := -fpic -fshort-wchar -DEFI_STUB \ +CFLAGS_efi.o := -fpic -fshort-wchar \ $(if $(CONFIG_EFI_STUB_64BIT),-m64) extra-$(CONFIG_EFI_STUB) += efi_stub.o efi.o
Signature · 1 line
2.7.4
PATCH 2/6 x86: Change __kernel_size_t conditionals to use compiler provided defines
In reply to Bin MengSince commit bb0bb91cf0aa ("efi_stub: Use efi_uintn_t"), EFI x86 64-bit payload does not work anymore. The call to GetMemoryMap() in efi_stub.c fails with return code EFI_INVALID_PARAMETER. Since the payload itself is still 32-bit U-Boot, efi_uintn_t gets wrongly interpreted as int, but it should actually be long in a 64-bit EFI environment.
This changes the x86 __kernel_size_t conditionals to use compiler provided defines instead. That way we always adhere to the build environment we're in and the definitions adjust automatically.
---
arch/x86/include/asm/posix_types.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/include/asm/posix_types.h +2 -1
@@ -16,7 +16,8 @@ typedef int __kernel_pid_t;typedef unsigned short __kernel_ipc_pid_t ;typedef unsigned short __kernel_uid_t ;typedef unsigned short __kernel_gid_t ; -#if CONFIG_IS_ENABLED (X86_64 ) +/* checking against __x86_64__ covers both 64-bit EFI stub and 64-bit U-Boot */ +#if defined(__x86_64__)typedef unsigned long __kernel_size_t ;typedef long __kernel_ssize_t ;#else
Signature · 1 line
2.7.4
PATCH 3/6 efi: stub: Move the use_uart assignment immediately after exit_boot_services() call
In reply to Bin MengThe use_uart assignment should follow immediately after the call to exit_boot_services(), in case we want some debug output after that.
---
lib/efi/efi_stub.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/efi/efi_stub.c +3 -3
@@ -361,14 +361,14 @@ efi_status_t EFIAPI efi_main(efi_handle_t image, } } +/* The EFI UART won't work now, switch to a debug one */ + use_uart = true; + map.version = version; map.desc_size = desc_size;add_entry_addr (priv,EFIET_MEMORY_MAP , &map,sizeof (map), desc, size);add_entry_addr (priv,EFIET_END ,NULL ,0 ,0 ,0 ); -/* The EFI UART won't work now, switch to a debug one */ - use_uart = true; -memcpy ((void *)CONFIG_SYS_TEXT_BASE , _binary_u_boot_bin_start, (ulong )_binary_u_boot_bin_end - (ulong )_binary_u_boot_bin_start);
Signature · 1 line
2.7.4
PATCH 4/6 x86: efi-x86_payload: Enable PRE_CONSOLE_BUFFER
In reply to Bin MengEnable PRE_CONSOLE_BUFFER so that the full boot output can be viewed on the video console for the EFI payload.
---
configs/efi-x86_payload32_defconfig | 2 ++ configs/efi-x86_payload64_defconfig | 2 ++ 2 files changed, 4 insertions(+)
configs/efi-x86_payload32_defconfig +2 -0
@@ -6,6 +6,8 @@ CONFIG_FIT=y CONFIG_FIT_SIGNATURE=y CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="root=/dev/sdb3 init=/sbin/init rootwait ro" +CONFIG_PRE_CONSOLE_BUFFER=y +CONFIG_PRE_CON_BUF_ADDR=0x100000 CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_LAST_STAGE_INIT=y
configs/efi-x86_payload64_defconfig +2 -0
@@ -6,6 +6,8 @@ CONFIG_FIT=y CONFIG_FIT_SIGNATURE=y CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="root=/dev/sdb3 init=/sbin/init rootwait ro" +CONFIG_PRE_CONSOLE_BUFFER=y +CONFIG_PRE_CON_BUF_ADDR=0x100000 CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_LAST_STAGE_INIT=y
Signature · 1 line
2.7.4
PATCH 5/6 x86: efi: payload: Count in conventional memory above 4GB in DRAM bank
In reply to Bin MengAt present in dram_init_banksize() it ignores conventional memory below 4GB. This leads to wrong DRAM size is printed during boot. Remove such limitation.
---
arch/x86/cpu/efi/payload.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/cpu/efi/payload.c +1 -2
@@ -109,11 +109,10 @@ int dram_init_banksize(void) desc < end && num_banks <CONFIG_NR_DRAM_BANKS ; desc = efi_get_next_mem_desc(map, desc)) {/* -* We only use conventional memory below 4GB, and ignore +* We only use conventional memory and ignore * anything less than 1MB. */ if (desc->type !=EFI_CONVENTIONAL_MEMORY || - desc->physical_start >=1ULL <<32 || (desc->num_pages <<EFI_PAGE_SHIFT ) <1 <<20 )continue ; gd->bd->bi_dram[num_banks].start = desc->physical_start;
Signature · 1 line
2.7.4
PATCH 6/6 cmd: efi: Fix wrong memory descriptor end address
In reply to Bin MengEach entry of the EFI memory descriptors occupies map->desc_size, not sizeof(struct efi_mem_desc).
---
cmd/efi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
cmd/efi.c +1 -1
@@ -83,7 +83,7 @@ void *efi_build_mem_table(struct efi_entry_memmap *map, int size, bool skip_bs) prev =NULL ; addr =0 ; dest = base; - end = base + count; + end = (struct efi_mem_desc *)((ulong )base + count * map->desc_size);for (desc = base; desc < end; desc =efi_get_next_mem_desc (map, desc)) {bool merge = true;int type = desc->type;
Signature · 1 line
2.7.4
PATCH 3/6 efi: stub: Move the use_uart assignment immediately after exit_boot_services() call
In reply to Bin MengQuoted 8 lines · Bin Meng
The
use_uartassignment should follow immediately after the call toexit_boot_services(), in case we want some debug output after that.Signed-off-by Bin Meng <[email protected]>---
lib/efi/efi_stub.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
PATCH 4/6 x86: efi-x86_payload: Enable PRE_CONSOLE_BUFFER
In reply to Bin MengQuoted 9 lines · Bin Meng
Enable
PRE_CONSOLE_BUFFERso that the full boot output can be viewed on the video console for the EFI payload.Signed-off-by Bin Meng <[email protected]>---
configs/efi-x86_payload32_defconfig | 2 ++ configs/efi-x86_payload64_defconfig | 2 ++ 2 files changed, 4 insertions(+)
PATCH 5/6 x86: efi: payload: Count in conventional memory above 4GB in DRAM bank
In reply to Bin MengQuoted 9 lines · Bin Meng
At present in
dram_init_banksize()it ignores conventional memory below 4GB. This leads to wrong DRAM size is printed during boot. Remove such limitation.Signed-off-by Bin Meng <[email protected]>---
arch/x86/cpu/efi/payload.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
PATCH 6/6 cmd: efi: Fix wrong memory descriptor end address
In reply to Bin MengQuoted 9 lines · Bin Meng
Each entry of the EFI memory descriptors occupies
map->desc_size, notsizeof(struct efi_mem_desc).Signed-off-by Bin Meng <[email protected]>---
cmd/efi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
cover x86: efi: payload: Various fixes
In reply to Bin MengHi Simon,
Quoted 4 lines · Bin Meng
This series includes 3 patches that were previously sent to ML but not applied, along with some new patches with various fixes on efi x86 payload support.
I see your have reviewed the other 3 patches. Thanks a lot!
Quoted 5 lines
For [01:
efi.h: Do not use config options] and [02: x86: Change__kernel_size_tconditionals to use compiler provided defines], the changes are mainly adding some comments to describe the changes in more details.
For patch [01] & [02], does the added comments look good to you?
Quoted 2 lines
This series is available at u-boot-x86/efi2-working for testing.
Regards,
Bin
PATCH 1/6 efi.h: Do not use config options
In reply to Bin MengQuoted 17 lines · Bin Meng
From: Alexander Graf <[email protected]>
Currently
efi.hdetermines a few bits of its environment according to config options. This falls apart with the efi stub support which may result inefi.hgetting pulled into the stub as well as real U-Boot code. In that case, one may be 32bit while the other one is 64bit.This patch changes the conditionals to use compiler provided defines instead. That way we always adhere to the build environment we're in and the definitions adjust automatically.
Signed-off-by Alexander Graf <[email protected]>Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>[bmeng: added some comments to describe the __x86_64__ check]Signed-off-by Bin Meng <[email protected]>
Quoted 5 lines
---
include/efi.h | 24 +++++++++++------------- lib/efi/Makefile | 4 ++-- 2 files changed, 13 insertions(+), 15 deletions(-)
PATCH 2/6 x86: Change __kernel_size_t conditionals to use compiler provided defines
In reply to Bin MengQuoted 11 lines · Bin Meng
Since commit
bb0bb91cf0aa("efi_stub: Useefi_uintn_t"), EFI x86 64-bit payload does not work anymore. The call toGetMemoryMap()inefi_stub.cfails with return codeEFI_INVALID_PARAMETER. Since the payload itself is still 32-bit U-Boot,efi_uintn_tgets wrongly interpreted as int, but it should actually be long in a 64-bit EFI environment.This changes the x86
__kernel_size_tconditionals to use compiler provided defines instead. That way we always adhere to the build environment we're in and the definitions adjust automatically.
Quoted 6 lines
Fixes bb0bb91cf0aa ("efi_stub: Use efi_uintn_t")Signed-off-by Bin Meng <[email protected]>---
arch/x86/include/asm/posix_types.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
PATCH 1/6 efi.h: Do not use config options
In reply to Simon GlassQuoted 18 lines · Simon Glass
Quoted 17 lines · Bin Meng
From: Alexander Graf <[email protected]>
Currently
efi.hdetermines a few bits of its environment according to config options. This falls apart with the efi stub support which may result inefi.hgetting pulled into the stub as well as real U-Boot code. In that case, one may be 32bit while the other one is 64bit.This patch changes the conditionals to use compiler provided defines instead. That way we always adhere to the build environment we're in and the definitions adjust automatically.
Signed-off-by Alexander Graf <[email protected]>Reviewed-by Bin Meng <[email protected]>Tested-by Bin Meng <[email protected]>[bmeng: added some comments to describe the __x86_64__ check]Signed-off-by Bin Meng <[email protected]>
Quoted 7 lines
Quoted 5 lines
---
include/efi.h | 24 +++++++++++------------- lib/efi/Makefile | 4 ++-- 2 files changed, 13 insertions(+), 15 deletions(-)Reviewed-by Simon Glass <[email protected]>
applied to u-boot-x86, thanks!
PATCH 2/6 x86: Change __kernel_size_t conditionals to use compiler provided defines
In reply to Simon GlassQuoted 12 lines · Simon Glass
Quoted 11 lines · Bin Meng
Since commit
bb0bb91cf0aa("efi_stub: Useefi_uintn_t"), EFI x86 64-bit payload does not work anymore. The call toGetMemoryMap()inefi_stub.cfails with return codeEFI_INVALID_PARAMETER. Since the payload itself is still 32-bit U-Boot,efi_uintn_tgets wrongly interpreted as int, but it should actually be long in a 64-bit EFI environment.This changes the x86
__kernel_size_tconditionals to use compiler provided defines instead. That way we always adhere to the build environment we're in and the definitions adjust automatically.
Quoted 8 lines
Quoted 6 lines
Fixes bb0bb91cf0aa ("efi_stub: Use efi_uintn_t")Signed-off-by Bin Meng <[email protected]>---
arch/x86/include/asm/posix_types.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Reviewed-by Simon Glass <[email protected]>
applied to u-boot-x86, thanks!
PATCH 3/6 efi: stub: Move the use_uart assignment immediately after exit_boot_services() call
In reply to Simon GlassQuoted 11 lines · Simon Glass
Quoted 8 lines · Bin Meng
The
use_uartassignment should follow immediately after the call toexit_boot_services(), in case we want some debug output after that.Signed-off-by Bin Meng <[email protected]>---
lib/efi/efi_stub.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)Reviewed-by Simon Glass <[email protected]>
applied to u-boot-x86, thanks!
PATCH 4/6 x86: efi-x86_payload: Enable PRE_CONSOLE_BUFFER
In reply to Simon GlassQuoted 4 lines · Simon Glass
Quoted 3 lines · Bin Meng
Enable
PRE_CONSOLE_BUFFERso that the full boot output can be viewed on the video console for the EFI payload.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Bin Meng <[email protected]>---
configs/efi-x86_payload32_defconfig | 2 ++ configs/efi-x86_payload64_defconfig | 2 ++ 2 files changed, 4 insertions(+)Reviewed-by Simon Glass <[email protected]>
applied to u-boot-x86, thanks!
PATCH 5/6 x86: efi: payload: Count in conventional memory above 4GB in DRAM bank
In reply to Simon GlassQuoted 3 lines · Simon Glass
Quoted 2 lines · Bin Meng
At present in
dram_init_banksize()it ignores conventional memory below 4GB. This leads to wrong DRAM size is printed during boot.
This should be "above" 4GB.
Quoted 9 lines
Quoted 7 lines
Remove such limitation.
Signed-off-by Bin Meng <[email protected]>---
arch/x86/cpu/efi/payload.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)Reviewed-by Simon Glass <[email protected]>
Fixed the commit message, and
applied to u-boot-x86, thanks!
PATCH 6/6 cmd: efi: Fix wrong memory descriptor end address
In reply to Simon GlassQuoted 4 lines · Simon Glass
Quoted 3 lines · Bin Meng
Each entry of the EFI memory descriptors occupies
map->desc_size, notsizeof(struct efi_mem_desc).
Quoted 8 lines
Quoted 6 lines
Signed-off-by Bin Meng <[email protected]>---
cmd/efi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Reviewed-by Simon Glass <[email protected]>
applied to u-boot-x86, thanks!