* [PATCH] libfdt: overlay: Fix phandle overwrite check for new subtrees
@ 2024-06-26 7:55 Uwe Kleine-König
2024-07-02 13:44 ` Uwe Kleine-König
2024-07-05 23:46 ` David Gibson
0 siblings, 2 replies; 6+ messages in thread
From: Uwe Kleine-König @ 2024-06-26 7:55 UTC (permalink / raw)
To: devicetree-compiler
Cc: Rob Herring, Geert Uytterhoeven, Saravana Kannan, devicetree
If the overlay's target is only created in a previous fragment, it
doesn't exist in the unmodified base device tree. For the phandle
overwrite check this can be ignored because in this case the base tree
doesn't contain a phandle that could be overwritten.
Adapt the corresponding check to not error out if that happens but just
continue with the next fragment.
This is currently triggered by
arch/arm64/boot/dts/renesas/salvator-panel-aa104xd12.dtso in the kernel
repository which creates /panel in its first fragment and modifies it in
its second.
Reported-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/all/CAL_JsqL9MPycDjqQfPNAuGfC6EMrdzUivr+fuOS7YgU3biGd4A@mail.gmail.com/
Fixes: 1fad065080e6 ("libfdt: overlay: ensure that existing phandles are not overwritten")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
libfdt/fdt_overlay.c | 8 +++++++-
tests/overlay_overlay_bypath.dts | 4 ++++
tests/overlay_overlay_no_fixups.dts | 8 ++++++++
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/libfdt/fdt_overlay.c b/libfdt/fdt_overlay.c
index e19506fb56a5..28b667ffc490 100644
--- a/libfdt/fdt_overlay.c
+++ b/libfdt/fdt_overlay.c
@@ -729,7 +729,13 @@ static int overlay_prevent_phandle_overwrite(void *fdt, void *fdto)
return overlay;
target = fdt_overlay_target_offset(fdt, fdto, fragment, NULL);
- if (target < 0)
+ if (target == -FDT_ERR_NOTFOUND)
+ /*
+ * The subtree doesn't exist in the base, so nothing
+ * will be overwritten.
+ */
+ continue;
+ else if (target < 0)
return target;
ret = overlay_prevent_phandle_overwrite_node(fdt, target,
diff --git a/tests/overlay_overlay_bypath.dts b/tests/overlay_overlay_bypath.dts
index f23e7b6035e2..dfcb7cdb25a4 100644
--- a/tests/overlay_overlay_bypath.dts
+++ b/tests/overlay_overlay_bypath.dts
@@ -46,3 +46,7 @@
new-sub-test-property;
};
};
+
+&{/new-local-node} {
+ another-new-property;
+};
diff --git a/tests/overlay_overlay_no_fixups.dts b/tests/overlay_overlay_no_fixups.dts
index e8d0f96d889c..1dbdcdc2b40f 100644
--- a/tests/overlay_overlay_no_fixups.dts
+++ b/tests/overlay_overlay_no_fixups.dts
@@ -72,6 +72,14 @@
};
};
+ fragment@7 {
+ target-path = "/new-local-node";
+
+ __overlay__ {
+ another-new-property;
+ };
+ };
+
__local_fixups__ {
fragment@5 {
__overlay__ {
base-commit: ff4f17eb58650784ffb2e8a8fbefebce1038f80b
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] libfdt: overlay: Fix phandle overwrite check for new subtrees
2024-06-26 7:55 [PATCH] libfdt: overlay: Fix phandle overwrite check for new subtrees Uwe Kleine-König
@ 2024-07-02 13:44 ` Uwe Kleine-König
2024-07-03 17:06 ` Rob Herring
2024-07-05 23:46 ` David Gibson
1 sibling, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2024-07-02 13:44 UTC (permalink / raw)
To: David Gibson
Cc: devicetree-compiler, Rob Herring, Geert Uytterhoeven,
Saravana Kannan, devicetree
[-- Attachment #1: Type: text/plain, Size: 1472 bytes --]
Hello David,
On Wed, Jun 26, 2024 at 09:55:52AM +0200, Uwe Kleine-König wrote:
> If the overlay's target is only created in a previous fragment, it
> doesn't exist in the unmodified base device tree. For the phandle
> overwrite check this can be ignored because in this case the base tree
> doesn't contain a phandle that could be overwritten.
>
> Adapt the corresponding check to not error out if that happens but just
> continue with the next fragment.
>
> This is currently triggered by
> arch/arm64/boot/dts/renesas/salvator-panel-aa104xd12.dtso in the kernel
> repository which creates /panel in its first fragment and modifies it in
> its second.
>
> Reported-by: Rob Herring <robh@kernel.org>
> Link: https://lore.kernel.org/all/CAL_JsqL9MPycDjqQfPNAuGfC6EMrdzUivr+fuOS7YgU3biGd4A@mail.gmail.com/
> Fixes: 1fad065080e6 ("libfdt: overlay: ensure that existing phandles are not overwritten")
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
I wonder about this patch's state. Does David wait for feedback by Rob
as he reported the issue? Does Rob expect Geert to comment as
salvator-panel-aa104xd12.dtso is in his maintainer area? Are the
responsible people just busy; or is this fix already hidden in their
backlog?
Otherwise I think the patch is fine to go in. It passes the test suite
and adds a new test that fails without the code change (but passes when
the patch is applied completely).
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] libfdt: overlay: Fix phandle overwrite check for new subtrees
2024-07-02 13:44 ` Uwe Kleine-König
@ 2024-07-03 17:06 ` Rob Herring
2024-07-05 11:49 ` David Gibson
0 siblings, 1 reply; 6+ messages in thread
From: Rob Herring @ 2024-07-03 17:06 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: David Gibson, devicetree-compiler, Geert Uytterhoeven,
Saravana Kannan, devicetree
On Tue, Jul 2, 2024 at 7:44 AM Uwe Kleine-König
<u.kleine-koenig@baylibre.com> wrote:
>
> Hello David,
>
> On Wed, Jun 26, 2024 at 09:55:52AM +0200, Uwe Kleine-König wrote:
> > If the overlay's target is only created in a previous fragment, it
> > doesn't exist in the unmodified base device tree. For the phandle
> > overwrite check this can be ignored because in this case the base tree
> > doesn't contain a phandle that could be overwritten.
> >
> > Adapt the corresponding check to not error out if that happens but just
> > continue with the next fragment.
> >
> > This is currently triggered by
> > arch/arm64/boot/dts/renesas/salvator-panel-aa104xd12.dtso in the kernel
> > repository which creates /panel in its first fragment and modifies it in
> > its second.
> >
> > Reported-by: Rob Herring <robh@kernel.org>
> > Link: https://lore.kernel.org/all/CAL_JsqL9MPycDjqQfPNAuGfC6EMrdzUivr+fuOS7YgU3biGd4A@mail.gmail.com/
> > Fixes: 1fad065080e6 ("libfdt: overlay: ensure that existing phandles are not overwritten")
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
>
> I wonder about this patch's state. Does David wait for feedback by Rob
> as he reported the issue? Does Rob expect Geert to comment as
> salvator-panel-aa104xd12.dtso is in his maintainer area? Are the
> responsible people just busy; or is this fix already hidden in their
> backlog?
I think it's just waiting on David.
The patch looks good to me, but I haven't tested it nor am I that
familiar with this particular code.
Rob
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] libfdt: overlay: Fix phandle overwrite check for new subtrees
2024-07-03 17:06 ` Rob Herring
@ 2024-07-05 11:49 ` David Gibson
2024-07-05 20:53 ` Uwe Kleine-König
0 siblings, 1 reply; 6+ messages in thread
From: David Gibson @ 2024-07-05 11:49 UTC (permalink / raw)
To: Rob Herring
Cc: Uwe Kleine-König, devicetree-compiler, Geert Uytterhoeven,
Saravana Kannan, devicetree
[-- Attachment #1: Type: text/plain, Size: 2157 bytes --]
On Wed, Jul 03, 2024 at 11:06:32AM -0600, Rob Herring wrote:
> On Tue, Jul 2, 2024 at 7:44 AM Uwe Kleine-König
> <u.kleine-koenig@baylibre.com> wrote:
> >
> > Hello David,
> >
> > On Wed, Jun 26, 2024 at 09:55:52AM +0200, Uwe Kleine-König wrote:
> > > If the overlay's target is only created in a previous fragment, it
> > > doesn't exist in the unmodified base device tree. For the phandle
> > > overwrite check this can be ignored because in this case the base tree
> > > doesn't contain a phandle that could be overwritten.
> > >
> > > Adapt the corresponding check to not error out if that happens but just
> > > continue with the next fragment.
> > >
> > > This is currently triggered by
> > > arch/arm64/boot/dts/renesas/salvator-panel-aa104xd12.dtso in the kernel
> > > repository which creates /panel in its first fragment and modifies it in
> > > its second.
> > >
> > > Reported-by: Rob Herring <robh@kernel.org>
> > > Link: https://lore.kernel.org/all/CAL_JsqL9MPycDjqQfPNAuGfC6EMrdzUivr+fuOS7YgU3biGd4A@mail.gmail.com/
> > > Fixes: 1fad065080e6 ("libfdt: overlay: ensure that existing phandles are not overwritten")
> > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
> >
> > I wonder about this patch's state. Does David wait for feedback by Rob
> > as he reported the issue? Does Rob expect Geert to comment as
> > salvator-panel-aa104xd12.dtso is in his maintainer area? Are the
> > responsible people just busy; or is this fix already hidden in their
> > backlog?
>
> I think it's just waiting on David.
Sorry, yes. I'm always finding it hard to find time for dtc/libfdt
maintenance stuff, and I've been particularly busy lately. I did
catch up on a bunch of trivial dtc/libfdt patches lately, but this
one's a bit more complex so I didn't get to it yet.
> The patch looks good to me, but I haven't tested it nor am I that
> familiar with this particular code.
>
> Rob
>
--
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] libfdt: overlay: Fix phandle overwrite check for new subtrees
2024-07-05 11:49 ` David Gibson
@ 2024-07-05 20:53 ` Uwe Kleine-König
0 siblings, 0 replies; 6+ messages in thread
From: Uwe Kleine-König @ 2024-07-05 20:53 UTC (permalink / raw)
To: David Gibson
Cc: Rob Herring, devicetree-compiler, Geert Uytterhoeven,
Saravana Kannan, devicetree
[-- Attachment #1: Type: text/plain, Size: 598 bytes --]
Hello David,
On Fri, Jul 05, 2024 at 09:49:17PM +1000, David Gibson wrote:
> On Wed, Jul 03, 2024 at 11:06:32AM -0600, Rob Herring wrote:
> > I think it's just waiting on David.
>
> Sorry, yes. I'm always finding it hard to find time for dtc/libfdt
> maintenance stuff, and I've been particularly busy lately. I did
> catch up on a bunch of trivial dtc/libfdt patches lately, but this
> one's a bit more complex so I didn't get to it yet.
Good to know it's on your radar. If you have questions or other needs to
talk about this, don't hesitate to contact me.
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] libfdt: overlay: Fix phandle overwrite check for new subtrees
2024-06-26 7:55 [PATCH] libfdt: overlay: Fix phandle overwrite check for new subtrees Uwe Kleine-König
2024-07-02 13:44 ` Uwe Kleine-König
@ 2024-07-05 23:46 ` David Gibson
1 sibling, 0 replies; 6+ messages in thread
From: David Gibson @ 2024-07-05 23:46 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: devicetree-compiler, Rob Herring, Geert Uytterhoeven,
Saravana Kannan, devicetree
[-- Attachment #1: Type: text/plain, Size: 2933 bytes --]
On Wed, Jun 26, 2024 at 09:55:52AM +0200, Uwe Kleine-König wrote:
> If the overlay's target is only created in a previous fragment, it
> doesn't exist in the unmodified base device tree. For the phandle
> overwrite check this can be ignored because in this case the base tree
> doesn't contain a phandle that could be overwritten.
>
> Adapt the corresponding check to not error out if that happens but just
> continue with the next fragment.
>
> This is currently triggered by
> arch/arm64/boot/dts/renesas/salvator-panel-aa104xd12.dtso in the kernel
> repository which creates /panel in its first fragment and modifies it in
> its second.
>
> Reported-by: Rob Herring <robh@kernel.org>
> Link: https://lore.kernel.org/all/CAL_JsqL9MPycDjqQfPNAuGfC6EMrdzUivr+fuOS7YgU3biGd4A@mail.gmail.com/
> Fixes: 1fad065080e6 ("libfdt: overlay: ensure that existing phandles are not overwritten")
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Merged, thanks.
> ---
> libfdt/fdt_overlay.c | 8 +++++++-
> tests/overlay_overlay_bypath.dts | 4 ++++
> tests/overlay_overlay_no_fixups.dts | 8 ++++++++
> 3 files changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/libfdt/fdt_overlay.c b/libfdt/fdt_overlay.c
> index e19506fb56a5..28b667ffc490 100644
> --- a/libfdt/fdt_overlay.c
> +++ b/libfdt/fdt_overlay.c
> @@ -729,7 +729,13 @@ static int overlay_prevent_phandle_overwrite(void *fdt, void *fdto)
> return overlay;
>
> target = fdt_overlay_target_offset(fdt, fdto, fragment, NULL);
> - if (target < 0)
> + if (target == -FDT_ERR_NOTFOUND)
> + /*
> + * The subtree doesn't exist in the base, so nothing
> + * will be overwritten.
> + */
> + continue;
> + else if (target < 0)
> return target;
>
> ret = overlay_prevent_phandle_overwrite_node(fdt, target,
> diff --git a/tests/overlay_overlay_bypath.dts b/tests/overlay_overlay_bypath.dts
> index f23e7b6035e2..dfcb7cdb25a4 100644
> --- a/tests/overlay_overlay_bypath.dts
> +++ b/tests/overlay_overlay_bypath.dts
> @@ -46,3 +46,7 @@
> new-sub-test-property;
> };
> };
> +
> +&{/new-local-node} {
> + another-new-property;
> +};
> diff --git a/tests/overlay_overlay_no_fixups.dts b/tests/overlay_overlay_no_fixups.dts
> index e8d0f96d889c..1dbdcdc2b40f 100644
> --- a/tests/overlay_overlay_no_fixups.dts
> +++ b/tests/overlay_overlay_no_fixups.dts
> @@ -72,6 +72,14 @@
> };
> };
>
> + fragment@7 {
> + target-path = "/new-local-node";
> +
> + __overlay__ {
> + another-new-property;
> + };
> + };
> +
> __local_fixups__ {
> fragment@5 {
> __overlay__ {
>
> base-commit: ff4f17eb58650784ffb2e8a8fbefebce1038f80b
--
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-07-05 23:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-26 7:55 [PATCH] libfdt: overlay: Fix phandle overwrite check for new subtrees Uwe Kleine-König
2024-07-02 13:44 ` Uwe Kleine-König
2024-07-03 17:06 ` Rob Herring
2024-07-05 11:49 ` David Gibson
2024-07-05 20:53 ` Uwe Kleine-König
2024-07-05 23:46 ` David Gibson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).