[PATCH v5 22/23] efi_bootmgr: Avoid casts in try_load_from_uri_path()
Simon Glass
sjg at chromium.org
Wed Dec 11 14:54:16 CET 2024
Update this function to use map_sysmem() so that it can work correctly
on sandbox
Signed-off-by: Simon Glass <sjg at chromium.org>
---
(no changes since v1)
lib/efi_loader/efi_bootmgr.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c
index 9383adbd958..98799aead84 100644
--- a/lib/efi_loader/efi_bootmgr.c
+++ b/lib/efi_loader/efi_bootmgr.c
@@ -498,6 +498,7 @@ static efi_status_t try_load_from_uri_path(struct efi_device_path_uri *uridp,
* If the file is PE-COFF image, load the downloaded file.
*/
uri_len = strlen(uridp->uri);
+ source_buffer = map_sysmem(image_addr, image_size);
if (!strncmp(&uridp->uri[uri_len - 4], ".iso", 4) ||
!strncmp(&uridp->uri[uri_len - 4], ".img", 4)) {
ret = prepare_loaded_image(lo_label, image_addr, image_size,
@@ -507,21 +508,19 @@ static efi_status_t try_load_from_uri_path(struct efi_device_path_uri *uridp,
source_buffer = NULL;
source_size = 0;
-
- /* TODO(sjg): This does not work on sandbox */
- } else if (efi_check_pe((void *)image_addr, image_size, NULL) == EFI_SUCCESS) {
+ } else if (efi_check_pe(source_buffer, image_size, NULL) ==
+ EFI_SUCCESS) {
/*
* loaded_dp must exist until efi application returns,
* will be freed in return_to_efibootmgr event callback.
*/
loaded_dp = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
- (uintptr_t)image_addr, image_size);
+ image_addr, image_size);
ret = efi_install_multiple_protocol_interfaces(
&mem_handle, &efi_guid_device_path, loaded_dp, NULL);
if (ret != EFI_SUCCESS)
goto err;
- source_buffer = (void *)image_addr;
source_size = image_size;
} else {
log_err("Error: file type is not supported\n");
--
2.34.1
More information about the U-Boot
mailing list