From 106557d9d1888765cf6fccca7fe0dcf2b8fbe7fb Mon Sep 17 00:00:00 2001 From: Oliver O'Halloran Date: Thu, 8 Jun 2017 21:51:22 +1000 Subject: core/fdt: Always add a reserve map Currently we skip adding the reserved ranges block to the generated FDT blob if we are excluding the root node. This can result in a DTB that dtc will barf on because the reserved memory ranges overlap with the start of the dt_struct block. As an example: $ fdtdump broken.dtb -d /dts-v1/; // magic: 0xd00dfeed // totalsize: 0x7f3 (2035) // off_dt_struct: 0x30 <----\ // off_dt_strings: 0x7b8 | this is bad! // off_mem_rsvmap: 0x30 <----/ // version: 17 // last_comp_version: 16 // boot_cpuid_phys: 0x0 // size_dt_strings: 0x3b // size_dt_struct: 0x788 /memreserve/ 0x100000000 0x300000004; /memreserve/ 0x3300000001 0x169626d2c; /memreserve/ 0x706369652d736c6f 0x7473000000000003; *continues* With this patch: $ fdtdump working.dtb -d /dts-v1/; // magic: 0xd00dfeed // totalsize: 0x803 (2051) // off_dt_struct: 0x40 // off_dt_strings: 0x7c8 // off_mem_rsvmap: 0x30 // version: 17 // last_comp_version: 16 // boot_cpuid_phys: 0x0 // size_dt_strings: 0x3b // size_dt_struct: 0x788 // 0040: tag: 0x00000001 (FDT_BEGIN_NODE) / { // 0048: tag: 0x00000003 (FDT_PROP) // 07fb: string: phandle // 0054: value phandle = <0x00000001>; *continues* Signed-off-by: Oliver O'Halloran Signed-off-by: Stewart Smith --- core/fdt.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'core') diff --git a/core/fdt.c b/core/fdt.c index eabbd54..0131c5e 100644 --- a/core/fdt.c +++ b/core/fdt.c @@ -172,6 +172,9 @@ static int __create_dtb(void *fdt, size_t len, fdt_create(fdt, len); if (root == dt_root && !exclusive) create_dtb_reservemap(fdt, root); + else + fdt_finish_reservemap(fdt); + flatten_dt_node(fdt, root, exclusive); save_err(fdt_finish(fdt)); -- cgit v1.1