Port-m68k archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Preliminary results - was: Re: Question on BIGGEST_ALIGNMENT in GCC on NetBSD/m68k



Hi Arnd,

On Mon, 2 Feb 2026 at 11:53, Geert Uytterhoeven <geert%linux-m68k.org@localhost> wrote:
> On Wed, 7 Jan 2026 at 09:20, Arnd Bergmann <arnd%arndb.de@localhost> 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@localhost> 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@localhost

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


Home | Main Index | Thread Index | Old Index