summaryrefslogtreecommitdiffstats
path: root/src/image/efi_image.c
diff options
context:
space:
mode:
authorMichael Brown2023-05-05 15:46:42 +0200
committerMichael Brown2023-05-05 15:54:20 +0200
commit0bb0aea878bc9c2f775d967df83d3c081c1c34a2 (patch)
tree8c00f79289f3c71592dd50ccee8742f9d91534b0 /src/image/efi_image.c
parent[image] Allow for images to be hidden from lists of all images (diff)
downloadipxe-0bb0aea878bc9c2f775d967df83d3c081c1c34a2.tar.gz
ipxe-0bb0aea878bc9c2f775d967df83d3c081c1c34a2.tar.xz
ipxe-0bb0aea878bc9c2f775d967df83d3c081c1c34a2.zip
[efi] Allow currently executing image to be opened via virtual filesystem
When invoking a kernel via the UEFI shim, the kernel image must be accessible via EFI_SIMPLE_FILE_SYSTEM_PROTOCOL but must not be present in the magic initrd constructed from all registered images. Re-register a currently executing EFI image and mark it as hidden, thereby allowing it to be accessed via the virtual filesystem exposed via EFI_SIMPLE_FILE_SYSTEM_PROTOCOL without appearing in the magic initrd contents. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/image/efi_image.c')
-rw-r--r--src/image/efi_image.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/image/efi_image.c b/src/image/efi_image.c
index 467fb05a..0be48564 100644
--- a/src/image/efi_image.c
+++ b/src/image/efi_image.c
@@ -141,6 +141,7 @@ static int efi_image_exec ( struct image *image ) {
EFI_HANDLE handle;
EFI_MEMORY_TYPE type;
wchar_t *cmdline;
+ unsigned int toggle;
EFI_STATUS efirc;
int rc;
@@ -153,6 +154,12 @@ static int efi_image_exec ( struct image *image ) {
goto err_no_snpdev;
}
+ /* Re-register as a hidden image to allow for access via file I/O */
+ toggle = ( ~image->flags & IMAGE_HIDDEN );
+ image->flags |= IMAGE_HIDDEN;
+ if ( ( rc = register_image ( image ) ) != 0 )
+ goto err_register_image;
+
/* Install file I/O protocols */
if ( ( rc = efi_file_install ( snpdev->handle ) ) != 0 ) {
DBGC ( image, "EFIIMAGE %s could not install file protocol: "
@@ -296,6 +303,9 @@ static int efi_image_exec ( struct image *image ) {
err_pxe_install:
efi_file_uninstall ( snpdev->handle );
err_file_install:
+ unregister_image ( image );
+ err_register_image:
+ image->flags ^= toggle;
err_no_snpdev:
return rc;
}