[Skiboot] [PATCH] core/fdt: Always add a reserve map

Oliver O'Halloran oohall at gmail.com
Thu Jun 8 21:51:22 AEST 2017


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 <oohall at gmail.com>
---
 core/fdt.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/core/fdt.c b/core/fdt.c
index eabbd5411a47..0131c5e21f84 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));
-- 
2.9.3



More information about the Skiboot mailing list