From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: Yves-Alexis Perez <corsac@debian.org>,
devicetree-compiler@vger.kernel.org, entwicklung@pengutronix.de
Subject: Re: [PATCH v3] libfdt: overlay: ensure that existing phandles are not overwritten
Date: Sun, 10 Mar 2024 09:30:31 +0100 [thread overview]
Message-ID: <mpmdkpzzfpw6vrgvpd3e324zouwd4u3oxq7rpmc2sktxjtojj7@gauowuw3mug5> (raw)
In-Reply-To: <ZdwncYaatDrRBkKU@zatzit>
[-- Attachment #1: Type: text/plain, Size: 3022 bytes --]
Hello David,
On Mon, Feb 26, 2024 at 04:53:53PM +1100, David Gibson wrote:
> On Sun, Feb 25, 2024 at 06:54:23PM +0100, Uwe Kleine-König wrote:
> > A phandle in an overlay is not supposed to overwrite a phandle that
> > already exists in the base dtb as this breaks references to the
> > respective node in the base.
> >
> > So add another iteration over the fdto that checks for such overwrites
> > and fixes the fdto phandle's value to match the fdt's.
> >
> > A test is added that checks that newly added phandles and existing
> > phandles work as expected.
> >
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > ---
> > Hello,
> >
> > here comes the next iteration of the patch that fixes overlay
> > application to not overwrite existing phandles.
> >
> > It is rebased to current main branch. The changes since v2 are:
> >
> > - Add documentation
> > - Apply the simplification from 24f60011fd43 ("libfdt: Simplify
> > adjustment of values for local fixups") in the functions added here.
> > - Rename functions using shorter and better names
> > - Changed the test device trees to yield a hole in the phandle space
> > - Checked each phandle value not being overwritten separately
> >
> > Note I didn't switch the order of overlay_prevent_phandle_overwrite() and
> > overlay_fixup_phandles() because the overlay's phandles must be resolved
> > before I can do the recursion needed in
> > overlay_prevent_phandle_overwrite().
>
> I'm not following what you mean here. IIUC, conflicts of the sort
> you're handling can only arise when the overlay describes a phandle
> for the target node of the reference - and therefore that target is in
> the overlay. In that case all references to it in the overlay should
> be encoded in __local_fixups__ rather than __fixups__. __fixups__, in
> contrast describes references to nodes that aren't in the overlay, and
> so can't be filled in - even with a tentative value - until the
> overlay is applied.
>
> So, I'm not seeing how fixing these conflicts depends on resolution of
> those "external" fixups, rather than just the "local" fixups. Am I
> missing something?
yupp, look at the overlay dts I added in tests/. It has
&node_a {
value = <32>;
};
which is translated to:
fragment@1 {
target = <0xffffffff>;
__overlay__ {
value = <0x00000020>;
};
};
...
__fixups__ {
node_a = ..., "/fragment@1:target:0"
};
Before I can recurse over fragment@1 and the matching base dtb node to
check for phandle conflicts, I need /fragment@1:target resolved;
otherwise I don't know where to look in the base dtb.
So if I switch the order, fdtoverlay reports
Failed to apply 'overlay_overlay_phandle.test.dtb': FDT_ERR_BADPHANDLE
in make check.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2024-03-10 8:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-25 17:54 [PATCH v3] libfdt: overlay: ensure that existing phandles are not overwritten Uwe Kleine-König
2024-02-26 5:53 ` David Gibson
2024-03-10 8:30 ` Uwe Kleine-König [this message]
2024-03-14 4:43 ` David Gibson
2024-03-14 9:06 ` Uwe Kleine-König
2024-03-14 10:40 ` David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=mpmdkpzzfpw6vrgvpd3e324zouwd4u3oxq7rpmc2sktxjtojj7@gauowuw3mug5 \
--to=u.kleine-koenig@pengutronix.de \
--cc=corsac@debian.org \
--cc=david@gibson.dropbear.id.au \
--cc=devicetree-compiler@vger.kernel.org \
--cc=entwicklung@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).