U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marek.vasut@mailbox.org>
To: Simon Glass <sjg@chromium.org>
Cc: Marek Vasut <marek.vasut+renesas@mailbox.org>,
	u-boot@lists.denx.de, Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Quentin Schulz <quentin.schulz@cherry.de>,
	Tom Rini <trini@konsulko.com>,
	Wolfgang Wallner <wolfgang.wallner@br-automation.com>
Subject: Re: [PATCH] boot: Assure FDT is always at 8-byte aligned address
Date: Sat, 15 Nov 2025 18:19:53 +0100	[thread overview]
Message-ID: <c5300029-9bab-4a06-b426-ccc443d0928c@mailbox.org> (raw)
In-Reply-To: <CAFLszThNLoS7j0pe_8G93dHtX91j331DCBiUgWpUPXi4Oi2-9w@mail.gmail.com>

On 11/13/25 11:46 PM, Simon Glass wrote:

Hello Simon,

>>> The problem should be fixed higher up, in its callers, etc. For one
>>> thing, the caller knows whether it is a DT or not, so putting this
>>> logic here is messy. See boot_get_fdt_fit()
>>
>> This is triggered by a fitImage with DT embedded in that fitImage as
>> non-external-data. That DT is at 4-byte aligned address, so how can the
>> caller deal with it ? The caller gets a fitImage, which itself is at
>> 8-byte aligned address, but the DT in it is not at 8-byte aligned
>> address, so that DT has to be relocated somehow and that happens here.
> 
> OK, but don't put the code in here...see boot_get_fdt_fit(). But even
> then, why does it matter where the FDT is?

The FDT has to be at 8-byte aligned offset.

> We are going to use
> fdt_openinto() at some point and put it elsewhere, right, so we can do
> pre-boot fixups?

Look at the fit load code, cca. 10 lines below, it checks the FDT for 
validity using fdt_check_header() . At that point, the FDT must be at 
8-byte aligned address already:

2294         } else if (load_op != FIT_LOAD_IGNORED && image_type == 
IH_TYPE_FLATDT &&
2295                    ((uintptr_t)buf & 7)) {
2296                 loadbuf = memalign(8, len);
2297                 load = map_to_sysmem(loadbuf);
2298                 memcpy(loadbuf, buf, len);

...

2309         /* verify that image data is a proper FDT blob */
2310         if (load_op != FIT_LOAD_IGNORED && image_type == 
IH_TYPE_FLATDT &&
2311             fdt_check_header(loadbuf)) { <----------------- this
2312                 puts("Subimage data is not a FDT\n");
2313                 return -ENOEXEC;
2314         }

> Perhaps we should deprecate FITs with internal data, too?
We cannot break compatibility and stop supporting old fitImage, so this 
is irrelevant here.

  reply	other threads:[~2025-11-16  0:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-13 11:54 [PATCH] boot: Assure FDT is always at 8-byte aligned address Marek Vasut
2025-11-13 19:33 ` Simon Glass
2025-11-13 21:56   ` Marek Vasut
2025-11-13 22:46     ` Simon Glass
2025-11-15 17:19       ` Marek Vasut [this message]
2025-11-17 17:04         ` Simon Glass
2025-11-17 17:10           ` Marek Vasut
2025-11-18  3:47             ` Simon Glass
2025-11-19 21:29               ` Marek Vasut
2025-11-20  2:07                 ` Simon Glass
2025-11-28 17:41 ` Tom Rini

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=c5300029-9bab-4a06-b426-ccc443d0928c@mailbox.org \
    --to=marek.vasut@mailbox.org \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=quentin.schulz@cherry.de \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=wolfgang.wallner@br-automation.com \
    --cc=xypron.glpk@gmx.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