[PATCH v3 26/28] efi_bootmgr: Avoid casts in try_load_from_uri_path()
Simon Glass
sjg at chromium.org
Thu Nov 28 20:12:42 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 | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c
index b4ea6b817b6..98799aead84 100644
--- a/lib/efi_loader/efi_bootmgr.c
+++ b/lib/efi_loader/efi_bootmgr.c
@@ -14,6 +14,7 @@
#include <efi.h>
#include <log.h>
#include <malloc.h>
+#include <mapmem.h>
#include <net.h>
#include <efi_loader.h>
#include <efi_variable.h>
@@ -497,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,
@@ -506,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