With sandbox the U-Boot code is not mapped into the sandbox memory range
so does not need to be excluded when allocating EFI memory. Update the EFI
memory init code to take account of that.

Signed-off-by: Simon Glass <s...@chromium.org>
---

 lib/efi_loader/efi_memory.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index ad3d277be6..c1a080e2e9 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -459,18 +459,22 @@ int efi_memory_init(void)
 
        efi_add_known_memory();
 
-       /* Add U-Boot */
-       uboot_start = (gd->start_addr_sp - uboot_stack_size) & ~EFI_PAGE_MASK;
-       uboot_pages = (gd->ram_top - uboot_start) >> EFI_PAGE_SHIFT;
-       efi_add_memory_map(uboot_start, uboot_pages, EFI_LOADER_DATA, false);
-
-       /* Add Runtime Services */
-       runtime_start = (ulong)&__efi_runtime_start & ~EFI_PAGE_MASK;
-       runtime_end = (ulong)&__efi_runtime_stop;
-       runtime_end = (runtime_end + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
-       runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;
-       efi_add_memory_map(runtime_start, runtime_pages,
-                          EFI_RUNTIME_SERVICES_CODE, false);
+       if (!IS_ENABLED(CONFIG_SANDBOX)) {
+               /* Add U-Boot */
+               uboot_start = (gd->start_addr_sp - uboot_stack_size) &
+                               ~EFI_PAGE_MASK;
+               uboot_pages = (gd->ram_top - uboot_start) >> EFI_PAGE_SHIFT;
+               efi_add_memory_map(uboot_start, uboot_pages, EFI_LOADER_DATA,
+                                  false);
+
+               /* Add Runtime Services */
+               runtime_start = (ulong)&__efi_runtime_start & ~EFI_PAGE_MASK;
+               runtime_end = (ulong)&__efi_runtime_stop;
+               runtime_end = (runtime_end + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
+               runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;
+               efi_add_memory_map(runtime_start, runtime_pages,
+                                  EFI_RUNTIME_SERVICES_CODE, false);
+       }
 
 #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER
        /* Request a 32bit 64MB bounce buffer region */
-- 
2.14.1.690.gbb1197296e-goog

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to