-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libfdt: overlay: Skip phandles not in subnodes #97
base: main
Are you sure you want to change the base?
Conversation
A phandle property in an __overlay__ node has the potential to break phandle linkage within the base fdt file to which it is applied. Filter them out to avoid that situation. Signed-off-by: Phil Elwell <[email protected]>
Hmm - am I right in thinking that an overlay:
|
You might want to check #98 which (I think) addresses the problem you describe in a more robust way. |
Yes, that's allowed.
Hm, I think that should be allowed. In general nodes are allowed to have multiple labels.
I'm not really sure what you mean by this. If the label is not copied to the base dtb it has no effect. Note that it's not the act of adding the label that causes the extra phandle to be assigned. The extra phandle is assigned when the node is referenced by a label that dtc thinks is local at compile time, but turns out not to be at overlay apply time.
No, but I'm afraid it's not acceptable because it's very fragile. Although existing nodes being the top-level of a single overlay fragment is the most common case, it's entirely possible for overlay fragments to make tweaks to an entire tree of existing nodes, so checking the depth doesn't really help us. |
So, there's a real issue, but how to deal with it is pretty tricky. This patch doesn't work because it relies on an inaccurate heuristic to work out whether we can apply the phandle change. #98 sent by @ukleinek doesn't work because it relies on dynamic allocation which is not allowed in libfdt. Option 1 In Option 1a Ban overlays which rewrite phandles as in Option 1, also change the order of things so we merge the symbol tables before merging the trees themselves. On the dtc side, completely deprecate use of
Option 2 Resolve the new and existing phandles at overlay apply time. I think it's possible, but it's pretty darn complex.
I think that will do it. It's at least O(n^2)-ish, but that might already be true of overlay application. I'm a bit worried I've missed something that will make it O(n^3) or worse. Maybe there's a clever way to make that more elegant, but I haven't spotted it. |
I think this problem is solved on current HEAD, isn't it? |
A Raspberry Pi user reported (raspberrypi/firmware#1718) that some overlays that work with the Pi tools can't be applied by fdtoverlay (even ignoring the non-standard parameter stuff). After some digging I traced the problem to unwanted phandles being copied into the base dtb, overwriting an existing phandle and breaking references to that node.
This patch filters out phandles in the outer level of overlay nodes (i.e. not in subnodes).