lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260112142009.1006236-77-herve.codina@bootlin.com>
Date: Mon, 12 Jan 2026 15:20:06 +0100
From: Herve Codina <herve.codina@...tlin.com>
To: David Gibson <david@...son.dropbear.id.au>,
	Rob Herring <robh@...nel.org>,
	Krzysztof Kozlowski <krzk@...nel.org>,
	Conor Dooley <conor+dt@...nel.org>
Cc: Ayush Singh <ayush@...gleboard.org>,
	Geert Uytterhoeven <geert@...ux-m68k.org>,
	devicetree-compiler@...r.kernel.org,
	devicetree@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	devicetree-spec@...r.kernel.org,
	Hui Pu <hui.pu@...ealthcare.com>,
	Ian Ray <ian.ray@...ealthcare.com>,
	Luca Ceresoli <luca.ceresoli@...tlin.com>,
	Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
	Herve Codina <herve.codina@...tlin.com>
Subject: [RFC PATCH 76/77] tests: fdtaddon: Add a test for using 'stacked' addons

Addon can be stacked on top of each other.

A first addon can be applied. This first addon exports some symbols and
those exported symbols can be used by a second addon.

Add a test for this feature.

Signed-off-by: Herve Codina <herve.codina@...tlin.com>
---
 .../fdtaddon_stack_1st-merged.dtb.dts.expect  | 51 ++++++++++++++
 tests/fdtaddon_stack_1st-merged.dtb.expect    | 41 +++++++++++
 tests/fdtaddon_stack_1st.dtba.expect          | 24 +++++++
 tests/fdtaddon_stack_1st.dtsa                 | 27 +++++++
 .../fdtaddon_stack_2nd-merged.dtb.dts.expect  | 70 +++++++++++++++++++
 tests/fdtaddon_stack_2nd-merged.dtb.expect    | 59 ++++++++++++++++
 tests/fdtaddon_stack_2nd.dtba.expect          | 30 ++++++++
 tests/fdtaddon_stack_2nd.dtsa                 | 35 ++++++++++
 tests/run_tests.sh                            | 21 ++++++
 9 files changed, 358 insertions(+)
 create mode 100644 tests/fdtaddon_stack_1st-merged.dtb.dts.expect
 create mode 100644 tests/fdtaddon_stack_1st-merged.dtb.expect
 create mode 100644 tests/fdtaddon_stack_1st.dtba.expect
 create mode 100644 tests/fdtaddon_stack_1st.dtsa
 create mode 100644 tests/fdtaddon_stack_2nd-merged.dtb.dts.expect
 create mode 100644 tests/fdtaddon_stack_2nd-merged.dtb.expect
 create mode 100644 tests/fdtaddon_stack_2nd.dtba.expect
 create mode 100644 tests/fdtaddon_stack_2nd.dtsa

diff --git a/tests/fdtaddon_stack_1st-merged.dtb.dts.expect b/tests/fdtaddon_stack_1st-merged.dtb.dts.expect
new file mode 100644
index 0000000..eb6ee30
--- /dev/null
+++ b/tests/fdtaddon_stack_1st-merged.dtb.dts.expect
@@ -0,0 +1,51 @@
+/dts-v1/;
+
+/ {
+
+	base-node {
+
+		sub-node {
+			prop = <0x00>;
+			phandle = <0x02>;
+		};
+	};
+
+	somewhere {
+
+		node-a1 {
+			compatible = "abc,aaa";
+			phandle = <0x01>;
+
+			/export/ node_a: &{/somewhere/node-a1};
+			/export/ other: &{/base-node/sub-node};
+
+			addon1-node {
+				ref-other = <&{/base-node/sub-node} 0x0a>;
+				prop = <0x00>;
+
+				sub-node-other {
+					phandle = <0x05>;
+					prop = <0x01>;
+				};
+
+				sub-node-stack1 {
+					phandle = <0x04>;
+					prop = <0x00>;
+					compatible = "abc,bbb";
+
+					/export/ stack: &{/somewhere/node-a1/addon1-node/sub-node-stack1};
+					/export/ other: &{/somewhere/node-a1/addon1-node/sub-node-other};
+					/export/ base_other: &{/base-node/sub-node};
+				};
+			};
+		};
+
+		node-a2 {
+			compatible = "abc,aaa";
+			phandle = <0x03>;
+
+			/export/ node_a: &{/somewhere/node-a2};
+			/export/ other: &{/base-node/sub-node};
+		};
+	};
+};
diff --git a/tests/fdtaddon_stack_1st-merged.dtb.expect b/tests/fdtaddon_stack_1st-merged.dtb.expect
new file mode 100644
index 0000000..332bb26
--- /dev/null
+++ b/tests/fdtaddon_stack_1st-merged.dtb.expect
@@ -0,0 +1,41 @@
+/dts-v1/;
+
+/ {
+    base-node {
+        sub-node {
+            prop = <0x00000000>;
+            phandle = <0x00000002>;
+        };
+    };
+    somewhere {
+        node-a1 {
+            compatible = "abc,aaa";
+            phandle = <0x00000001>;
+            // [FDT_EXPORT_SYM] 'node_a' -> phandle 0x00000001
+            // [FDT_EXPORT_SYM] 'other' -> phandle 0x00000002
+            addon1-node {
+                ref-other = <0x00000002 0x0000000a>;
+                // [FDT_REF_LOCAL] ref-other[0]
+                prop = <0x00000000>;
+                sub-node-other {
+                    phandle = <0x00000005>;
+                    prop = <0x00000001>;
+                };
+                sub-node-stack1 {
+                    phandle = <0x00000004>;
+                    prop = <0x00000000>;
+                    compatible = "abc,bbb";
+                    // [FDT_EXPORT_SYM] 'stack' -> phandle 0x00000004
+                    // [FDT_EXPORT_SYM] 'other' -> phandle 0x00000005
+                    // [FDT_EXPORT_SYM] 'base_other' -> phandle 0x00000002
+                };
+            };
+        };
+        node-a2 {
+            compatible = "abc,aaa";
+            phandle = <0x00000003>;
+            // [FDT_EXPORT_SYM] 'node_a' -> phandle 0x00000003
+            // [FDT_EXPORT_SYM] 'other' -> phandle 0x00000002
+        };
+    };
+};
diff --git a/tests/fdtaddon_stack_1st.dtba.expect b/tests/fdtaddon_stack_1st.dtba.expect
new file mode 100644
index 0000000..1e1ce57
--- /dev/null
+++ b/tests/fdtaddon_stack_1st.dtba.expect
@@ -0,0 +1,24 @@
+/dts-v1/;
+/addon/;
+
+// [FDT_IMPORT_SYM] 'node_a' (abc,aaa)
+// [FDT_IMPORT_SYM] 'other' ()
+&node_a {
+    addon1-node {
+        prop = <0x00000000>;
+        ref-other = <0xffffffff 0x0000000a>;
+        // [FDT_REF_PHANDLE] ref-other[0], ref = other
+        sub-node-stack1 {
+            compatible = "abc,bbb";
+            prop = <0x00000000>;
+            phandle = <0x00000001>;
+            // [FDT_EXPORT_SYM] 'stack' -> phandle 0x00000001
+            // [FDT_EXPORT_SYM] 'other' -> phandle 0x00000002
+            // [FDT_EXPORT_SYM_REF] 'base_other' -> 'other'
+        };
+        sub-node-other {
+            prop = <0x00000001>;
+            phandle = <0x00000002>;
+        };
+    };
+};
diff --git a/tests/fdtaddon_stack_1st.dtsa b/tests/fdtaddon_stack_1st.dtsa
new file mode 100644
index 0000000..5529dde
--- /dev/null
+++ b/tests/fdtaddon_stack_1st.dtsa
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
+/*
+ * Copyright (C) 2026 Bootlin
+ */
+
+/dts-v1/;
+/addon/;
+
+/import/ node_a: "abc,aaa";
+/import/ other: "";
+
+&node_a {
+	addon1-node {
+		prop = <0>;
+		ref-other = <&other 10>;
+		stack1: sub-node-stack1 {
+			compatible = "abc,bbb";
+			prop = <0>;
+			/export/ stack: &stack1;
+			/export/ other: &new_other;
+			/export/ base_other: &other;
+		};
+		new_other: sub-node-other {
+			prop = <1>;
+		};
+	};
+};
diff --git a/tests/fdtaddon_stack_2nd-merged.dtb.dts.expect b/tests/fdtaddon_stack_2nd-merged.dtb.dts.expect
new file mode 100644
index 0000000..af31f05
--- /dev/null
+++ b/tests/fdtaddon_stack_2nd-merged.dtb.dts.expect
@@ -0,0 +1,70 @@
+/dts-v1/;
+
+/ {
+
+	base-node {
+
+		sub-node {
+			prop = <0x00>;
+			phandle = <0x02>;
+
+			addon2-node-base-other {
+				ref = <&{/somewhere/node-a1/addon1-node/sub-node-stack1/addon2-node}>;
+				prop = <0x01>;
+			};
+		};
+	};
+
+	somewhere {
+
+		node-a1 {
+			compatible = "abc,aaa";
+			phandle = <0x01>;
+
+			/export/ node_a: &{/somewhere/node-a1};
+			/export/ other: &{/base-node/sub-node};
+
+			addon1-node {
+				ref-other = <&{/base-node/sub-node} 0x0a>;
+				prop = <0x00>;
+
+				sub-node-other {
+					phandle = <0x05>;
+					prop = <0x01>;
+
+					addon2-node-other {
+						prop = <&{/base-node/sub-node}>;
+
+						addon2-subnode {
+							prop = <0x02>;
+						};
+					};
+				};
+
+				sub-node-stack1 {
+					phandle = <0x04>;
+					prop = <0x00>;
+					compatible = "abc,bbb";
+
+					/export/ stack: &{/somewhere/node-a1/addon1-node/sub-node-stack1};
+					/export/ other: &{/somewhere/node-a1/addon1-node/sub-node-other};
+					/export/ base_other: &{/base-node/sub-node};
+
+					addon2-node {
+						phandle = <0x06>;
+						ref-other = <&{/somewhere/node-a1/addon1-node/sub-node-other} 0x0a>;
+						prop = <0x00>;
+					};
+				};
+			};
+		};
+
+		node-a2 {
+			compatible = "abc,aaa";
+			phandle = <0x03>;
+
+			/export/ node_a: &{/somewhere/node-a2};
+			/export/ other: &{/base-node/sub-node};
+		};
+	};
+};
diff --git a/tests/fdtaddon_stack_2nd-merged.dtb.expect b/tests/fdtaddon_stack_2nd-merged.dtb.expect
new file mode 100644
index 0000000..ccae793
--- /dev/null
+++ b/tests/fdtaddon_stack_2nd-merged.dtb.expect
@@ -0,0 +1,59 @@
+/dts-v1/;
+
+/ {
+    base-node {
+        sub-node {
+            prop = <0x00000000>;
+            phandle = <0x00000002>;
+            addon2-node-base-other {
+                ref = <0x00000006>;
+                // [FDT_REF_LOCAL] ref[0]
+                prop = <0x00000001>;
+            };
+        };
+    };
+    somewhere {
+        node-a1 {
+            compatible = "abc,aaa";
+            phandle = <0x00000001>;
+            // [FDT_EXPORT_SYM] 'node_a' -> phandle 0x00000001
+            // [FDT_EXPORT_SYM] 'other' -> phandle 0x00000002
+            addon1-node {
+                ref-other = <0x00000002 0x0000000a>;
+                // [FDT_REF_LOCAL] ref-other[0]
+                prop = <0x00000000>;
+                sub-node-other {
+                    phandle = <0x00000005>;
+                    prop = <0x00000001>;
+                    addon2-node-other {
+                        prop = <0x00000002>;
+                        // [FDT_REF_LOCAL] prop[0]
+                        addon2-subnode {
+                            prop = <0x00000002>;
+                        };
+                    };
+                };
+                sub-node-stack1 {
+                    phandle = <0x00000004>;
+                    prop = <0x00000000>;
+                    compatible = "abc,bbb";
+                    // [FDT_EXPORT_SYM] 'stack' -> phandle 0x00000004
+                    // [FDT_EXPORT_SYM] 'other' -> phandle 0x00000005
+                    // [FDT_EXPORT_SYM] 'base_other' -> phandle 0x00000002
+                    addon2-node {
+                        phandle = <0x00000006>;
+                        ref-other = <0x00000005 0x0000000a>;
+                        // [FDT_REF_LOCAL] ref-other[0]
+                        prop = <0x00000000>;
+                    };
+                };
+            };
+        };
+        node-a2 {
+            compatible = "abc,aaa";
+            phandle = <0x00000003>;
+            // [FDT_EXPORT_SYM] 'node_a' -> phandle 0x00000003
+            // [FDT_EXPORT_SYM] 'other' -> phandle 0x00000002
+        };
+    };
+};
diff --git a/tests/fdtaddon_stack_2nd.dtba.expect b/tests/fdtaddon_stack_2nd.dtba.expect
new file mode 100644
index 0000000..dbb8afa
--- /dev/null
+++ b/tests/fdtaddon_stack_2nd.dtba.expect
@@ -0,0 +1,30 @@
+/dts-v1/;
+/addon/;
+
+// [FDT_IMPORT_SYM] 'stack' (abc,bbb)
+// [FDT_IMPORT_SYM] 'other' ()
+// [FDT_IMPORT_SYM] 'base_other' ()
+&stack {
+    addon2-node {
+        prop = <0x00000000>;
+        ref-other = <0xffffffff 0x0000000a>;
+        // [FDT_REF_PHANDLE] ref-other[0], ref = other
+        phandle = <0x00000001>;
+    };
+};
+&other {
+    addon2-node-other {
+        prop = <0xffffffff>;
+        // [FDT_REF_PHANDLE] prop[0], ref = base_other
+        addon2-subnode {
+            prop = <0x00000002>;
+        };
+    };
+};
+&base_other {
+    addon2-node-base-other {
+        prop = <0x00000001>;
+        ref = <0x00000001>;
+        // [FDT_REF_LOCAL] ref[0]
+    };
+};
diff --git a/tests/fdtaddon_stack_2nd.dtsa b/tests/fdtaddon_stack_2nd.dtsa
new file mode 100644
index 0000000..21d80d2
--- /dev/null
+++ b/tests/fdtaddon_stack_2nd.dtsa
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: (GPL-2.0-or-later OR BSD-2-Clause)
+/*
+ * Copyright (C) 2026 Bootlin
+ */
+
+/dts-v1/;
+/addon/;
+
+/import/ stack: "abc,bbb";
+/import/ other: "";
+/import/ base_other: "";
+
+&stack {
+	addon2_node: addon2-node {
+		prop = <0>;
+		ref-other = <&other 10>;
+	};
+};
+
+&other {
+	addon2-node-other {
+		prop = <&base_other>;
+
+		addon2-subnode {
+			prop = <2>;
+		};
+	};
+};
+
+&base_other {
+	addon2-node-base-other {
+		prop = <1>;
+		ref = <&addon2_node>;
+	};
+};
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 2cdfd89..69ca39e 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -1221,6 +1221,27 @@ fdtaddon_tests() {
 
 	run_dtc_test -I dtb -O dts -o fdtaddon_addon_namespace-merged.dtb.dts fdtaddon_addon_namespace-merged.dtb
 	check_dts fdtaddon_addon_namespace-merged.dtb.dts
+
+	# test stacked addons
+	run_dtc_test -I dts -O dtb -o fdtaddon_stack_1st.dtba "$SRCDIR/fdtaddon_stack_1st.dtsa"
+	check_dtb fdtaddon_stack_1st.dtba
+
+	run_fdtaddon_test -i fdtaddon_base.dtb -o fdtaddon_stack_1st-merged.dtb \
+			  -t "/somewhere/node-a1" fdtaddon_stack_1st.dtba
+	check_dtb fdtaddon_stack_1st-merged.dtb
+
+	run_dtc_test -I dtb -O dts -o fdtaddon_stack_1st-merged.dtb.dts fdtaddon_stack_1st-merged.dtb
+	check_dts fdtaddon_stack_1st-merged.dtb.dts
+
+	run_dtc_test -I dts -O dtb -o fdtaddon_stack_2nd.dtba "$SRCDIR/fdtaddon_stack_2nd.dtsa"
+	check_dtb fdtaddon_stack_2nd.dtba
+
+	run_fdtaddon_test -i fdtaddon_stack_1st-merged.dtb -o fdtaddon_stack_2nd-merged.dtb \
+			  -t "/somewhere/node-a1/addon1-node/sub-node-stack1" fdtaddon_stack_2nd.dtba
+	check_dtb fdtaddon_stack_2nd-merged.dtb
+
+	run_dtc_test -I dtb -O dts -o fdtaddon_stack_2nd-merged.dtb.dts fdtaddon_stack_2nd-merged.dtb
+	check_dts fdtaddon_stack_2nd-merged.dtb.dts
 }
 
 pylibfdt_tests () {
-- 
2.52.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ