Re: [RFC PATCH 14/15] libfdt: Handle unknown tags on dtb modifications

Luca Ceresoli
2026-04-01T15:18:59Z

On Tue Feb 10, 2026 at 6:33 PM CET, Herve Codina wrote:
> The structured tag value definition introduced recently gives the
> ability to ignore unknown tags without any error.
>
> When the dtb is modified those unknown tags have to be taken into
> account.
>
> First, depending on the unknown tag location, the item associated with
> the tag is identified:
> - An unknown tag located just after a FDT_BEGIN_NODE is related to the
> node.
>
> - An unknown tag located just after a FDT_PROP is related to the
> property.
>
> - An unknown tag out of any node (i.e located before the first
> FDT_BEGIN_NODE or after the last FDT_END_NODE is a global tag
^
missing ')'
> related to the dtb itself.

Out of curiosity, is there a real use case for global tags after
FDT_END_NODE?

> Then, if we are allowed to write a dtb containing unknown tags, the
> following rules are used:
> - When a property is modified, tags related to this property are
> removed and the dtb version is downgraded.
>
> - When a property is removed, tags related to this property are
> obviously removed. The dtb version is kept unchanged.
>
> - When a property or a node is added, obviously no unknown tags are
> added and the dtb version is kept unchanged.
>
> - When a node is removed, tags related to this node are obviously
> removed. The dtb version is kept unchanged.
>
> - Adding, removing or modifying a property is not considered as a node
> modification and so, those operations have no impacts on unknown
> tags related to the node. Those node related tags are kept unchanged.
>
> - The only modification considered as a node modification is setting
> its name. We consider that this operation has no impact on tags
> related to the node. Here also, those node related tags and the
> dtb version are kept unchanged.
>
> - Global (dtb related) unknown tags are kept unchanged regardless the
> modification done.
>
> Implement those rules when a dtb is modified.
>
> Signed-off-by: Herve Codina <herve.codina@bootlin.com>

With the tests updated as per comments in patch 10:
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering