arm: Support building as an EFI app
Subsystems (8)
v4 cover arm: Support building as an EFI app
The original x86 EFI-app was written back in 2015, about a year before the EFI-loader was introduced. At that point, ARM mostly used U-Boot and FIT (Flat Image Tree).
Today, sadly, there are a few efforts to re-invent FIT poorly, to cater to more primitive boot-environments than U-Boot. One justification for this re-invetion has been that EDK2 did not support FIT.
EDK2 does now support FIT but only for the firmware stage. Even then, vendors tend to use their own forks, so any new features are slow to make it into the market.
EDK2 also supports the ext4 filesystem, but many devices don't include that feature, so most distros make use of FAT for storing their boot files. Since FAT is not journalled, it is not particularly reliable in the face of reset, power failure, etc.
As an interim measure, we can use U-Boot as an EFI app running on top of whatever EDK2 fork is in use. This allows use of modern features such as FIT and filesystems other than FAT. So far this only supports x86, but recent ARM laptops are making use of EFI too.
So this series adds an EFI app for 64-bit ARM.
Note: Since U-Boot does not support EFI's GOP 'blt-only' mode, the vidconsole does not operate, but it can still be used, since EDK2 handles drawing instead of U-Boot. As a result, the U-Boot logo is not shown.
Changes in v4:
- Got back to depending on HAVE_TEXT_BASE
- Drop the confusing comment about position-independent code
- Put EFI_LDS back as it is required for building helloword.efi etc.
- Put the config.mk changes in the board directory
Changes in v3:
- Use the same copyright message as the original pci_rom.c file
- Rewrite the commit message
- Drop setting of EFI_LDS and rely on the CONFIG_SYS_LDSCRIPT value
Changes in v2:
- Depend on CONFIG_EFI_APP instead
- Drop change to u-boot-elf rule
- Mention '64-bit ARM' here, rather than just 'ARM'
- Drop the word 'Sadly'
- Mention '64-bit ARM' here, rather than just 'ARM'
- Add new patch to rename VENDOR_EFI to ARCH_EFI
- Update to use ARCH_EFI instead of VENDOR_EFI
- Mention '64-bit ARM' here, rather than just 'ARM'
- Mention '64-bit ARM' here, rather than just 'ARM'
- Rework the commit message to clarify the relationship to link-scripts
- Expand commit message to explains that EFI_APP skips relocation
- Mention '64-bit ARM' here, rather than just 'ARM'
- Document the x86 field better and add a comment for ARM too
- Mention '64-bit ARM' here, rather than just 'ARM'
- Put the EFI-app case first in setup_mon_len(), for clarity
- Use ARCH_EFI instead of VENDOR_EFI
- Merge the linker-script rules into Kconfig in this patch
- Drop patch 'Select the EFI linker script for the app'
Simon Glass (29):
Makefile: Avoid using TEXT_BASE with the EFI APP
video: Move vesa_setup_video_priv() into its own file
video: Use a local mode_info struct in the EFI driver
lib: Provide fdtdec_get_pci_bar32() only with PCI enabled
efi: Rename app and payload to include x86
efi: Allow board/efi Kconfig to be used outside x86
efi: x86: Move EFI SDRAM-handling into a common file
treewide: Rename VENDOR_EFI to ARCH_EFI
efi: x86: Rework VENDOR_EFI option to permit other archs
efi: x86: Allow setting the global_data pointer with EFI
efi: Tidy up setup of global_data
efi: Rename ImageBase to image_base
efi: lmb: Avoid access to _start
efi: arm: Don't do the EL2 switch when running under EFI
efi: arm: Avoid allocating page tables when running under EFI
efi: arm: Avoid enabling caches when running under EFI
efi: arm: Implement access to global_data for EFI
efi: arm: Omit the ARM start-up code in the EFI app
efi: arm: Drop exception-level code when running as EFI app
efi: arm: x86: Allow use of the EFI table in the app
efi: arm: Disable --gc-sections for the app
efi: arm: Drop startup code from the app
efi: arm: Adjust how the monitor length is calculated
efi: arm: Provide startup and relocation code
efi: Generate the app as a shared library
efi: arm: Disable STATIC_RELA for the EFI app
efi: arm: Use EFI flags for all compilation with the app
efi: arm: Simplify the crt0 file and update link script
efi: arm: Add an EFI app for arm64
Kconfig | 1 +
MAINTAINERS | 4 +-
Makefile | 7 +-
arch/Kconfig | 2 +
arch/arm/Kconfig | 6 +-
arch/arm/Makefile | 2 +
arch/arm/config.mk | 12 ++
arch/arm/cpu/armv8/Makefile | 4 +-
arch/arm/cpu/armv8/config.mk | 2 +-
arch/arm/dts/efi-arm_app.dts | 31 +++++
arch/arm/include/asm/global_data.h | 18 ++-
arch/arm/lib/Makefile | 12 +-
arch/arm/lib/bootm.c | 7 +-
arch/arm/lib/cache.c | 3 +
arch/arm/lib/crt0_aarch64_efi.S | 158 ++++----------------------
arch/arm/lib/crt0_arm_efi.S | 2 +-
arch/arm/lib/elf_aarch64_efi.lds | 49 +++++---
arch/riscv/lib/crt0_riscv_efi.S | 30 ++---
arch/x86/Kconfig | 4 +-
arch/x86/cpu/efi/Makefile | 1 -
arch/x86/include/asm/global_data.h | 9 +-
board/efi/Kconfig | 44 ++++++-
board/efi/efi-arm_app/Kconfig | 19 ++++
board/efi/efi-arm_app/MAINTAINERS | 13 +++
board/efi/efi-arm_app/Makefile | 5 +
board/efi/efi-arm_app/board.c | 18 +++
board/efi/efi-arm_app/config.mk | 4 +
board/efi/efi-arm_app/efi-arm_app.env | 11 ++
board/efi/efi-x86_payload/Kconfig | 2 +-
common/board_f.c | 6 +-
common/board_r.c | 9 +-
configs/efi-arm_app64_defconfig | 51 +++++++++
configs/efi-x86_app32_defconfig | 4 +-
configs/efi-x86_app64_defconfig | 4 +-
configs/efi-x86_payload32_defconfig | 4 +-
configs/efi-x86_payload64_defconfig | 4 +-
doc/develop/uefi/u-boot_on_efi.rst | 17 +--
drivers/pci/pci_rom.c | 32 ------
drivers/video/Makefile | 2 +
drivers/video/efi.c | 1 +
drivers/video/vesa_helper.c | 41 +++++++
include/asm-generic/sections.h | 2 +
include/vesa.h | 2 +
lib/efi/Kconfig | 2 +-
lib/efi/Makefile | 1 +
lib/efi/efi_app.c | 13 ++-
{arch/x86/cpu => lib}/efi/sdram.c | 1 -
lib/fdtdec.c | 2 +
lib/lmb.c | 3 +-
49 files changed, 431 insertions(+), 250 deletions(-)
create mode 100644 arch/arm/dts/efi-arm_app.dts
create mode 100644 board/efi/efi-arm_app/Kconfig
create mode 100644 board/efi/efi-arm_app/MAINTAINERS
create mode 100644 board/efi/efi-arm_app/Makefile
create mode 100644 board/efi/efi-arm_app/board.c
create mode 100644 board/efi/efi-arm_app/config.mk
create mode 100644 board/efi/efi-arm_app/efi-arm_app.env
create mode 100644 configs/efi-arm_app64_defconfig
create mode 100644 drivers/video/vesa_helper.c
rename {arch/x86/cpu => lib}/efi/sdram.c (94%)Signature · 1 line
2.43.0
PATCH v4 1/29 Makefile: Avoid using TEXT_BASE with the EFI APP
This value is not available with the EFI app. Add a condition to avoid introducing errors when linking.
---
Changes in v4:
- Got back to depending on HAVE_TEXT_BASE
Changes in v2:
- Depend on CONFIG_EFI_APP instead
- Drop change to u-boot-elf rule
Makefile | 2 ++ 1 file changed, 2 insertions(+)
Makefile +2 -0
@@ -1050,8 +1050,10 @@ LDFLAGS_u-boot += -z notext $(call ld-option,--apply-dynamic-relocs) LDFLAGS_u-boot += --build-id=none ifeq ($(CONFIG_ARC)$(CONFIG_NIOS2)$(CONFIG_X86)$(CONFIG_XTENSA),) +ifdef CONFIG_HAVE_TEXT_BASE LDFLAGS_u-boot += -Ttext $(CONFIG_TEXT_BASE) endif +endif # make the checker run with the right architecture CHECKFLAGS += --arch=$(ARCH)
Signature · 1 line
2.43.0
Re: [PATCH v4 01/29] Makefile: Avoid using TEXT_BASE with the EFI APP
Quoted 4 lines · Simon Glass
This value is not available with the EFI app. Add a condition to avoid introducing errors when linking.
Signed-off-by Simon Glass <[email protected]>
Signature · 1 line
Tom
PATCH v4 2/29 video: Move vesa_setup_video_priv() into its own file
In reply to Simon GlassThis helper is used by the EFI driver and we would like to use that on ARM. Move the helper function into its own file, separate from PCI ROMs, which are an x86 thing.
Add a forward declaration for struct udevice so that the header can be included directly.
---
(no changes since v3)
Changes in v3:
- Use the same copyright message as the original pci_rom.c file
drivers/pci/pci_rom.c | 32 ----------------------------- drivers/video/Makefile | 2 ++ drivers/video/vesa_helper.c | 41 +++++++++++++++++++++++++++++++++++++ include/vesa.h | 2 ++ 4 files changed, 45 insertions(+), 32 deletions(-) create mode 100644 drivers/video/vesa_helper.c
drivers/pci/pci_rom.c +0 -32
@@ -334,38 +334,6 @@ err:return ret; } -int vesa_setup_video_priv (struct vesa_mode_info *vesa,u64 fb, -struct video_priv *uc_priv, -struct video_uc_plat *plat) -{ -if (!vesa->x_resolution) -return log_msg_ret ("No x resolution" , -ENXIO ); - uc_priv->xsize = vesa->x_resolution; - uc_priv->ysize = vesa->y_resolution; - uc_priv->line_length = vesa->bytes_per_scanline; -switch (vesa->bits_per_pixel) { -case 32 : -case 24 : - uc_priv->bpix =VIDEO_BPP32 ; -break ; -case 16 : - uc_priv->bpix =VIDEO_BPP16 ; -break ; -default : -return -EPROTONOSUPPORT ; - } - -/* Use double buffering if enabled */ -if (IS_ENABLED (CONFIG_VIDEO_COPY ) && plat->base) - plat->copy_base = fb; -else - plat->base = fb; -log_debug ("base = %lx, copy_base = %lx\n" , plat->base, plat->copy_base); - plat->size = vesa->bytes_per_scanline * vesa->y_resolution; - -return 0 ; -} -int vesa_setup_video (struct udevice *dev,int (*int15_handler)(void )) {struct video_uc_plat *plat =dev_get_uclass_plat (dev);
drivers/video/Makefile +2 -0
@@ -27,6 +27,8 @@ obj-$(CONFIG_$(PHASE_)SIMPLE_PANEL) += simple_panel.o obj-$(CONFIG_VIDEO_LOGO) += u_boot_logo.o obj-$(CONFIG_$(PHASE_)BMP) += bmp.o +obj-y += vesa_helper.o + endif obj-$(CONFIG_BACKLIGHT_LM3533) += lm3533_backlight.o
drivers/video/vesa_helper.c new file +41 -0
41 lines not on this page · raw message
include/vesa.h +2 -0
@@ -10,6 +10,8 @@#ifndef _VESA_H#define _VESA_H +struct udevice ; +/* these structs are for input from and output to OF */ struct __packed vesa_screen_info {u8 display_type;/* 0=NONE, 1= analog, 2=digital */
Signature · 1 line
2.43.0
PATCH v4 3/29 video: Use a local mode_info struct in the EFI driver
In reply to Simon GlassThere is no need to use the global struct provided by PCI. Declare a local structure instead, so this can be used on ARM without including support for PCI ROMs.
---
(no changes since v1)
drivers/video/efi.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/efi.c +1 -0
@@ -183,6 +183,7 @@ static int efi_video_probe(struct udevice *dev) {struct video_uc_plat *plat =dev_get_uclass_plat (dev);struct video_priv *uc_priv =dev_get_uclass_priv (dev); +struct vesa_state mode_info;struct vesa_mode_info *vesa = &mode_info.vesa;u64 fb;int ret;
Signature · 1 line
2.43.0
Re: [PATCH v4 03/29] video: Use a local mode_info struct in the EFI driver
Quoted 3 lines · Simon Glass
There is no need to use the global struct provided by PCI. Declare a local structure instead, so this can be used on ARM without including support for PCI ROMs.
Honestly this solution is so obvious I assumed it wouldn't work when I was hacking on this stuff heh
Quoted 2 lines
Signed-off-by Simon Glass <[email protected]>
Quoted 19 lines
---
(no changes since v1)
drivers/video/efi.c | 1 + 1 file changed, 1 insertion(+)drivers/video/efi.c +1
-0@@ -183,6 +183,7 @@ static int efi_video_probe(struct udevice *dev) {struct video_uc_plat *plat =dev_get_uclass_plat (dev);struct video_priv *uc_priv =dev_get_uclass_priv (dev); +struct vesa_state mode_info;struct vesa_mode_info *vesa = &mode_info.vesa;u64 fb;int ret;
Signature · 1 line
Caleb (they/them)
PATCH v4 4/29 lib: Provide fdtdec_get_pci_bar32() only with PCI enabled
In reply to Simon GlassThis function calls dm_pci_read_bar32() which is only available if PCI is enabled. Add this condition here too, so that the EFI app can build without needing --gc-sections
---
(no changes since v1)
lib/fdtdec.c | 2 ++ 1 file changed, 2 insertions(+)
lib/fdtdec.c +2 -0
@@ -248,6 +248,7 @@ int fdtdec_get_pci_vendev(const void *blob, int node, u16 *vendor, u16 *device)return -ENOENT ; } +#ifdef CONFIG_PCI int fdtdec_get_pci_bar32 (const struct udevice *dev,struct fdt_pci_addr *addr,u32 *bar) {
@@ -264,6 +265,7 @@ int fdtdec_get_pci_bar32(const struct udevice *dev, struct fdt_pci_addr *addr, return 0; } +#endif int fdtdec_get_pci_bus_range (const void *blob,int node,struct fdt_resource *res)
Signature · 1 line
2.43.0
PATCH v4 5/29 efi: Rename app and payload to include x86
In reply to Simon GlassSince we plan to support the EFI app and payload on 64-bit ARM too, rename the x86 target.
Adjust the Kconfig rules to allow non-x86 builds to be added.
---
(no changes since v2)
Changes in v2:
- Mention '64-bit ARM' here, rather than just 'ARM'
board/efi/Kconfig | 12 ++++++++---- board/efi/efi-x86_payload/Kconfig | 2 +- configs/efi-x86_app32_defconfig | 2 +- configs/efi-x86_app64_defconfig | 2 +- configs/efi-x86_payload32_defconfig | 2 +- configs/efi-x86_payload64_defconfig | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-)
board/efi/Kconfig +8 -4
@@ -4,7 +4,7 @@ choice prompt "Mainboard model" optional -config TARGET_EFI_APP32 +config TARGET_EFI_X86_APP32 bool "32-bit efi application" select EFI_APP help
@@ -13,17 +13,17 @@ config TARGET_EFI_APP32 takes over once the RAM, video and CPU are fully running. U-Boot is loaded as an application from EFI. -config TARGET_EFI_APP64 +config TARGET_EFI_X86_APP64 bool "64-bit efi application" select EFI_APP - select X86_64 + select X86_64 if X86 help This target is used for running U-Boot on top of EFI in 64-bit mode. In this case EFI does the early initialisation, and U-Boot takes over once the RAM, video and CPU are fully running. U-Boot is loaded as an application from EFI. -config TARGET_EFI_PAYLOAD +config TARGET_EFI_X86_PAYLOAD bool "efi payload" help This target is used for running U-Boot on top of EFI. In
@@ -33,7 +33,11 @@ config TARGET_EFI_PAYLOAD endchoice +if X86 + source "board/efi/efi-x86_app/Kconfig" source "board/efi/efi-x86_payload/Kconfig" endif + +endif
board/efi/efi-x86_payload/Kconfig +1 -1
@@ -1,4 +1,4 @@ -if TARGET_EFI_PAYLOAD +if TARGET_EFI_X86_PAYLOAD config SYS_BOARD default "efi-x86_payload"
configs/efi-x86_app32_defconfig +1 -1
@@ -5,7 +5,7 @@ CONFIG_DEFAULT_DEVICE_TREE="efi-x86_app" CONFIG_DEBUG_UART_BASE=0x0 CONFIG_DEBUG_UART_CLOCK=0 CONFIG_VENDOR_EFI=y -CONFIG_TARGET_EFI_APP32=y +CONFIG_TARGET_EFI_X86_APP32=y CONFIG_DEBUG_UART=y CONFIG_EFI=y CONFIG_FIT=y
configs/efi-x86_app64_defconfig +1 -1
@@ -6,7 +6,7 @@ CONFIG_DEBUG_UART_BASE=0x0 CONFIG_DEBUG_UART_CLOCK=0 CONFIG_X86_RUN_64BIT=y CONFIG_VENDOR_EFI=y -CONFIG_TARGET_EFI_APP64=y +CONFIG_TARGET_EFI_X86_APP64=y CONFIG_DEBUG_UART=y CONFIG_EFI=y CONFIG_EFI_APP_64BIT=y
configs/efi-x86_payload32_defconfig +1 -1
@@ -4,7 +4,7 @@ CONFIG_ENV_SIZE=0x1000 CONFIG_DEFAULT_DEVICE_TREE="efi-x86_payload" CONFIG_PRE_CON_BUF_ADDR=0x100000 CONFIG_VENDOR_EFI=y -CONFIG_TARGET_EFI_PAYLOAD=y +CONFIG_TARGET_EFI_X86_PAYLOAD=y CONFIG_EFI=y CONFIG_EFI_STUB=y CONFIG_FIT=y
configs/efi-x86_payload64_defconfig +1 -1
@@ -4,7 +4,7 @@ CONFIG_ENV_SIZE=0x1000 CONFIG_DEFAULT_DEVICE_TREE="efi-x86_payload" CONFIG_PRE_CON_BUF_ADDR=0x100000 CONFIG_VENDOR_EFI=y -CONFIG_TARGET_EFI_PAYLOAD=y +CONFIG_TARGET_EFI_X86_PAYLOAD=y CONFIG_EFI=y CONFIG_EFI_STUB=y CONFIG_EFI_STUB_64BIT=y
Signature · 1 line
2.43.0
PATCH v4 6/29 efi: Allow board/efi Kconfig to be used outside x86
In reply to Simon GlassSo far only x86 supports the EFI app. ARM is going the same way, so allow these options to be enabled for 64-bit ARM too.
---
(no changes since v2)
Changes in v2:
- Drop the word 'Sadly'
- Mention '64-bit ARM' here, rather than just 'ARM'
arch/Kconfig | 2 ++ arch/x86/Kconfig | 1 - board/efi/Kconfig | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-)
arch/Kconfig +2 -0
@@ -544,6 +544,8 @@ source "arch/Kconfig.nxp" endif +source "board/efi/Kconfig" + source "board/keymile/Kconfig" choice
arch/x86/Kconfig +0 -1
@@ -100,7 +100,6 @@ source "board/advantech/Kconfig" source "board/congatec/Kconfig" source "board/coreboot/Kconfig" source "board/dfi/Kconfig" -source "board/efi/Kconfig" source "board/emulation/Kconfig" source "board/google/Kconfig" source "board/intel/Kconfig"
board/efi/Kconfig +2 -2
@@ -1,5 +1,7 @@ if VENDOR_EFI +if X86 + choice prompt "Mainboard model" optional
@@ -33,8 +35,6 @@ config TARGET_EFI_X86_PAYLOAD endchoice -if X86 - source "board/efi/efi-x86_app/Kconfig" source "board/efi/efi-x86_payload/Kconfig"
Signature · 1 line
2.43.0
PATCH v4 7/29 efi: x86: Move EFI SDRAM-handling into a common file
In reply to Simon GlassThis code is not actually x86-specific, so move it into the lib/efi dir where other archs can use it.
Drop inclusion of the unnecessary x86-specific header.
---
(no changes since v1)
arch/x86/cpu/efi/Makefile | 1 -
lib/efi/Makefile | 1 +
{arch/x86/cpu => lib}/efi/sdram.c | 1 -
3 files changed, 1 insertion(+), 2 deletions(-)
rename {arch/x86/cpu => lib}/efi/sdram.c (94%)arch/x86/cpu/efi/Makefile +0 -1
@@ -4,7 +4,6 @@ ifdef CONFIG_EFI_APP obj-y += app.o -obj-y += sdram.o endif ifdef CONFIG_EFI_STUB
lib/efi/Makefile +1 -0
@@ -3,6 +3,7 @@ # (C) Copyright 2015 Google, Inc obj-$(CONFIG_EFI_APP) += efi_app.o efi.o efi_app_init.o efi_vars.o efi_dtb.o +obj-$(CONFIG_EFI_APP) += sdram.o obj-$(CONFIG_EFI_STUB) += efi_info.o ifeq ($(CONFIG_ARM64),y)
lib/efi/sdram.c renamed from arch/x86/cpu/efi/sdram.c +0 -1
@@ -6,7 +6,6 @@#include <efi.h> #include <init.h> #include <asm/global_data.h> -#include <asm/u-boot-x86.h> DECLARE_GLOBAL_DATA_PTR ;
Signature · 1 line
2.43.0
PATCH v4 8/29 treewide: Rename VENDOR_EFI to ARCH_EFI
In reply to Simon GlassThe 'vendor' concept comes from arch/x86. Rather than letting this spread around the tree, rename it to ARCH_EFI.
While EFI is not quite an architecture in the strict sense, it is similar to sandbox in that it sits somewhat above the CPU architecture.
---
Ideas for a better name are welcome.
(no changes since v2)
Changes in v2:
- Add new patch to rename VENDOR_EFI to ARCH_EFI
arch/arm/lib/crt0_aarch64_efi.S | 2 +- arch/arm/lib/crt0_arm_efi.S | 2 +- arch/riscv/lib/crt0_riscv_efi.S | 2 +- arch/x86/Kconfig | 2 +- board/efi/Kconfig | 2 +- configs/efi-x86_app32_defconfig | 2 +- configs/efi-x86_app64_defconfig | 2 +- configs/efi-x86_payload32_defconfig | 2 +- configs/efi-x86_payload64_defconfig | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-)
arch/arm/lib/crt0_aarch64_efi.S +1 -1
@@ -66,7 +66,7 @@ extra_header_fields: .long _start - ImageBase /* SizeOfHeaders */ .long 0 /* CheckSum */ .short IMAGE_SUBSYSTEM_EFI_APPLICATION /* Subsystem */ -#if CONFIG_VENDOR_EFI +#if CONFIG_ARCH_EFI .short 0 /* DllCharacteristics */ #else .short IMAGE_DLLCHARACTERISTICS_NX_COMPAT
arch/arm/lib/crt0_arm_efi.S +1 -1
@@ -65,7 +65,7 @@ extra_header_fields: .long _start - image_base /* SizeOfHeaders */ .long 0 /* CheckSum */ .short IMAGE_SUBSYSTEM_EFI_APPLICATION /* Subsystem */ -#if CONFIG_VENDOR_EFI +#if CONFIG_ARCH_EFI .short 0 /* DllCharacteristics */ #else .short IMAGE_DLLCHARACTERISTICS_NX_COMPAT
arch/riscv/lib/crt0_riscv_efi.S +1 -1
@@ -96,7 +96,7 @@ extra_header_fields: .long _start - ImageBase /* SizeOfHeaders */ .long 0 /* CheckSum */ .short IMAGE_SUBSYSTEM_EFI_APPLICATION /* Subsystem */ -#if CONFIG_VENDOR_EFI +#if CONFIG_ARCH_EFI .short 0 /* DllCharacteristics */ #else .short IMAGE_DLLCHARACTERISTICS_NX_COMPAT
arch/x86/Kconfig +1 -1
@@ -65,7 +65,7 @@ config VENDOR_COREBOOT config VENDOR_DFI bool "dfi" -config VENDOR_EFI +config ARCH_EFI bool "efi" config VENDOR_EMULATION
board/efi/Kconfig +1 -1
@@ -1,4 +1,4 @@ -if VENDOR_EFI +if ARCH_EFI if X86
configs/efi-x86_app32_defconfig +1 -1
@@ -4,7 +4,7 @@ CONFIG_ENV_SIZE=0x1000 CONFIG_DEFAULT_DEVICE_TREE="efi-x86_app" CONFIG_DEBUG_UART_BASE=0x0 CONFIG_DEBUG_UART_CLOCK=0 -CONFIG_VENDOR_EFI=y +CONFIG_ARCH_EFI=y CONFIG_TARGET_EFI_X86_APP32=y CONFIG_DEBUG_UART=y CONFIG_EFI=y
configs/efi-x86_app64_defconfig +1 -1
@@ -5,7 +5,7 @@ CONFIG_DEFAULT_DEVICE_TREE="efi-x86_app" CONFIG_DEBUG_UART_BASE=0x0 CONFIG_DEBUG_UART_CLOCK=0 CONFIG_X86_RUN_64BIT=y -CONFIG_VENDOR_EFI=y +CONFIG_ARCH_EFI=y CONFIG_TARGET_EFI_X86_APP64=y CONFIG_DEBUG_UART=y CONFIG_EFI=y
configs/efi-x86_payload32_defconfig +1 -1
@@ -3,7 +3,7 @@ CONFIG_NR_DRAM_BANKS=8 CONFIG_ENV_SIZE=0x1000 CONFIG_DEFAULT_DEVICE_TREE="efi-x86_payload" CONFIG_PRE_CON_BUF_ADDR=0x100000 -CONFIG_VENDOR_EFI=y +CONFIG_ARCH_EFI=y CONFIG_TARGET_EFI_X86_PAYLOAD=y CONFIG_EFI=y CONFIG_EFI_STUB=y
configs/efi-x86_payload64_defconfig +1 -1
@@ -3,7 +3,7 @@ CONFIG_NR_DRAM_BANKS=8 CONFIG_ENV_SIZE=0x1000 CONFIG_DEFAULT_DEVICE_TREE="efi-x86_payload" CONFIG_PRE_CON_BUF_ADDR=0x100000 -CONFIG_VENDOR_EFI=y +CONFIG_ARCH_EFI=y CONFIG_TARGET_EFI_X86_PAYLOAD=y CONFIG_EFI=y CONFIG_EFI_STUB=y
Signature · 1 line
2.43.0
PATCH v4 9/29 efi: x86: Rework VENDOR_EFI option to permit other archs
In reply to Simon GlassAt present only x86 supports the EFI app and (apart from Qualcomm) the payload. In preparation for supporting 64-bit ARM more generally, rename the existing ARCH_EFI option to ARCH_EFI_X86, using that to define a generic ARCH_EFI which will be enabled for all architectures.
---
(no changes since v2)
Changes in v2:
- Update to use ARCH_EFI instead of VENDOR_EFI
- Mention '64-bit ARM' here, rather than just 'ARM'
arch/arm/Kconfig | 4 ++++ arch/x86/Kconfig | 3 ++- board/efi/Kconfig | 9 +++++++-- configs/efi-x86_app32_defconfig | 2 +- configs/efi-x86_app64_defconfig | 2 +- configs/efi-x86_payload32_defconfig | 2 +- configs/efi-x86_payload64_defconfig | 2 +- 7 files changed, 17 insertions(+), 7 deletions(-)
arch/arm/Kconfig +4 -0
@@ -2158,6 +2158,10 @@ config ARCH_GXP select OF_CONTROL imply CMD_DM +config ARCH_EFI_ARM + bool "efi" + select ARCH_EFI + endchoice config SUPPORT_PASSING_ATAGS
arch/x86/Kconfig +2 -1
@@ -65,8 +65,9 @@ config VENDOR_COREBOOT config VENDOR_DFI bool "dfi" -config ARCH_EFI +config ARCH_EFI_X86 bool "efi" + select ARCH_EFI config VENDOR_EMULATION bool "emulation"
board/efi/Kconfig +7 -2
@@ -1,3 +1,8 @@ +config ARCH_EFI + bool + select OF_CONTROL + select DM_SERIAL + if ARCH_EFI if X86
@@ -38,6 +43,6 @@ endchoice source "board/efi/efi-x86_app/Kconfig" source "board/efi/efi-x86_payload/Kconfig" -endif +endif # X86 -endif +endif # ARCH_EFI
configs/efi-x86_app32_defconfig +1 -1
@@ -4,7 +4,7 @@ CONFIG_ENV_SIZE=0x1000 CONFIG_DEFAULT_DEVICE_TREE="efi-x86_app" CONFIG_DEBUG_UART_BASE=0x0 CONFIG_DEBUG_UART_CLOCK=0 -CONFIG_ARCH_EFI=y +CONFIG_ARCH_EFI_X86=y CONFIG_TARGET_EFI_X86_APP32=y CONFIG_DEBUG_UART=y CONFIG_EFI=y
configs/efi-x86_app64_defconfig +1 -1
@@ -5,7 +5,7 @@ CONFIG_DEFAULT_DEVICE_TREE="efi-x86_app" CONFIG_DEBUG_UART_BASE=0x0 CONFIG_DEBUG_UART_CLOCK=0 CONFIG_X86_RUN_64BIT=y -CONFIG_ARCH_EFI=y +CONFIG_ARCH_EFI_X86=y CONFIG_TARGET_EFI_X86_APP64=y CONFIG_DEBUG_UART=y CONFIG_EFI=y
configs/efi-x86_payload32_defconfig +1 -1
@@ -3,7 +3,7 @@ CONFIG_NR_DRAM_BANKS=8 CONFIG_ENV_SIZE=0x1000 CONFIG_DEFAULT_DEVICE_TREE="efi-x86_payload" CONFIG_PRE_CON_BUF_ADDR=0x100000 -CONFIG_ARCH_EFI=y +CONFIG_ARCH_EFI_X86=y CONFIG_TARGET_EFI_X86_PAYLOAD=y CONFIG_EFI=y CONFIG_EFI_STUB=y
configs/efi-x86_payload64_defconfig +1 -1
@@ -3,7 +3,7 @@ CONFIG_NR_DRAM_BANKS=8 CONFIG_ENV_SIZE=0x1000 CONFIG_DEFAULT_DEVICE_TREE="efi-x86_payload" CONFIG_PRE_CON_BUF_ADDR=0x100000 -CONFIG_ARCH_EFI=y +CONFIG_ARCH_EFI_X86=y CONFIG_TARGET_EFI_X86_PAYLOAD=y CONFIG_EFI=y CONFIG_EFI_STUB=y
Signature · 1 line
2.43.0
PATCH v4 10/29 efi: x86: Allow setting the global_data pointer with EFI
In reply to Simon GlassProvide a function which sets this pointer, for use in the EFI app.
---
(no changes since v1)
arch/x86/include/asm/global_data.h | 7 +++++++ 1 file changed, 7 insertions(+)
arch/x86/include/asm/global_data.h +7 -0
@@ -142,6 +142,13 @@ struct arch_global_data {/* TODO([email protected]): Consider using a fixed register for gd on x86_64 */ #define gd global_data_ptr +static inline void set_gd (volatile gd_t *gd_ptr) +{ +extern struct global_data *global_data_ptr; + + global_data_ptr = (void *)gd_ptr; +} +#define DECLARE_GLOBAL_DATA_PTR extern struct global_data *global_data_ptr# else static inline notrace gd_t *get_fs_gd_ptr(void)
Signature · 1 line
2.43.0
PATCH v4 11/29 efi: Tidy up setup of global_data
In reply to Simon GlassUse the available functions for setting and getting the global_data pointer so that EFI-startup can operate on 64-bit ARM as well as x86.
---
(no changes since v2)
Changes in v2:
- Mention '64-bit ARM' here, rather than just 'ARM'
lib/efi/efi_app.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
lib/efi/efi_app.c +8 -5
@@ -77,6 +77,7 @@ int efi_get_mmap(struct efi_mem_desc **descp, int *sizep, uint *keyp,static efi_status_t setup_memory (struct efi_priv *priv) {struct efi_boot_services *boot = priv->boot; +struct global_data *ptr;efi_physical_addr_t addr;efi_status_t ret;int pages;
@@ -86,10 +87,12 @@ static efi_status_t setup_memory(struct efi_priv *priv)* are very few assignments to global_data in U-Boot and this makes * it easier to find them. */ - global_data_ptr =efi_malloc (priv,sizeof (struct global_data ), &ret); -if (!global_data_ptr) + ptr =efi_malloc (priv,sizeof (*ptr), &ret); +if (!ptr)return ret; -memset (gd,'\0' ,sizeof (*gd)); +memset (ptr,'\0' ,sizeof (*ptr)); + +set_gd (ptr); gd->malloc_base = (ulong )efi_malloc (priv,CONFIG_VAL (SYS_MALLOC_F_LEN ), &ret);
@@ -138,8 +141,8 @@ static void free_memory(struct efi_priv *priv) boot->free_pages (priv->ram_base, gd->ram_size >>12 );efi_free (priv, (void *)gd->malloc_base); -efi_free (priv, gd); - global_data_ptr =NULL ; +efi_free (priv, (void *)gd); +set_gd ((void *)NULL ); }static void scan_tables (struct efi_system_table *sys_table)
Signature · 1 line
2.43.0
PATCH v4 12/29 efi: Rename ImageBase to image_base
In reply to Simon GlassIt is confusing to have a camel-case indentifier in the these files. Rename them to fit with U-Boot's snake-case style.
The image_base symbol is already used in the x86 link-scripts.
---
(no changes since v2)
Changes in v2:
- Rework the commit message to clarify the relationship to link-scripts
arch/arm/lib/crt0_aarch64_efi.S | 26 +++++++++++++------------- arch/riscv/lib/crt0_riscv_efi.S | 28 ++++++++++++++-------------- include/asm-generic/sections.h | 2 ++ 3 files changed, 29 insertions(+), 27 deletions(-)
arch/arm/lib/crt0_aarch64_efi.S +13 -13
@@ -15,12 +15,12 @@ /* * Magic "MZ" signature for PE/COFF */ - .globl ImageBase -ImageBase: + .globl image_base +image_base: .short IMAGE_DOS_SIGNATURE /* 'MZ' */ .skip 54 /* 'MZ' + pad + offset == 64 */ .long LINUX_ARM64_MAGIC /* For GRUB's linux command */ - .long pe_header - ImageBase /* Offset to the PE header */ + .long pe_header - image_base /* Offset to the PE header */ pe_header: .long IMAGE_NT_SIGNATURE /* 'PE' */ coff_header:
@@ -43,11 +43,11 @@ optional_header: .long _etext - _start /* SizeOfCode */ .long 0 /* SizeOfInitializedData */ .long 0 /* SizeOfUninitializedData */ - .long _start - ImageBase /* AddressOfEntryPoint */ - .long _start - ImageBase /* BaseOfCode */ + .long _start - image_base /* AddressOfEntryPoint */ + .long _start - image_base /* BaseOfCode */ extra_header_fields: - .quad 0 /* ImageBase */ + .quad 0 /* image_base */ .long 0x1000 /* SectionAlignment */ .long 0x200 /* FileAlignment */ .short 0 /* MajorOperatingSystemVersion */
@@ -58,12 +58,12 @@ extra_header_fields: .short 0 /* MinorSubsystemVersion */ .long 0 /* Win32VersionValue */ - .long _edata - ImageBase /* SizeOfImage */ + .long _edata - image_base /* SizeOfImage */ /* * Everything before the kernel image is considered part of the header */ - .long _start - ImageBase /* SizeOfHeaders */ + .long _start - image_base /* SizeOfHeaders */ .long 0 /* CheckSum */ .short IMAGE_SUBSYSTEM_EFI_APPLICATION /* Subsystem */ #if CONFIG_ARCH_EFI
@@ -114,9 +114,9 @@ section_table: .byte 0 .byte 0 /* end of 0 padding of section name */ .long _etext - _start /* VirtualSize */ - .long _start - ImageBase /* VirtualAddress */ + .long _start - image_base /* VirtualAddress */ .long _etext - _start /* SizeOfRawData */ - .long _start - ImageBase /* PointerToRawData */ + .long _start - image_base /* PointerToRawData */ .long 0 /* PointerToRelocations */ .long 0 /* PointerToLineNumbers */ .short 0 /* NumberOfRelocations */
@@ -131,9 +131,9 @@ section_table: .byte 0 .byte 0 /* end of 0 padding of section name */ .long _data_size /* VirtualSize */ - .long _data - ImageBase /* VirtualAddress */ + .long _data - image_base /* VirtualAddress */ .long _data_size /* SizeOfRawData */ - .long _data - ImageBase /* PointerToRawData */ + .long _data - image_base /* PointerToRawData */ .long 0 /* PointerToRelocations */ .long 0 /* PointerToLineNumbers */ .short 0 /* NumberOfRelocations */
@@ -149,7 +149,7 @@ _start: mov x29, sp stp x0, x1, [sp, #16] - adr x0, ImageBase + adr x0, image_base adrp x1, _DYNAMIC add x1, x1, #:lo12:_DYNAMIC bl _relocate
arch/riscv/lib/crt0_riscv_efi.S +14 -14
@@ -41,14 +41,14 @@ /* * Magic "MZ" signature for PE/COFF */ - .globl ImageBase -ImageBase: + .globl image_base +image_base: .short IMAGE_DOS_SIGNATURE /* 'MZ' */ .skip 46 /* 'MZ' + pad + offset == 64 */ .long 0x43534952 /* Linux magic "RISCV */ .long 0x00000056 .long 0x05435352 /* Linux magic2 "RSC\x05*/ - .long pe_header - ImageBase /* Offset to the PE header */ + .long pe_header - image_base /* Offset to the PE header */ pe_header: .long IMAGE_NT_SIGNATURE /* 'PE' */ coff_header:
@@ -66,17 +66,17 @@ optional_header: .long _edata - _start /* SizeOfCode */ .long 0 /* SizeOfInitializedData */ .long 0 /* SizeOfUninitializedData */ - .long _start - ImageBase /* AddressOfEntryPoint */ - .long _start - ImageBase /* BaseOfCode */ + .long _start - image_base /* AddressOfEntryPoint */ + .long _start - image_base /* BaseOfCode */ #if __riscv_xlen == 32 .long 0 /* BaseOfData */ #endif extra_header_fields: #if __riscv_xlen == 32 - .long 0 /* ImageBase */ + .long 0 /* image_base */ #else - .quad 0 /* ImageBase */ + .quad 0 /* image_base */ #endif .long 0x200 /* SectionAlignment */ .long 0x200 /* FileAlignment */
@@ -88,12 +88,12 @@ extra_header_fields: .short 0 /* MinorSubsystemVersion */ .long 0 /* Win32VersionValue */ - .long _edata - ImageBase /* SizeOfImage */ + .long _edata - image_base /* SizeOfImage */ /* * Everything before the kernel image is considered part of the header */ - .long _start - ImageBase /* SizeOfHeaders */ + .long _start - image_base /* SizeOfHeaders */ .long 0 /* CheckSum */ .short IMAGE_SUBSYSTEM_EFI_APPLICATION /* Subsystem */ #if CONFIG_ARCH_EFI
@@ -149,9 +149,9 @@ section_table: .byte 0 .byte 0 /* end of 0 padding of section name */ .long _etext - _start /* VirtualSize */ - .long _start - ImageBase /* VirtualAddress */ + .long _start - image_base /* VirtualAddress */ .long _etext - _start /* SizeOfRawData */ - .long _start - ImageBase /* PointerToRawData */ + .long _start - image_base /* PointerToRawData */ .long 0 /* PointerToRelocations (0 for executables) */ .long 0 /* PointerToLineNumbers (0 for executables) */ .short 0 /* NumberOfRelocations (0 for executables) */
@@ -166,9 +166,9 @@ section_table: .byte 0 .byte 0 /* end of 0 padding of section name */ .long _edata - _data /* VirtualSize */ - .long _data - ImageBase /* VirtualAddress */ + .long _data - image_base /* VirtualAddress */ .long _edata - _data /* SizeOfRawData */ - .long _data - ImageBase /* PointerToRawData */ + .long _data - image_base /* PointerToRawData */ .long 0 /* PointerToRelocations */ .long 0 /* PointerToLineNumbers */ .short 0 /* NumberOfRelocations */
@@ -185,7 +185,7 @@ _start: SAVE_LONG(a1, 1) SAVE_LONG(ra, 2) - lla a0, ImageBase + lla a0, image_base lla a1, _DYNAMIC call _relocate bne a0, zero, 0f
include/asm-generic/sections.h +2 -0
@@ -75,6 +75,8 @@ extern char __rel_dyn_start[], __rel_dyn_end[];extern char _image_binary_end[];extern char __dtb[]; +extern char image_base[]; +/* * This is the U-Boot entry point - prior to relocation it should be same * as __text_start
Signature · 1 line
2.43.0
PATCH v4 13/29 efi: lmb: Avoid access to _start
In reply to Simon GlassThe app does not have this symbol. Also the memory where the app is loaded is not under U-Boot's control.
There is no sense in relocating from one alloced region to another. U-Boot is not able to relocate to the top of memory, nor decide what other parts of memory are used for.
For these reasons, the EFI app skips relocation. It is not running at the address pointed to by the _start symbol.
So disable this reservation for the EFI app.
---
(no changes since v2)
Changes in v2:
- Expand commit message to explains that EFI_APP skips relocation
lib/lmb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/lmb.c +2 -1
@@ -560,7 +560,8 @@ static void lmb_reserve_uboot_region(void)lmb_reserve_flags (rsv_start, bank_end - rsv_start +1 ,LMB_NOOVERWRITE ); -if (gd->flags &GD_FLG_SKIP_RELOC ) +if (!IS_ENABLED (CONFIG_EFI_APP ) && + (gd->flags &GD_FLG_SKIP_RELOC ))lmb_reserve_flags ((phys_addr_t )(uintptr_t )_start, gd->mon_len,LMB_NOOVERWRITE );
Signature · 1 line
2.43.0
Re: [PATCH v4 13/29] efi: lmb: Avoid access to _start
Quoted 9 lines · Simon Glass
The app does not have this symbol. Also the memory where the app is loaded is not under U-Boot's control.
There is no sense in relocating from one alloced region to another. U-Boot is not able to relocate to the top of memory, nor decide what other parts of memory are used for.
For these reasons, the EFI app skips relocation. It is not running at the address pointed to by the
_startsymbol.
is there a symbol or not? If there is could we have some "relocate in place" mechanism so that it's valid? When I (finally...) get around to re-sending the symbol lookup support it would be nice if it worked for the EFI app, and it relies on _start.
Quoted 29 lines
So disable this reservation for the EFI app.
Signed-off-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>---
(no changes since v2)
Changes in v2:
- Expand commit message to explains thatEFI_APPskips relocationlib/lmb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)lib/lmb.c +2
-1@@ -560,7 +560,8 @@ static void lmb_reserve_uboot_region(void)lmb_reserve_flags (rsv_start, bank_end - rsv_start +1 ,LMB_NOOVERWRITE ); -if (gd->flags &GD_FLG_SKIP_RELOC ) +if (!IS_ENABLED (CONFIG_EFI_APP ) && + (gd->flags &GD_FLG_SKIP_RELOC ))lmb_reserve_flags ((phys_addr_t )(uintptr_t )_start, gd->mon_len,LMB_NOOVERWRITE );
Signature · 1 line
Caleb (they/them)
Re: [PATCH v4 13/29] efi: lmb: Avoid access to _start
Hi Caleb,
Quoted 11 lines · Caleb Connolly
Quoted 7 lines · Simon Glass
The app does not have this symbol. Also the memory where the app is loaded is not under U-Boot's control.
There is no sense in relocating from one alloced region to another. U-Boot is not able to relocate to the top of memory, nor decide what other parts of memory are used for.
Quoted 7 lines
Quoted 2 lines
For these reasons, the EFI app skips relocation. It is not running at the address pointed to by the
_startsymbol.is there a symbol or not? If there is could we have some "relocate in place" mechanism so that it's valid? When I (finally...) get around to re-sending the symbol lookup support it would be nice if it worked for the EFI app, and it relies on
_start.
Can I leave you to do that clean-up/investigation in your series, then? Tom has already reviewed this patch and it has been sitting here for 6 weeks. I applied it yesterday.
Quoted 23 lines
Quoted 23 lines
So disable this reservation for the EFI app.
Signed-off-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>---
(no changes since v2)
Changes in v2:
- Expand commit message to explains thatEFI_APPskips relocationlib/lmb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)lib/lmb.c +0
-0@@ -560,7 +560,8 @@ static void lmb_reserve_uboot_region(void)lmb_reserve_flags (rsv_start, bank_end - rsv_start +1 ,LMB_NOOVERWRITE );
Quoted 10 lines
lib/lmb.c static void lmb_reserve_uboot_region(void) · line 567
Quoted 6 lines
lib/lmb.c +2
-1-if (gd->flags &GD_FLG_SKIP_RELOC ) +if (!IS_ENABLED (CONFIG_EFI_APP ) && + (gd->flags &GD_FLG_SKIP_RELOC ))lmb_reserve_flags ((phys_addr_t )(uintptr_t )_start, gd->mon_len,LMB_NOOVERWRITE );--
Caleb (they/them)
Regards,
Simon
PATCH v4 14/29 efi: arm: Don't do the EL2 switch when running under EFI
In reply to Simon GlassThe previous bootloader has likely done this already, so avoid trying to do it again. This fixes a crash in QEMU when booting from EDK2
---
(no changes since v1)
arch/arm/lib/bootm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/arm/lib/bootm.c +5 -2
@@ -16,6 +16,7 @@#include <command.h> #include <cpu_func.h> #include <dm.h> +#include <init.h> #include <log.h> #include <asm/global_data.h> #include <dm/root.h>
@@ -186,8 +187,10 @@ __weak void setup_board_tags(struct tag **in_params) {}#ifdef CONFIG_ARM64 static void do_nonsec_virt_switch (void ) { -smp_kick_all_cpus (); -dcache_disable ();/* flush cache before swtiching to EL2 */ +if (ll_boot_init ()) { +smp_kick_all_cpus (); +dcache_disable ();/* flush cache before swtiching to EL2 */ + } }#endif
Signature · 1 line
2.43.0
Re: [PATCH v4 14/29] efi: arm: Don't do the EL2 switch when running under EFI
Quoted 4 lines · Simon Glass
The previous bootloader has likely done this already, so avoid trying to do it again. This fixes a crash in QEMU when booting from EDK2
Signed-off-by Simon Glass <[email protected]>
ll_boot_init is a pretty unintuitive name tbh. skip_lowlevel_init() might be clearer?
off-topic, but how is EBS called?
Quoted 32 lines
---
(no changes since v1)
arch/arm/lib/bootm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)arch/arm/lib/bootm.c +5
-2@@ -16,6 +16,7 @@#include <command.h> #include <cpu_func.h> #include <dm.h> +#include <init.h> #include <log.h> #include <asm/global_data.h> #include <dm/root.h> @@ -186,8 +187,10 @@ __weak void setup_board_tags(struct tag **in_params) {}#ifdef CONFIG_ARM64 static void do_nonsec_virt_switch (void ) { -smp_kick_all_cpus (); -dcache_disable ();/* flush cache before swtiching to EL2 */ +if (ll_boot_init ()) { +smp_kick_all_cpus (); +dcache_disable ();/* flush cache before swtiching to EL2 */ + } }#endif
Signature · 1 line
Caleb (they/them)
Re: [PATCH v4 14/29] efi: arm: Don't do the EL2 switch when running under EFI
Hi Caleb,
Quoted 11 lines · Caleb Connolly
Quoted 4 lines · Simon Glass
The previous bootloader has likely done this already, so avoid trying to do it again. This fixes a crash in QEMU when booting from EDK2
Signed-off-by Simon Glass <[email protected]>
ll_boot_initis a pretty unintuitive name tbh.skip_lowlevel_init()might be clearer?
The ll_boot_init() name has been there for ages. I didn't use lowlevel_init as that symbols is widely used in ARM and it would be too confusion. Perhaps bare_metal() ?
Quoted 2 lines
off-topic, but how is EBS called?
Assuming that Linux is booted as an EFI app, by Linux. Otherwise, the app currently doesn't work properly.
Quoted 29 lines
Reviewed-by Caleb Connolly <[email protected]>Quoted 27 lines
---
(no changes since v1)
arch/arm/lib/bootm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)arch/arm/lib/bootm.c +3
-2@@ -16,6 +16,7 @@#include <command.h> #include <cpu_func.h> #include <dm.h> +#include <init.h> #include <log.h> #include <asm/global_data.h> #include <dm/root.h> @@ -186,8 +187,10 @@ __weak void setup_board_tags(struct tag **in_params) {}#ifdef CONFIG_ARM64 static void do_nonsec_virt_switch (void ) { -smp_kick_all_cpus (); -dcache_disable ();/* flush cache before swtiching to EL2 */ +if (ll_boot_init ()) { +smp_kick_all_cpus ();
Quoted 9 lines
arch/arm/lib/bootm.c __weak void setup_board_tags(struct tag **in_params) {} · line 196
Quoted 5 lines
arch/arm/lib/bootm.c +2
-0+ dcache_disable(); /* flush cache before swtiching to EL2 */ + } }#endif --
Caleb (they/them)
Regards,
Simon
PATCH v4 15/29 efi: arm: Avoid allocating page tables when running under EFI
In reply to Simon GlassThe previous bootloader has already set up the page tables, so don't try to do it again.
This fixes a crash in QEMU when booting from EDK2
---
(no changes since v1)
arch/arm/lib/cache.c | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/lib/cache.c +3 -0
@@ -6,6 +6,7 @@#include <config.h> #include <cpu_func.h> +#include <init.h> #include <log.h> #include <malloc.h> #include <asm/cache.h>
@@ -138,6 +139,8 @@ int arch_reserve_mmu(void)__weak int arm_reserve_mmu (void ) { +if (!ll_boot_init ()) +return 0 ;#if !(CONFIG_IS_ENABLED (SYS_ICACHE_OFF ) &&CONFIG_IS_ENABLED (SYS_DCACHE_OFF ))/* reserve TLB table */ gd->arch.tlb_size =PGTABLE_SIZE ;
Signature · 1 line
2.43.0
Re: [PATCH v4 15/29] efi: arm: Avoid allocating page tables when running under EFI
Quoted 6 lines · Simon Glass
The previous bootloader has already set up the page tables, so don't try to do it again.
This fixes a crash in QEMU when booting from EDK2
Signed-off-by Simon Glass <[email protected]>
Quoted 28 lines
---
(no changes since v1)
arch/arm/lib/cache.c | 3 +++ 1 file changed, 3 insertions(+)arch/arm/lib/cache.c +3
-0@@ -6,6 +6,7 @@#include <config.h> #include <cpu_func.h> +#include <init.h> #include <log.h> #include <malloc.h> #include <asm/cache.h> @@ -138,6 +139,8 @@ int arch_reserve_mmu(void)__weak int arm_reserve_mmu (void ) { +if (!ll_boot_init ()) +return 0 ;#if !(CONFIG_IS_ENABLED (SYS_ICACHE_OFF ) &&CONFIG_IS_ENABLED (SYS_DCACHE_OFF ))/* reserve TLB table */ gd->arch.tlb_size =PGTABLE_SIZE ;
Signature · 1 line
Caleb (they/them)
PATCH v4 16/29 efi: arm: Avoid enabling caches when running under EFI
In reply to Simon GlassThe previous bootloader has already set up the cache, so don't try to do it again.
This fixes a crash in QEMU when booting from EDK2
---
(no changes since v1)
common/board_r.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
common/board_r.c +3 -2
@@ -110,8 +110,9 @@ static int initr_reloc(void)*/ static int initr_caches (void ) { -/* Enable caches */ -enable_caches (); +if (ll_boot_init ()) +enable_caches (); +return 0 ; }#endif
Signature · 1 line
2.43.0
Re: [PATCH v4 16/29] efi: arm: Avoid enabling caches when running under EFI
Quoted 18 lines · Simon Glass
The previous bootloader has already set up the cache, so don't try to do it again.
This fixes a crash in QEMU when booting from EDK2
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
common/board_r.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)common/board_r.c +0
-0
common/board_r.c static int initr_reloc(void) · line 114
Quoted 7 lines
common/board_r.c +2
-2@@ -110,8 +110,9 @@ static int initr_reloc(void)*/ static int initr_caches (void ) { -/* Enable caches */ -enable_caches (); +if (ll_boot_init ()) +enable_caches ();
For the sake of consistency I think this check should be inverted.
Quoted 4 lines
common/board_r.c +1
-0+ return 0; }#endif
Signature · 1 line
Caleb (they/them)
Re: [PATCH v4 16/29] efi: arm: Avoid enabling caches when running under EFI
Hi Caleb,
Quoted 17 lines · Caleb Connolly
Quoted 13 lines · Simon Glass
The previous bootloader has already set up the cache, so don't try to do it again.
This fixes a crash in QEMU when booting from EDK2
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
common/board_r.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Quoted 14 lines
common/board_r.c static int initr_reloc(void) · line 114
Quoted 12 lines
common/board_r.c +2
-2@@ -110,8 +110,9 @@ static int initr_reloc(void)*/ static int initr_caches (void ) { -/* Enable caches */ -enable_caches (); +if (ll_boot_init ()) +enable_caches ();For the sake of consistency I think this check should be inverted.
Do you mean:
if (!ll_boot_init())
enable_caches()
But then we wouldn't enable the cache.
Quoted 8 lines
common/board_r.c static int initr_reloc(void) · line 118
Quoted 4 lines
common/board_r.c +1
-0+ return 0; }#endif --
Caleb (they/them)
Regards,
Simon
PATCH v4 17/29 efi: arm: Implement access to global_data for EFI
In reply to Simon GlassThe EFI app likes to use a simple variable for global data. Implement this for ARM (for use only with 64-bit ARM at present).
---
(no changes since v2)
Changes in v2:
- Mention '64-bit ARM' here, rather than just 'ARM'
arch/arm/include/asm/global_data.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
arch/arm/include/asm/global_data.h +12 -2
@@ -115,7 +115,13 @@ struct arch_global_data {#include <asm-generic/global_data.h> -#if defined(__clang__) || defined(LTO_ENABLE ) +#ifdef CONFIG_EFI_APP + +#define DECLARE_GLOBAL_DATA_PTR extern struct global_data *global_data_ptr + +#define gd global_data_ptr + +#elif defined(__clang__) || defined(LTO_ENABLE )#define DECLARE_GLOBAL_DATA_PTR #define gd get_gd()
@@ -144,7 +150,11 @@ static inline gd_t *get_gd(void)static inline void set_gd (volatile gd_t *gd_ptr) { -#ifdef CONFIG_ARM64 +#ifdef CONFIG_EFI_APP +extern struct global_data *global_data_ptr; + + global_data_ptr = (void *)gd_ptr; +#elif definedCONFIG_ARM64 __asm__volatile ("ldr x18, %0\n" : :"m" (gd_ptr));#elif __ARM_ARCH >=7 __asm__volatile ("ldr r9, %0\n" : :"m" (gd_ptr));
Signature · 1 line
2.43.0
Re: [PATCH v4 17/29] efi: arm: Implement access to global_data for EFI
Quoted 5 lines · Simon Glass
The EFI app likes to use a simple variable for global data. Implement this for ARM (for use only with 64-bit ARM at present).
Signed-off-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>
Quoted 42 lines
---
(no changes since v2)
Changes in v2:
- Mention '64-bit ARM' here, rather than just 'ARM'arch/arm/include/asm/global_data.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)arch/arm/include/asm/global_data.h +12
-2@@ -115,7 +115,13 @@ struct arch_global_data {#include <asm-generic/global_data.h> -#if defined(__clang__) || defined(LTO_ENABLE ) +#ifdef CONFIG_EFI_APP + +#define DECLARE_GLOBAL_DATA_PTR extern struct global_data *global_data_ptr + +#define gd global_data_ptr + +#elif defined(__clang__) || defined(LTO_ENABLE )#define DECLARE_GLOBAL_DATA_PTR #define gd get_gd()@@ -144,7 +150,11 @@ static inline gd_t *get_gd(void)static inline void set_gd (volatile gd_t *gd_ptr) { -#ifdef CONFIG_ARM64 +#ifdef CONFIG_EFI_APP +extern struct global_data *global_data_ptr; + + global_data_ptr = (void *)gd_ptr; +#elif definedCONFIG_ARM64 __asm__volatile ("ldr x18, %0\n" : :"m" (gd_ptr));#elif __ARM_ARCH >=7 __asm__volatile ("ldr r9, %0\n" : :"m" (gd_ptr));
Signature · 1 line
Caleb (they/them)
PATCH v4 18/29 efi: arm: Omit the ARM start-up code in the EFI app
In reply to Simon GlassThis code is not used with the EFI app, since it enters through a call to efi_main(). Remove start.S and crt files from the build.
---
(no changes since v1)
arch/arm/Makefile | 2 ++ arch/arm/lib/Makefile | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-)
arch/arm/Makefile +2 -0
@@ -104,7 +104,9 @@ PLATFORM_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs)) libs-y += $(machdirs) +ifndef CONFIG_EFI_APP head-y := arch/arm/cpu/$(CPU)/start.o +endif ifeq ($(CONFIG_XPL_BUILD),y) ifeq ($(CONFIG_SYS_SOC)$(CONFIG_SPL_FRAMEWORK),"mxs")
arch/arm/lib/Makefile +4 -2
@@ -7,19 +7,21 @@ lib-$(CONFIG_USE_PRIVATE_LIBGCC) += ashldi3.o ashrdi3.o lshrdi3.o \ lib1funcs.o uldivmod.o div0.o \ div64.o muldi3.o +ifndef CONFIG_EFI_APP ifdef CONFIG_CPU_V7M obj-y += vectors_m.o crt0.o else ifdef CONFIG_ARM64 obj-y += crt0_64.o else obj-y += vectors.o crt0.o -endif +endif # CPU type ifdef CONFIG_ARM64 obj-y += setjmp_aarch64.o else obj-y += setjmp.o -endif +endif # ARM64 +endif # CONFIG_EFI_APP ifndef CONFIG_XPL_BUILD ifdef CONFIG_ARM64
Signature · 1 line
2.43.0
Re: [PATCH v4 18/29] efi: arm: Omit the ARM start-up code in the EFI app
Quoted 5 lines · Simon Glass
This code is not used with the EFI app, since it enters through a call to
efi_main(). Removestart.Sand crt files from the build.Signed-off-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>
Quoted 50 lines
---
(no changes since v1)
arch/arm/Makefile | 2 ++ arch/arm/lib/Makefile | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-)arch/arm/Makefile +2
-0@@ -104,7 +104,9 @@ PLATFORM_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs)) libs-y += $(machdirs) +ifndef CONFIG_EFI_APP head-y := arch/arm/cpu/$(CPU)/start.o +endif ifeq ($(CONFIG_XPL_BUILD),y) ifeq ($(CONFIG_SYS_SOC)$(CONFIG_SPL_FRAMEWORK),"mxs")arch/arm/lib/Makefile +4
-2@@ -7,19 +7,21 @@ lib-$(CONFIG_USE_PRIVATE_LIBGCC) += ashldi3.o ashrdi3.o lshrdi3.o \ lib1funcs.o uldivmod.o div0.o \ div64.o muldi3.o +ifndef CONFIG_EFI_APP ifdef CONFIG_CPU_V7M obj-y += vectors_m.o crt0.o else ifdef CONFIG_ARM64 obj-y += crt0_64.o else obj-y += vectors.o crt0.o -endif +endif # CPU type ifdef CONFIG_ARM64 obj-y += setjmp_aarch64.o else obj-y += setjmp.o -endif +endif # ARM64 +endif # CONFIG_EFI_APP ifndef CONFIG_XPL_BUILD ifdef CONFIG_ARM64
Signature · 1 line
Caleb (they/them)
PATCH v4 19/29 efi: arm: Drop exception-level code when running as EFI app
In reply to Simon GlassThe switch_to_non_secure_mode() function cannot be used since EFI is in charge of managing exception-levels.
Build just the exceptions.S file.
Modify the existing SPL rule to cater to the EFI app too.
This is quite confusing, so add an issue to clean this up:
https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/36
---
(no changes since v3)
Changes in v3:
- Rewrite the commit message
arch/arm/cpu/armv8/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/cpu/armv8/Makefile +1 -1
@@ -13,7 +13,7 @@ ifndef CONFIG_$(XPL_)SYS_DCACHE_OFF obj-y += cache_v8.o obj-y += cache.o endif -ifdef CONFIG_XPL_BUILD +ifneq ($(CONFIG_XPL_BUILD)$(CONFIG_EFI_APP),) obj-$(CONFIG_ARMV8_SPL_EXCEPTION_VECTORS) += exceptions.o else obj-y += exceptions.o
Signature · 1 line
2.43.0
PATCH v4 20/29 efi: arm: x86: Allow use of the EFI table in the app
In reply to Simon GlassIt isn't worth the hassle of omitting this field for the app, since code is shared between the payload and the app. Adjust the condition to avoid a build error in the 'efi' command with the app on 64-bit ARM.
---
(no changes since v2)
Changes in v2:
- Document the x86 field better and add a comment for ARM too
- Mention '64-bit ARM' here, rather than just 'ARM'
arch/arm/include/asm/global_data.h | 4 ++-- arch/x86/include/asm/global_data.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/arm/include/asm/global_data.h +2 -2
@@ -108,8 +108,8 @@ struct arch_global_data {#ifdef CONFIG_SMBIOS ulong smbios_start;/* Start address of SMBIOS table */ #endif -#ifdef CONFIG_EFI_STUB -ulong table; +#ifdef CONFIG_EFI +ulong table;/* holds the table address from previous EFI firmware */ #endif };
arch/x86/include/asm/global_data.h +1 -1
@@ -110,7 +110,7 @@ struct arch_global_data {int has_mtrr;/* MRC training data */ struct mrc_output mrc[MRC_TYPE_COUNT ]; -ulong table;/* Table pointer from previous loader */ +ulong table;/* coreboot/EFI table address from previous loader */ int turbo_state;/* Current turbo state */ struct irq_routing_table *pirq_routing_table;int dw_i2c_num_cards;/* Used by designware i2c driver */
Signature · 1 line
2.43.0
PATCH v4 21/29 efi: arm: Disable --gc-sections for the app
In reply to Simon GlassThis option cannot be used with a shared library, since it results in everything being removed. Disable it.
---
(no changes since v1)
arch/arm/config.mk | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/config.mk +2 -0
@@ -14,8 +14,10 @@ CFLAGS_NON_EFI := -fno-pic $(FIXED_REG) -ffunction-sections -fdata-sections \ CFLAGS_EFI := -fpic -fshort-wchar ifneq ($(LTO_ENABLE)$(CONFIG_USE_PRIVATE_LIBGCC),yy) +ifndef CONFIG_EFI_APP LDFLAGS_FINAL += --gc-sections endif +endif ifneq ($(LTO_ENABLE),y) PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
Signature · 1 line
2.43.0
PATCH v4 22/29 efi: arm: Drop startup code from the app
In reply to Simon GlassThe EFI app uses different startup and relocation code and the existing code uses symbols not present in the app. Drop it.
---
(no changes since v1)
arch/arm/cpu/armv8/Makefile | 2 ++ arch/arm/lib/Makefile | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-)
arch/arm/cpu/armv8/Makefile +2 -0
@@ -3,7 +3,9 @@ # (C) Copyright 2000-2003 # Wolfgang Denk, DENX Software Engineering, [email protected]. +ifndef CONFIG_EFI_APP extra-y := start.o +endif obj-y += cpu.o ifndef CONFIG_$(PHASE_)TIMER
arch/arm/lib/Makefile +3 -1
@@ -24,11 +24,13 @@ endif # ARM64 endif # CONFIG_EFI_APP ifndef CONFIG_XPL_BUILD +ifndef CONFIG_EFI_APP ifdef CONFIG_ARM64 obj-y += relocate_64.o else obj-y += relocate.o -endif +endif # ARM64 +endif # EFI_APP obj-$(CONFIG_CPU_V7M) += cmd_boot.o obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
Signature · 1 line
2.43.0
Re: [PATCH v4 22/29] efi: arm: Drop startup code from the app
Quoted 2 lines · Simon Glass
The EFI app uses different startup and relocation code and the existing code uses symbols not present in the app. Drop it.
Shouldn't this be squashed into patch 18 ("efi: arm: Omit the ARM start-up code in the EFI app")?
Quoted 44 lines
Signed-off-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>---
(no changes since v1)
arch/arm/cpu/armv8/Makefile | 2 ++ arch/arm/lib/Makefile | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-)arch/arm/cpu/armv8/Makefile +2
-0@@ -3,7 +3,9 @@ # (C) Copyright 2000-2003 # Wolfgang Denk, DENX Software Engineering, [email protected]. +ifndef CONFIG_EFI_APP extra-y := start.o +endif obj-y += cpu.o ifndef CONFIG_$(PHASE_)TIMERarch/arm/lib/Makefile +3
-1@@ -24,11 +24,13 @@ endif # ARM64 endif # CONFIG_EFI_APP ifndef CONFIG_XPL_BUILD +ifndef CONFIG_EFI_APP ifdef CONFIG_ARM64 obj-y += relocate_64.o else obj-y += relocate.o -endif +endif # ARM64 +endif # EFI_APP obj-$(CONFIG_CPU_V7M) += cmd_boot.o obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o
Signature · 1 line
Caleb (they/them)
Re: [PATCH v4 22/29] efi: arm: Drop startup code from the app
Hi Caleb,
Quoted 9 lines · Caleb Connolly
Quoted 2 lines · Simon Glass
The EFI app uses different startup and relocation code and the existing code uses symbols not present in the app. Drop it.
Shouldn't this be squashed into patch 18 ("efi: arm: Omit the ARM start-up code in the EFI app")?
Why is that?
Quoted 11 lines
Quoted 11 lines
Signed-off-by Simon Glass <[email protected]>Reviewed-by Tom Rini <[email protected]>---
(no changes since v1)
arch/arm/cpu/armv8/Makefile | 2 ++ arch/arm/lib/Makefile | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-)
Regards,
SImon
PATCH v4 23/29 efi: arm: Adjust how the monitor length is calculated
In reply to Simon GlassAdjust the conditions to support the EFI app when running on ARM.
---
(no changes since v2)
Changes in v2:
- Put the EFI-app case first in setup_mon_len(), for clarity
common/board_f.c | 6 +++--- common/board_r.c | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-)
common/board_f.c +3 -3
@@ -261,7 +261,9 @@ static int init_func_i2c(void)static int setup_mon_len (void ) { -#if defined(CONFIG_ARCH_NEXELL ) +#if defined(CONFIG_EFI_APP ) + gd->mon_len = (ulong )_end - (ulong )image_base; +#elif defined(CONFIG_ARCH_NEXELL ) gd->mon_len = (ulong )__bss_end - (ulong )__image_copy_start;#elif defined(__ARM__) || defined(__MICROBLAZE__) gd->mon_len = (ulong )__bss_end - (ulong )_start;
@@ -270,8 +272,6 @@ static int setup_mon_len(void)#elif defined(CONFIG_SANDBOX )/* gcc does not provide _init in crti.o on RISC-V */ gd->mon_len =0 ; -#elif defined(CONFIG_EFI_APP ) - gd->mon_len = (ulong )_end - (ulong )_init;#elif defined(CONFIG_NIOS2 ) || defined(CONFIG_XTENSA ) gd->mon_len =CONFIG_SYS_MONITOR_LEN ;#elif defined(CONFIG_SH ) || defined(CONFIG_RISCV )
common/board_r.c +3 -1
@@ -124,7 +124,9 @@ __weak int fixup_cpu(void)static int initr_reloc_global_data (void ) { -#ifdef __ARM__ +#if defined(CONFIG_EFI_APP ) + monitor_flash_len = (ulong )_end - (ulong )image_base; +#elif defined __ARM__ monitor_flash_len = _end - __image_copy_start;#elif defined(CONFIG_RISCV ) monitor_flash_len = (ulong )_end - (ulong )_start;
Signature · 1 line
2.43.0
PATCH v4 24/29 efi: arm: Provide startup and relocation code
In reply to Simon GlassBuild in the EFI-app startup code as well as the code to relocate U-Boot to the loaded position, since this is under the control of the previous firmware.
---
(no changes since v1)
arch/arm/lib/Makefile | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/lib/Makefile +2 -0
@@ -32,6 +32,8 @@ obj-y += relocate.o endif # ARM64 endif # EFI_APP +obj-$(CONFIG_EFI_APP) += $(EFI_CRT0) $(EFI_RELOC) + obj-$(CONFIG_CPU_V7M) += cmd_boot.o obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o obj-$(CONFIG_CMD_BOOTI) += bootm.o image.o
Signature · 1 line
2.43.0
PATCH v4 25/29 efi: Generate the app as a shared library
In reply to Simon GlassThe app should be built as a shared library, with position-independent code and the -shared flags. Update the Makefile to handle this.
---
Changes in v4:
- Drop the confusing comment about position-independent code
Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Makefile +4 -1
@@ -452,9 +452,12 @@ KBUILD_CFLAGS += $(call cc-option, -no-integrated-as) KBUILD_AFLAGS += $(call cc-option, -no-integrated-as) endif -# Don't generate position independent code +ifdef CONFIG_EFI_APP +KBUILD_CFLAGS += -shared +else KBUILD_CFLAGS += $(call cc-option,-fno-PIE) KBUILD_AFLAGS += $(call cc-option,-fno-PIE) +endif # Read UBOOTRELEASE from include/config/uboot.release (if it exists) UBOOTRELEASE = $(shell cat include/config/uboot.release 2> /dev/null)
Signature · 1 line
2.43.0
PATCH v4 26/29 efi: arm: Disable STATIC_RELA for the EFI app
In reply to Simon GlassThis feature should not be used with the app, since we don't know where U-Boot will be loaded. Disable it.
---
(no changes since v1)
arch/arm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/Kconfig +1 -1
@@ -142,7 +142,7 @@ config GICV3_SUPPORT_GIC600 config STATIC_RELA bool - default y if ARM64 + default y if ARM64 && !EFI_APP config DMA_ADDR_T_64BIT bool
Signature · 1 line
2.43.0
PATCH v4 27/29 efi: arm: Use EFI flags for all compilation with the app
In reply to Simon GlassAs opposed to the payload, which is built normally with just an EFI stub, the app is build homogenously using EFI flags. Update PLATFORM_CPPFLAGS to enable this.
---
(no changes since v1)
arch/arm/cpu/armv8/config.mk | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/cpu/armv8/config.mk +4 -0
@@ -21,3 +21,7 @@ LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined \ CPPFLAGS_REMOVE_crt0-efi-aarch64.o += $(CFLAGS_NON_EFI) CPPFLAGS_crt0-efi-aarch64.o += $(CFLAGS_EFI) + +ifeq ($(CONFIG_EFI_APP),y) +PLATFORM_CPPFLAGS += $(CFLAGS_EFI) +endif
Signature · 1 line
2.43.0
PATCH v4 28/29 efi: arm: Simplify the crt0 file and update link script
In reply to Simon GlassWe don't need to manually add the PE header, since binutils has support for this now. Remove it to simplify the file.
Set the link-target to efi-app-aarch64 so that binutils knows what to do. Add rules to pick up the arm64 files.
Make some updates to the link-script for arm64, so this all works:
- Pass .hash .eh_frame and .reloc sections through to objcopy
- Put RELA pieces into a single section
- Put linker lists into .data
- Embed the dtb
Add a config.mk fragment into the baord directory.
Note that it does not seem to be possible to use this approach with 32-bit ARM, so this is left alone.
---
Changes in v4:
- Put EFI_LDS back as it is required for building helloword.efi etc.
- Put the config.mk changes in the board directory
Changes in v3:
- Drop setting of EFI_LDS and rely on the CONFIG_SYS_LDSCRIPT value
arch/arm/config.mk | 10 ++ arch/arm/cpu/armv8/config.mk | 6 +- arch/arm/lib/crt0_aarch64_efi.S | 156 +++++-------------------------- arch/arm/lib/elf_aarch64_efi.lds | 49 +++++++--- board/efi/efi-arm_app/config.mk | 4 + 5 files changed, 74 insertions(+), 151 deletions(-) create mode 100644 board/efi/efi-arm_app/config.mk
arch/arm/config.mk +10 -0
@@ -149,6 +149,9 @@ OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .hash \ -j .binman_sym_table -j .text_rest endif +OBJCOPYFLAGS_EFI += $(OBJCOPYFLAGS) -j .dynamic -j .rela -j .reloc \ + -j .embedded_dtb + # if a dtb section exists we always have to include it # there are only two cases where it is generated # 1) OF_EMBEDED is turned on
@@ -178,6 +181,13 @@ endif endif endif +ifdef CONFIG_ARM64 +EFI_LDS := elf_aarch64_efi.lds +EFI_CRT0 := crt0_aarch64_efi.o +EFI_RELOC := reloc_aarch64_efi.o +EFI_TARGET := --target=efi-app-aarch64 +else EFI_LDS := elf_arm_efi.lds EFI_CRT0 := crt0_arm_efi.o EFI_RELOC := reloc_arm_efi.o +endif
arch/arm/cpu/armv8/config.mk +1 -5
@@ -13,7 +13,7 @@ EFI_RELOC := reloc_aarch64_efi.o LDSCRIPT_EFI := $(srctree)/arch/arm/lib/elf_aarch64_efi.lds EFISTUB := crt0_aarch64_efi.o reloc_aarch64_efi.o -OBJCOPYFLAGS_EFI += --target=pei-aarch64-little +OBJCOPYFLAGS_EFI += -O binary --target=efi-app-aarch64 EFIPAYLOAD_BFDTARGET := pei-aarch64-little EFIPAYLOAD_BFDARCH := aarch64 LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined \
@@ -21,7 +21,3 @@ LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined \ CPPFLAGS_REMOVE_crt0-efi-aarch64.o += $(CFLAGS_NON_EFI) CPPFLAGS_crt0-efi-aarch64.o += $(CFLAGS_EFI) - -ifeq ($(CONFIG_EFI_APP),y) -PLATFORM_CPPFLAGS += $(CFLAGS_EFI) -endif
arch/arm/lib/crt0_aarch64_efi.S +23 -133
166 lines not on this page · raw message
arch/arm/lib/elf_aarch64_efi.lds +36 -13
86 lines not on this page · raw message
board/efi/efi-arm_app/config.mk new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0+ + +BUILD_CFLAGS += -shared +PLATFORM_CPPFLAGS += $(CFLAGS_EFI)
Signature · 1 line
2.43.0
PATCH v4 29/29 efi: arm: Add an EFI app for arm64
In reply to Simon GlassIntroduce an EFI app for arm64 and update the documentation.
Provide a value for LOAD_ADDR to avoid a link error.
---
(no changes since v2)
Changes in v2:
- Use ARCH_EFI instead of VENDOR_EFI
- Merge the linker-script rules into Kconfig in this patch
- Drop patch 'Select the EFI linker script for the app'
Kconfig | 1 + MAINTAINERS | 4 ++- arch/arm/dts/efi-arm_app.dts | 31 ++++++++++++++++ board/efi/Kconfig | 23 ++++++++++++ board/efi/efi-arm_app/Kconfig | 19 ++++++++++ board/efi/efi-arm_app/MAINTAINERS | 13 +++++++ board/efi/efi-arm_app/Makefile | 5 +++ board/efi/efi-arm_app/board.c | 18 ++++++++++ board/efi/efi-arm_app/efi-arm_app.env | 11 ++++++ configs/efi-arm_app64_defconfig | 51 +++++++++++++++++++++++++++ doc/develop/uefi/u-boot_on_efi.rst | 17 ++++----- lib/efi/Kconfig | 2 +- 12 files changed, 185 insertions(+), 10 deletions(-) create mode 100644 arch/arm/dts/efi-arm_app.dts create mode 100644 board/efi/efi-arm_app/Kconfig create mode 100644 board/efi/efi-arm_app/MAINTAINERS create mode 100644 board/efi/efi-arm_app/Makefile create mode 100644 board/efi/efi-arm_app/board.c create mode 100644 board/efi/efi-arm_app/efi-arm_app.env create mode 100644 configs/efi-arm_app64_defconfig
Kconfig +1 -0
@@ -551,6 +551,7 @@ config SYS_LOAD_ADDR default 0x12000000 if ARCH_MX6 && !(MX6SL || MX6SLL || MX6SX || MX6UL || MX6ULL) default 0x80800000 if ARCH_MX7 default 0x90000000 if FSL_LSCH2 || FSL_LSCH3 + default 0x02000000 if ARCH_EFI default 0x0 if ARCH_SC5XX help Address in memory to use as the default safe load address.
MAINTAINERS +3 -1
@@ -1066,12 +1066,14 @@ M: Simon Glass <[email protected]> M: Heinrich Schuchardt <[email protected]> S: Maintained W: https://docs.u-boot.org/en/latest/develop/uefi/u-boot_on_efi.html +F: board/efi/efi-arm_app F: board/efi/efi-x86_app +F: configs/efi-arm_app* F: configs/efi-x86_app* F: doc/develop/uefi/u-boot_on_efi.rst F: drivers/block/efi-media-uclass.c F: drivers/block/sb_efi_media.c -F: lib/efi/efi_app.c +F: lib/efi/ F: scripts/build-efi.py F: test/dm/efi_media.c
arch/arm/dts/efi-arm_app.dts new file +31 -0
@@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2015 Google, Inc + */ + +/dts-v1/; + +/include/ "skeleton.dtsi" + +/ { + model = "EFI ARM Application"; + compatible = "efi,arm-app"; + + chosen { + stdout-path = &serial; + }; + + serial: serial { + compatible = "efi,uart"; + }; + + reset { + compatible = "efi,reset"; + bootph-all; + }; + efi-fb { + compatible = "efi-fb"; + bootph-some-ram; + }; + +};
board/efi/Kconfig +23 -0
@@ -45,4 +45,27 @@ source "board/efi/efi-x86_payload/Kconfig" endif # X86 +if ARM + +choice + prompt "Mainboard model" + optional + +config TARGET_EFI_ARM_APP64 + bool "64-bit efi application" + select EFI_APP + select SYS_CUSTOM_LDSCRIPT + select ARM64 + help + This target is used for running U-Boot on top of EFI in 64-bit mode. + In this case EFI does the early initialisation, and U-Boot + takes over once the RAM, video and CPU are fully running. + U-Boot is loaded as an application from EFI. + +endchoice + +source "board/efi/efi-arm_app/Kconfig" + +endif # ARM + endif # ARCH_EFI
board/efi/efi-arm_app/Kconfig new file +19 -0
@@ -0,0 +1,19 @@ +if EFI_APP + +config SYS_BOARD + default "efi-arm_app" + +config SYS_VENDOR + default "efi" + +config SYS_SOC + default "efi" + +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + imply VIDEO_EFI + +config SYS_LDSCRIPT + default "arch/arm/lib/elf_aarch64_efi.lds" + +endif
board/efi/efi-arm_app/MAINTAINERS new file +13 -0
@@ -0,0 +1,13 @@ +EFI-ARM_APP32 BOARD +M: Simon Glass <[email protected]> +S: Maintained +F: board/efi/Kconfig +F: board/efi/efi-arm_app/ +F: configs/efi-arm_app32_defconfig + +EFI-ARM_APP64 BOARD +M: Simon Glass <[email protected]> +S: Maintained +F: board/efi/Kconfig +F: board/efi/efi-arm_app/ +F: configs/efi-arm_app64_defconfig
board/efi/efi-arm_app/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2018, Bin Meng <[email protected]> + +obj-y += board.o
board/efi/efi-arm_app/board.c new file +18 -0
@@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (c) 2015 Google, Inc +*/ + +#include <init.h> + +struct mm_region *mem_map; + +int print_cpuinfo (void ) +{ +return 0 ; +} + +int board_init (void ) +{ +return 0 ; +}
board/efi/efi-arm_app/efi-arm_app.env new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Environment file for ARM EFI app + * + * Copyright 2025, Simon Glass <[email protected]> + */ + +/* common console settings */ +stdin=serial +stdout=serial,vidconsole +stderr=serial,vidconsole
configs/efi-arm_app64_defconfig new file +51 -0
51 lines not on this page · raw message
doc/develop/uefi/u-boot_on_efi.rst +9 -8
@@ -27,16 +27,17 @@ Running U-Boot on EFI is useful in several situations: Status ------ -Only x86 is supported at present. If you are using EFI on another architecture -you may want to reconsider. However, much of the code is generic so could be -ported. +Only x86 and ARM64 are supported at present. If you are using EFI on another +architecture you may want to reconsider. However, much of the code is generic so +could be ported. -U-Boot supports running as an EFI application for both 32- and 64-bit EFI. +U-Boot supports running as an EFI application for both 32- and 64-bit EFI on +x86, and for 64-bit on ARM. -U-Boot supports building itself as a payload for either 32-bit or 64-bit EFI. -U-Boot is packaged up and loaded in its entirety by EFI. Once started, U-Boot -changes to 32-bit mode (currently) and takes over the machine. You can use -devices, boot a kernel, etc. +On x86, U-Boot supports building itself as a payload for either 32-bit or 64-bit +EFI. U-Boot is packaged up and loaded in its entirety by EFI. Once started, +U-Boot changes to 32-bit mode (currently) and takes over the machine. You can +use devices, boot a kernel, etc. Build Instructions
lib/efi/Kconfig +1 -1
@@ -17,7 +17,7 @@ choice config EFI_APP bool "Support running as an EFI application" - depends on !ARM + depends on X86 || ARM select CHARSET help Build U-Boot as an application which can be started from EFI. This
Signature · 1 line
2.43.0
Re: [PATCH v4 29/29] efi: arm: Add an EFI app for arm64
Quoted 40 lines · Simon Glass
Introduce an EFI app for arm64 and update the documentation.
Provide a value for
LOAD_ADDRto avoid a link error.Signed-off-by Simon Glass <[email protected]>---
(no changes since v2)
Changes in v2:
- UseARCH_EFIinstead ofVENDOR_EFI
- Merge the linker-script rules intoKconfigin this patch
- Drop patch 'Select the EFI linker script for the app'Kconfig | 1 + MAINTAINERS | 4 ++- arch/arm/dts/efi-arm_app.dts | 31 ++++++++++++++++ board/efi/Kconfig | 23 ++++++++++++ board/efi/efi-arm_app/Kconfig | 19 ++++++++++ board/efi/efi-arm_app/MAINTAINERS | 13 +++++++ board/efi/efi-arm_app/Makefile | 5 +++ board/efi/efi-arm_app/board.c | 18 ++++++++++ board/efi/efi-arm_app/efi-arm_app.env | 11 ++++++ configs/efi-arm_app64_defconfig | 51 +++++++++++++++++++++++++++ doc/develop/uefi/u-boot_on_efi.rst | 17 ++++----- lib/efi/Kconfig | 2 +- 12 files changed, 185 insertions(+), 10 deletions(-)create mode 100644
arch/arm/dts/efi-arm_app.dtscreate mode 100644 board/efi/efi-arm_app/Kconfig create mode 100644 board/efi/efi-arm_app/MAINTAINERS create mode 100644 board/efi/efi-arm_app/Makefile create mode 100644board/efi/efi-arm_app/board.ccreate mode 100644 board/efi/efi-arm_app/efi-arm_app.env create mode 100644 configs/efi-arm_app64_defconfigKconfig +0
-0
Kconfig config SYS_LOAD_ADDR · line 554
Quoted 4 lines
Kconfig +1
-0@@ -551,6 +551,7 @@ config SYS_LOAD_ADDR default 0x12000000 if ARCH_MX6 && !(MX6SL || MX6SLL || MX6SX || MX6UL || MX6ULL) default 0x80800000 if ARCH_MX7 default 0x90000000 if FSL_LSCH2 || FSL_LSCH3 + default 0x02000000 if ARCH_EFI
This value should be clearly wrong like 0x0 or 0xdeada555 or something. So when it gets used at runtime by mistake it's more obvious what happened.
Quoted 48 lines
Kconfig +0
-0default 0x0 if ARCH_SC5XX help Address in memory to use as the default safe load address.MAINTAINERS +3
-1@@ -1066,12 +1066,14 @@ M: Simon Glass <[email protected]> M: Heinrich Schuchardt <[email protected]> S: Maintained W: https://docs.u-boot.org/en/latest/develop/uefi/u-boot_on_efi.html +F: board/efi/efi-arm_app F: board/efi/efi-x86_app +F: configs/efi-arm_app* F: configs/efi-x86_app* F: doc/develop/uefi/u-boot_on_efi.rst F: drivers/block/efi-media-uclass.c F: drivers/block/sb_efi_media.c -F: lib/efi/efi_app.c +F: lib/efi/ F: scripts/build-efi.py F: test/dm/efi_media.carch/arm/dts/efi-arm_app.dts new file +19
-0@@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2015 Google, Inc + */ + +/dts-v1/; + +/include/ "skeleton.dtsi" + +/ { + model = "EFI ARM Application"; + compatible = "efi,arm-app"; + + chosen { + stdout-path = &serial; + }; + + serial: serial { + compatible = "efi,uart";
arch/arm/dts/efi-arm_app.dts line 29
Quoted 10 lines
arch/arm/dts/efi-arm_app.dts new file +10
-0+ }; + + reset { + compatible = "efi,reset"; + bootph-all; + }; + efi-fb { + compatible = "efi-fb"; + bootph-some-ram; + };
what is this?? We shouldn't be using devicetree, we're running on EFI. This makes absolutely no sense.
I see the original x86 app back in the day did it this way, but this is just wrong. I can understanding reusing U-Boot's DM, but at least then build this DT at runtime based on discovering EFI drivers.
Quoted 15 lines
arch/arm/dts/efi-arm_app.dts new file +2
-0+ +};board/efi/Kconfig +5
-0@@ -45,4 +45,27 @@ source "board/efi/efi-x86_payload/Kconfig" endif # X86 +if ARM + +choice + prompt "Mainboard model" + optional
board/efi/Kconfig source "board/efi/efi-x86_payload/Kconfig" · line 62
Quoted 10 lines
board/efi/Kconfig +10
-0+ +config TARGET_EFI_ARM_APP64 + bool "64-bit efi application" + select EFI_APP + select SYS_CUSTOM_LDSCRIPT + select ARM64 + help + This target is used for running U-Boot on top of EFI in 64-bit mode. + In this case EFI does the early initialisation, and U-Boot + takes over once the RAM, video and CPU are fully running.
EFI boot services are still running (and stuff like interrupts will be handled by EFI drivers), I wouldn't say U-Boot "takes over" until/unless it calls EBS.
Quoted 19 lines
board/efi/Kconfig +8
-0+ U-Boot is loaded as an application from EFI. + +endchoice + +source "board/efi/efi-arm_app/Kconfig" + +endif # ARM + endif # ARCH_EFIboard/efi/efi-arm_app/Kconfig new file +4
-0@@ -0,0 +1,19 @@ +if EFI_APP + +config SYS_BOARD + default "efi-arm_app"
board/efi/efi-arm_app/Kconfig line 14
Quoted 10 lines
board/efi/efi-arm_app/Kconfig new file +10
-0+ +config SYS_VENDOR + default "efi" + +config SYS_SOC + default "efi" + +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + imply VIDEO_EFI
Why not just put this in TARGET_EFI_ARM_APP64?
Quoted 11 lines
board/efi/efi-arm_app/Kconfig new file +5
-0+ +config SYS_LDSCRIPT + default "arch/arm/lib/elf_aarch64_efi.lds" + +endifboard/efi/efi-arm_app/MAINTAINERS new file +0
-0
board/efi/efi-arm_app/MAINTAINERS line 6
Quoted 6 lines
board/efi/efi-arm_app/MAINTAINERS new file +6
-0@@ -0,0 +1,13 @@ +EFI-ARM_APP32 BOARD +M: Simon Glass <[email protected]> +S: Maintained +F: board/efi/Kconfig +F: board/efi/efi-arm_app/ +F: configs/efi-arm_app32_defconfig
Am I missing something or is this not there?
Quoted 24 lines
board/efi/efi-arm_app/MAINTAINERS new file +7
-0+ +EFI-ARM_APP64 BOARD +M: Simon Glass <[email protected]> +S: Maintained +F: board/efi/Kconfig +F: board/efi/efi-arm_app/ +F: configs/efi-arm_app64_defconfigboard/efi/efi-arm_app/Makefile new file +5
-0@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2018, Bin Meng <[email protected]> + +obj-y += board.oboard/efi/efi-arm_app/board.c new file +0
-0
board/efi/efi-arm_app/board.c line 3
Quoted 3 lines
board/efi/efi-arm_app/board.c new file +3
-0@@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (c) 2015 Google, Inc
10 years out of date here
board/efi/efi-arm_app/board.c line 10
Quoted 7 lines
board/efi/efi-arm_app/board.c new file +7
-0+*/ + +#include <init.h> + +struct mm_region *mem_map; + +int print_cpuinfo (void )
Just disable CONFIG_DISPLAY_CPUINFO
Quoted 31 lines
board/efi/efi-arm_app/board.c new file +8
-0+{ +return 0 ; +} + +int board_init (void ) +{ +return 0 ; +}board/efi/efi-arm_app/efi-arm_app.env new file +11
-0@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Environment file for ARM EFI app + * + * Copyright 2025, Simon Glass <[email protected]> + */ + +/* common console settings */ +stdin=serial +stdout=serial,vidconsole +stderr=serial,vidconsoleconfigs/efi-arm_app64_defconfig new file +0
-0
configs/efi-arm_app64_defconfig line 4
Quoted 4 lines
configs/efi-arm_app64_defconfig new file +4
-0@@ -0,0 +1,51 @@ +CONFIG_ARM=y +# CONFIG_ARM64_CRC32 is not set +CONFIG_ARCH_EFI_ARM=y +CONFIG_NR_DRAM_BANKS=8
Real platforms have way more than this, 32 might be better.
Saying that, it doesn't seem like gd->bd->bi_dram is populated anywhere, am I missing something?
configs/efi-arm_app64_defconfig line 12
Quoted 8 lines
configs/efi-arm_app64_defconfig new file +8
-0+CONFIG_ENV_SIZE=0x1000 +CONFIG_DEFAULT_DEVICE_TREE="efi-arm_app" +CONFIG_DEBUG_UART_BASE=0x0 +CONFIG_DEBUG_UART_CLOCK=0 +CONFIG_DEBUG_UART=y +CONFIG_TARGET_EFI_ARM_APP64=y +CONFIG_EFI=y +CONFIG_EFI_APP_64BIT=y
Looking at these next to each other, it seems odd to have CONFIG_TARGET_EFI_ARM_APP64 and CONFIG_EFI_APP_64BIT, would you ever have one but not the other?
CONFIG_TARGET_EFI_ARM_APP64 can just go I think.
Quoted 82 lines
configs/efi-arm_app64_defconfig new file +39
-0+CONFIG_FIT=y +# CONFIG_BOOTSTD is not set +CONFIG_SHOW_BOOT_PROGRESS=y +CONFIG_USE_BOOTARGS=y +CONFIG_SYS_PBSIZE=532 +CONFIG_SYS_CONSOLE_INFO_QUIET=y +CONFIG_LOG=y +CONFIG_DISPLAY_BOARDINFO_LATE=y +CONFIG_HUSH_PARSER=y +CONFIG_CMD_BOOTZ=y +CONFIG_CMD_MEMINFO=y +CONFIG_CMD_MEMINFO_MAP=y +CONFIG_CMD_DM=y +CONFIG_CMD_PART=y +CONFIG_CMD_DNS=y +CONFIG_CMD_WGET=y +CONFIG_CMD_CACHE=y +CONFIG_CMD_TIME=y +CONFIG_CMD_EXT2=y +CONFIG_CMD_EXT4=y +CONFIG_CMD_EXT4_WRITE=y +CONFIG_CMD_FAT=y +CONFIG_CMD_FS_GENERIC=y +CONFIG_MAC_PARTITION=y +CONFIG_ISO_PARTITION=y +CONFIG_EFI_PARTITION=y +CONFIG_OF_LIVE=y +CONFIG_ENV_OVERWRITE=y +CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_USE_BOOTFILE=y +CONFIG_BOOTFILE="bzImage" +CONFIG_REGMAP=y +CONFIG_SYSCON=y +CONFIG_EFI_NET=y +CONFIG_DM_RNG=y +CONFIG_SYSRESET=y +CONFIG_VIDEO=y +CONFIG_CONSOLE_SCROLL_LINES=5 +CONFIG_CMD_DHRYSTONE=ydoc/develop/uefi/u-boot_on_efi.rst +9
-8@@ -27,16 +27,17 @@ Running U-Boot on EFI is useful in several situations: Status ------ -Only x86 is supported at present. If you are using EFI on another architecture -you may want to reconsider. However, much of the code is generic so could be -ported. +Only x86 and ARM64 are supported at present. If you are using EFI on another +architecture you may want to reconsider. However, much of the code is generic so +could be ported. -U-Boot supports running as an EFI application for both 32- and 64-bit EFI. +U-Boot supports running as an EFI application for both 32- and 64-bit EFI on +x86, and for 64-bit on ARM. -U-Boot supports building itself as a payload for either 32-bit or 64-bit EFI. -U-Boot is packaged up and loaded in its entirety by EFI. Once started, U-Boot -changes to 32-bit mode (currently) and takes over the machine. You can use -devices, boot a kernel, etc. +On x86, U-Boot supports building itself as a payload for either 32-bit or 64-bit +EFI. U-Boot is packaged up and loaded in its entirety by EFI. Once started, +U-Boot changes to 32-bit mode (currently) and takes over the machine. You can +use devices, boot a kernel, etc. Build Instructionslib/efi/Kconfig +1
-1@@ -17,7 +17,7 @@ choice config EFI_APP bool "Support running as an EFI application" - depends on !ARM + depends on X86 || ARM select CHARSET help Build U-Boot as an application which can be started from EFI. This
Signature · 1 line
Caleb (they/them)
Re: [PATCH v4 29/29] efi: arm: Add an EFI app for arm64
Hi Caleb,
Quoted 39 lines · Caleb Connolly
Quoted 35 lines · Simon Glass
Introduce an EFI app for arm64 and update the documentation.
Provide a value for
LOAD_ADDRto avoid a link error.Signed-off-by Simon Glass <[email protected]>---
(no changes since v2)
Changes in v2:
- UseARCH_EFIinstead ofVENDOR_EFI
- Merge the linker-script rules intoKconfigin this patch
- Drop patch 'Select the EFI linker script for the app'Kconfig | 1 + MAINTAINERS | 4 ++- arch/arm/dts/efi-arm_app.dts | 31 ++++++++++++++++ board/efi/Kconfig | 23 ++++++++++++ board/efi/efi-arm_app/Kconfig | 19 ++++++++++ board/efi/efi-arm_app/MAINTAINERS | 13 +++++++ board/efi/efi-arm_app/Makefile | 5 +++ board/efi/efi-arm_app/board.c | 18 ++++++++++ board/efi/efi-arm_app/efi-arm_app.env | 11 ++++++ configs/efi-arm_app64_defconfig | 51 +++++++++++++++++++++++++++ doc/develop/uefi/u-boot_on_efi.rst | 17 ++++----- lib/efi/Kconfig | 2 +- 12 files changed, 185 insertions(+), 10 deletions(-)create mode 100644
arch/arm/dts/efi-arm_app.dtscreate mode 100644 board/efi/efi-arm_app/Kconfig create mode 100644 board/efi/efi-arm_app/MAINTAINERS create mode 100644 board/efi/efi-arm_app/Makefile create mode 100644board/efi/efi-arm_app/board.ccreate mode 100644 board/efi/efi-arm_app/efi-arm_app.env create mode 100644 configs/efi-arm_app64_defconfig
Quoted 12 lines
Kconfig config SYS_LOAD_ADDR · line 554
Quoted 9 lines
Kconfig +1
-0@@ -551,6 +551,7 @@ config SYS_LOAD_ADDR default 0x12000000 if ARCH_MX6 && !(MX6SL || MX6SLL || MX6SX || MX6UL || MX6ULL) default 0x80800000 if ARCH_MX7 default 0x90000000 if FSL_LSCH2 || FSL_LSCH3 + default 0x02000000 if ARCH_EFIThis value should be clearly wrong like
0x0or0xdeada555or something. So when it gets used at runtime by mistake it's more obvious what happened.
OK, I'll send a follow-up patch for this.
Quoted 62 lines
Quoted 48 lines
Kconfig +0
-0default 0x0 if ARCH_SC5XX help Address in memory to use as the default safe load address.MAINTAINERS +3
-1@@ -1066,12 +1066,14 @@ M: Simon Glass <[email protected]> M: Heinrich Schuchardt <[email protected]> S: Maintained W: https://docs.u-boot.org/en/latest/develop/uefi/u-boot_on_efi.html +F: board/efi/efi-arm_app F: board/efi/efi-x86_app +F: configs/efi-arm_app* F: configs/efi-x86_app* F: doc/develop/uefi/u-boot_on_efi.rst F: drivers/block/efi-media-uclass.c F: drivers/block/sb_efi_media.c -F: lib/efi/efi_app.c +F: lib/efi/ F: scripts/build-efi.py F: test/dm/efi_media.carch/arm/dts/efi-arm_app.dts new file +19
-0@@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2015 Google, Inc + */ + +/dts-v1/; + +/include/ "skeleton.dtsi" + +/ { + model = "EFI ARM Application"; + compatible = "efi,arm-app"; + + chosen { + stdout-path = &serial; + }; + + serial: serial { + compatible = "efi,uart";arch/arm/dts/efi-arm_app.dts line 29
Quoted 10 lines
arch/arm/dts/efi-arm_app.dts new file +10
-0+ }; + + reset { + compatible = "efi,reset"; + bootph-all; + }; + efi-fb { + compatible = "efi-fb"; + bootph-some-ram; + };what is this?? We shouldn't be using devicetree, we're running on EFI. This makes absolutely no sense.
Quoted 3 lines
I see the original x86 app back in the day did it this way, but this is just wrong. I can understanding reusing U-Boot's DM, but at least then build this DT at runtime based on discovering EFI drivers.
Sorry, no. U-Boot uses devicetree to instantiate its drivers, no matter what environment we are in. E.g. it is used on x86 even though x86 uses ACPI.
Quoted 21 lines
Quoted 21 lines
arch/arm/dts/efi-arm_app.dts new file +2
-0+ +};board/efi/Kconfig +11
-0@@ -45,4 +45,27 @@ source "board/efi/efi-x86_payload/Kconfig" endif # X86 +if ARM + +choice + prompt "Mainboard model" + optional + +config TARGET_EFI_ARM_APP64 + bool "64-bit efi application" + select EFI_APP + select SYS_CUSTOM_LDSCRIPT + select ARM64
Quoted 8 lines
board/efi/Kconfig source "board/efi/efi-x86_payload/Kconfig" · line 62
Quoted 4 lines
board/efi/Kconfig +4
-0+ help + This target is used for running U-Boot on top of EFI in 64-bit mode. + In this case EFI does the early initialisation, and U-Boot + takes over once the RAM, video and CPU are fully running.EFI boot services are still running (and stuff like interrupts will be handled by EFI drivers), I wouldn't say U-Boot "takes over" until/unless it calls EBS.
Yes, good point, I'll send a follow-up patch.
Quoted 23 lines
Quoted 23 lines
board/efi/Kconfig +8
-0+ U-Boot is loaded as an application from EFI. + +endchoice + +source "board/efi/efi-arm_app/Kconfig" + +endif # ARM + endif # ARCH_EFIboard/efi/efi-arm_app/Kconfig new file +8
-0@@ -0,0 +1,19 @@ +if EFI_APP + +config SYS_BOARD + default "efi-arm_app" + +config SYS_VENDOR + default "efi" +
Quoted 8 lines
board/efi/efi-arm_app/Kconfig line 14
Quoted 6 lines
board/efi/efi-arm_app/Kconfig new file +6
-0+config SYS_SOC + default "efi" + +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + imply VIDEO_EFIWhy not just put this in
TARGET_EFI_ARM_APP64?
This fits with how x86 does it and allows us to add other boards which are based on the EFI app.
Quoted 11 lines
Quoted 11 lines
board/efi/efi-arm_app/Kconfig new file +5
-0+ +config SYS_LDSCRIPT + default "arch/arm/lib/elf_aarch64_efi.lds" + +endifboard/efi/efi-arm_app/MAINTAINERS new file +0
-0@@ -0,0 +1,13 @@
Quoted 8 lines
board/efi/efi-arm_app/MAINTAINERS line 6
Quoted 6 lines
board/efi/efi-arm_app/MAINTAINERS new file +6
-0+EFI-ARM_APP32 BOARD +M: Simon Glass <[email protected]> +S: Maintained +F: board/efi/Kconfig +F: board/efi/efi-arm_app/ +F: configs/efi-arm_app32_defconfigAm I missing something or is this not there?
Oh yes, this needs to be deleted. I gave up trying to make it work.
Quoted 21 lines
Quoted 21 lines
board/efi/efi-arm_app/MAINTAINERS new file +7
-0+ +EFI-ARM_APP64 BOARD +M: Simon Glass <[email protected]> +S: Maintained +F: board/efi/Kconfig +F: board/efi/efi-arm_app/ +F: configs/efi-arm_app64_defconfigboard/efi/efi-arm_app/Makefile new file +5
-0@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2018, Bin Meng <[email protected]> + +obj-y += board.oboard/efi/efi-arm_app/board.c new file +0
-0
Quoted 8 lines
board/efi/efi-arm_app/board.c line 3
Quoted 6 lines
board/efi/efi-arm_app/board.c new file +3
-0@@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (c) 2015 Google, Inc 10 years out of date here
Indeed. When I copy a file I keep the original author and copyright.
Quoted 9 lines
board/efi/efi-arm_app/board.c line 10
Quoted 7 lines
board/efi/efi-arm_app/board.c new file +7
-0+*/ + +#include <init.h> + +struct mm_region *mem_map; + +int print_cpuinfo (void )Just disable
CONFIG_DISPLAY_CPUINFO
OK
Quoted 38 lines
Quoted 31 lines
board/efi/efi-arm_app/board.c new file +8
-0+{ +return 0 ; +} + +int board_init (void ) +{ +return 0 ; +}board/efi/efi-arm_app/efi-arm_app.env new file +11
-0@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Environment file for ARM EFI app + * + * Copyright 2025, Simon Glass <[email protected]> + */ + +/* common console settings */ +stdin=serial +stdout=serial,vidconsole +stderr=serial,vidconsoleconfigs/efi-arm_app64_defconfig new file +0
-0configs/efi-arm_app64_defconfig line 4
Quoted 4 lines
configs/efi-arm_app64_defconfig new file +4
-0@@ -0,0 +1,51 @@ +CONFIG_ARM=y +# CONFIG_ARM64_CRC32 is not set +CONFIG_ARCH_EFI_ARM=y +CONFIG_NR_DRAM_BANKS=8Real platforms have way more than this, 32 might be better.
Quoted 2 lines
Saying that, it doesn't seem like
gd->bd->bi_dramis populated anywhere, am I missing something?
Yes, you are right, it is not. It doesn't really make any sense in the EFI app. We just allocate a single block of memory and don't worry too much about what is going on elsewhere.
Quoted 13 lines
configs/efi-arm_app64_defconfig line 12
Quoted 9 lines
configs/efi-arm_app64_defconfig new file +8
-0+CONFIG_ENV_SIZE=0x1000 +CONFIG_DEFAULT_DEVICE_TREE="efi-arm_app" +CONFIG_DEBUG_UART_BASE=0x0 +CONFIG_DEBUG_UART_CLOCK=0 +CONFIG_DEBUG_UART=y +CONFIG_TARGET_EFI_ARM_APP64=y +CONFIG_EFI=y +CONFIG_EFI_APP_64BIT=yLooking at these next to each other, it seems odd to have
CONFIG_TARGET_EFI_ARM_APP64andCONFIG_EFI_APP_64BIT, would you ever have one but not the other?
At least with postmarketOS we are seeing boards which are EFI payloads but have their own config, so I thought it best to keep the same approach here.
[..]
Regards,
Simon
Quoted 22 lines · Simon Glass
The original x86 EFI-app was written back in 2015, about a year before the EFI-loader was introduced. At that point, ARM mostly used U-Boot and FIT (Flat Image Tree).
Today, sadly, there are a few efforts to re-invent FIT poorly, to cater to more primitive boot-environments than U-Boot. One justification for this re-invetion has been that EDK2 did not support FIT.
EDK2 does now support FIT but only for the firmware stage. Even then, vendors tend to use their own forks, so any new features are slow to make it into the market.
EDK2 also supports the ext4 filesystem, but many devices don't include that feature, so most distros make use of FAT for storing their boot files. Since FAT is not journalled, it is not particularly reliable in the face of reset, power failure, etc.
As an interim measure, we can use U-Boot as an EFI app running on top of whatever EDK2 fork is in use. This allows use of modern features such as FIT and filesystems other than FAT. So far this only supports x86, but recent ARM laptops are making use of EFI too.
Quoted 6 lines
So this series adds an EFI app for 64-bit ARM.
Note: Since U-Boot does not support EFI's GOP 'blt-only' mode, the vidconsole does not operate, but it can still be used, since EDK2 handles drawing instead of U-Boot. As a result, the U-Boot logo is not shown.
You did miss some of the tags I provided against v3, fwiw.
Signature · 1 line
Tom
Hi Tom,
Quoted 25 lines · Tom Rini
Quoted 22 lines · Simon Glass
The original x86 EFI-app was written back in 2015, about a year before the EFI-loader was introduced. At that point, ARM mostly used U-Boot and FIT (Flat Image Tree).
Today, sadly, there are a few efforts to re-invent FIT poorly, to cater to more primitive boot-environments than U-Boot. One justification for this re-invetion has been that EDK2 did not support FIT.
EDK2 does now support FIT but only for the firmware stage. Even then, vendors tend to use their own forks, so any new features are slow to make it into the market.
EDK2 also supports the ext4 filesystem, but many devices don't include that feature, so most distros make use of FAT for storing their boot files. Since FAT is not journalled, it is not particularly reliable in the face of reset, power failure, etc.
As an interim measure, we can use U-Boot as an EFI app running on top of whatever EDK2 fork is in use. This allows use of modern features such as FIT and filesystems other than FAT. So far this only supports x86, but recent ARM laptops are making use of EFI too.
Quoted 8 lines
Quoted 6 lines
So this series adds an EFI app for 64-bit ARM.
Note: Since U-Boot does not support EFI's GOP 'blt-only' mode, the vidconsole does not operate, but it can still be used, since EDK2 handles drawing instead of U-Boot. As a result, the U-Boot logo is not shown.
You did miss some of the tags I provided against v3, fwiw.
I see this is marked as 'deferred' in patchwork. I'm going to apply it to my tree.
If you like, I could do a pull request against -next with the EFI-app updates.
Regards,
Simon
Quoted 35 lines · Simon Glass
Hi Tom,
Quoted 32 lines · Tom Rini
Quoted 28 lines · Simon Glass
The original x86 EFI-app was written back in 2015, about a year before the EFI-loader was introduced. At that point, ARM mostly used U-Boot and FIT (Flat Image Tree).
Today, sadly, there are a few efforts to re-invent FIT poorly, to cater to more primitive boot-environments than U-Boot. One justification for this re-invetion has been that EDK2 did not support FIT.
EDK2 does now support FIT but only for the firmware stage. Even then, vendors tend to use their own forks, so any new features are slow to make it into the market.
EDK2 also supports the ext4 filesystem, but many devices don't include that feature, so most distros make use of FAT for storing their boot files. Since FAT is not journalled, it is not particularly reliable in the face of reset, power failure, etc.
As an interim measure, we can use U-Boot as an EFI app running on top of whatever EDK2 fork is in use. This allows use of modern features such as FIT and filesystems other than FAT. So far this only supports x86, but recent ARM laptops are making use of EFI too.
So this series adds an EFI app for 64-bit ARM.
Note: Since U-Boot does not support EFI's GOP 'blt-only' mode, the vidconsole does not operate, but it can still be used, since EDK2 handles drawing instead of U-Boot. As a result, the U-Boot logo is not shown.
Quoted 6 lines
Quoted 1 line
You did miss some of the tags I provided against v3, fwiw.
I see this is marked as 'deferred' in patchwork. I'm going to apply it to my tree.
If you like, I could do a pull request against -next with the EFI-app updates.
Yes, I marked it as deferred as this was not based on next to start with. If you would like to see progress on this, please start by rebasing, addressing the outstanding feedback on and posting the pre-requisite patches you applied to your own tree.
Signature · 1 line
Tom
Hello Simon,
Quoted 153 lines · Simon Glass
The original x86 EFI-app was written back in 2015, about a year before the EFI-loader was introduced. At that point, ARM mostly used U-Boot and FIT (Flat Image Tree).
Today, sadly, there are a few efforts to re-invent FIT poorly, to cater to more primitive boot-environments than U-Boot. One justification for this re-invetion has been that EDK2 did not support FIT.
EDK2 does now support FIT but only for the firmware stage. Even then, vendors tend to use their own forks, so any new features are slow to make it into the market.
EDK2 also supports the ext4 filesystem, but many devices don't include that feature, so most distros make use of FAT for storing their boot files. Since FAT is not journalled, it is not particularly reliable in the face of reset, power failure, etc.
As an interim measure, we can use U-Boot as an EFI app running on top of whatever EDK2 fork is in use. This allows use of modern features such as FIT and filesystems other than FAT. So far this only supports x86, but recent ARM laptops are making use of EFI too.
So this series adds an EFI app for 64-bit ARM.
Note: Since U-Boot does not support EFI's GOP 'blt-only' mode, the vidconsole does not operate, but it can still be used, since EDK2 handles drawing instead of U-Boot. As a result, the U-Boot logo is not shown.
Changes in v4:
- Got back to depending onHAVE_TEXT_BASE
- Drop the confusing comment about position-independent code
- PutEFI_LDSback as it is required for building helloword.efi etc.
- Put the config.mk changes in the board directoryChanges in v3:
- Use the same copyright message as the originalpci_rom.cfile
- Rewrite the commit message
- Drop setting ofEFI_LDSand rely on theCONFIG_SYS_LDSCRIPTvalueChanges in v2:
- Depend onCONFIG_EFI_APPinstead
- Drop change to u-boot-elf rule
- Mention '64-bit ARM' here, rather than just 'ARM'
- Drop the word 'Sadly'
- Mention '64-bit ARM' here, rather than just 'ARM'
- Add new patch to renameVENDOR_EFItoARCH_EFI
- Update to useARCH_EFIinstead ofVENDOR_EFI
- Mention '64-bit ARM' here, rather than just 'ARM'
- Mention '64-bit ARM' here, rather than just 'ARM'
- Rework the commit message to clarify the relationship to link-scripts
- Expand commit message to explains thatEFI_APPskips relocation
- Mention '64-bit ARM' here, rather than just 'ARM'
- Document the x86 field better and add a comment for ARM too
- Mention '64-bit ARM' here, rather than just 'ARM'
- Put the EFI-app case first insetup_mon_len(), for clarity
- UseARCH_EFIinstead ofVENDOR_EFI
- Merge the linker-script rules intoKconfigin this patch
- Drop patch 'Select the EFI linker script for the app'Simon Glass (29):
Makefile: Avoid usingTEXT_BASEwith the EFI APP
video: Movevesa_setup_video_priv()into its own file
video: Use a localmode_infostruct in the EFI driver
lib: Providefdtdec_get_pci_bar32()only with PCI enabled
efi: Rename app and payload to include x86
efi: Allow board/efiKconfigto be used outside x86
efi: x86: Move EFI SDRAM-handling into a common file
treewide: RenameVENDOR_EFItoARCH_EFI
efi: x86: ReworkVENDOR_EFIoption to permit other archs
efi: x86: Allow setting theglobal_datapointer with EFI
efi: Tidy up setup ofglobal_data
efi: Rename ImageBase toimage_base
efi: lmb: Avoid access to_start
efi: arm: Don't do the EL2 switch when running under EFI
efi: arm: Avoid allocating page tables when running under EFI
efi: arm: Avoid enabling caches when running under EFI
efi: arm: Implement access toglobal_datafor EFI
efi: arm: Omit the ARM start-up code in the EFI app
efi: arm: Drop exception-level code when running as EFI app
efi: arm: x86: Allow use of the EFI table in the app
efi: arm: Disable --gc-sections for the app
efi: arm: Drop startup code from the app
efi: arm: Adjust how the monitor length is calculated
efi: arm: Provide startup and relocation code
efi: Generate the app as a shared library
efi: arm: DisableSTATIC_RELAfor the EFI app
efi: arm: Use EFI flags for all compilation with the app
efi: arm: Simplify the crt0 file and update link script
efi: arm: Add an EFI app for arm64Kconfig | 1 + MAINTAINERS | 4 +- Makefile | 7 +- arch/Kconfig | 2 + arch/arm/Kconfig | 6 +- arch/arm/Makefile | 2 + arch/arm/config.mk | 12 ++ arch/arm/cpu/armv8/Makefile | 4 +- arch/arm/cpu/armv8/config.mk | 2 +- arch/arm/dts/efi-arm_app.dts | 31 +++++ arch/arm/include/asm/global_data.h | 18 ++- arch/arm/lib/Makefile | 12 +- arch/arm/lib/bootm.c | 7 +- arch/arm/lib/cache.c | 3 + arch/arm/lib/crt0_aarch64_efi.S | 158 ++++---------------------- arch/arm/lib/crt0_arm_efi.S | 2 +- arch/arm/lib/elf_aarch64_efi.lds | 49 +++++--- arch/riscv/lib/crt0_riscv_efi.S | 30 ++--- arch/x86/Kconfig | 4 +- arch/x86/cpu/efi/Makefile | 1 - arch/x86/include/asm/global_data.h | 9 +- board/efi/Kconfig | 44 ++++++- board/efi/efi-arm_app/Kconfig | 19 ++++ board/efi/efi-arm_app/MAINTAINERS | 13 +++ board/efi/efi-arm_app/Makefile | 5 + board/efi/efi-arm_app/board.c | 18 +++ board/efi/efi-arm_app/config.mk | 4 + board/efi/efi-arm_app/efi-arm_app.env | 11 ++ board/efi/efi-x86_payload/Kconfig | 2 +- common/board_f.c | 6 +- common/board_r.c | 9 +- configs/efi-arm_app64_defconfig | 51 +++++++++ configs/efi-x86_app32_defconfig | 4 +- configs/efi-x86_app64_defconfig | 4 +- configs/efi-x86_payload32_defconfig | 4 +- configs/efi-x86_payload64_defconfig | 4 +- doc/develop/uefi/u-boot_on_efi.rst | 17 +-- drivers/pci/pci_rom.c | 32 ------ drivers/video/Makefile | 2 + drivers/video/efi.c | 1 + drivers/video/vesa_helper.c | 41 +++++++ include/asm-generic/sections.h | 2 + include/vesa.h | 2 + lib/efi/Kconfig | 2 +- lib/efi/Makefile | 1 + lib/efi/efi_app.c | 13 ++- {arch/x86/cpu => lib}/efi/sdram.c | 1 - lib/fdtdec.c | 2 + lib/lmb.c | 3 +- 49 files changed, 431 insertions(+), 250 deletions(-) create mode 100644 arch/arm/dts/efi-arm_app.dts create mode 100644 board/efi/efi-arm_app/Kconfig create mode 100644 board/efi/efi-arm_app/MAINTAINERS create mode 100644 board/efi/efi-arm_app/Makefile create mode 100644 board/efi/efi-arm_app/board.c create mode 100644 board/efi/efi-arm_app/config.mk create mode 100644 board/efi/efi-arm_app/efi-arm_app.env create mode 100644 configs/efi-arm_app64_defconfig create mode 100644 drivers/video/vesa_helper.c rename {arch/x86/cpu => lib}/efi/sdram.c (94%)
Quoted 3 lines
--
2.43.0
It looks like some patches, such as "efi: x86: Move EFI SDRAM-handling into a common file,"
depend on another patch series from Matthew Garrett [1], which has already been merged into "ci/master.".
Could you please provide a link to that branch (assuming it's [1])? I wasn't able to
find it in the custodian trees.
[1] https://www.mail-archive.com/[email protected]/msg528541.html
Signature · 7 lines
Best regards - Atentamente - Meilleures salutations Igor Opaniuk mailto: [email protected] skype: igor.opanyuk https://www.linkedin.com/in/iopaniuk
Hi Igor,
Quoted 166 lines · Igor Opaniuk
Hello Simon,
Quoted 153 lines · Simon Glass
The original x86 EFI-app was written back in 2015, about a year before the EFI-loader was introduced. At that point, ARM mostly used U-Boot and FIT (Flat Image Tree).
Today, sadly, there are a few efforts to re-invent FIT poorly, to cater to more primitive boot-environments than U-Boot. One justification for this re-invetion has been that EDK2 did not support FIT.
EDK2 does now support FIT but only for the firmware stage. Even then, vendors tend to use their own forks, so any new features are slow to make it into the market.
EDK2 also supports the ext4 filesystem, but many devices don't include that feature, so most distros make use of FAT for storing their boot files. Since FAT is not journalled, it is not particularly reliable in the face of reset, power failure, etc.
As an interim measure, we can use U-Boot as an EFI app running on top of whatever EDK2 fork is in use. This allows use of modern features such as FIT and filesystems other than FAT. So far this only supports x86, but recent ARM laptops are making use of EFI too.
So this series adds an EFI app for 64-bit ARM.
Note: Since U-Boot does not support EFI's GOP 'blt-only' mode, the vidconsole does not operate, but it can still be used, since EDK2 handles drawing instead of U-Boot. As a result, the U-Boot logo is not shown.
Changes in v4:
- Got back to depending onHAVE_TEXT_BASE
- Drop the confusing comment about position-independent code
- PutEFI_LDSback as it is required for building helloword.efi etc.
- Put the config.mk changes in the board directoryChanges in v3:
- Use the same copyright message as the originalpci_rom.cfile
- Rewrite the commit message
- Drop setting ofEFI_LDSand rely on theCONFIG_SYS_LDSCRIPTvalueChanges in v2:
- Depend onCONFIG_EFI_APPinstead
- Drop change to u-boot-elf rule
- Mention '64-bit ARM' here, rather than just 'ARM'
- Drop the word 'Sadly'
- Mention '64-bit ARM' here, rather than just 'ARM'
- Add new patch to renameVENDOR_EFItoARCH_EFI
- Update to useARCH_EFIinstead ofVENDOR_EFI
- Mention '64-bit ARM' here, rather than just 'ARM'
- Mention '64-bit ARM' here, rather than just 'ARM'
- Rework the commit message to clarify the relationship to link-scripts
- Expand commit message to explains thatEFI_APPskips relocation
- Mention '64-bit ARM' here, rather than just 'ARM'
- Document the x86 field better and add a comment for ARM too
- Mention '64-bit ARM' here, rather than just 'ARM'
- Put the EFI-app case first insetup_mon_len(), for clarity
- UseARCH_EFIinstead ofVENDOR_EFI
- Merge the linker-script rules intoKconfigin this patch
- Drop patch 'Select the EFI linker script for the app'Simon Glass (29):
Makefile: Avoid usingTEXT_BASEwith the EFI APP
video: Movevesa_setup_video_priv()into its own file
video: Use a localmode_infostruct in the EFI driver
lib: Providefdtdec_get_pci_bar32()only with PCI enabled
efi: Rename app and payload to include x86
efi: Allow board/efiKconfigto be used outside x86
efi: x86: Move EFI SDRAM-handling into a common file
treewide: RenameVENDOR_EFItoARCH_EFI
efi: x86: ReworkVENDOR_EFIoption to permit other archs
efi: x86: Allow setting theglobal_datapointer with EFI
efi: Tidy up setup ofglobal_data
efi: Rename ImageBase toimage_base
efi: lmb: Avoid access to_start
efi: arm: Don't do the EL2 switch when running under EFI
efi: arm: Avoid allocating page tables when running under EFI
efi: arm: Avoid enabling caches when running under EFI
efi: arm: Implement access toglobal_datafor EFI
efi: arm: Omit the ARM start-up code in the EFI app
efi: arm: Drop exception-level code when running as EFI app
efi: arm: x86: Allow use of the EFI table in the app
efi: arm: Disable --gc-sections for the app
efi: arm: Drop startup code from the app
efi: arm: Adjust how the monitor length is calculated
efi: arm: Provide startup and relocation code
efi: Generate the app as a shared library
efi: arm: DisableSTATIC_RELAfor the EFI app
efi: arm: Use EFI flags for all compilation with the app
efi: arm: Simplify the crt0 file and update link script
efi: arm: Add an EFI app for arm64Kconfig | 1 + MAINTAINERS | 4 +- Makefile | 7 +- arch/Kconfig | 2 + arch/arm/Kconfig | 6 +- arch/arm/Makefile | 2 + arch/arm/config.mk | 12 ++ arch/arm/cpu/armv8/Makefile | 4 +- arch/arm/cpu/armv8/config.mk | 2 +- arch/arm/dts/efi-arm_app.dts | 31 +++++ arch/arm/include/asm/global_data.h | 18 ++- arch/arm/lib/Makefile | 12 +- arch/arm/lib/bootm.c | 7 +- arch/arm/lib/cache.c | 3 + arch/arm/lib/crt0_aarch64_efi.S | 158 ++++---------------------- arch/arm/lib/crt0_arm_efi.S | 2 +- arch/arm/lib/elf_aarch64_efi.lds | 49 +++++--- arch/riscv/lib/crt0_riscv_efi.S | 30 ++--- arch/x86/Kconfig | 4 +- arch/x86/cpu/efi/Makefile | 1 - arch/x86/include/asm/global_data.h | 9 +- board/efi/Kconfig | 44 ++++++- board/efi/efi-arm_app/Kconfig | 19 ++++ board/efi/efi-arm_app/MAINTAINERS | 13 +++ board/efi/efi-arm_app/Makefile | 5 + board/efi/efi-arm_app/board.c | 18 +++ board/efi/efi-arm_app/config.mk | 4 + board/efi/efi-arm_app/efi-arm_app.env | 11 ++ board/efi/efi-x86_payload/Kconfig | 2 +- common/board_f.c | 6 +- common/board_r.c | 9 +- configs/efi-arm_app64_defconfig | 51 +++++++++ configs/efi-x86_app32_defconfig | 4 +- configs/efi-x86_app64_defconfig | 4 +- configs/efi-x86_payload32_defconfig | 4 +- configs/efi-x86_payload64_defconfig | 4 +- doc/develop/uefi/u-boot_on_efi.rst | 17 +-- drivers/pci/pci_rom.c | 32 ------ drivers/video/Makefile | 2 + drivers/video/efi.c | 1 + drivers/video/vesa_helper.c | 41 +++++++ include/asm-generic/sections.h | 2 + include/vesa.h | 2 + lib/efi/Kconfig | 2 +- lib/efi/Makefile | 1 + lib/efi/efi_app.c | 13 ++- {arch/x86/cpu => lib}/efi/sdram.c | 1 - lib/fdtdec.c | 2 + lib/lmb.c | 3 +- 49 files changed, 431 insertions(+), 250 deletions(-) create mode 100644 arch/arm/dts/efi-arm_app.dts create mode 100644 board/efi/efi-arm_app/Kconfig create mode 100644 board/efi/efi-arm_app/MAINTAINERS create mode 100644 board/efi/efi-arm_app/Makefile create mode 100644 board/efi/efi-arm_app/board.c create mode 100644 board/efi/efi-arm_app/config.mk create mode 100644 board/efi/efi-arm_app/efi-arm_app.env create mode 100644 configs/efi-arm_app64_defconfig create mode 100644 drivers/video/vesa_helper.c rename {arch/x86/cpu => lib}/efi/sdram.c (94%)Quoted 3 lines
--
2.43.0It looks like some patches, such as "efi: x86: Move EFI SDRAM-handling into a common file,"
depend on another patch series from Matthew Garrett [1], which has already been merged into "ci/master.".
Quoted 6 lines
Could you please provide a link to that branch (assuming it's [1])? I wasn't able to
find it in the custodian trees.[1] https://www.mail-archive.com/[email protected]/msg528541.html
Yes, it is here:
https://sjg.u-boot.org/u-boot/u-boot/-/tree/master?ref_type=heads
Regards,
Simon
Quoted 17 lines · Simon Glass
The original x86 EFI-app was written back in 2015, about a year before the EFI-loader was introduced. At that point, ARM mostly used U-Boot and FIT (Flat Image Tree).
Today, sadly, there are a few efforts to re-invent FIT poorly, to cater to more primitive boot-environments than U-Boot. One justification for this re-invetion has been that EDK2 did not support FIT.
EDK2 does now support FIT but only for the firmware stage. Even then, vendors tend to use their own forks, so any new features are slow to make it into the market.
EDK2 also supports the ext4 filesystem, but many devices don't include that feature, so most distros make use of FAT for storing their boot files. Since FAT is not journalled, it is not particularly reliable in the face of reset, power failure, etc.
Quoted 6 lines
As an interim measure, we can use U-Boot as an EFI app running on top of whatever EDK2 fork is in use. This allows use of modern features such as FIT and filesystems other than FAT. So far this only supports x86, but recent ARM laptops are making use of EFI too.
So this series adds an EFI app for 64-bit ARM.
It also does a lot of small tangential cleanup (and is kinda big). Could you send patches 2, 3, 11 and 12 separately? These are all sensible in their own right (and would help with EFI stub as well).
A looot of the later patches look like they can be squashed too, as-is I don't think this series is bisect-safe (which in fairness would probably only affect someone who is actually building the EFI app, but even so).
I'm looking forward to getting all this EFI loader stuff in better shape for when I finally get back around to working on the EFI stub support for ARM, so happy to see this cleanup.
Kind regards,
Quoted 129 lines
Note: Since U-Boot does not support EFI's GOP 'blt-only' mode, the vidconsole does not operate, but it can still be used, since EDK2 handles drawing instead of U-Boot. As a result, the U-Boot logo is not shown.
Changes in v4:
- Got back to depending onHAVE_TEXT_BASE
- Drop the confusing comment about position-independent code
- PutEFI_LDSback as it is required for building helloword.efi etc.
- Put the config.mk changes in the board directoryChanges in v3:
- Use the same copyright message as the originalpci_rom.cfile
- Rewrite the commit message
- Drop setting ofEFI_LDSand rely on theCONFIG_SYS_LDSCRIPTvalueChanges in v2:
- Depend onCONFIG_EFI_APPinstead
- Drop change to u-boot-elf rule
- Mention '64-bit ARM' here, rather than just 'ARM'
- Drop the word 'Sadly'
- Mention '64-bit ARM' here, rather than just 'ARM'
- Add new patch to renameVENDOR_EFItoARCH_EFI
- Update to useARCH_EFIinstead ofVENDOR_EFI
- Mention '64-bit ARM' here, rather than just 'ARM'
- Mention '64-bit ARM' here, rather than just 'ARM'
- Rework the commit message to clarify the relationship to link-scripts
- Expand commit message to explains thatEFI_APPskips relocation
- Mention '64-bit ARM' here, rather than just 'ARM'
- Document the x86 field better and add a comment for ARM too
- Mention '64-bit ARM' here, rather than just 'ARM'
- Put the EFI-app case first insetup_mon_len(), for clarity
- UseARCH_EFIinstead ofVENDOR_EFI
- Merge the linker-script rules intoKconfigin this patch
- Drop patch 'Select the EFI linker script for the app'Simon Glass (29):
Makefile: Avoid usingTEXT_BASEwith the EFI APP
video: Movevesa_setup_video_priv()into its own file
video: Use a localmode_infostruct in the EFI driver
lib: Providefdtdec_get_pci_bar32()only with PCI enabled
efi: Rename app and payload to include x86
efi: Allow board/efiKconfigto be used outside x86
efi: x86: Move EFI SDRAM-handling into a common file
treewide: RenameVENDOR_EFItoARCH_EFI
efi: x86: ReworkVENDOR_EFIoption to permit other archs
efi: x86: Allow setting theglobal_datapointer with EFI
efi: Tidy up setup ofglobal_data
efi: Rename ImageBase toimage_base
efi: lmb: Avoid access to_start
efi: arm: Don't do the EL2 switch when running under EFI
efi: arm: Avoid allocating page tables when running under EFI
efi: arm: Avoid enabling caches when running under EFI
efi: arm: Implement access toglobal_datafor EFI
efi: arm: Omit the ARM start-up code in the EFI app
efi: arm: Drop exception-level code when running as EFI app
efi: arm: x86: Allow use of the EFI table in the app
efi: arm: Disable --gc-sections for the app
efi: arm: Drop startup code from the app
efi: arm: Adjust how the monitor length is calculated
efi: arm: Provide startup and relocation code
efi: Generate the app as a shared library
efi: arm: DisableSTATIC_RELAfor the EFI app
efi: arm: Use EFI flags for all compilation with the app
efi: arm: Simplify the crt0 file and update link script
efi: arm: Add an EFI app for arm64Kconfig | 1 + MAINTAINERS | 4 +- Makefile | 7 +- arch/Kconfig | 2 + arch/arm/Kconfig | 6 +- arch/arm/Makefile | 2 + arch/arm/config.mk | 12 ++ arch/arm/cpu/armv8/Makefile | 4 +- arch/arm/cpu/armv8/config.mk | 2 +- arch/arm/dts/efi-arm_app.dts | 31 +++++ arch/arm/include/asm/global_data.h | 18 ++- arch/arm/lib/Makefile | 12 +- arch/arm/lib/bootm.c | 7 +- arch/arm/lib/cache.c | 3 + arch/arm/lib/crt0_aarch64_efi.S | 158 ++++---------------------- arch/arm/lib/crt0_arm_efi.S | 2 +- arch/arm/lib/elf_aarch64_efi.lds | 49 +++++--- arch/riscv/lib/crt0_riscv_efi.S | 30 ++--- arch/x86/Kconfig | 4 +- arch/x86/cpu/efi/Makefile | 1 - arch/x86/include/asm/global_data.h | 9 +- board/efi/Kconfig | 44 ++++++- board/efi/efi-arm_app/Kconfig | 19 ++++ board/efi/efi-arm_app/MAINTAINERS | 13 +++ board/efi/efi-arm_app/Makefile | 5 + board/efi/efi-arm_app/board.c | 18 +++ board/efi/efi-arm_app/config.mk | 4 + board/efi/efi-arm_app/efi-arm_app.env | 11 ++ board/efi/efi-x86_payload/Kconfig | 2 +- common/board_f.c | 6 +- common/board_r.c | 9 +- configs/efi-arm_app64_defconfig | 51 +++++++++ configs/efi-x86_app32_defconfig | 4 +- configs/efi-x86_app64_defconfig | 4 +- configs/efi-x86_payload32_defconfig | 4 +- configs/efi-x86_payload64_defconfig | 4 +- doc/develop/uefi/u-boot_on_efi.rst | 17 +-- drivers/pci/pci_rom.c | 32 ------ drivers/video/Makefile | 2 + drivers/video/efi.c | 1 + drivers/video/vesa_helper.c | 41 +++++++ include/asm-generic/sections.h | 2 + include/vesa.h | 2 + lib/efi/Kconfig | 2 +- lib/efi/Makefile | 1 + lib/efi/efi_app.c | 13 ++- {arch/x86/cpu => lib}/efi/sdram.c | 1 - lib/fdtdec.c | 2 + lib/lmb.c | 3 +- 49 files changed, 431 insertions(+), 250 deletions(-)create mode 100644
arch/arm/dts/efi-arm_app.dtscreate mode 100644 board/efi/efi-arm_app/Kconfig create mode 100644 board/efi/efi-arm_app/MAINTAINERS create mode 100644 board/efi/efi-arm_app/Makefile create mode 100644board/efi/efi-arm_app/board.ccreate mode 100644board/efi/efi-arm_app/config.mkcreate mode 100644 board/efi/efi-arm_app/efi-arm_app.env create mode 100644 configs/efi-arm_app64_defconfig create mode 100644drivers/video/vesa_helper.crename {arch/x86/cpu=>lib}/efi/sdram.c(94%)
Signature · 1 line
Caleb (they/them)
Hi Caleb,
Quoted 32 lines · Caleb Connolly
Quoted 17 lines · Simon Glass
The original x86 EFI-app was written back in 2015, about a year before the EFI-loader was introduced. At that point, ARM mostly used U-Boot and FIT (Flat Image Tree).
Today, sadly, there are a few efforts to re-invent FIT poorly, to cater to more primitive boot-environments than U-Boot. One justification for this re-invetion has been that EDK2 did not support FIT.
EDK2 does now support FIT but only for the firmware stage. Even then, vendors tend to use their own forks, so any new features are slow to make it into the market.
EDK2 also supports the ext4 filesystem, but many devices don't include that feature, so most distros make use of FAT for storing their boot files. Since FAT is not journalled, it is not particularly reliable in the face of reset, power failure, etc.
Quoted 6 lines
As an interim measure, we can use U-Boot as an EFI app running on top of whatever EDK2 fork is in use. This allows use of modern features such as FIT and filesystems other than FAT. So far this only supports x86, but recent ARM laptops are making use of EFI too.
So this series adds an EFI app for 64-bit ARM.
It also does a lot of small tangential cleanup (and is kinda big). Could you send patches 2, 3, 11 and 12 separately? These are all sensible in their own right (and would help with EFI stub as well).
Quoted 7 lines
A looot of the later patches look like they can be squashed too, as-is I don't think this series is bisect-safe (which in fairness would probably only affect someone who is actually building the EFI app, but even so).
I'm looking forward to getting all this EFI loader stuff in better shape for when I finally get back around to working on the EFI stub support for ARM, so happy to see this cleanup.
OK good.
BTW I'm not sure what you mean by the cleanup patches, but they are only needed by this series and wouldn't have much motivation otherwise.
There is definitely work to do on the EFI loader side so I look forward to seeing your patches.
For now, the app boots Linux, but we don't have CI tests, etc.
Quoted 132 lines
Kind regards,
Quoted 118 lines
Note: Since U-Boot does not support EFI's GOP 'blt-only' mode, the vidconsole does not operate, but it can still be used, since EDK2 handles drawing instead of U-Boot. As a result, the U-Boot logo is not shown.
Changes in v4:
- Got back to depending onHAVE_TEXT_BASE
- Drop the confusing comment about position-independent code
- PutEFI_LDSback as it is required for building helloword.efi etc.
- Put the config.mk changes in the board directoryChanges in v3:
- Use the same copyright message as the originalpci_rom.cfile
- Rewrite the commit message
- Drop setting ofEFI_LDSand rely on theCONFIG_SYS_LDSCRIPTvalueChanges in v2:
- Depend onCONFIG_EFI_APPinstead
- Drop change to u-boot-elf rule
- Mention '64-bit ARM' here, rather than just 'ARM'
- Drop the word 'Sadly'
- Mention '64-bit ARM' here, rather than just 'ARM'
- Add new patch to renameVENDOR_EFItoARCH_EFI
- Update to useARCH_EFIinstead ofVENDOR_EFI
- Mention '64-bit ARM' here, rather than just 'ARM'
- Mention '64-bit ARM' here, rather than just 'ARM'
- Rework the commit message to clarify the relationship to link-scripts
- Expand commit message to explains thatEFI_APPskips relocation
- Mention '64-bit ARM' here, rather than just 'ARM'
- Document the x86 field better and add a comment for ARM too
- Mention '64-bit ARM' here, rather than just 'ARM'
- Put the EFI-app case first insetup_mon_len(), for clarity
- UseARCH_EFIinstead ofVENDOR_EFI
- Merge the linker-script rules intoKconfigin this patch
- Drop patch 'Select the EFI linker script for the app'Simon Glass (29):
Makefile: Avoid usingTEXT_BASEwith the EFI APP
video: Movevesa_setup_video_priv()into its own file
video: Use a localmode_infostruct in the EFI driver
lib: Providefdtdec_get_pci_bar32()only with PCI enabled
efi: Rename app and payload to include x86
efi: Allow board/efiKconfigto be used outside x86
efi: x86: Move EFI SDRAM-handling into a common file
treewide: RenameVENDOR_EFItoARCH_EFI
efi: x86: ReworkVENDOR_EFIoption to permit other archs
efi: x86: Allow setting theglobal_datapointer with EFI
efi: Tidy up setup ofglobal_data
efi: Rename ImageBase toimage_base
efi: lmb: Avoid access to_start
efi: arm: Don't do the EL2 switch when running under EFI
efi: arm: Avoid allocating page tables when running under EFI
efi: arm: Avoid enabling caches when running under EFI
efi: arm: Implement access toglobal_datafor EFI
efi: arm: Omit the ARM start-up code in the EFI app
efi: arm: Drop exception-level code when running as EFI app
efi: arm: x86: Allow use of the EFI table in the app
efi: arm: Disable --gc-sections for the app
efi: arm: Drop startup code from the app
efi: arm: Adjust how the monitor length is calculated
efi: arm: Provide startup and relocation code
efi: Generate the app as a shared library
efi: arm: DisableSTATIC_RELAfor the EFI app
efi: arm: Use EFI flags for all compilation with the app
efi: arm: Simplify the crt0 file and update link script
efi: arm: Add an EFI app for arm64Kconfig | 1 + MAINTAINERS | 4 +- Makefile | 7 +- arch/Kconfig | 2 + arch/arm/Kconfig | 6 +- arch/arm/Makefile | 2 + arch/arm/config.mk | 12 ++ arch/arm/cpu/armv8/Makefile | 4 +- arch/arm/cpu/armv8/config.mk | 2 +- arch/arm/dts/efi-arm_app.dts | 31 +++++ arch/arm/include/asm/global_data.h | 18 ++- arch/arm/lib/Makefile | 12 +- arch/arm/lib/bootm.c | 7 +- arch/arm/lib/cache.c | 3 + arch/arm/lib/crt0_aarch64_efi.S | 158 ++++---------------------- arch/arm/lib/crt0_arm_efi.S | 2 +- arch/arm/lib/elf_aarch64_efi.lds | 49 +++++--- arch/riscv/lib/crt0_riscv_efi.S | 30 ++--- arch/x86/Kconfig | 4 +- arch/x86/cpu/efi/Makefile | 1 - arch/x86/include/asm/global_data.h | 9 +- board/efi/Kconfig | 44 ++++++- board/efi/efi-arm_app/Kconfig | 19 ++++ board/efi/efi-arm_app/MAINTAINERS | 13 +++ board/efi/efi-arm_app/Makefile | 5 + board/efi/efi-arm_app/board.c | 18 +++ board/efi/efi-arm_app/config.mk | 4 + board/efi/efi-arm_app/efi-arm_app.env | 11 ++ board/efi/efi-x86_payload/Kconfig | 2 +- common/board_f.c | 6 +- common/board_r.c | 9 +- configs/efi-arm_app64_defconfig | 51 +++++++++ configs/efi-x86_app32_defconfig | 4 +- configs/efi-x86_app64_defconfig | 4 +- configs/efi-x86_payload32_defconfig | 4 +- configs/efi-x86_payload64_defconfig | 4 +- doc/develop/uefi/u-boot_on_efi.rst | 17 +-- drivers/pci/pci_rom.c | 32 ------ drivers/video/Makefile | 2 + drivers/video/efi.c | 1 + drivers/video/vesa_helper.c | 41 +++++++ include/asm-generic/sections.h | 2 + include/vesa.h | 2 + lib/efi/Kconfig | 2 +- lib/efi/Makefile | 1 + lib/efi/efi_app.c | 13 ++- {arch/x86/cpu => lib}/efi/sdram.c | 1 - lib/fdtdec.c | 2 + lib/lmb.c | 3 +- 49 files changed, 431 insertions(+), 250 deletions(-)Quoted 11 lines
create mode 100644
arch/arm/dts/efi-arm_app.dtscreate mode 100644 board/efi/efi-arm_app/Kconfig create mode 100644 board/efi/efi-arm_app/MAINTAINERS create mode 100644 board/efi/efi-arm_app/Makefile create mode 100644board/efi/efi-arm_app/board.ccreate mode 100644board/efi/efi-arm_app/config.mkcreate mode 100644 board/efi/efi-arm_app/efi-arm_app.env create mode 100644 configs/efi-arm_app64_defconfig create mode 100644drivers/video/vesa_helper.crename {arch/x86/cpu=>lib}/efi/sdram.c(94%)
Quoted 3 lines
--
Caleb (they/them)
Regards,
SImon