diff mbox series

[v2,2/3] efi/libstub: Pass loaded image EFI handle to efi_load_initrd()

Message ID 20230321161803.3289140-3-ardb@kernel.org
State New
Headers show
Series efi: Allow initrd LoadFile2 proto on loaded image | expand

Commit Message

Ard Biesheuvel March 21, 2023, 4:18 p.m. UTC
In preparation for allowing loaders to pass the initrd loadfile2
protocol implementation via the loaded image handle instead of a global
singleton device path, pass the loaded image EFI handle down to the code
that loads the initrd.

Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 drivers/firmware/efi/libstub/efi-stub-helper.c | 3 ++-
 drivers/firmware/efi/libstub/efi-stub.c        | 4 ++--
 drivers/firmware/efi/libstub/efistub.h         | 3 ++-
 drivers/firmware/efi/libstub/x86-stub.c        | 4 ++--
 4 files changed, 8 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
index ff60e3a78337ce5c..d1026c6a544058b4 100644
--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
@@ -554,7 +554,8 @@  efi_status_t efi_load_initrd_cmdline(efi_loaded_image_t *image,
  *
  * Return:	status code
  */
-efi_status_t efi_load_initrd(efi_loaded_image_t *image,
+efi_status_t efi_load_initrd(efi_handle_t handle,
+			     efi_loaded_image_t *image,
 			     unsigned long soft_limit,
 			     unsigned long hard_limit,
 			     const struct linux_efi_initrd **out)
diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c
index 2955c1ac6a36ee00..a5eb773a574143cf 100644
--- a/drivers/firmware/efi/libstub/efi-stub.c
+++ b/drivers/firmware/efi/libstub/efi-stub.c
@@ -177,8 +177,8 @@  efi_status_t efi_stub_common(efi_handle_t handle,
 	/* Ask the firmware to clear memory on unclean shutdown */
 	efi_enable_reset_attack_mitigation();
 
-	efi_load_initrd(image, ULONG_MAX, efi_get_max_initrd_addr(image_addr),
-			NULL);
+	efi_load_initrd(handle, image, ULONG_MAX,
+			efi_get_max_initrd_addr(image_addr), NULL);
 
 	efi_random_get_seed();
 
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
index 96a04ee05cdbb8bf..d772f2e33af7c270 100644
--- a/drivers/firmware/efi/libstub/efistub.h
+++ b/drivers/firmware/efi/libstub/efistub.h
@@ -1019,7 +1019,8 @@  static inline efi_status_t efi_load_dtb(efi_loaded_image_t *image,
 				    ULONG_MAX, ULONG_MAX, load_addr, load_size);
 }
 
-efi_status_t efi_load_initrd(efi_loaded_image_t *image,
+efi_status_t efi_load_initrd(efi_handle_t handle,
+			     efi_loaded_image_t *image,
 			     unsigned long soft_limit,
 			     unsigned long hard_limit,
 			     const struct linux_efi_initrd **out);
diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
index a0bfd31358ba97b1..e79f6977b41c15c2 100644
--- a/drivers/firmware/efi/libstub/x86-stub.c
+++ b/drivers/firmware/efi/libstub/x86-stub.c
@@ -867,8 +867,8 @@  asmlinkage unsigned long efi_main(efi_handle_t handle,
 	 * arguments will be processed only if image is not NULL, which will be
 	 * the case only if we were loaded via the PE entry point.
 	 */
-	status = efi_load_initrd(image, hdr->initrd_addr_max, ULONG_MAX,
-				 &initrd);
+	status = efi_load_initrd(handle, image, hdr->initrd_addr_max,
+				 ULONG_MAX, &initrd);
 	if (status != EFI_SUCCESS)
 		goto fail;
 	if (initrd && initrd->size > 0) {