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 <[email protected]>
---
v3
        rebase patch
---
 cmd/bootefi.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index bbba3382a32..122b7f4b113 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -285,13 +285,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,
@@ -312,6 +305,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)
@@ -322,8 +318,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)
-- 
2.19.1

_______________________________________________
U-Boot mailing list
[email protected]
https://lists.denx.de/listinfo/u-boot

Reply via email to