[PATCHv2] boot/image-fit.c: Resort to using malloc for USE_HOSTCC
Simon Glass
sjg at chromium.org
Tue Dec 2 21:07:00 CET 2025
Hi Tom,
On Tue, 2 Dec 2025 at 16:22, Tom Rini <trini at konsulko.com> wrote:
>
> With the changes in commit 8fbcc0e0e839 ("boot: Assure FDT is always at
> 8-byte aligned address") to call memalign(...) we now always call
> memalign(...) rather than malloc(...) when allocating a buffer that may
> contain a device tree. However, memalign(...) is not portable among all
> of the host OSes we support. Specifically on macOS it isn't seemingly
> possible to get memalign exactly. To keep alignment we would need to
> rework to use posix_memalign(...) for USE_HOSTCC and memalign(...) for
> U-Boot itself. This would get rather tricky. However, given the limited
> use case in question, it makes more sense to fall back to malloc(...)
> for the USE_HOSTCC case.
>
> Fixes: 8fbcc0e0e839 ("boot: Assure FDT is always at 8-byte aligned address")
> Signed-off-by: Tom Rini <trini at konsulko.com>
> ---
> Cc: Marek Vasut <marek.vasut+renesas at mailbox.org>
>
> My biggest take-away from this is that I need to move up the plans I had
> about asking if anyone even uses the host tools on Windows / macOS from
> post-v2026.01 to instead be later today.
>
> This change is a work-around at best. Ideally, we can drop Windows /
> macOS host build support and revert this commit at that time.
>
> Changes in v2:
> - Rework things entirely, and elaborate on the commit message.
> ---
> boot/image-fit.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
That patch was not a great solution. There is no indication in the
commit message that it is doing an allocation:
commit 8fbcc0e0e839a8e25f636c76e59311033d3817b5
Author: Marek Vasut <marek.vasut+renesas at mailbox.org>
Date: Thu Nov 13 12:54:51 2025 +0100
boot: Assure FDT is always at 8-byte aligned address
The fitImage may contain FDT at 4-byte aligned address, because alignment
of DT tags is 4 bytes. However, libfdt and also Linux expects DT to be at
8-byte aligned address. Make sure that the DTs embedded in fitImages are
always used from 8-byte aligned addresses. In case the DT is decompressed,
make sure the target buffer is 8-byte aligned. In case the DT is only
loaded, make sure the target buffer is 8-byte aligned too.
Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
Regards,
Simon
More information about the U-Boot
mailing list