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(-) (limited to 'lib/efi_loader') 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 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(-) (limited to 'lib/efi_loader') 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