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
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.
Ok, good. The more interesting bit then is what happens when
you actually turn on -malign-int for the kernel itself. There
are many drivers that change behavior, but mostly this is going
to be a fix rather than a regression. As far as I can tell, this
change is all that should be needed for atari:
diff --git a/arch/m68k/include/asm/atarihw.h b/arch/m68k/include/asm/atarihw.h
index 9a038a3edb83..467005598fc6 100644
--- a/arch/m68k/include/asm/atarihw.h
+++ b/arch/m68k/include/asm/atarihw.h
@@ -334,7 +334,7 @@ struct TT_DMA {
u_char dma_cnt_lmd;
u_char char_dummy7;
u_char dma_cnt_lo;
- u_long dma_restdata;
+ u_long dma_restdata __packed;
u_short dma_ctrl;
};
#define tt_scsi_dma ((*(volatile struct TT_DMA *)TT_SCSI_DMA_BAS))
@@ -417,13 +417,13 @@ struct BLITTER
u_short halftone[16];
u_short src_x_inc;
u_short src_y_inc;
- u_long src_address;
+ u_long src_address __packed;
u_short endmask1;
u_short endmask2;
u_short endmask3;
u_short dst_x_inc;
u_short dst_y_inc;
- u_long dst_address;
+ u_long dst_address __packed;
u_short wd_per_line;
u_short ln_per_bb;
u_short hlf_op_reg;
diff --git a/arch/m68k/include/asm/openprom.h b/arch/m68k/include/asm/openprom.h
index 6456ba40a946..741e83d76ff2 100644
--- a/arch/m68k/include/asm/openprom.h
+++ b/arch/m68k/include/asm/openprom.h
@@ -78,7 +78,7 @@ struct linux_arguments_v0 {
int dev_partition;
char *kernel_file_name;
void *aieee1; /* XXX */
-};
+} __packed;
/* V2 and up boot things. */
struct linux_bootargs_v2 {
> However, m68k allmodconfig fails with:
>
> In file included from tools/include/nolibc/nolibc.h:97,
> from tools/include/nolibc/stddef.h:8,
> from ./usr/include/scsi/fc/fc_els.h:14,
> from <command-line>:
> tools/include/nolibc/types.h:120:1: error: padding struct size to
> alignment boundary with 1 bytes [-Werror=padded]
> 120 | };
> | ^
> cc1: all warnings being treated as errors
> make[4]: *** [usr/include/Makefile:85:
> usr/include/scsi/fc/fc_els.hdrtest] Error 1
>
> This is due to struct linux_dirent64 in tools/include/nolibc/types.h.
> The same definition in include/linux/dirent.h doesn't cause issues.
I left out the nolibc changes, as Thomas Weißschuh has already
posted patches to remove the dependency entirely. This is what
I use for testing with nolibc at the moment:
diff --git a/tools/include/nolibc/netinet/in.h b/tools/include/nolibc/netinet/in.h
new file mode 100644
index 000000000000..a6a1b19f5242
--- /dev/null
+++ b/tools/include/nolibc/netinet/in.h
@@ -0,0 +1 @@
+#include <linux/in.h>
diff --git a/tools/include/nolibc/std.h b/tools/include/nolibc/std.h
index 392f4dd94158..3fe83a4f7a2d 100644
--- a/tools/include/nolibc/std.h
+++ b/tools/include/nolibc/std.h
@@ -25,7 +25,7 @@ typedef unsigned int mode_t;
typedef signed int pid_t;
typedef unsigned int uid_t;
typedef unsigned int gid_t;
-typedef unsigned long nlink_t;
+typedef unsigned int nlink_t;
typedef int64_t off_t;
typedef signed long blksize_t;
typedef signed long blkcnt_t;
diff --git a/tools/include/nolibc/stdlib.h b/tools/include/nolibc/stdlib.h
index f184e108ed0a..497cbe1b5dba 100644
--- a/tools/include/nolibc/stdlib.h
+++ b/tools/include/nolibc/stdlib.h
@@ -19,6 +19,7 @@
struct nolibc_heap {
size_t len;
+ char __pad[__alignof__(struct {} __attribute__((__aligned__))) - __alignof__(size_t)];
char user_p[] __attribute__((__aligned__));
};
diff --git a/tools/include/nolibc/sys/socket.h b/tools/include/nolibc/sys/socket.h
new file mode 100644
index 000000000000..1d97008308ea
--- /dev/null
+++ b/tools/include/nolibc/sys/socket.h
@@ -0,0 +1,26 @@
+#include "../nolibc.h"
+
+#ifndef _NOLIBC_SYS_SOCKET_H
+#define _NOLIBC_SYS_SOCKET_H
+
+#include <linux/socket.h>
+
+typedef __kernel_sa_family_t sa_family_t;
+
+/*
+ * 1003.1g requires sa_family_t and that sa_data is char.
+ */
+
+struct sockaddr {
+ sa_family_t sa_family; /* address family, AF_xxx */
+#ifdef __clang__
+ char sa_data[14]; /* prevent -Wgnu-variable-sized-type-not-at-end warning */
+#else
+ union {
+ char sa_data_min[14]; /* Minimum 14 bytes of protocol address */
+ __DECLARE_FLEX_ARRAY(char, sa_data);
+ };
+#endif
+};
+
+#endif
diff --git a/tools/include/nolibc/types.h b/tools/include/nolibc/types.h
index 470a5f77bc0f..a3193424e818 100644
--- a/tools/include/nolibc/types.h
+++ b/tools/include/nolibc/types.h
@@ -10,6 +10,8 @@
#ifndef _NOLIBC_TYPES_H
#define _NOLIBC_TYPES_H
+#include <linux/types.h>
+
#include "std.h"
#include <linux/mman.h>
#include <linux/stat.h>
@@ -116,7 +118,10 @@ struct linux_dirent64 {
int64_t d_off;
unsigned short d_reclen;
unsigned char d_type;
- char d_name[];
+ union {
+ char __pad[5];
+ __DECLARE_FLEX_ARRAY(char, d_name);
+ };
};
/* The format of the struct as returned by the libc to the application, which
@@ -124,8 +129,8 @@ struct linux_dirent64 {
*/
struct stat {
dev_t st_dev; /* ID of device containing file */
- ino_t st_ino; /* inode number */
mode_t st_mode; /* protection */
+ ino_t st_ino; /* inode number */
nlink_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of owner */
gid_t st_gid; /* group ID of owner */
>> --- a/usr/include/Makefile
>> +++ b/usr/include/Makefile
>> @@ -6,7 +6,10 @@
>> #
>> # -std=c90 (equivalent to -ansi) catches the violation of those.
>> # We cannot go as far as adding -Wpedantic since it emits too many warnings.
>> -UAPI_CFLAGS := -std=c90 -Werror=implicit-function-declaration
>> +UAPI_CFLAGS := -std=c90 -Werror=implicit-function-declaration -Werror=padded
>> +
>> +# when cross-compiling with a minimal toolchain, use nolibc headers
>> +UAPI_CFLAGS += -I$(srctree)/tools/include/nolibc/
>
> Without the rest of the patch, this line on its own is already causing
> various allmodconfig failures for me:
>
> In file included from /usr/m68k-linux-gnu/include/sys/socket.h:26,
> from usr/include/linux/if.h:28,
> from ./usr/include/linux/netfilter_bridge/ebtables.h:17,
> from <command-line>:
> /usr/m68k-linux-gnu/include/bits/types/struct_iovec.h:26:8: error:
> redefinition of ‘struct iovec’
This should also be addressed by either my nolibc change or Thomas'
uapi cleanup.
> Dropping this line made the linux_dirent64 issue go away, and revealed
> a few more missing pieces, so here is a gmail-whitespace-damaged patch:
>
> diff --git a/include/uapi/linux/xfrm.h b/include/uapi/linux/xfrm.h
> index 70eece6aa30e9306..4c10f5402d77757d 100644
> --- a/include/uapi/linux/xfrm.h
> +++ b/include/uapi/linux/xfrm.h
> @@ -27,7 +27,9 @@ struct xfrm_id {
> xfrm_address_t daddr;
> __be32 spi;
> __u8 proto;
> -};
> + __uapi_arch_pad8;
> + __uapi_arch_pad16;
> +} __uapi_arch_align;
>
> struct xfrm_sec_ctx {
> __u8 ctx_doi;
> @@ -255,6 +257,7 @@ struct xfrm_user_tmpl {
> __u8 mode;
> __u8 share;
> __u8 optional;
> + __uapi_arch_pad8;
> __u32 aalgos;
> __u32 ealgos;
> __u32 calgos;
>
Right, I missed this one because I had another patch in my
test tree that did a similar change but wasn't part of the
padding series.:
https://lore.kernel.org/all/20240216202657.2493685-1-arnd%kernel.org@localhost/
Arnd
Home |
Main Index |
Thread Index |
Old Index