]> git.baikalelectronics.ru Git - uboot.git/commitdiff
efi_loader: carving out memory reservations
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Mon, 12 Nov 2018 17:55:23 +0000 (18:55 +0100)
committerAlexander Graf <agraf@suse.de>
Sun, 2 Dec 2018 20:59:37 +0000 (21:59 +0100)
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@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
cmd/bootefi.c

index 8c4049b7db12b000ee2b9d905b834a0a5a793e08..3e37805ea132d8d70d536fcb896849fec8e81b54 100644 (file)
@@ -275,7 +275,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);