efi: Fix efiboot for payloads loaded from memory
authorChristian Kohlschütter <christian@kohlschutter.com>
Sun, 23 Mar 2025 19:03:03 +0000 (20:03 +0100)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Fri, 11 Apr 2025 11:20:38 +0000 (13:20 +0200)
commit85403c46e681653ccc0a31755b51b13c8ac53714
treeb5708584a1ea78f86d6067cd890853d9fc40dec4
parent70d5f6e21ee33693d2d34b8eede34c83d45663b8
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>
lib/efi_loader/efi_bootbin.c