efi: Fix efiboot for payloads loaded from memory

Calling bootefi on an address that was loaded from memory (e.g., cramfs
or SPI flash via "sf read", etc.), currently results in the EFI binary
not being able to access the EFI image device path.

For example, iPXE would fail with an error "EFI could not get loaded
image's device path: Error 0x7f39e082 (https://ipxe.org/7f39e082)".

This is due to an incomplete special-case in efi_binary_run, where a new
device path was created but not used in all required places.

Fix the in-memory special case, set the "bootefi_device_path" to the
generated "file_path".

iPXE will now boot, and report the device path as
"/MemoryMapped(0x0,0xSTART,0xLEN)"

Signed-off-by: Christian Kohlschütter <christian@kohlschutter.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
This commit is contained in:
Christian Kohlschütter 2025-03-23 20:03:03 +01:00 committed by Heinrich Schuchardt
parent 70d5f6e21e
commit 85403c46e6

View file

@ -283,6 +283,9 @@ efi_status_t efi_binary_run(void *image, size_t size, void *fdt, void *initrd, s
file_path, NULL); file_path, NULL);
if (ret != EFI_SUCCESS) if (ret != EFI_SUCCESS)
goto out; goto out;
bootefi_device_path = file_path;
bootefi_image_path = NULL;
} else { } else {
log_debug("Loaded from disk\n"); log_debug("Loaded from disk\n");
} }