From: Tom Rini <trini@konsulko.com>
To: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Sam Edwards <cfsworks@gmail.com>,
Marek Vasut <marek.vasut+renesas@mailbox.org>,
Sumit Garg <sumit.garg@linaro.org>,
Peter Robinson <pbrobinson@gmail.com>,
Richard Henderson <richard.henderson@linaro.org>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Simon Glass <sjg@chromium.org>, Bin Meng <bmeng.cn@gmail.com>,
u-boot@lists.denx.de,
Patrice Chotard <patrice.chotard@foss.st.com>
Subject: Re: [PATCH 10/17] spl: Align FDT load address
Date: Mon, 24 Feb 2025 10:03:05 -0600 [thread overview]
Message-ID: <20250224160305.GG1233568@bill-the-cat> (raw)
In-Reply-To: <31342144-345b-4dd8-b80e-f53376a591d8@gmx.de>
[-- Attachment #1: Type: text/plain, Size: 2439 bytes --]
On Mon, Feb 24, 2025 at 04:54:09PM +0100, Heinrich Schuchardt wrote:
> On 24.02.25 15:56, Tom Rini wrote:
> > On Mon, Feb 24, 2025 at 09:59:42AM +0100, Heinrich Schuchardt wrote:
> > > On 2/24/25 06:55, Sam Edwards wrote:
> > > > While the image size is generally a multiple of 8 bytes, this is not
> > > > actually guaranteed; some linkers (like LLD) may shave a few bytes off
> > > > of the end of output sections if there are no content bytes there. Since
> > > > libfdt imposes a hard rule of 8-byte alignment, make the SPL also be
> > > > explicit about the alignment when loading the FDT.
> > > >
> > > > Signed-off-by: Sam Edwards <CFSworks@gmail.com>
> > > > ---
> > > > common/spl/spl_fit.c | 2 +-
> > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
> > > > index 49b4df60560..86506d6905c 100644
> > > > --- a/common/spl/spl_fit.c
> > > > +++ b/common/spl/spl_fit.c
> > > > @@ -397,7 +397,7 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
> > > > * Use the address following the image as target address for the
> > > > * device tree.
> > > > */
> > > > - image_info.load_addr = spl_image->load_addr + spl_image->size;
> > > > + image_info.load_addr = ALIGN(spl_image->load_addr + spl_image->size, 8);
> > >
> > > We want to keep the SPL code size as small as possible as on many
> > > platforms it is restricted to the cache size.
> > >
> > > Can't we fix this linker issue in the linker script by properly aligning
> > > the SPL image end address?
> >
> > Size growth is always something to watch for, but not at the expense of
> > correctness and saving a few bytes. We really do need to fix the places
> > where U-Boot could but doesn't ensure the device tree is correctly
> > aligned in memory.
> >
>
> Hello Tom,
>
> spl_image->load_addr is always a multiple of 8.
>
> Adding
>
> . = ALIGN(8)"
>
> in arch/riscv/cpu/u-boot-spl.lds before
>
> _end = .;
> _image_binary_end = .;
>
> is all it takes.
But this is generic code and I don't see how we know that in every case
every way we could be reading the device tree that it will be at an 8
byte aligned location. There's a number of ways today where it's not,
which is what Patrice found as part of updating our own libfdt to one
that enforces the alignment check.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
next prev parent reply other threads:[~2025-02-24 16:03 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-24 5:55 [PATCH 00/17] Various toolchain compatibility fixes/improvements Sam Edwards
2025-02-24 5:55 ` [PATCH 01/17] arm: Remove stray .mmutable reference in linker script Sam Edwards
2025-02-26 14:44 ` Ilias Apalodimas
2025-02-24 5:55 ` [PATCH 02/17] arm: Exclude eabi_compat from LTO Sam Edwards
2025-03-09 8:47 ` Ilias Apalodimas
2025-02-24 5:55 ` [PATCH 03/17] arm: Add __aeabi_memclr in eabi_compat Sam Edwards
2025-03-09 8:45 ` Ilias Apalodimas
2025-02-24 5:55 ` [PATCH 04/17] arm: Add aligned-memory aliases to eabi_compat Sam Edwards
2025-03-09 8:51 ` Ilias Apalodimas
2025-02-24 5:55 ` [PATCH 05/17] arm: Discard unwanted sections in linker script Sam Edwards
2025-02-24 5:55 ` [PATCH 06/17] arm: Use -mstrict-align when the MMU is off Sam Edwards
2025-02-24 8:20 ` Heinrich Schuchardt
2025-02-24 11:21 ` Mark Kettenis
2025-02-24 5:55 ` [PATCH 07/17] arm: Replace 'adrl' in EFI crt0 Sam Edwards
2025-02-24 8:42 ` Heinrich Schuchardt
2025-02-25 2:16 ` Sam Edwards
2025-02-24 5:55 ` [PATCH 08/17] x86: Fix call64's section flags Sam Edwards
2025-02-24 5:55 ` [PATCH 09/17] spl: riscv: opensbi: Error on misaligned FDT Sam Edwards
2025-02-24 8:54 ` Heinrich Schuchardt
2025-02-24 14:54 ` Tom Rini
2025-02-25 2:29 ` Sam Edwards
2025-02-24 5:55 ` [PATCH 10/17] spl: Align FDT load address Sam Edwards
2025-02-24 8:59 ` Heinrich Schuchardt
2025-02-24 14:56 ` Tom Rini
2025-02-24 15:54 ` Heinrich Schuchardt
2025-02-24 16:03 ` Tom Rini [this message]
2025-02-25 2:48 ` Sam Edwards
2025-02-24 5:55 ` [PATCH 11/17] makefile: Fix symbol typo in binary_size_check Sam Edwards
2025-02-24 9:17 ` Heinrich Schuchardt
2025-02-25 13:04 ` Simon Glass
2025-02-24 5:55 ` [PATCH 12/17] makefile: Avoid objcopy --gap-fill for .hex/.srec Sam Edwards
2025-02-24 5:55 ` [PATCH 13/17] makefile: Add `norelro` linker option Sam Edwards
2025-03-11 14:31 ` Ilias Apalodimas
2025-02-24 5:55 ` [PATCH 14/17] makefile: Add READELF command variable Sam Edwards
2025-02-24 9:20 ` Heinrich Schuchardt
2025-02-26 9:51 ` Ilias Apalodimas
2025-02-24 5:55 ` [PATCH 15/17] efi_loader: Remove ENTRY(_start) from linker script Sam Edwards
2025-02-24 9:36 ` Heinrich Schuchardt
2025-02-25 2:21 ` Sam Edwards
2025-02-24 5:55 ` [PATCH 16/17] efi_loader: Move .dynamic out of .text in EFI Sam Edwards
2025-02-24 7:34 ` Heinrich Schuchardt
2025-03-04 2:37 ` Sam Edwards
2025-02-24 5:55 ` [PATCH 17/17] scripts/Makefile.lib: efi: Preserve the .dynstr section as well Sam Edwards
2025-02-24 9:46 ` Heinrich Schuchardt
2025-03-06 3:46 ` [PATCH 00/17] Various toolchain compatibility fixes/improvements Sam Edwards
2025-03-06 13:15 ` Ilias Apalodimas
2025-03-06 15:47 ` Tom Rini
2025-03-08 6:48 ` Sam Edwards
2025-03-10 14:07 ` 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=20250224160305.GG1233568@bill-the-cat \
--to=trini@konsulko.com \
--cc=bmeng.cn@gmail.com \
--cc=cfsworks@gmail.com \
--cc=ilias.apalodimas@linaro.org \
--cc=marek.vasut+renesas@mailbox.org \
--cc=patrice.chotard@foss.st.com \
--cc=pbrobinson@gmail.com \
--cc=richard.henderson@linaro.org \
--cc=sjg@chromium.org \
--cc=sumit.garg@linaro.org \
--cc=u-boot@lists.denx.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.