]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
efi_loader: create fdt reservation before copy
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Sun, 18 Nov 2018 16:58:53 +0000 (17:58 +0100)
committerAlexander Graf <agraf@suse.de>
Sun, 2 Dec 2018 20:59:37 +0000 (21:59 +0100)
When copying the device we must ensure that the copy does not fall into a
memory area reserved by the same.

So let's change the sequence: first create memory reservations and then
copy the device tree.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
cmd/bootefi.c

index ad97a9c01960098fe33b60bd13a13a98db7cb40b..38679ffc56a95af3737daacf16240b3fd82755e2 100644 (file)
@@ -280,13 +280,6 @@ static void efi_carve_out_dt_rsv(void *fdt)
                /* Convert from sandbox address space. */
                addr = (uintptr_t)map_sysmem(addr, 0);
 
-               /*
-                * Do not carve out the device tree. It is already marked as
-                * EFI_RUNTIME_SERVICES_DATA
-                */
-               if (addr == (uintptr_t)fdt)
-                       continue;
-
                pages = efi_size_in_pages(size + (addr & EFI_PAGE_MASK));
                addr &= ~EFI_PAGE_MASK;
                if (!efi_add_memory_map(addr, pages, EFI_RESERVED_MEMORY_TYPE,
@@ -307,6 +300,9 @@ static efi_status_t efi_install_fdt(ulong fdt_addr)
                return EFI_INVALID_PARAMETER;
        }
 
+       /* Create memory reservation as indicated by the device tree */
+       efi_carve_out_dt_rsv(fdt);
+
        /* Prepare fdt for payload */
        ret = copy_fdt(&fdt);
        if (ret)
@@ -317,8 +313,6 @@ static efi_status_t efi_install_fdt(ulong fdt_addr)
                return EFI_LOAD_ERROR;
        }
 
-       efi_carve_out_dt_rsv(fdt);
-
        /* Link to it in the efi tables */
        ret = efi_install_configuration_table(&efi_guid_fdt, fdt);
        if (ret != EFI_SUCCESS)