diff options
author | Tom Rini <trini@konsulko.com> | 2024-10-09 16:58:42 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2024-10-09 22:04:56 -0600 |
commit | 1ff60b1f0a0973b5acda21232262f6745491e5af (patch) | |
tree | 84e785eb54ca23b131931569558e6ad7d42c5a20 | |
parent | 93b9cd792089e536f2bfa85d9903fd4798209f76 (diff) | |
parent | 5ba825194aa0e04fbd07da6f618c37d9934f4f2d (diff) |
Merge tag 'efi-2025-01-rc1' of https://source.denx.de/u-boot/custodians/u-boot-efi
Pull request efi-2025-01-rc1
Documentation:
* Move the generic memory-documentation to doc/
* Fix typo boormethod
UEFI:
* Delete rng-seed if having EFI RNG protocol
* Don't call restart_uboot in EFI watchdog test
* Simplify building EFI binaries in Makefile
* Show FirmwareVendor and FirmwareRevision in helloworld
* Add debug output for efi bootmeth
Other:
* CONFIG_CMD_CLK should depend on CONFIG_CLK
* simplify clk command
* enable clk command on the sandbox
30 files changed, 153 insertions, 156 deletions
@@ -2516,51 +2516,6 @@ On RISC-V, the following registers are used: ==> U-Boot will use gp to hold a pointer to the global data -Memory Management: ------------------- - -U-Boot runs in system state and uses physical addresses, i.e. the -MMU is not used either for address mapping nor for memory protection. - -The available memory is mapped to fixed addresses using the memory -controller. In this process, a contiguous block is formed for each -memory type (Flash, SDRAM, SRAM), even when it consists of several -physical memory banks. - -U-Boot is installed in the first 128 kB of the first Flash bank (on -TQM8xxL modules this is the range 0x40000000 ... 0x4001FFFF). After -booting and sizing and initializing DRAM, the code relocates itself -to the upper end of DRAM. Immediately below the U-Boot code some -memory is reserved for use by malloc() [see CONFIG_SYS_MALLOC_LEN -configuration setting]. Below that, a structure with global Board -Info data is placed, followed by the stack (growing downward). - -Additionally, some exception handler code is copied to the low 8 kB -of DRAM (0x00000000 ... 0x00001FFF). - -So a typical memory configuration with 16 MB of DRAM could look like -this: - - 0x0000 0000 Exception Vector code - : - 0x0000 1FFF - 0x0000 2000 Free for Application Use - : - : - - : - : - 0x00FB FF20 Monitor Stack (Growing downward) - 0x00FB FFAC Board Info Data and permanent copy of global data - 0x00FC 0000 Malloc Arena - : - 0x00FD FFFF - 0x00FE 0000 RAM Copy of Monitor Code - ... eventually: LCD or video framebuffer - ... eventually: pRAM (Protected RAM - unchanged by reset) - 0x00FF FFFF [End of RAM] - - System Initialization: ---------------------- diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile index 67275fba616..87000d1609b 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -129,11 +129,3 @@ CFLAGS_REMOVE_$(EFI_CRT0) := $(CFLAGS_NON_EFI) CFLAGS_$(EFI_RELOC) := $(CFLAGS_EFI) CFLAGS_REMOVE_$(EFI_RELOC) := $(CFLAGS_NON_EFI) - -extra-$(CONFIG_CMD_BOOTEFI_HELLO_COMPILE) += $(EFI_CRT0) $(EFI_RELOC) -# TODO: As of v2019.01 the relocation code for the EFI application cannot -# be built on ARMv7-M. -ifndef CONFIG_CPU_V7M -#extra-$(CONFIG_CMD_BOOTEFI_SELFTEST) += $(EFI_CRT0) $(EFI_RELOC) -endif -extra-$(CONFIG_EFI) += $(EFI_CRT0) $(EFI_RELOC) diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile index 65dc49f6fa5..bcfdb516b76 100644 --- a/arch/riscv/lib/Makefile +++ b/arch/riscv/lib/Makefile @@ -36,10 +36,6 @@ CFLAGS_REMOVE_$(EFI_CRT0) := $(CFLAGS_NON_EFI) CFLAGS_$(EFI_RELOC) := $(CFLAGS_EFI) CFLAGS_REMOVE_$(EFI_RELOC) := $(CFLAGS_NON_EFI) -extra-$(CONFIG_CMD_BOOTEFI_HELLO_COMPILE) += $(EFI_CRT0) $(EFI_RELOC) -extra-$(CONFIG_CMD_BOOTEFI_SELFTEST) += $(EFI_CRT0) $(EFI_RELOC) -extra-$(CONFIG_EFI) += $(EFI_CRT0) $(EFI_RELOC) - obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMSET) += memset.o obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMMOVE) += memmove.o obj-$(CONFIG_$(SPL_TPL_)USE_ARCH_MEMCPY) += memcpy.o diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile index 8fc35e1b51e..d6ea9c955f8 100644 --- a/arch/x86/lib/Makefile +++ b/arch/x86/lib/Makefile @@ -87,19 +87,3 @@ extra-$(CONFIG_EFI_STUB_32BIT) += crt0_ia32_efi.o reloc_ia32_efi.o extra-$(CONFIG_EFI_STUB_64BIT) += crt0_x86_64_efi.o reloc_x86_64_efi.o endif - -ifdef CONFIG_EFI_STUB - -ifeq ($(CONFIG_$(SPL_)X86_64),) -extra-y += $(EFI_CRT0) $(EFI_RELOC) -endif - -else - -ifndef CONFIG_SPL_BUILD -ifneq ($(CONFIG_CMD_BOOTEFI_SELFTEST)$(CONFIG_CMD_BOOTEFI_HELLO_COMPILE),) -extra-y += $(EFI_CRT0) $(EFI_RELOC) -endif -endif - -endif diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c index 6b41c0999f1..2ad6d3b4ace 100644 --- a/boot/bootmeth_efi.c +++ b/boot/bootmeth_efi.c @@ -162,8 +162,10 @@ static int distro_efi_try_bootflow_files(struct udevice *dev, int ret, seq; /* We require a partition table */ - if (!bflow->part) + if (!bflow->part) { + log_debug("no partitions\n"); return -ENOENT; + } strcpy(fname, EFI_DIRNAME); strcat(fname, BOOTEFI_NAME); @@ -171,8 +173,10 @@ static int distro_efi_try_bootflow_files(struct udevice *dev, if (bflow->blk) desc = dev_get_uclass_plat(bflow->blk); ret = bootmeth_try_file(bflow, desc, NULL, fname); - if (ret) + if (ret) { + log_debug("File '%s' not found\n", fname); return log_msg_ret("try", ret); + } /* Since we can access the file, let's call it ready */ bflow->state = BOOTFLOWST_READY; @@ -307,6 +311,8 @@ static int distro_efi_read_bootflow(struct udevice *dev, struct bootflow *bflow) { int ret; + log_debug("dev='%s', part=%d\n", bflow->dev->name, bflow->part); + /* * bootmeth_efi doesn't allocate any buffer neither for blk nor net device * set flag to avoid freeing static buffer. @@ -332,6 +338,7 @@ static int distro_efi_boot(struct udevice *dev, struct bootflow *bflow) ulong kernel, fdt; int ret; + log_debug("distro EFI boot\n"); kernel = env_get_hex("kernel_addr_r", 0); if (!bootmeth_uses_network(bflow)) { ret = efiload_read_file(bflow, kernel); diff --git a/boot/bootstd-uclass.c b/boot/bootstd-uclass.c index 5de8efce19a..fdb8d69e320 100644 --- a/boot/bootstd-uclass.c +++ b/boot/bootstd-uclass.c @@ -122,7 +122,7 @@ static int bootstd_probe(struct udevice *dev) return 0; } -/* For now, bind the boormethod device if none are found in the devicetree */ +/* For now, bind the bootmethod device if none are found in the devicetree */ int dm_scan_other(bool pre_reloc_only) { struct driver *drv = ll_entry_start(struct driver, driver); diff --git a/cmd/Kconfig b/cmd/Kconfig index dd33266cec7..37894eb80d6 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -438,21 +438,9 @@ config CMD_BOOTEFI_BOOTMGR This subcommand will allow you to select the UEFI binary to be booted via UEFI variables Boot####, BootOrder, and BootNext. -config CMD_BOOTEFI_HELLO_COMPILE - bool "Compile a standard EFI hello world binary for testing" - default y - help - This compiles a standard EFI hello world application with U-Boot so - that it can be used with the test/py testing framework. This is useful - for testing that EFI is working at a basic level, and for bringing - up EFI support on a new architecture. - - No additional space will be required in the resulting U-Boot binary - when this option is enabled. - config CMD_BOOTEFI_HELLO bool "Allow booting a standard EFI hello world for testing" - depends on CMD_BOOTEFI_BINARY && CMD_BOOTEFI_HELLO_COMPILE + depends on CMD_BOOTEFI_BINARY && BOOTEFI_HELLO_COMPILE default y if CMD_BOOTEFI_SELFTEST help This adds a standard EFI hello world application to U-Boot so that @@ -1091,13 +1079,10 @@ config CMD_BIND gadget driver from the command line. config CMD_CLK - bool "clk - Show clock frequencies" + bool "clk - Show and set clock frequencies" + depends on CLK help - (deprecated) - Shows clock frequences by calling a sock_clk_dump() hook function. - This is depreated in favour of using the CLK uclass and accessing - clock values from associated drivers. However currently no command - exists for this. + Show and set clock frequencies managed by CLK uclass drivers. config CMD_DEMO bool "demo - Demonstration commands for driver model" diff --git a/cmd/clk.c b/cmd/clk.c index 6fda6efb1ce..2fc834e5549 100644 --- a/cmd/clk.c +++ b/cmd/clk.c @@ -4,15 +4,12 @@ */ #include <command.h> #include <clk.h> -#if defined(CONFIG_DM) && defined(CONFIG_CLK) #include <dm.h> #include <dm/device.h> #include <dm/root.h> #include <dm/device-internal.h> #include <linux/clk-provider.h> -#endif -#if defined(CONFIG_DM) && defined(CONFIG_CLK) static void show_clks(struct udevice *dev, int depth, int last_flag) { int i, is_last; @@ -79,13 +76,6 @@ static int soc_clk_dump(void) return 0; } -#else -static int soc_clk_dump(void) -{ - puts("Not implemented\n"); - return 1; -} -#endif static int do_clk_dump(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) @@ -101,7 +91,6 @@ static int do_clk_dump(struct cmd_tbl *cmdtp, int flag, int argc, return ret; } -#if CONFIG_IS_ENABLED(DM) && CONFIG_IS_ENABLED(CLK) static int do_clk_setfreq(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { @@ -131,13 +120,10 @@ static int do_clk_setfreq(struct cmd_tbl *cmdtp, int flag, int argc, printf("set_rate returns %u\n", freq); return 0; } -#endif static struct cmd_tbl cmd_clk_sub[] = { U_BOOT_CMD_MKENT(dump, 1, 1, do_clk_dump, "", ""), -#if CONFIG_IS_ENABLED(DM) && CONFIG_IS_ENABLED(CLK) U_BOOT_CMD_MKENT(setfreq, 3, 1, do_clk_setfreq, "", ""), -#endif }; static int do_clk(struct cmd_tbl *cmdtp, int flag, int argc, diff --git a/configs/octeontx2_95xx_defconfig b/configs/octeontx2_95xx_defconfig index b9d36d612d2..7909a33919e 100644 --- a/configs/octeontx2_95xx_defconfig +++ b/configs/octeontx2_95xx_defconfig @@ -38,7 +38,7 @@ CONFIG_SYS_PBSIZE=1050 CONFIG_BOARD_EARLY_INIT_R=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="Marvell> " -# CONFIG_CMD_BOOTEFI_HELLO_COMPILE is not set +# CONFIG_BOOTEFI_HELLO_COMPILE is not set CONFIG_CMD_MD5SUM=y CONFIG_MD5SUM_VERIFY=y CONFIG_CMD_MX_CYCLIC=y diff --git a/configs/octeontx2_96xx_defconfig b/configs/octeontx2_96xx_defconfig index 89e01539399..cac337cb84b 100644 --- a/configs/octeontx2_96xx_defconfig +++ b/configs/octeontx2_96xx_defconfig @@ -38,7 +38,7 @@ CONFIG_SYS_PBSIZE=1050 CONFIG_BOARD_EARLY_INIT_R=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="Marvell> " -# CONFIG_CMD_BOOTEFI_HELLO_COMPILE is not set +# CONFIG_BOOTEFI_HELLO_COMPILE is not set CONFIG_CMD_MD5SUM=y CONFIG_MD5SUM_VERIFY=y CONFIG_CMD_MX_CYCLIC=y diff --git a/configs/octeontx_81xx_defconfig b/configs/octeontx_81xx_defconfig index 2fd30050b26..c935c4ee1c6 100644 --- a/configs/octeontx_81xx_defconfig +++ b/configs/octeontx_81xx_defconfig @@ -39,7 +39,7 @@ CONFIG_SYS_PBSIZE=1050 CONFIG_BOARD_EARLY_INIT_R=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="Marvell> " -# CONFIG_CMD_BOOTEFI_HELLO_COMPILE is not set +# CONFIG_BOOTEFI_HELLO_COMPILE is not set CONFIG_CMD_MD5SUM=y CONFIG_MD5SUM_VERIFY=y CONFIG_CMD_MX_CYCLIC=y diff --git a/configs/octeontx_83xx_defconfig b/configs/octeontx_83xx_defconfig index 6ab8ebc41b3..b2143394eae 100644 --- a/configs/octeontx_83xx_defconfig +++ b/configs/octeontx_83xx_defconfig @@ -37,7 +37,7 @@ CONFIG_SYS_PBSIZE=1050 CONFIG_BOARD_EARLY_INIT_R=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="Marvell> " -# CONFIG_CMD_BOOTEFI_HELLO_COMPILE is not set +# CONFIG_BOOTEFI_HELLO_COMPILE is not set CONFIG_CMD_MD5SUM=y CONFIG_MD5SUM_VERIFY=y CONFIG_CMD_MX_CYCLIC=y diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig index e2f57c11f0e..1b3b8c6e788 100644 --- a/configs/sandbox64_defconfig +++ b/configs/sandbox64_defconfig @@ -46,6 +46,7 @@ CONFIG_CMD_MD5SUM=y CONFIG_CMD_MEMINFO=y CONFIG_CMD_MX_CYCLIC=y CONFIG_CMD_MEMTEST=y +CONFIG_CMD_CLK=y CONFIG_CMD_DEMO=y CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 540ccef8950..f31ecef4f58 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -75,6 +75,7 @@ CONFIG_CMD_MEMINFO=y CONFIG_CMD_MEM_SEARCH=y CONFIG_CMD_MX_CYCLIC=y CONFIG_CMD_MEMTEST=y +CONFIG_CMD_CLK=y CONFIG_CMD_DEMO=y CONFIG_CMD_GPIO=y CONFIG_CMD_GPIO_READ=y diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig index dd62adbebd5..0313fa09532 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -44,6 +44,7 @@ CONFIG_CMD_MD5SUM=y CONFIG_CMD_MEMINFO=y CONFIG_CMD_MX_CYCLIC=y CONFIG_CMD_MEMTEST=y +CONFIG_CMD_CLK=y CONFIG_CMD_DEMO=y CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y diff --git a/configs/sandbox_noinst_defconfig b/configs/sandbox_noinst_defconfig index 41fa96ace32..a48ef1fcf6f 100644 --- a/configs/sandbox_noinst_defconfig +++ b/configs/sandbox_noinst_defconfig @@ -81,6 +81,7 @@ CONFIG_CMD_MD5SUM=y CONFIG_CMD_MEMINFO=y CONFIG_CMD_MX_CYCLIC=y CONFIG_CMD_MEMTEST=y +CONFIG_CMD_CLK=y CONFIG_CMD_DEMO=y CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig index 0b820ce62f5..f4469626090 100644 --- a/configs/sandbox_spl_defconfig +++ b/configs/sandbox_spl_defconfig @@ -60,6 +60,7 @@ CONFIG_CMD_MD5SUM=y CONFIG_CMD_MEMINFO=y CONFIG_CMD_MX_CYCLIC=y CONFIG_CMD_MEMTEST=y +CONFIG_CMD_CLK=y CONFIG_CMD_DEMO=y CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y diff --git a/configs/sandbox_vpl_defconfig b/configs/sandbox_vpl_defconfig index beb740d1b34..cda25263ac4 100644 --- a/configs/sandbox_vpl_defconfig +++ b/configs/sandbox_vpl_defconfig @@ -71,6 +71,7 @@ CONFIG_CMD_MD5SUM=y CONFIG_CMD_MEMINFO=y CONFIG_CMD_MX_CYCLIC=y CONFIG_CMD_MEMTEST=y +CONFIG_CMD_CLK=y CONFIG_CMD_DEMO=y CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y diff --git a/doc/develop/index.rst b/doc/develop/index.rst index 0d0e60ab56c..cbea38d4323 100644 --- a/doc/develop/index.rst +++ b/doc/develop/index.rst @@ -13,6 +13,7 @@ General codingstyle designprinciples docstyle + memory patman process release_cycle diff --git a/doc/develop/memory.rst b/doc/develop/memory.rst new file mode 100644 index 00000000000..e9e65ba4c6c --- /dev/null +++ b/doc/develop/memory.rst @@ -0,0 +1,49 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +Memory Management +----------------- + +.. note:: + + This information is outdated and needs to be updated. + +U-Boot runs in system state and uses physical addresses, i.e. the +MMU is not used either for address mapping nor for memory protection. + +The available memory is mapped to fixed addresses using the +memory-controller. In this process, a contiguous block is formed for each +memory type (Flash, SDRAM, SRAM), even when it consists of several +physical-memory banks. + +U-Boot is installed in XIP flash memory, or may be loaded into a lower region of +RAM by a secondary program loader (SPL). After +booting and sizing and initialising DRAM, the code relocates itself +to the upper end of DRAM. Immediately below the U-Boot code some +memory is reserved for use by malloc() [see CONFIG_SYS_MALLOC_LEN +configuration setting]. Below that, a structure with global Board-Info +data is placed, followed by the stack (growing downward). + +Additionally, some exception handler code may be copied to the low 8 kB +of DRAM (0x00000000 ... 0x00001fff). + +So a typical memory configuration with 16 MB of DRAM could look like +this:: + + 0x0000 0000 Exception Vector code + : + 0x0000 1fff + 0x0000 2000 Free for Application Use + : + : + + : + : + 0x00fb ff20 Monitor Stack (Growing downward) + 0x00fb ffac Board Info Data and permanent copy of global data + 0x00fc 0000 Malloc Arena + : + 0x00fd ffff + 0x00fe 0000 RAM Copy of Monitor Code + ... eventually: LCD or video framebuffer + ... eventually: pRAM (Protected RAM - unchanged by reset) + 0x00ff ffff [End of RAM] diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst index 94482758573..0760ca91d4f 100644 --- a/doc/develop/uefi/uefi.rst +++ b/doc/develop/uefi/uefi.rst @@ -720,7 +720,7 @@ Executing the built in hello world application A hello world UEFI application can be built with:: - CONFIG_CMD_BOOTEFI_HELLO_COMPILE=y + CONFIG_BOOTEFI_HELLO_COMPILE=y It can be embedded into the U-Boot binary with:: diff --git a/include/efi_loader.h b/include/efi_loader.h index f84852e384f..511281e150e 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -567,7 +567,7 @@ efi_status_t EFIAPI efi_convert_pointer(efi_uintn_t debug_disposition, /* Carve out DT reserved memory ranges */ void efi_carve_out_dt_rsv(void *fdt); /* Purge unused kaslr-seed */ -void efi_try_purge_kaslr_seed(void *fdt); +void efi_try_purge_rng_seed(void *fdt); /* Called by bootefi to make console interface available */ efi_status_t efi_console_register(void); /* Called by efi_init_obj_list() to proble all block devices */ diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index e58b8825605..6f6fa8d629d 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -552,6 +552,18 @@ config EFI_HTTP_BOOT directly boot from network. endmenu +config BOOTEFI_HELLO_COMPILE + bool "Compile a standard EFI hello world binary for testing" + default y + help + This compiles a standard EFI hello world application with U-Boot so + that it can be used with the test/py testing framework. This is useful + for testing that EFI is working at a basic level, and for bringing + up EFI support on a new architecture. + + No additional space will be required in the resulting U-Boot binary + when this option is enabled. + endif source "lib/efi/Kconfig" diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index 2af6f2066b5..00d18966f9e 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -11,40 +11,14 @@ asflags-y += -I. CFLAGS_efi_boottime.o += \ -DFW_VERSION="0x$(VERSION)" \ -DFW_PATCHLEVEL="0x$(PATCHLEVEL)" -CFLAGS_boothart.o := $(CFLAGS_EFI) -Os -ffreestanding -CFLAGS_REMOVE_boothart.o := $(CFLAGS_NON_EFI) -CFLAGS_helloworld.o := $(CFLAGS_EFI) -Os -ffreestanding -CFLAGS_REMOVE_helloworld.o := $(CFLAGS_NON_EFI) -CFLAGS_smbiosdump.o := $(CFLAGS_EFI) -Os -ffreestanding -CFLAGS_REMOVE_smbiosdump.o := $(CFLAGS_NON_EFI) -CFLAGS_dtbdump.o := $(CFLAGS_EFI) -Os -ffreestanding -CFLAGS_REMOVE_dtbdump.o := $(CFLAGS_NON_EFI) -CFLAGS_initrddump.o := $(CFLAGS_EFI) -Os -ffreestanding -CFLAGS_REMOVE_initrddump.o := $(CFLAGS_NON_EFI) - -ifdef CONFIG_RISCV -always += boothart.efi -targets += boothart.o -endif - -ifneq ($(CONFIG_CMD_BOOTEFI_HELLO_COMPILE),) -always += helloworld.efi -targets += helloworld.o -endif - -ifneq ($(CONFIG_GENERATE_SMBIOS_TABLE),) -always += smbiosdump.efi -targets += smbiosdump.o -endif +# These are the apps that are built +apps-$(CONFIG_RISCV) += boothart +apps-$(CONFIG_BOOTEFI_HELLO_COMPILE) += helloworld +apps-$(CONFIG_GENERATE_SMBIOS_TABLE) += smbiosdump +apps-$(CONFIG_EFI_LOAD_FILE2_INITRD) += initrddump ifeq ($(CONFIG_GENERATE_ACPI_TABLE),) -always += dtbdump.efi -targets += dtbdump.o -endif - -ifdef CONFIG_EFI_LOAD_FILE2_INITRD -always += initrddump.efi -targets += initrddump.o +apps-y += dtbdump endif obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o @@ -95,3 +69,11 @@ obj-$(CONFIG_EFI_ECPT) += efi_conformance.o EFI_VAR_SEED_FILE := $(subst $\",,$(CONFIG_EFI_VAR_SEED_FILE)) $(obj)/efi_var_seed.o: $(srctree)/$(EFI_VAR_SEED_FILE) + +# Set the C flags to add and remove for each app +$(foreach f,$(apps-y),\ + $(eval CFLAGS_$(f).o := $(CFLAGS_EFI) -Os -ffreestanding)\ + $(eval CFLAGS_REMOVE_$(f).o := $(CFLAGS_NON_EFI))) + +always += $(foreach f,$(apps-y),$(f).efi) +targets += $(foreach f,$(apps-y),$(f).o) diff --git a/lib/efi_loader/efi_dt_fixup.c b/lib/efi_loader/efi_dt_fixup.c index 9d017804eea..0dac94b0c6c 100644 --- a/lib/efi_loader/efi_dt_fixup.c +++ b/lib/efi_loader/efi_dt_fixup.c @@ -41,7 +41,7 @@ static void efi_reserve_memory(u64 addr, u64 size, bool nomap) } /** - * efi_try_purge_kaslr_seed() - Remove unused kaslr-seed + * efi_try_purge_rng_seed() - Remove unused kaslr-seed, rng-seed * * Kernel's EFI STUB only relies on EFI_RNG_PROTOCOL for randomization * and completely ignores the kaslr-seed for its own randomness needs @@ -51,8 +51,9 @@ static void efi_reserve_memory(u64 addr, u64 size, bool nomap) * * @fdt: Pointer to device tree */ -void efi_try_purge_kaslr_seed(void *fdt) +void efi_try_purge_rng_seed(void *fdt) { + const char * const prop[] = {"kaslr-seed", "rng-seed"}; const efi_guid_t efi_guid_rng_protocol = EFI_RNG_PROTOCOL_GUID; struct efi_handler *handler; efi_status_t ret; @@ -67,9 +68,13 @@ void efi_try_purge_kaslr_seed(void *fdt) if (nodeoff < 0) return; - err = fdt_delprop(fdt, nodeoff, "kaslr-seed"); - if (err < 0 && err != -FDT_ERR_NOTFOUND) - log_err("Error deleting kaslr-seed\n"); + for (size_t i = 0; i < ARRAY_SIZE(prop); ++i) { + err = fdt_delprop(fdt, nodeoff, prop[i]); + if (err < 0 && err != -FDT_ERR_NOTFOUND) + log_err("Error deleting %s\n", prop[i]); + else + log_debug("Deleted /chosen/%s\n", prop[i]); + } } /** diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c index 96f847652ec..a481eb4b7e3 100644 --- a/lib/efi_loader/efi_helper.c +++ b/lib/efi_loader/efi_helper.c @@ -522,7 +522,7 @@ efi_status_t efi_install_fdt(void *fdt) /* Create memory reservations as indicated by the device tree */ efi_carve_out_dt_rsv(fdt); - efi_try_purge_kaslr_seed(fdt); + efi_try_purge_rng_seed(fdt); if (CONFIG_IS_ENABLED(EFI_TCG2_PROTOCOL_MEASURE_DTB)) { ret = efi_tcg2_measure_dtb(fdt); diff --git a/lib/efi_loader/helloworld.c b/lib/efi_loader/helloworld.c index 586177de0c8..d10a5229f74 100644 --- a/lib/efi_loader/helloworld.c +++ b/lib/efi_loader/helloworld.c @@ -72,6 +72,33 @@ static void uint2dec(u32 value, u16 **buf) } /** + * Print an unsigned 32bit value as hexadecimal number to an u16 string + * + * @value: value to be printed + * @buf: pointer to buffer address + * on return position of terminating zero word + */ +static void uint2hex(u32 value, u16 **buf) +{ + u16 *pos = *buf; + int i; + u16 c; + + for (i = 0; i < 8; ++i) { + /* Write current digit */ + c = value >> 28; + value <<= 4; + if (c < 10) + c += '0'; + else + c += 'a' - 10; + *pos++ = c; + } + *pos = 0; + *buf = pos; +} + +/** * print_uefi_revision() - print UEFI revision number */ static void print_uefi_revision(void) @@ -96,6 +123,16 @@ static void print_uefi_revision(void) con_out->output_string(con_out, u"Running on UEFI "); con_out->output_string(con_out, rev); con_out->output_string(con_out, u"\r\n"); + + con_out->output_string(con_out, u"Firmware vendor: "); + con_out->output_string(con_out, systable->fw_vendor); + con_out->output_string(con_out, u"\r\n"); + + buf = rev; + uint2hex(systable->fw_revision, &buf); + con_out->output_string(con_out, u"Firmware revision: "); + con_out->output_string(con_out, rev); + con_out->output_string(con_out, u"\r\n"); } /** diff --git a/test/py/tests/test_efi_fit.py b/test/py/tests/test_efi_fit.py index 0ad483500f8..550058a30fd 100644 --- a/test/py/tests/test_efi_fit.py +++ b/test/py/tests/test_efi_fit.py @@ -119,7 +119,7 @@ FDT_DATA = ''' ''' @pytest.mark.buildconfigspec('bootm_efi') -@pytest.mark.buildconfigspec('cmd_bootefi_hello_compile') +@pytest.mark.buildconfigspec('BOOTEFI_HELLO_COMPILE') @pytest.mark.buildconfigspec('fit') @pytest.mark.notbuildconfigspec('generate_acpi_table') @pytest.mark.requiredtool('dtc') diff --git a/test/py/tests/test_efi_loader.py b/test/py/tests/test_efi_loader.py index 5f3b448a066..707b2c9e795 100644 --- a/test/py/tests/test_efi_loader.py +++ b/test/py/tests/test_efi_loader.py @@ -170,7 +170,7 @@ def do_test_efi_helloworld_net(u_boot_console, proto): assert expected_text not in output @pytest.mark.buildconfigspec('of_control') -@pytest.mark.buildconfigspec('cmd_bootefi_hello_compile') +@pytest.mark.buildconfigspec('bootefi_hello_compile') @pytest.mark.buildconfigspec('cmd_tftpboot') def test_efi_helloworld_net_tftp(u_boot_console): """Run the helloworld.efi binary via TFTP. diff --git a/test/py/tests/test_efi_selftest.py b/test/py/tests/test_efi_selftest.py index 43f24245582..310d8ed294a 100644 --- a/test/py/tests/test_efi_selftest.py +++ b/test/py/tests/test_efi_selftest.py @@ -58,7 +58,7 @@ def test_efi_selftest_watchdog_reboot(u_boot_console): u_boot_console.run_command(cmd='bootefi selftest', wait_for_prompt=False) if u_boot_console.p.expect(['resetting', 'U-Boot']): raise Exception('Reset failed in \'watchdog reboot\' test') - u_boot_console.restart_uboot() + u_boot_console.run_command(cmd='', send_nl=False, wait_for_reboot=True) @pytest.mark.buildconfigspec('cmd_bootefi_selftest') def test_efi_selftest_text_input(u_boot_console): |