Re: [PATCH] libfdt: fdt_check_full: Add can_assume(PERFECT) check
David Gibson <[email protected]> Wed, 27 May 2026 14:23:20 +1000
| Newsgroups | org.kernel.vger.devicetree-compiler |
|---|---|
| Message-ID | <ahZxuCONf2JfMXU8@zatzit> |
--sjf9qHOugQSVtDi0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, May 26, 2026 at 02:30:22PM -0600, Tom Rini wrote: > In this function from fdt_check.c we have (reasonably and as the name > implies) a number of checks on the DTB. However, there are cases where > we may wish to assume that we have been given a perfect DTB already and > do nothing here. Add a test for can_assume(PERFECT) as the first check > in this function and if true, perform no checks. >=20 > Signed-off-by: Tom Rini <[email protected]> > --- > Along the lines of the patches I posted back in December, in U-Boot SPL > we just don't have the space for this check much of the time and so have > always omitted it (going back to at least when Simon posted the initial > patch to make libfdt/fdt_check.c here). This is another case where it's > a noticeable size win for us. I had missed this change in particular > because we had in turn missed catching up on fdt_check_full being moved > out of fdt_ro.c and in to fdt_check.c. I'm not necessarily against this, but I have some misgivings. fdt_check_full() is (deliberately) not called from anywhere else in libfdt - it's intended to allow the user to explicitly do a full validity check on the tree. Given that meaning, I'm not sure it's wise to turn it into a no-op based on the assume flags. Your comment seems to imply that the issue here is size - simply having this function compiled - rather than being too expensive when (explicitly) called. That's a little surprising to me - it's in its own compilation unit, specifically so that the linker can omit it if it's not used. Is there something unusual about your build environment that's not letting that happen? > --- > libfdt/fdt_check.c | 2 ++ > 1 file changed, 2 insertions(+) >=20 > diff --git a/libfdt/fdt_check.c b/libfdt/fdt_check.c > index cca052353213..2fd5b61d016a 100644 > --- a/libfdt/fdt_check.c > +++ b/libfdt/fdt_check.c > @@ -21,6 +21,8 @@ int fdt_check_full(const void *fdt, size_t bufsize) > const char *propname; > bool expect_end =3D false; > =20 > + if (can_assume(PERFECT)) > + return 0; > if (bufsize < FDT_V1_SIZE) > return -FDT_ERR_TRUNCATED; > if (bufsize < fdt_header_size(fdt)) > --=20 > 2.43.0 >=20 >=20 --=20 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 --sjf9qHOugQSVtDi0 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmoWcbcACgkQzQJF27ox 2GdW3A//bbggvFXzCFduBfz1RdLt6pNjZJS7SoFqjJiQsWaGopi83gVGtnJCyGV0 9jMkGr27ieMKYAYLrq+5Gl6tuLRwrJ7dvHTVg5R0w/eN+sW75ZIQNvl8sVyNnkDx 5QcAaJAtLwg5d28Jve/ZlFkXubzuHImp0Y/I1pdIBImv2mE/1AiSP5oJZV/h1qjf Zhc+VDVraCXR/4Sn/WADeWdLTxw8TNWBhY61JgtBd2rSGOydJyb7MaF/MGFA73of 2kdml63aKHzSCnWjDRfomeIa2tZ4s2gjUnhBJISTbQWVrHWczroL71ALPq87eCBa iahgc8l8p4jawuFQ6peYsR40ipPrwKHDRmI17WjcH29U6kc6uEhgzZm4VjNW4O7r eHZPdw2rt5S54gDUVXxipMAC/l73irDnmN5Ne9WvxIUDzrEV8NI1+VvGS0sb9aX3 qNKlf4aXj5mG+ifKg4wI1hR3sRYXsQJTg3v8prLQTxkXT3ukbvMKwFy9AHSA9DTi 1Y1JZXFjpbNfSI1hi8izVvT3lxLhp18Xg2danpoX5FgF+ICddae6EkOJVD4IznWe vJiHxncqOOu4qbVSLTdOz6RFu8gQGq+3AUob6bb9g3j/3sCpaZEFVkprEnfXWe79 +ZjWXdjJ8Lz/LN5ImoEqO8mYcWS3ZBGK/wx3NB7L4rHAuK+K3m0= =Aqgr -----END PGP SIGNATURE----- --sjf9qHOugQSVtDi0--