Thread (160 messages) 160 messages, 4 authors, 2026-01-29

Re: [RFC PATCH 02/77] Introduce v18 dtb version

From: David Gibson <hidden>
Date: 2026-01-15 00:27:30
Also in: lkml

On Mon, Jan 12, 2026 at 03:18:52PM +0100, Herve Codina wrote:
This v18 version will add support for
 - metadata in device-tree blobs in order to have a better handling of
   phandles and unresolved references.
 - Addon device-tree blob (successor of device-tree overlay)
 - Import and export symbols feature
 - multiple trees in a addon device-tree blob (i.e. root device tree and
   orphan node tree)
So, once this patch is applied, the rest of the series pretty much has
to be applied "atomically" - otherwise a version built in the interim
will be lying in saying that it supports v18.

I therefore suggest moving any changes that *can* be moved before this
patch, should be moved before this patch.  That will assist in
reviewing and merging the series piecemeal, rather than as a single
giant blob.


Regarding the content itself.  It seems like this is a pretty major
change to the dtb format - maybe that would suggest bumping the
version by more than one (e.g. like we went from v3 to v16 in the
past).

It would also be nice to have some docs for the new dtb extensions
before or at the same time as this.
quoted hunk ↗ jump to hunk
Signed-off-by: Herve Codina <herve.codina@bootlin.com>
---
 dtc.h                   |  2 +-
 fdtdump.c               |  2 +-
 flattree.c              |  2 ++
 libfdt/fdt.h            |  1 +
 libfdt/fdt_rw.c         | 13 +++++++------
 libfdt/libfdt.h         |  2 +-
 tests/pylibfdt_tests.py |  2 +-
 tests/trees.S           |  2 +-
 8 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/dtc.h b/dtc.h
index 3a220b9..186caad 100644
--- a/dtc.h
+++ b/dtc.h
@@ -29,7 +29,7 @@
 #define debug(...)
 #endif
 
-#define DEFAULT_FDT_VERSION	17
+#define DEFAULT_FDT_VERSION	18
 
 /*
  * Command line options
diff --git a/fdtdump.c b/fdtdump.c
index d424869..ec25edf 100644
--- a/fdtdump.c
+++ b/fdtdump.c
@@ -18,7 +18,7 @@
 #include "util.h"
 
 #define FDT_MAGIC_SIZE	4
-#define MAX_VERSION 17U
+#define MAX_VERSION 18U
 
 #define ALIGN(x, a)	(((x) + ((a) - 1)) & ~((a) - 1))
 #define PALIGN(p, a)	((void *)(ALIGN((uintptr_t)(p), (a))))
diff --git a/flattree.c b/flattree.c
index 30e6de2..c3887da 100644
--- a/flattree.c
+++ b/flattree.c
@@ -30,6 +30,8 @@ static struct version_info {
 	 FTF_BOOTCPUID|FTF_STRTABSIZE|FTF_NOPS},
 	{17, 16, FDT_V17_SIZE,
 	 FTF_BOOTCPUID|FTF_STRTABSIZE|FTF_STRUCTSIZE|FTF_NOPS},
+	{18, 18, FDT_V18_SIZE,
+	 FTF_BOOTCPUID|FTF_STRTABSIZE|FTF_STRUCTSIZE|FTF_NOPS},
 };
 
 struct emitter {
diff --git a/libfdt/fdt.h b/libfdt/fdt.h
index a07abfc..9372353 100644
--- a/libfdt/fdt.h
+++ b/libfdt/fdt.h
@@ -62,5 +62,6 @@ struct fdt_property {
 #define FDT_V3_SIZE	(FDT_V2_SIZE + sizeof(fdt32_t))
 #define FDT_V16_SIZE	FDT_V3_SIZE
 #define FDT_V17_SIZE	(FDT_V16_SIZE + sizeof(fdt32_t))
+#define FDT_V18_SIZE	FDT_V17_SIZE
 
 #endif /* FDT_H */
diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c
index 7475caf..00e32bb 100644
--- a/libfdt/fdt_rw.c
+++ b/libfdt/fdt_rw.c
@@ -28,13 +28,13 @@ static int fdt_rw_probe_(void *fdt)
 		return 0;
 	FDT_RO_PROBE(fdt);
 
-	if (!can_assume(LATEST) && fdt_version(fdt) < 17)
+	if (!can_assume(LATEST) && fdt_version(fdt) < 18)
 		return -FDT_ERR_BADVERSION;
 	if (fdt_blocks_misordered_(fdt, sizeof(struct fdt_reserve_entry),
 				   fdt_size_dt_struct(fdt)))
 		return -FDT_ERR_BADLAYOUT;
-	if (!can_assume(LATEST) && fdt_version(fdt) > 17)
-		fdt_set_version(fdt, 17);
+	if (!can_assume(LATEST) && fdt_version(fdt) > 18)
+		fdt_set_version(fdt, 18);
 
 	return 0;
 }
@@ -455,7 +455,8 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize)
 		err = fdt_move(fdt, buf, bufsize);
 		if (err)
 			return err;
-		fdt_set_version(buf, 17);
+		fdt_set_version(buf, 18);
+		fdt_set_last_comp_version(buf, 18);
 		fdt_set_size_dt_struct(buf, struct_size);
 		fdt_set_totalsize(buf, bufsize);
 		return 0;
@@ -484,8 +485,8 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize)
 
 	fdt_set_magic(buf, FDT_MAGIC);
 	fdt_set_totalsize(buf, bufsize);
-	fdt_set_version(buf, 17);
-	fdt_set_last_comp_version(buf, 16);
+	fdt_set_version(buf, 18);
+	fdt_set_last_comp_version(buf, 18);
 	fdt_set_boot_cpuid_phys(buf, fdt_boot_cpuid_phys(fdt));
 
 	return 0;
diff --git a/libfdt/libfdt.h b/libfdt/libfdt.h
index 7a10f66..c5cd35d 100644
--- a/libfdt/libfdt.h
+++ b/libfdt/libfdt.h
@@ -15,7 +15,7 @@ extern "C" {
 
 #define FDT_FIRST_SUPPORTED_VERSION	0x02
 #define FDT_LAST_COMPATIBLE_VERSION	0x10
-#define FDT_LAST_SUPPORTED_VERSION	0x11
+#define FDT_LAST_SUPPORTED_VERSION	0x12
 
 /* Error codes: informative error codes */
 #define FDT_ERR_NOTFOUND	1
diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py
index a4f73ed..373e11a 100644
--- a/tests/pylibfdt_tests.py
+++ b/tests/pylibfdt_tests.py
@@ -288,7 +288,7 @@ class PyLibfdtBasicTests(unittest.TestCase):
         self.assertEqual(self.fdt.off_dt_struct(), 88)
         self.assertEqual(self.fdt.off_dt_strings(), 652)
         self.assertEqual(self.fdt.off_mem_rsvmap(), 40)
-        self.assertEqual(self.fdt.version(), 17)
+        self.assertEqual(self.fdt.version(), 18)
         self.assertEqual(self.fdt.last_comp_version(), 16)
         self.assertEqual(self.fdt.boot_cpuid_phys(), 0)
         self.assertEqual(self.fdt.size_dt_strings(), 105)
diff --git a/tests/trees.S b/tests/trees.S
index d69f7f1..ecd43bc 100644
--- a/tests/trees.S
+++ b/tests/trees.S
@@ -17,7 +17,7 @@
 	fdtlong	(\tree\()_struct - \tree)
 	fdtlong	(\tree\()_strings - \tree)
 	fdtlong	(\tree\()_rsvmap - \tree)
-	fdtlong	0x11
+	fdtlong	0x12
 	fdtlong	0x10
 	fdtlong	0
 	fdtlong	(\tree\()_strings_end - \tree\()_strings)
-- 
2.52.0
-- 
David Gibson (he or they)	| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you, not the other way
				| around.
http://www.ozlabs.org/~dgibson

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help