[U-Boot] [PATCH v2 4/9] efi_loader: carving out memory reservations

Heinrich Schuchardt xypron.glpk at gmx.de
Mon Nov 12 17:55:23 UTC 2018


The "Devicetree Specification 0.2" does not prescribe that memory
reservations must be EFI page aligned. So let's not make such an
assumption in our code.

Do not carve out the pages for the device tree. This memory area is
already marked as EFI_RUNTIME_SERVICES_DATA.

Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
v2:
	no change
---
 cmd/bootefi.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index f2950817a13..c73e6228d3e 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -280,7 +280,16 @@ static void efi_carve_out_dt_rsv(void *fdt)
 		if (fdt_get_mem_rsv(fdt, i, &addr, &size) != 0)
 			continue;
 
-		pages = ALIGN(size, EFI_PAGE_SIZE) >> EFI_PAGE_SHIFT;
+		/*
+		 * Do not carve out the device tree. It is already marked as
+		 * EFI_RUNTIME_SERVICES_DATA
+		 */
+		if (addr == (uintptr_t)fdt)
+			continue;
+
+		pages = ALIGN(size + (addr & EFI_PAGE_MASK), EFI_PAGE_SIZE) >>
+			EFI_PAGE_SHIFT;
+		addr &= ~EFI_PAGE_MASK;
 		if (!efi_add_memory_map(addr, pages, EFI_RESERVED_MEMORY_TYPE,
 					false))
 			printf("FDT memrsv map %d: Failed to add to map\n", i);
-- 
2.19.1



More information about the U-Boot mailing list