[PATCH v3 1/1] image: fit: Apply overlays using aligned writable FDT copies
James Hilliard
james.hilliard1 at gmail.com
Wed Feb 11 23:13:37 CET 2026
On Wed, Feb 11, 2026 at 5:29 AM <Jamie.Gibbons at microchip.com> wrote:
>
> Hi James,
>
> On Tue, 2026-02-10 at 19:13 -0700, James Hilliard wrote:
> > EXTERNAL EMAIL: Do not click links or open attachments unless you
> > know the content is safe
> >
> > libfdt expects FDT/DTO blobs to be 8-byte aligned. When loading the
> > base FDT or overlays from a FIT, the mapped buffer may be unaligned,
> > which can break fdt_open_into() on strict-alignment architectures.
> >
> > boot_get_fdt_fit() relocates the base FDT with boot_relocate_fdt()
> > before applying overlays. That uses the bootm memory map and can
> > overlap with the FIT buffer when the FIT is loaded into RAM,
> > corrupting data needed to load the kernel and ramdisk.
> >
> > Allocate writable, 8-byte aligned copies of the base FDT and overlays
> > with memalign() and fdt_open_into(). Grow the base buffer as needed,
> > apply overlays to it and pack the final tree. Free each temporary
> > overlay copy after application and check fdt_pack() errors.
> >
> I am looking to test this patch but unfortunately it fails to apply at
> boot/image-fit.c:2465 for me. I have tried both master and next
> branches. What base are you working from?
Oh, it was a random slightly older commit I think, I went ahead
and rebased it on master here:
https://patchwork.ozlabs.org/project/uboot/patch/20260211180645.3313596-1-james.hilliard1@gmail.com/
>
> Thanks,
> Jamie.
> > Fixes: 8fbcc0e0e839 ("boot: Assure FDT is always 8-byte aligned")
> > Fixes: 881f0b77dc8c ("image: apply FDTOs on FDT image node")
> > Signed-off-by: James Hilliard <james.hilliard1 at gmail.com>
> > Cc: Jamie Gibbons <Jamie.Gibbons at microchip.com>
> > ---
> > Changes v1 -> v2:
> > - also fix alignment issues
> > Changes v2 -> v3:
> > - do not print on -ENOMEM errors
> > - let boot_get_fdt_fit_into_buffer() reuse buffers and handle
> > rounding
> > ---
> > boot/image-fit.c | 161 ++++++++++++++++++++++++++++++++++++---------
> > --
> > 1 file changed, 124 insertions(+), 37 deletions(-)
> >
> > diff --git a/boot/image-fit.c b/boot/image-fit.c
> > index 41ab1f552b0..09a57bbb670 100644
> > --- a/boot/image-fit.c
> > +++ b/boot/image-fit.c
More information about the U-Boot
mailing list