From d0d1c4a4f5d13c8dd792d5cc5379eb4c1e0f0c46 Mon Sep 17 00:00:00 2001 From: Harsimran Singh Tungal Date: Mon, 27 Apr 2026 16:05:30 +0100 Subject: efi_loader: fix AllocatePages overlap status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return EFI_NOT_FOUND for EFI_ALLOCATE_ADDRESS overlap When efi_allocate_pages() is called with EFI_ALLOCATE_ADDRESS, UEFI expects EFI_NOT_FOUND if the requested address range is already allocated or unavailable. U-Boot currently returns EFI_OUT_OF_RESOURCES when efi_update_memory_map() detects an overlap after a successful lmb_alloc_mem(), which does not match EFI_ALLOCATE_ADDRESS semantics. Return EFI_NOT_FOUND for EFI_ALLOCATE_ADDRESS requests that fail due to an overlapping EFI memory descriptor, while keeping EFI_OUT_OF_RESOURCES for other allocation types. The UEFI specification [1] specifies that EFI_BOOT_SERVICES.AllocatePages must return EFI_NOT_FOUND when the requested address range is unavailable or already allocated; EFI_OUT_OF_RESOURCES applies to non‑address‑specific allocation failures. [1] https://uefi.org/specs/UEFI/2.10_A/07_Services_Boot_Services.html Signed-off-by: Harsimran Singh Tungal The UEFI specification does not clearly specify the behavior. But let's follow the EDK II precedent here. Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_memory.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 046a2bb4641..2feb29f0a2c 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -495,7 +495,9 @@ efi_status_t efi_allocate_pages(enum efi_allocate_type type, /* Map would overlap, bail out */ lmb_free(addr, (u64)pages << EFI_PAGE_SHIFT, flags); unmap_sysmem((void *)(uintptr_t)efi_addr); - return EFI_OUT_OF_RESOURCES; + if (type == EFI_ALLOCATE_ADDRESS) + return EFI_NOT_FOUND; + return EFI_OUT_OF_RESOURCES; } *memory = efi_addr; -- cgit v1.2.3 From 1076feb8a3f96e2def81485f852e9c1a451cedf4 Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Thu, 7 May 2026 17:04:05 +0200 Subject: cmd: boot: fix edl being shown when not supported edl is implemented in the sysreset_ops.request_arg callback of the qcom-psci sysreset driver. That callback is only called from sysreset_request_arg() which is compiled only when CONFIG_SYSRESET_CMD_RESET_ARGS=y. Therefore, only show the edl option if that symbol is enabled. It is in a separate if block because any option but -w will only be handled when CONFIG_SYSRESET_CMD_RESET_ARGS=y as seen with the implementation in do_reset() in drivers/sysreset/sysreset-uclass.c. Fixes: ef06c5d76ff4 ("cmd: boot: Add '-edl' option to reset command documentation") Signed-off-by: Quentin Schulz Reviewed-by: Simon Glass --- cmd/boot.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/boot.c b/cmd/boot.c index d80f9d8c05d..29cdf4a9a81 100644 --- a/cmd/boot.c +++ b/cmd/boot.c @@ -60,8 +60,11 @@ U_BOOT_CMD( reset, 2, 0, do_reset, "Perform RESET of the CPU", "- cold boot without level specifier\n" +#if IS_ENABLED(CONFIG_SYSRESET_CMD_RESET_ARGS) +// All options handled by sysreset drivers via their sysreset_ops.request_arg callback #ifdef CONFIG_SYSRESET_QCOM_PSCI "reset -edl - Boot to Emergency DownLoad mode\n" +#endif #endif "reset -w - warm reset if implemented" ); -- cgit v1.2.3 From fe725640ece0405730507a556061cb3b32586c1f Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Thu, 7 May 2026 17:04:06 +0200 Subject: doc: usage: cmd: reset: fix typo "Do warm WARM" doesn't mean anything, I'm assuming the intent was to say "Do WARM reset" so reword. Fixes: 34e452dd0252 ("doc: usage: Group all shell command docs into cmd/ sub-directory") Signed-off-by: Quentin Schulz Reviewed-by: Simon Glass --- doc/usage/cmd/reset.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/usage/cmd/reset.rst b/doc/usage/cmd/reset.rst index 366b17eea16..88261293924 100644 --- a/doc/usage/cmd/reset.rst +++ b/doc/usage/cmd/reset.rst @@ -20,7 +20,7 @@ Perform reset of the CPU. By default does COLD reset, which resets CPU, DDR and peripherals, on some boards also resets external PMIC. -w - Do warm WARM, reset CPU but keep peripheral/DDR/PMIC active. + Do WARM reset: reset CPU but keep peripheral/DDR/PMIC active. -edl Boot to Emergency DownLoad mode on supported Qualcomm platforms. -- cgit v1.2.3 From e49c84f7bb7b69a9736e8243665b30b46075ab55 Mon Sep 17 00:00:00 2001 From: Quentin Schulz Date: Thu, 7 May 2026 17:04:07 +0200 Subject: doc: usage: cmd: reset: specify when the -edl option is available The option is only available when CONFIG_SYSRESET_QCOM_PSCI is enabled, so let's make that explicit in the boot cmd documentation. Due to the implementation in drivers/sysreset/sysreset-uclass.c do_reset() function, all options to the reset command are passed to all sysreset drivers' sysreset_ops.request_arg callback (including -w) which is only available when CONFIG_SYSRESET_CMD_RESET_ARGS=y. -w, however, works also without this option. Fixes: ef06c5d76ff4 ("cmd: boot: Add '-edl' option to reset command documentation") Signed-off-by: Quentin Schulz Reviewed-by: Simon Glass --- doc/usage/cmd/reset.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/usage/cmd/reset.rst b/doc/usage/cmd/reset.rst index 88261293924..79bc8b9deca 100644 --- a/doc/usage/cmd/reset.rst +++ b/doc/usage/cmd/reset.rst @@ -11,7 +11,9 @@ Synopsis :: - reset [-w] + reset + reset -w + reset -edl Description ----------- @@ -22,8 +24,12 @@ DDR and peripherals, on some boards also resets external PMIC. -w Do WARM reset: reset CPU but keep peripheral/DDR/PMIC active. +All other options require CONFIG_SYSRESET_CMD_RESET_ARGS=y. + -edl - Boot to Emergency DownLoad mode on supported Qualcomm platforms. + Boot to Emergency DownLoad mode on supported Qualcomm platforms. Unsupported + platforms will print an error message but the command will successfully + return (having done nothing). Requires CONFIG_SYSRESET_QCOM_PSCI=y. Return value ------------ -- cgit v1.2.3 From ec95a60d9dcd9436faa08f8151f05e4bba8e14a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Stehl=C3=A9?= Date: Tue, 12 May 2026 19:40:33 +0200 Subject: efi_loader: fix hii keyboard layout pointer computation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The EFI_HII_KEYBOARD_LAYOUT field `layout_length' is expressed in bytes, but we add it to the `layout' pointer with (scaled) pointer arithmetic. When adding an HII keyboard package with multiple keyboard layouts, this results in only the first layout being added correctly; fix it. Fixes: 8d3b77e36e10 ("efi: hii: add keyboard layout package support") Signed-off-by: Vincent Stehlé Cc: Heinrich Schuchardt Cc: Ilias Apalodimas Cc: Tom Rini Cc: AKASHI Takahiro --- lib/efi_loader/efi_hii.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_hii.c b/lib/efi_loader/efi_hii.c index 330d7c5830b..7bf51ad43d1 100644 --- a/lib/efi_loader/efi_hii.c +++ b/lib/efi_loader/efi_hii.c @@ -324,7 +324,8 @@ add_keyboard_package(struct efi_hii_packagelist *hii, list_add_tail(&layout_data->link_sys, &efi_keyboard_layout_list); - layout += layout_length; + layout = (struct efi_hii_keyboard_layout *) + ((uintptr_t)layout + layout_length); } list_add_tail(&package_data->link, &hii->keyboard_packages); -- cgit v1.2.3 From 5824ed13bcdf4726c13ef76e8186bc145d8e43f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Stehl=C3=A9?= Date: Tue, 12 May 2026 19:40:34 +0200 Subject: efi_selftest: test hii keyboard layouts more MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The HII database test for keyboard layouts register two package lists with two keyboard layouts each, but the test verifies only the GUID of the first keyboard layout. This does not catch the bugs happening with the keyboard layouts after the first one in a package. Verify all the keyboard layout GUIDs in the unit test to prevent this. Signed-off-by: Vincent Stehlé Cc: Heinrich Schuchardt Cc: Ilias Apalodimas Cc: Tom Rini --- lib/efi_selftest/efi_selftest_hii.c | 67 ++++++++++++++++++-------------- lib/efi_selftest/efi_selftest_hii_data.c | 12 ++++++ 2 files changed, 49 insertions(+), 30 deletions(-) diff --git a/lib/efi_selftest/efi_selftest_hii.c b/lib/efi_selftest/efi_selftest_hii.c index 228dc296950..fdbb08fb417 100644 --- a/lib/efi_selftest/efi_selftest_hii.c +++ b/lib/efi_selftest/efi_selftest_hii.c @@ -452,8 +452,7 @@ out: * test_hii_database_get_keyboard_layout() - test retrieval of keyboard layout * * This test adds two package lists, each of which has two keyboard layouts - * and then tries to get a handle to keyboard layout with a specific guid - * and the current one. + * and then tries to get a handle to every keyboard layout and the current one. * * @Return: status code */ @@ -463,7 +462,11 @@ static int test_hii_database_get_keyboard_layout(void) struct efi_hii_keyboard_layout *kb_layout; u16 kb_layout_size; efi_status_t ret; - int result = EFI_ST_FAILURE; + int result = EFI_ST_FAILURE, i; + static efi_guid_t *const kb_layout_guids[] = { + &kb_layout_guid11, &kb_layout_guid12, + &kb_layout_guid21, &kb_layout_guid22 + }; PRINT_TESTNAME; ret = hii_database_protocol->new_package_list(hii_database_protocol, @@ -484,33 +487,37 @@ static int test_hii_database_get_keyboard_layout(void) goto out; } - /* specific keyboard_layout(guid11) */ - kb_layout = NULL; - kb_layout_size = 0; - ret = hii_database_protocol->get_keyboard_layout(hii_database_protocol, - &kb_layout_guid11, &kb_layout_size, kb_layout); - if (ret != EFI_BUFFER_TOO_SMALL) { - efi_st_error("get_keyboard_layout returned %u\n", - (unsigned int)ret); - goto out; - } - ret = boottime->allocate_pool(EFI_LOADER_DATA, kb_layout_size, - (void **)&kb_layout); - if (ret != EFI_SUCCESS) { - efi_st_error("AllocatePool failed\n"); - goto out; - } - ret = hii_database_protocol->get_keyboard_layout(hii_database_protocol, - &kb_layout_guid11, &kb_layout_size, kb_layout); - if (ret != EFI_SUCCESS) { - efi_st_error("get_keyboard_layout returned %u\n", - (unsigned int)ret); - goto out; - } - ret = boottime->free_pool(kb_layout); - if (ret != EFI_SUCCESS) { - efi_st_error("FreePool failed\n"); - goto out; + /* Verify all keyboard layouts */ + for (i = 0; i < ARRAY_SIZE(kb_layout_guids); i++) { + efi_guid_t *kb_layout_guid = kb_layout_guids[i]; + + kb_layout = NULL; + kb_layout_size = 0; + ret = hii_database_protocol->get_keyboard_layout(hii_database_protocol, + kb_layout_guid, &kb_layout_size, kb_layout); + if (ret != EFI_BUFFER_TOO_SMALL) { + efi_st_error("get_keyboard_layout returned %u\n", + (unsigned int)ret); + goto out; + } + ret = boottime->allocate_pool(EFI_LOADER_DATA, kb_layout_size, + (void **)&kb_layout); + if (ret != EFI_SUCCESS) { + efi_st_error("AllocatePool failed\n"); + goto out; + } + ret = hii_database_protocol->get_keyboard_layout(hii_database_protocol, + kb_layout_guid, &kb_layout_size, kb_layout); + if (ret != EFI_SUCCESS) { + efi_st_error("get_keyboard_layout returned %u\n", + (unsigned int)ret); + goto out; + } + ret = boottime->free_pool(kb_layout); + if (ret != EFI_SUCCESS) { + efi_st_error("FreePool failed\n"); + goto out; + } } /* current */ diff --git a/lib/efi_selftest/efi_selftest_hii_data.c b/lib/efi_selftest/efi_selftest_hii_data.c index 5fc890112b4..2d29bb045d3 100644 --- a/lib/efi_selftest/efi_selftest_hii_data.c +++ b/lib/efi_selftest/efi_selftest_hii_data.c @@ -428,6 +428,18 @@ static efi_guid_t kb_layout_guid11 = EFI_GUID(0x8d40e495, 0xe2aa, 0x4c6f, 0x89, 0x70, 0x68, 0x85, 0x09, 0xee, 0xc7, 0xd2); +static efi_guid_t kb_layout_guid12 = + EFI_GUID(0x2ae60b3e, 0xb9d6, 0x49d8, + 0x9a, 0x16, 0xc2, 0x48, 0xf1, 0xeb, 0xa8, 0xdb); + +static efi_guid_t kb_layout_guid21 = + EFI_GUID(0xe0f56a1f, 0xdf6b, 0x4a7e, + 0xa3, 0x9a, 0xe7, 0xa5, 0x19, 0x15, 0x45, 0xd6); + +static efi_guid_t kb_layout_guid22 = + EFI_GUID(0x47be6ac9, 0x54cc, 0x46f9, + 0xa2, 0x62, 0xd5, 0x3b, 0x25, 0x6a, 0x0c, 0x34); + static efi_guid_t package_guid = EFI_GUID(0x0387c95a, 0xd703, 0x2346, 0xb2, 0xab, 0xd0, 0xc7, 0xdd, 0x90, 0x44, 0xf8); -- cgit v1.2.3