[U-Boot] [PATCH v2 1/3] x86: efi: payload: Make EFI payload build again

Since commit 73c5c39 "Makefile: Drop unnecessary -dtb suffixes", EFI payload does not build anymore. This fixes the build.
Signed-off-by: Bin Meng bmeng.cn@gmail.com Reviewed-by: Simon Glass sjg@chromium.org ---
Changes in v2: None
include/efi.h | 2 +- lib/efi/efi_stub.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/efi.h b/include/efi.h index 1dbc3b7..21921f1 100644 --- a/include/efi.h +++ b/include/efi.h @@ -278,7 +278,7 @@ struct efi_priv { extern char image_base[];
/* Start and end of U-Boot image (for payload) */ -extern char _binary_u_boot_dtb_bin_start[], _binary_u_boot_dtb_bin_end[]; +extern char _binary_u_boot_bin_start[], _binary_u_boot_bin_end[];
/** * efi_get_sys_table() - Get access to the main EFI system table diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c index 8b4bb4e..1814960 100644 --- a/lib/efi/efi_stub.c +++ b/lib/efi/efi_stub.c @@ -354,9 +354,9 @@ efi_status_t efi_main(efi_handle_t image, struct efi_system_table *sys_table) /* The EFI UART won't work now, switch to a debug one */ use_uart = true;
- memcpy((void *)CONFIG_SYS_TEXT_BASE, _binary_u_boot_dtb_bin_start, - (ulong)_binary_u_boot_dtb_bin_end - - (ulong)_binary_u_boot_dtb_bin_start); + memcpy((void *)CONFIG_SYS_TEXT_BASE, _binary_u_boot_bin_start, + (ulong)_binary_u_boot_bin_end - + (ulong)_binary_u_boot_bin_start);
#ifdef DEBUG puts("EFI table at ");

There are lots of warnings when building EFI 64-bit payload.
include/asm-generic/bitops/__fls.h:17:2: warning: left shift count >= width of type if (!(word & (~0ul << 32))) { ^
In fact, U-Boot itself as EFI payload is running in 32-bit mode. So BITS_PER_LONG needs to still be 32, but EFI status codes are 64-bit when booting from 64-bit EFI. Introduce EFI_BITS_PER_LONG to bridge those status codes with U-Boot's BITS_PER_LONG.
Signed-off-by: Bin Meng bmeng.cn@gmail.com
---
Changes in v2: - Rework the patch to fix 64-bit payload boot issue
arch/x86/include/asm/types.h | 4 ---- include/efi.h | 32 ++++++++++++++++++++------------ 2 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/arch/x86/include/asm/types.h b/arch/x86/include/asm/types.h index 766617f..880dcb4 100644 --- a/arch/x86/include/asm/types.h +++ b/arch/x86/include/asm/types.h @@ -44,11 +44,7 @@ typedef __INT64_TYPE__ s64; typedef __UINT64_TYPE__ u64; #endif
-#ifdef CONFIG_EFI_STUB_64BIT -#define BITS_PER_LONG 64 -#else #define BITS_PER_LONG 32 -#endif /* Dma addresses are 32-bits wide. */
typedef u32 dma_addr_t; diff --git a/include/efi.h b/include/efi.h index 21921f1..83de2d4 100644 --- a/include/efi.h +++ b/include/efi.h @@ -27,19 +27,27 @@
struct efi_device_path;
+#define EFI_BITS_PER_LONG BITS_PER_LONG + +/* With 64-bit EFI stub, EFI_BITS_PER_LONG has to be 64 */ +#ifdef CONFIG_EFI_STUB_64BIT +#undef EFI_BITS_PER_LONG +#define EFI_BITS_PER_LONG 64 +#endif + #define EFI_SUCCESS 0 -#define EFI_LOAD_ERROR (1 | (1UL << (BITS_PER_LONG - 1))) -#define EFI_INVALID_PARAMETER (2 | (1UL << (BITS_PER_LONG - 1))) -#define EFI_UNSUPPORTED (3 | (1UL << (BITS_PER_LONG - 1))) -#define EFI_BAD_BUFFER_SIZE (4 | (1UL << (BITS_PER_LONG - 1))) -#define EFI_BUFFER_TOO_SMALL (5 | (1UL << (BITS_PER_LONG - 1))) -#define EFI_NOT_READY (6 | (1UL << (BITS_PER_LONG - 1))) -#define EFI_DEVICE_ERROR (7 | (1UL << (BITS_PER_LONG - 1))) -#define EFI_WRITE_PROTECTED (8 | (1UL << (BITS_PER_LONG - 1))) -#define EFI_OUT_OF_RESOURCES (9 | (1UL << (BITS_PER_LONG - 1))) -#define EFI_NOT_FOUND (14 | (1UL << (BITS_PER_LONG - 1))) -#define EFI_ACCESS_DENIED (15 | (1UL << (BITS_PER_LONG - 1))) -#define EFI_SECURITY_VIOLATION (26 | (1UL << (BITS_PER_LONG - 1))) +#define EFI_LOAD_ERROR (1 | (1UL << (EFI_BITS_PER_LONG - 1))) +#define EFI_INVALID_PARAMETER (2 | (1UL << (EFI_BITS_PER_LONG - 1))) +#define EFI_UNSUPPORTED (3 | (1UL << (EFI_BITS_PER_LONG - 1))) +#define EFI_BAD_BUFFER_SIZE (4 | (1UL << (EFI_BITS_PER_LONG - 1))) +#define EFI_BUFFER_TOO_SMALL (5 | (1UL << (EFI_BITS_PER_LONG - 1))) +#define EFI_NOT_READY (6 | (1UL << (EFI_BITS_PER_LONG - 1))) +#define EFI_DEVICE_ERROR (7 | (1UL << (EFI_BITS_PER_LONG - 1))) +#define EFI_WRITE_PROTECTED (8 | (1UL << (EFI_BITS_PER_LONG - 1))) +#define EFI_OUT_OF_RESOURCES (9 | (1UL << (EFI_BITS_PER_LONG - 1))) +#define EFI_NOT_FOUND (14 | (1UL << (EFI_BITS_PER_LONG - 1))) +#define EFI_ACCESS_DENIED (15 | (1UL << (EFI_BITS_PER_LONG - 1))) +#define EFI_SECURITY_VIOLATION (26 | (1UL << (EFI_BITS_PER_LONG - 1)))
typedef unsigned long efi_status_t; typedef u64 efi_physical_addr_t;

Hi Simon,
On Thu, Aug 25, 2016 at 4:47 PM, Bin Meng bmeng.cn@gmail.com wrote:
There are lots of warnings when building EFI 64-bit payload.
include/asm-generic/bitops/__fls.h:17:2: warning: left shift count >= width of type if (!(word & (~0ul << 32))) { ^
In fact, U-Boot itself as EFI payload is running in 32-bit mode. So BITS_PER_LONG needs to still be 32, but EFI status codes are 64-bit when booting from 64-bit EFI. Introduce EFI_BITS_PER_LONG to bridge those status codes with U-Boot's BITS_PER_LONG.
Signed-off-by: Bin Meng bmeng.cn@gmail.com
Changes in v2:
- Rework the patch to fix 64-bit payload boot issue
arch/x86/include/asm/types.h | 4 ---- include/efi.h | 32 ++++++++++++++++++++------------ 2 files changed, 20 insertions(+), 16 deletions(-)
Please have a look at this.
Regards, Bin

On 25 August 2016 at 02:47, Bin Meng bmeng.cn@gmail.com wrote:
There are lots of warnings when building EFI 64-bit payload.
include/asm-generic/bitops/__fls.h:17:2: warning: left shift count >= width of type if (!(word & (~0ul << 32))) { ^
In fact, U-Boot itself as EFI payload is running in 32-bit mode. So BITS_PER_LONG needs to still be 32, but EFI status codes are 64-bit when booting from 64-bit EFI. Introduce EFI_BITS_PER_LONG to bridge those status codes with U-Boot's BITS_PER_LONG.
Signed-off-by: Bin Meng bmeng.cn@gmail.com
Changes in v2:
- Rework the patch to fix 64-bit payload boot issue
arch/x86/include/asm/types.h | 4 ---- include/efi.h | 32 ++++++++++++++++++++------------ 2 files changed, 20 insertions(+), 16 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

On Tue, Aug 30, 2016 at 3:38 AM, Simon Glass sjg@chromium.org wrote:
On 25 August 2016 at 02:47, Bin Meng bmeng.cn@gmail.com wrote:
There are lots of warnings when building EFI 64-bit payload.
include/asm-generic/bitops/__fls.h:17:2: warning: left shift count >= width of type if (!(word & (~0ul << 32))) { ^
In fact, U-Boot itself as EFI payload is running in 32-bit mode. So BITS_PER_LONG needs to still be 32, but EFI status codes are 64-bit when booting from 64-bit EFI. Introduce EFI_BITS_PER_LONG to bridge those status codes with U-Boot's BITS_PER_LONG.
Signed-off-by: Bin Meng bmeng.cn@gmail.com
Changes in v2:
- Rework the patch to fix 64-bit payload boot issue
arch/x86/include/asm/types.h | 4 ---- include/efi.h | 32 ++++++++++++++++++++------------ 2 files changed, 20 insertions(+), 16 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
applied to u-boot-x86, thanks!

This introduces two board defconfig files for generating EFI 32-bit and 64-bit payloads, to run on QEMU x86 target.
With these in place, hopefully buildman will catch any build error with EFI payload support on x86.
Signed-off-by: Bin Meng bmeng.cn@gmail.com Reviewed-by: Simon Glass sjg@chromium.org
---
Changes in v2: - Add maintainter entry for the two boards
board/emulation/qemu-x86/MAINTAINERS | 2 ++ configs/qemu-x86_efi_payload32_defconfig | 48 +++++++++++++++++++++++++++++++ configs/qemu-x86_efi_payload64_defconfig | 49 ++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 configs/qemu-x86_efi_payload32_defconfig create mode 100644 configs/qemu-x86_efi_payload64_defconfig
diff --git a/board/emulation/qemu-x86/MAINTAINERS b/board/emulation/qemu-x86/MAINTAINERS index ea4dd19..54dc2c5 100644 --- a/board/emulation/qemu-x86/MAINTAINERS +++ b/board/emulation/qemu-x86/MAINTAINERS @@ -4,3 +4,5 @@ S: Maintained F: board/emulation/qemu-x86/ F: include/configs/qemu-x86.h F: configs/qemu-x86_defconfig +F: configs/qemu-x86_efi_payload32_defconfig +F: configs/qemu-x86_efi_payload64_defconfig diff --git a/configs/qemu-x86_efi_payload32_defconfig b/configs/qemu-x86_efi_payload32_defconfig new file mode 100644 index 0000000..eb9a110 --- /dev/null +++ b/configs/qemu-x86_efi_payload32_defconfig @@ -0,0 +1,48 @@ +CONFIG_X86=y +CONFIG_DEFAULT_DEVICE_TREE="qemu-x86_i440fx" +CONFIG_SMP=y +CONFIG_MAX_CPUS=2 +CONFIG_FIT=y +CONFIG_BOOTSTAGE=y +CONFIG_BOOTSTAGE_REPORT=y +CONFIG_HUSH_PARSER=y +CONFIG_CMD_CPU=y +# CONFIG_CMD_IMLS is not set +# CONFIG_CMD_FLASH is not set +CONFIG_CMD_SF=y +CONFIG_CMD_SPI=y +CONFIG_CMD_USB=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_CMD_DHCP=y +# CONFIG_CMD_NFS is not set +CONFIG_CMD_PING=y +CONFIG_CMD_TIME=y +CONFIG_CMD_QFW=y +CONFIG_CMD_BOOTSTAGE=y +CONFIG_CMD_EXT2=y +CONFIG_CMD_EXT4=y +CONFIG_CMD_EXT4_WRITE=y +CONFIG_CMD_FAT=y +CONFIG_CMD_FS_GENERIC=y +CONFIG_OF_CONTROL=y +CONFIG_REGMAP=y +CONFIG_SYSCON=y +CONFIG_CPU=y +CONFIG_SPI_FLASH=y +CONFIG_SPI_FLASH_GIGADEVICE=y +CONFIG_SPI_FLASH_MACRONIX=y +CONFIG_SPI_FLASH_WINBOND=y +CONFIG_DM_ETH=y +CONFIG_E1000=y +CONFIG_DM_PCI=y +CONFIG_DM_RTC=y +CONFIG_SYS_NS16550=y +CONFIG_TIMER=y +CONFIG_USB=y +CONFIG_DM_USB=y +CONFIG_VIDEO_VESA=y +CONFIG_FRAMEBUFFER_SET_VESA_MODE=y +CONFIG_FRAMEBUFFER_VESA_MODE_111=y +CONFIG_USE_PRIVATE_LIBGCC=y +CONFIG_EFI=y +CONFIG_EFI_STUB=y diff --git a/configs/qemu-x86_efi_payload64_defconfig b/configs/qemu-x86_efi_payload64_defconfig new file mode 100644 index 0000000..be3c913 --- /dev/null +++ b/configs/qemu-x86_efi_payload64_defconfig @@ -0,0 +1,49 @@ +CONFIG_X86=y +CONFIG_DEFAULT_DEVICE_TREE="qemu-x86_i440fx" +CONFIG_SMP=y +CONFIG_MAX_CPUS=2 +CONFIG_FIT=y +CONFIG_BOOTSTAGE=y +CONFIG_BOOTSTAGE_REPORT=y +CONFIG_HUSH_PARSER=y +CONFIG_CMD_CPU=y +# CONFIG_CMD_IMLS is not set +# CONFIG_CMD_FLASH is not set +CONFIG_CMD_SF=y +CONFIG_CMD_SPI=y +CONFIG_CMD_USB=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_CMD_DHCP=y +# CONFIG_CMD_NFS is not set +CONFIG_CMD_PING=y +CONFIG_CMD_TIME=y +CONFIG_CMD_QFW=y +CONFIG_CMD_BOOTSTAGE=y +CONFIG_CMD_EXT2=y +CONFIG_CMD_EXT4=y +CONFIG_CMD_EXT4_WRITE=y +CONFIG_CMD_FAT=y +CONFIG_CMD_FS_GENERIC=y +CONFIG_OF_CONTROL=y +CONFIG_REGMAP=y +CONFIG_SYSCON=y +CONFIG_CPU=y +CONFIG_SPI_FLASH=y +CONFIG_SPI_FLASH_GIGADEVICE=y +CONFIG_SPI_FLASH_MACRONIX=y +CONFIG_SPI_FLASH_WINBOND=y +CONFIG_DM_ETH=y +CONFIG_E1000=y +CONFIG_DM_PCI=y +CONFIG_DM_RTC=y +CONFIG_SYS_NS16550=y +CONFIG_TIMER=y +CONFIG_USB=y +CONFIG_DM_USB=y +CONFIG_VIDEO_VESA=y +CONFIG_FRAMEBUFFER_SET_VESA_MODE=y +CONFIG_FRAMEBUFFER_VESA_MODE_111=y +CONFIG_USE_PRIVATE_LIBGCC=y +CONFIG_EFI=y +CONFIG_EFI_STUB=y +CONFIG_EFI_STUB_64BIT=y

On Thu, Aug 25, 2016 at 4:47 PM, Bin Meng bmeng.cn@gmail.com wrote:
This introduces two board defconfig files for generating EFI 32-bit and 64-bit payloads, to run on QEMU x86 target.
With these in place, hopefully buildman will catch any build error with EFI payload support on x86.
Signed-off-by: Bin Meng bmeng.cn@gmail.com Reviewed-by: Simon Glass sjg@chromium.org
Changes in v2:
- Add maintainter entry for the two boards
board/emulation/qemu-x86/MAINTAINERS | 2 ++ configs/qemu-x86_efi_payload32_defconfig | 48 +++++++++++++++++++++++++++++++ configs/qemu-x86_efi_payload64_defconfig | 49 ++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 configs/qemu-x86_efi_payload32_defconfig create mode 100644 configs/qemu-x86_efi_payload64_defconfig
applied to u-boot-x86, thanks!

On Thu, Aug 25, 2016 at 4:47 PM, Bin Meng bmeng.cn@gmail.com wrote:
Since commit 73c5c39 "Makefile: Drop unnecessary -dtb suffixes", EFI payload does not build anymore. This fixes the build.
Signed-off-by: Bin Meng bmeng.cn@gmail.com Reviewed-by: Simon Glass sjg@chromium.org
Changes in v2: None
include/efi.h | 2 +- lib/efi/efi_stub.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
applied to u-boot-x86, thanks!
participants (2)
-
Bin Meng
-
Simon Glass