Skip to contentSkip to conversation

efi: Fix efiboot for payloads loaded from memory

PATCH In review Christian Kohlschütter 3 participants 3 messages Mar 23, 2025 – Apr 11, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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)"

---
 lib/efi_loader/efi_bootbin.c | 3 +++
 1 file changed, 3 insertions(+)
lib/efi_loader/efi_bootbin.c +3 -0
index 10ec5e9ada3..f78cf972228 100644
@@ -268,6 +268,9 @@ efi_status_t efi_binary_run(void *image, size_t size, void *fdt)
 							       file_path, NULL);
 		if (ret != EFI_SUCCESS)
 			goto out;
+
+		bootefi_device_path = file_path;
+		bootefi_image_path = NULL;
 	} else {
 		log_debug("Loaded from disk\n");
 	}
Signature · 1 line
2.48.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Christian Kohlschütter

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.

Quoted 7 lines

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)"

Hello Christian,

Thank you for the patch.

For future submission, please, use scripts/get_maintainer.pl to identify mail recipients.

Best regards

Quoted 18 lines
---
  lib/efi_loader/efi_bootbin.c | 3 +++
  1 file changed, 3 insertions(+)
lib/efi_loader/efi_bootbin.c +3 -0
index 10ec5e9ada3..f78cf972228 100644
@@ -268,6 +268,9 @@ efi_status_t efi_binary_run(void *image, size_t size, void *fdt)
  							       file_path, NULL);
  		if (ret != EFI_SUCCESS)
  			goto out;
+
+		bootefi_device_path = file_path;
+		bootefi_image_path = NULL;
  	} else {
  		log_debug("Loaded from disk\n");
  	}
Reviewed-by
#2 lore raw

Thanks for the CC Heinrich

Quoted 36 lines · Heinrich Schuchardt
Quoted 10 lines · Christian Kohlschütter

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.

Quoted 7 lines

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)"

Hello Christian,

Thank you for the patch.

For future submission, please, use scripts/get_maintainer.pl to identify mail recipients.

Best regards

Quoted 4 lines
---
  lib/efi_loader/efi_bootbin.c | 3 +++
  1 file changed, 3 insertions(+)
Quoted 15 lines
Quoted 5 lines
lib/efi_loader/efi_bootbin.c +0 -0
index 10ec5e9ada3..f78cf972228 100644

lib/efi_loader/efi_bootbin.c efi_status_t efi_binary_run(void *image, size_t size, void *fdt) · line 276

Quoted 9 lines
lib/efi_loader/efi_bootbin.c +3 -0
@@ -268,6 +268,9 @@ efi_status_t efi_binary_run(void *image, size_t size, void *fdt)
                                                             file_path, NULL);
              if (ret != EFI_SUCCESS)
                      goto out;
+
+             bootefi_device_path = file_path;
+             bootefi_image_path = NULL;
      } else {
              log_debug("Loaded from disk\n");
      }