Re: Preliminary results - was: Re: Question on BIGGEST_ALIGNMENT in GCC on NetBSD/m68k
- To: Arnd Bergmann <arnd@arndb.de>
- Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>, Kolbjørn Barmen <linux-m68k@kolla.no>, "port-m68k@netbsd.org" <port-m68k@netbsd.org>, "debian-68k@lists.debian.org" <debian-68k@lists.debian.org>, "linux-m68k@vger.kernel.org" <linux-m68k@vger.kernel.org>, Thomas Weißschuh <thomas.weissschuh@linutronix.de>
- Subject: Re: Preliminary results - was: Re: Question on BIGGEST_ALIGNMENT in GCC on NetBSD/m68k
- From: Geert Uytterhoeven <geert@linux-m68k.org>
- Date: Thu, 2 Jul 2026 14:43:03 +0200
- Message-id: <[🔎] CAMuHMdWdHVMdcAPgsgoRshY4nrQnnMHp9BCpo7SHnik37oySrg@mail.gmail.com>
- In-reply-to: <CAMuHMdUjOw2VJTNM97+8iiG6uB5_2XuksSxF=1AMWNR4WsyD0A@mail.gmail.com>
- References: <ae61eb01a3d323b61ee340919971725bed59ddef.camel@physik.fu-berlin.de> <8e0186f61cc9bbed2373ae215e80ab7e70042793.camel@physik.fu-berlin.de> <48ebcafa-467d-05a4-17f6-7cc078596d88@linux-m68k.org> <48af5d8ed5b1546cb3db3b2c2314b1e41de38aad.camel@physik.fu-berlin.de> <0d7b5c87-f0f7-70a4-cf75-5147e67904da@yahoo.com> <131b33a26efd2b0e21dfee784821dcaf3aeddad4.camel@physik.fu-berlin.de> <7d9d8c95-1b06-c6c5-0932-7ba3af55829a@linux-m68k.org> <CABq5eXH8S9MVoRi5znU+u7EJPmaRA+8yOyd-QKBJMQa10UoAmw@mail.gmail.com> <6c1d08bf4cd4d7c92338357bd61dca8a23559ad0.camel@physik.fu-berlin.de> <WtNQmVJr3uIeOkUfpStavGscYvoTLpprxvowAOsqJKw8V7XCOZqKDi3Qw7Z1m8JVMsv71f0VZCVqZ3MiKnjLYp-VwSvtvTLkoVtJpAkA0gA=@r-v-e.co> <c4f086207e68843ea154b5d41950957fa11c6837.camel@physik.fu-berlin.de> <CAMuHMdU7Px7bT4XCZC=vF6aUFGj8=cd=refOf2u17mRjp2FUSA@mail.gmail.com> <2c10a9539a82b534e4a815361bb24c04d30b7e67.camel@physik.fu-berlin.de> <CAMuHMdXnebgBVWp-uxrmxTFKZkQVU2h-OW7H+7hJ+4beN9DFLg@mail.gmail.com> <9f1613138de30db0248649e6a36c2b063693057f.camel@physik.fu-berlin.de> <f1f4afab-51a4-10b5-106c-e9e6e5528e6f@kolla.no> <9277b6ef0478bc6651c03b4220004a4c8a2e1cdb.camel@physik.fu-berlin.de> <e01dfc6d-a45f-4d17-a27c-67f913dc614c@app.fastmail.com> <CAMuHMdWVwXq+PzW_K1Lkn3hCAZuL4ps2VPEng4tB4wuhT+oytA@mail.gmail.com> <baadfe05-0893-4182-8c7e-7ea816aee905@app.fastmail.com> <CAMuHMdUjOw2VJTNM97+8iiG6uB5_2XuksSxF=1AMWNR4WsyD0A@mail.gmail.com>
Hi Arnd,
On Mon, 2 Feb 2026 at 11:53, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> On Wed, 7 Jan 2026 at 09:20, Arnd Bergmann <arnd@arndb.de> wrote:
> > On Tue, Jan 6, 2026, at 20:31, Geert Uytterhoeven wrote:
> > > On Tue, 6 Jan 2026 at 16:38, Arnd Bergmann <arnd@arndb.de> wrote:
> > >> On Tue, Jan 6, 2026, at 14:40, John Paul Adrian Glaubitz wrote:
> > >> > On Tue, 2026-01-06 at 14:34 +0100, Kolbjørn Barmen wrote:
> > >> The diffstat is
> > >>
> > >> 407 files changed, 2433 insertions(+), 754 deletions(-)
> > >>
> > >> and I think this touches around 1500 structures, though
> > >> most files only have a single one.
> > >
> > > Thanks, this seems to work fine for atari_defconfig, and generates
> > > the exact same code as before.
I kept on updating this during the last few months (I guess/hope you
did the same?)
> >
> > Ok, good. The more interesting bit then is what happens when
> > you actually turn on -malign-int for the kernel itself. There
>
> It fails to build due to wrong and missing annotations in union __sifields:
>
> arch/m68k/kernel/signal.c:621:9: note: in expansion of macro ‘BUILD_BUG_ON’
> 621 | BUILD_BUG_ON(offsetof(siginfo_t, si_lower) != 0x12);
>
> which is probably the same issue Kolla was seeing.
The following are failing with -malign-int:
BUILD_BUG_ON(offsetof(siginfo_t, si_lower) != 0x12);
BUILD_BUG_ON(offsetof(siginfo_t, si_upper) != 0x16);
BUILD_BUG_ON(offsetof(siginfo_t, si_pkey) != 0x12);
All of these are due to
#define __ADDR_BND_PKEY_PAD (__alignof__(void *) < sizeof(short) ? \
sizeof(short) : __alignof__(void *))
(which is no longer correct for m68k and -malign-int), and incorrect/missing
annotations for the three fields succeeding the use of the former.
I couldn't fix it using the __uapi_* infrastructure you provided, but
the following (gmail-whitespace-damaged) patch fixes the BUILD_BUG_ON()s:
--- a/include/uapi/asm-generic/siginfo.h
+++ b/include/uapi/asm-generic/siginfo.h
@@ -71,8 +71,12 @@ union __sifields {
struct {
void __user *_addr; /* faulting insn/memory ref. */
+#ifdef __m68k__
+#define __ADDR_BND_PKEY_PAD sizeof(short)
+#else
#define __ADDR_BND_PKEY_PAD (__alignof__(void *) < sizeof(short) ? \
sizeof(short) : __alignof__(void *))
+#endif
union {
/* used on alpha and sparc */
int _trapno; /* TRAP # which caused the signal */
@@ -84,13 +88,13 @@ union __sifields {
/* used when si_code=SEGV_BNDERR */
struct {
char _dummy_bnd[__ADDR_BND_PKEY_PAD];
- void __user *_lower;
- void __user *_upper;
+ void __user *_lower __attribute__
((packed, aligned(2)));
+ void __user *_upper __attribute__
((packed, aligned(2)));
} _addr_bnd;
/* used when si_code=SEGV_PKUERR */
struct {
char _dummy_pkey[__ADDR_BND_PKEY_PAD];
- __u32 _pkey;
+ __u32 _pkey __attribute__ ((packed,
aligned(2)));
} _addr_pkey;
/* used when si_code=TRAP_PERF */
struct {
Unfortunately the resulting kernel hangs (on ARAnyM) after:
Console: colour dummy device 80x25
printk: legacy console [tty0] enabled
Back to real work...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Reply to: