On Mon, 26 Sept 2022 at 11:06, Masahiro Yamada <masahiroy@xxxxxxxxxx> wrote: > > On Mon, Sep 26, 2022 at 5:48 PM Yann Sionneau <ysionneau@xxxxxxxxx> wrote: > > > > > > On 8/28/22 16:05, Masahiro Yamada wrote: > > > On Fri, Aug 26, 2022 at 7:17 PM Ard Biesheuvel <ardb@xxxxxxxxxx> wrote: > > >> On Thu, 25 Aug 2022 at 20:01, Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> wrote: > > >>> Hi Ard, > > >>> > > >>> On Thu, Aug 25, 2022 at 2:56 PM Ard Biesheuvel <ardb@xxxxxxxxxx> wrote: > > >>>> On Thu, 25 Aug 2022 at 14:21, Yann Sionneau <ysionneau@xxxxxxxxx> 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@xxxxxxxxxx> > 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@xxxxxxxxx/ > Link: https://lore.kernel.org/linux-kbuild/31ce5305-a76b-13d7-ea55-afca82c46cf2@xxxxxxxxx/ > Fixes: 7b4537199a4a ("kbuild: link symbol CRCs at final link, > removing CONFIG_MODULE_REL_CRCS") > Reported-by: Yann Sionneau <ysionneau@xxxxxxxxx> > Signed-off-by: Masahiro Yamada <masahiroy@xxxxxxxxxx> > Tested-by: Yann Sionneau <ysionneau@xxxxxxxxx> > I don't think we should merge this. kvm is an experimental out of tree port, and everywhere else, we already rely heavily on array sections constructed by the linker where it just concatenate sections from the input objects, and assumes there will be no padding.