From: Tom Rini <trini@konsulko.com>
To: Simon Glass <sjg@chromium.org>, Rasmus Villemoes <ravi@prevas.dk>
Cc: u-boot@lists.denx.de, Simon Glass <simon.glass@canonical.com>
Subject: Re: [PATCH 1/2] linker_lists: Fix end-marker alignment to prevent padding
Date: Mon, 13 Apr 2026 11:24:05 -0600 [thread overview]
Message-ID: <20260413172405.GC41863@bill-the-cat> (raw)
In-Reply-To: <CAFLszThfW=K1h1q2rHC5cFYNQ5SCiPBMMDKOxEXUTdxxwYo-FA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1694 bytes --]
On Sat, Apr 11, 2026 at 07:36:16PM -0600, Simon Glass wrote:
> Hi,
>
> On Sat, 21 Mar 2026 at 07:46, Simon Glass <sjg@chromium.org> wrote:
> >
> > From: Simon Glass <simon.glass@canonical.com>
> >
> > Change the alignment of end markers in ll_entry_end() and ll_end_decl()
> > from __aligned(4) and __aligned(CONFIG_LINKER_LIST_ALIGN) respectively
> > to __aligned(1).
> >
> > The linker places zero-size end markers at aligned boundaries based on
> > what follows them. When the next list's start marker has a high alignment
> > requirement (e.g., 32 bytes), padding gets inserted before the end
> > marker. This causes the byte span (end - start) to not be an exact
> > multiple of the struct size.
> >
> > The compiler optimises pointer subtraction (end - start) using
> > magic-number multiplication for division. This optimisation only produces
> > correct results when the byte span is an exact multiple of the struct
> > size. With padding, the result is garbage (e.g., -858993444 instead of
> > 15).
> >
> > By using __aligned(1), the end marker is placed immediately after the
> > last entry with no padding, ensuring (end - start) equals exactly
> > (n * sizeof) where n is the number of entries. This makes
> > ll_entry_count() and direct pointer arithmetic work correctly.
> >
> > Fixes: 0b2fa98aa5e5 ("linker_lists: Fix alignment issue")
> > Signed-off-by: Simon Glass <simon.glass@canonical.com>
> > ---
> >
> > include/linker_lists.h | 22 ++++++++++++++++++++--
> > 1 file changed, 20 insertions(+), 2 deletions(-)
> >
>
> Any thoughts on applying this one?
Yes, waiting for Rasmus to reply again to you or give some tags.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2026-04-13 17:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-21 13:46 [PATCH 0/2] A few linker-list fixes Simon Glass
2026-03-21 13:46 ` [PATCH 1/2] linker_lists: Fix end-marker alignment to prevent padding Simon Glass
2026-03-23 9:56 ` Rasmus Villemoes
2026-03-23 15:29 ` Tom Rini
2026-03-23 16:17 ` Simon Glass
2026-04-13 21:07 ` Rasmus Villemoes
2026-04-12 1:36 ` Simon Glass
2026-04-13 17:24 ` Tom Rini [this message]
2026-03-21 13:46 ` [PATCH 2/2] dm: Fix linker list alignment for ll_entry_get() Simon Glass
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=20260413172405.GC41863@bill-the-cat \
--to=trini@konsulko.com \
--cc=ravi@prevas.dk \
--cc=simon.glass@canonical.com \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.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