[PATCH v3 1/2] boot: android: Always use 8-byte aligned DT with libfdt

Tom Rini trini at konsulko.com
Wed Nov 19 20:39:22 CET 2025


On Wed, Nov 19, 2025 at 08:32:51PM +0100, Marek Vasut wrote:

> Newer versions of libfdt strictly check whether the FDT blob
> passed to them is at 8-byte aligned offset, if it is not, then
> the library fails checks with -FDT_ERR_ALIGNMENT . Currently,
> android_image_print_dtb_contents() passed FDT directly mapped
> from abootimg to libfdt, and this FDT is not always aligned to
> 8-byte offset. Specifically, the FDTs are somewhat packed in
> the abootimg, therefore if the first FDT blob is e.g. 0xfd bytes
> long, then the next FDT blob ends up at 0xfd offset, which is
> not 8-byte aligned.
> 
> Fix this by first extracting the header into 8-byte aligned buffer,
> checking only the header for validity, and then by copying the
> entire FDT into newly allocated 8-byte aligned buffer. While this
> is not efficient, it is the correct way to handle DTs, which must
> be at 8-byte aligned offsets. Mitigate the inefficiency for the
> common case by checking whether the DT might be 8-byte aligned and
> if it is, map it directly.
> 
> Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>

Thanks for doing this. We had talked off-list and I looked at the code
in question more and while it would be nice to abstract those two
similar loops in those functions, they're ultimately both different
enough in usage and small enough that it wouldn't really be a win, to
pull that out to a function of its own.

Reviewed-by: Tom Rini <trini at konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20251119/416716d6/attachment.sig>


More information about the U-Boot mailing list