All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: Yann Sionneau <ysionneau@kalray.eu>
Cc: Ard Biesheuvel <ardb@kernel.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Arnd Bergmann <arnd@arndb.de>,
	linux-kbuild <linux-kbuild@vger.kernel.org>,
	Linux-Arch <linux-arch@vger.kernel.org>
Subject: Re: [RFC PATCH 1/1] Fix __kcrctab+* sections alignment
Date: Mon, 26 Sep 2022 18:05:49 +0900	[thread overview]
Message-ID: <CAK7LNATccB3K-wagEB3+Tf8FVPp7F26nKAXEiCPPxjOd5qyt-Q@mail.gmail.com> (raw)
In-Reply-To: <197eb354-2fc8-1712-3c83-34be9391efa8@kalray.eu>

On Mon, Sep 26, 2022 at 5:48 PM Yann Sionneau <ysionneau@kalray.eu> wrote:
>
>
> On 8/28/22 16:05, Masahiro Yamada wrote:
> > On Fri, Aug 26, 2022 at 7:17 PM Ard Biesheuvel <ardb@kernel.org> wrote:
> >> On Thu, 25 Aug 2022 at 20:01, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> >>> Hi Ard,
> >>>
> >>> On Thu, Aug 25, 2022 at 2:56 PM Ard Biesheuvel <ardb@kernel.org> wrote:
> >>>> On Thu, 25 Aug 2022 at 14:21, Yann Sionneau <ysionneau@kalray.eu> wrote:
> >>>>> Well, I am not completely sure about that. See my cover letter, previous
> >>>>> mechanism for symbol CRC was actually enforcing the section alignment to
> >>>>> 4 bytes boundary as well.
> >>> Yes, because else it may become 2-byte aligned on m68k.
> >>>
> >>>>> Also, I'm not sure it is forbidden for an architecture/compiler
> >>>>> implementation to actually enforce a stronger alignment on u32, which in
> >>>>> theory would not break anything.
> >>>>>
> >>>> u32 is a Linux type, and Linux expects natural alignment (and padding).
> >>> Is it? You probably mean its alignment should not be larger than
> >>> 4 bytes? Less has been working since basically forever.
> >>>
> >> You are quite right. of course. And indeed, the issue here is padding
> >> not alignment.
> >>
> > I do not know if __align(4) should be used to avoid the padding issue.
> >
> >
> >
> > Do you think it is a good idea to use an inline assembler,
> > as prior to 7b4537199a4a8480b8c3ba37a2d44765ce76cd9b ?
> >
> >
> > This patch:
> >
> > diff --git a/include/linux/export-internal.h b/include/linux/export-internal.h
> > index c2b1d4fd5987..fb90f326b1b5 100644
> > --- a/include/linux/export-internal.h
> > +++ b/include/linux/export-internal.h
> > @@ -12,6 +12,9 @@
> >
> >   /* __used is needed to keep __crc_* for LTO */
> >   #define SYMBOL_CRC(sym, crc, sec)   \
> > -       u32 __section("___kcrctab" sec "+" #sym) __used __crc_##sym = crc
> > +       asm(".section \"___kcrctab" sec "+" #sym "\",\"a\""     "\n" \
> > +           "__crc_" #sym ":"                                   "\n" \
> > +           ".long " #crc                                       "\n" \
> > +           ".previous"                                         "\n")
> >
> >   #endif /* __LINUX_EXPORT_INTERNAL_H__ */
>
> Ping on this topic, should we "fix our toolchain"?
>
> Or should Linux code be modified to add either __align(4) or use the
> inline assembler? (I've tried your inline asm patch and it seems to fix
> the issue I'm having).
>
> Or both?
>
> Thanks,
>
> Yann
>
>
>
>
>


I queued up the patch.
You can see it in linux-next.


Once it lands in the mainline,
it will be back-ported.






masahiro@zoe:~/ref/linux-next$ git log -1 next-20220923 --
include/linux/export-internal.h
commit 60ecfddd7a092f9cbd2398dbc55da3abbb803ff0
Author: Masahiro Yamada <masahiroy@kernel.org>
Date:   Fri Sep 16 15:29:53 2022 +0900

    linux/export: use inline assembler to populate symbol CRCs

    Since commit 7b4537199a4a ("kbuild: link symbol CRCs at final link,
    removing CONFIG_MODULE_REL_CRCS"), the module versioning on the
    (non-upstreamed-yet) kvx Linux port is broken due to unexpected padding
    for __crc_* symbols. The kvx GCC adds padding so u32 gets 8-byte
    alignment instead of 4.

    I do not know if this happens for upstream architectures in general,
    but any compiler has the freedom to insert padding for faster access.

    Use the inline assembler to directly specify the wanted data layout.
    This is how we previously did before the breakage.

    Link: https://lore.kernel.org/lkml/20220817161438.32039-1-ysionneau@kalray.eu/
    Link: https://lore.kernel.org/linux-kbuild/31ce5305-a76b-13d7-ea55-afca82c46cf2@kalray.eu/
    Fixes: 7b4537199a4a ("kbuild: link symbol CRCs at final link,
removing CONFIG_MODULE_REL_CRCS")
    Reported-by: Yann Sionneau <ysionneau@kalray.eu>
    Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
    Tested-by: Yann Sionneau <ysionneau@kalray.eu>







-- 
Best Regards
Masahiro Yamada

  reply	other threads:[~2022-09-26  9:07 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-17 16:14 [RFC PATCH 0/1] Fix __kcrctab+* sections alignment Yann Sionneau
2022-08-17 16:14 ` [RFC PATCH 1/1] " Yann Sionneau
2022-08-25 12:03   ` Fwd: " Yann Sionneau
2022-08-25 12:12     ` Ard Biesheuvel
2022-08-25 12:21       ` Yann Sionneau
2022-08-25 12:41         ` Ard Biesheuvel
2022-08-25 18:01           ` Geert Uytterhoeven
2022-08-26 10:17             ` Ard Biesheuvel
2022-08-28 14:05               ` Masahiro Yamada
2022-09-05 15:26                 ` Yann Sionneau
2022-09-26  8:48                 ` Yann Sionneau
2022-09-26  9:05                   ` Masahiro Yamada [this message]
2022-09-26  9:11                     ` Ard Biesheuvel
2022-09-26  9:05                   ` Ard Biesheuvel
2022-08-28 13:41         ` Masahiro Yamada
2022-08-28 13:59         ` Masahiro Yamada
2022-09-05 13:56           ` Yann Sionneau
2022-08-25 12:03 ` Fwd: [RFC PATCH 0/1] " Yann Sionneau

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=CAK7LNATccB3K-wagEB3+Tf8FVPp7F26nKAXEiCPPxjOd5qyt-Q@mail.gmail.com \
    --to=masahiroy@kernel.org \
    --cc=ardb@kernel.org \
    --cc=arnd@arndb.de \
    --cc=geert@linux-m68k.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=ysionneau@kalray.eu \
    /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.