Skip to contentSkip to conversation

m68k build failure

DISCUSSION Andrew Morton 9 participants 24 messages Nov 28, 2007 – Dec 12, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Current Linus tree give me this, with m68k allmodconfig:

FATAL: drivers/bluetooth/btsdio: sizeof(struct sdio_device_id)=12 is not a modulo of the size of section __mod_sdio_device_table=30. Fix definition of struct sdio_device_id in mod_devicetable.h

which I haven't seen before. Any ideas?

Thanks.

#1 lore raw
Quoted 8 lines · On Tue, 27 Nov 2007 22:07:23 -0800 Andrew Morton <[email protected]>…

Current Linus tree give me this, with m68k allmodconfig:

FATAL: drivers/bluetooth/btsdio: sizeof(struct sdio_device_id)=12 is not a modulo of the size of section __mod_sdio_device_table=30. Fix definition of struct sdio_device_id in mod_devicetable.h

which I haven't seen before. Any ideas?

No the slightest. 12 seems like the correct, padded size. A size of 10 is just weird as the unpadded size is 9 bytes. Could you dump the __mod_sdio_device_table section so we can determine if it is cropped or just oddly padded.

Rgds
Pierre

#2 lore raw
Quoted 6 lines · On Wed, 28 Nov 2007 09:48:56 +0100 Pierre Ossman <[email protected]> wrote:
Quoted 3 lines · On Tue, 27 Nov 2007 22:07:23 -0800 Andrew Morton <[email protected]>…

Current Linus tree give me this, with m68k allmodconfig:

Quoted 8 lines
Quoted 5 lines

FATAL: drivers/bluetooth/btsdio: sizeof(struct sdio_device_id)=12 is not a modulo of the size of section __mod_sdio_device_table=30. Fix definition of struct sdio_device_id in mod_devicetable.h

which I haven't seen before. Any ideas?

No the slightest. 12 seems like the correct, padded size. A size of 10 is just weird as the unpadded size is 9 bytes. Could you dump the __mod_sdio_device_table section so we can determine if it is cropped or just oddly padded.

err, I'd rather not. I have no shortage of bugs to be going on with here.

http://userweb.kernel.org/~akpm/cross-compilers/ has the i386->m68k cross-compiler which I use.

#3 lore raw
Quoted 7 lines · Andrew Morton
Quoted 2 lines

No the slightest. 12 seems like the correct, padded size. A size of 10 is just weird as the unpadded size is 9 bytes. Could you dump the __mod_sdio_device_table section so we can determine if it is cropped or just oddly padded.

err, I'd rather not. I have no shortage of bugs to be going on with here.

http://userweb.kernel.org/~akpm/cross-compilers/ has the i386->m68k cross-compiler which I use.

Eh... m68k has 16bit alignment for unsigned long.

include/linux/mod_devicetable.h +2 -1
@@ -343,7 +343,8 @@ struct sdio_device_id {
 	__u8	class;			/* Standard interface or SDIO_ANY_ID */
 	__u16	vendor;			/* Vendor or SDIO_ANY_ID */
 	__u16	device;			/* Device ID or SDIO_ANY_ID */
-	kernel_ulong_t driver_data;	/* Data private to the driver */
+	kernel_ulong_t driver_data	/* Data private to the driver */
+		__attribute__((aligned(sizeof(kernel_ulong_t))));
 };
 
 /* SSB core, see drivers/ssb/ */
#4 lore raw
Quoted 7 lines · On Wed, 28 Nov 2007 09:28:56 +0000 Al Viro <[email protected]> wrote:

Eh... m68k has 16bit alignment for unsigned long.

include/linux/mod_devicetable.h struct sdio_device_id { · line 350

Quoted 9 lines
include/linux/mod_devicetable.h +2 -1
@@ -343,7 +343,8 @@ struct sdio_device_id {
 	__u8	class;			/* Standard interface or SDIO_ANY_ID */
 	__u16	vendor;			/* Vendor or SDIO_ANY_ID */
 	__u16	device;			/* Device ID or SDIO_ANY_ID */
-	kernel_ulong_t driver_data;	/* Data private to the driver */
+	kernel_ulong_t driver_data	/* Data private to the driver */
+		__attribute__((aligned(sizeof(kernel_ulong_t))));
 };
 
 /* SSB core, see drivers/ssb/ */

Unfortunately, that just papers over the symptom and doesn't solve the underlying issue. If you cross-compile on/for an arch with byte alignment, then the issue is back. Or one that uses 4-byte alignment even for u16.

Is there no directive we can stick in there that forces a reasonable alignment (e.g. alignment == sizeof(type)) independently of arch?

Rgds
Pierre

#5 lore raw
Quoted 17 lines · Pierre Ossman
Quoted 15 lines · On Wed, 28 Nov 2007 09:28:56 +0000 Al Viro <[email protected]> wrote:

Eh... m68k has 16bit alignment for unsigned long.

include/linux/mod_devicetable.h +2 -1
@@ -343,7 +343,8 @@ struct sdio_device_id {
 	__u8	class;			/* Standard interface or SDIO_ANY_ID */
 	__u16	vendor;			/* Vendor or SDIO_ANY_ID */
 	__u16	device;			/* Device ID or SDIO_ANY_ID */
-	kernel_ulong_t driver_data;	/* Data private to the driver */
+	kernel_ulong_t driver_data	/* Data private to the driver */
+		__attribute__((aligned(sizeof(kernel_ulong_t))));
 };
 
Quoted 5 lines

include/linux/mod_devicetable.h struct sdio_device_id { · line 350

Quoted 1 line
include/linux/mod_devicetable.h +0 -0
 /* SSB core, see drivers/ssb/ */

Unfortunately, that just papers over the symptom and doesn't solve the underlying issue. If you cross-compile on/for an arch with byte alignment, then the issue is back. Or one that uses 4-byte alignment even for u16.

Is there no directive we can stick in there that forces a reasonable alignment (e.g. alignment == sizeof(type)) independently of arch?

We could use something like is used for compat_*. E.g. compare compat_s64 in <asm/compat.h> for x86 and powerpc.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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

#6 lore raw
Quoted 7 lines · On Wed, 28 Nov 2007 13:34:02 +0100 (CET) Geert Uytterhoeven…
Quoted 2 lines · Pierre Ossman

Is there no directive we can stick in there that forces a reasonable alignment (e.g. alignment == sizeof(type)) independently of arch?

We could use something like is used for compat_*. E.g. compare compat_s64 in <asm/compat.h> for x86 and powerpc.

Yeah, that could work. Have a header with stuff like this:

typedef u16 __attribute__((aligned(2))) aligned_u16; typedef u32 __attribute__((aligned(4))) aligned_u32;

and let all structures in mod_devicetable.h use those types.

Now does anyone have the time to code and test this?

Rgds
Pierre

#7 lore raw

Correct types for mod_devicetable.h (was: Re: m68k build failure)

Quoted 11 lines · Pierre Ossman
Quoted 7 lines · On Wed, 28 Nov 2007 13:34:02 +0100 (CET) Geert Uytterhoeven…
Quoted 2 lines · Pierre Ossman

Is there no directive we can stick in there that forces a reasonable alignment (e.g. alignment == sizeof(type)) independently of arch?

We could use something like is used for compat_*. E.g. compare compat_s64 in <asm/compat.h> for x86 and powerpc.

Quoted 8 lines

Yeah, that could work. Have a header with stuff like this:

typedef u16 __attribute__((aligned(2))) aligned_u16; typedef u32 __attribute__((aligned(4))) aligned_u32;

and let all structures in mod_devicetable.h use those types.

Now does anyone have the time to code and test this?

I gave it a try:
- Remove existing alignment attributes from some device_id types
- Introduce kernel_* types with proper size and alignment for cross-compilation (sample <asm/kerneltypes.h> for m68k included)
- Introduce BITS_PER_KERNEL_LONG, to make it clearer it applies to the target

Apart from a cross-compile session for m68k, it's untested.

include/linux/mod_devicetable.h +94 -90
index e9fddb4..e1f98b1 100644
@@ -10,15 +10,22 @@
 #ifdef __KERNEL__
 #include <linux/types.h>
 typedef unsigned long kernel_ulong_t;
+typedef u8 kernel_u8;
+typedef u16 kernel_u16;
+typedef u32 kernel_u32;
+#define BITS_PER_KERNEL_LONG	BITS_PER_LONG
 #endif
 
 #define PCI_ANY_ID (~0)
 
 struct pci_device_id {
-	__u32 vendor, device;		/* Vendor and device ID or PCI_ANY_ID*/
-	__u32 subvendor, subdevice;	/* Subsystem ID's or PCI_ANY_ID */
-	__u32 class, class_mask;	/* (class,subclass,prog-if) triplet */
-	kernel_ulong_t driver_data;	/* Data private to the driver */
+	kernel_u32	vendor;		/* Vendor ID or PCI_ANY_ID*/
+	kernel_u32	device;		/* Device ID or PCI_ANY_ID*/
+	kernel_u32	subvendor;	/* Subsystem ID or PCI_ANY_ID */
+	kernel_u32	subdevice;	/* Subsystem ID or PCI_ANY_ID */
+	kernel_u32	class;		/* (class,subclass,prog-if) triplet */
+	kernel_u32	class_mask;	/* (class,subclass,prog-if) triplet */
+	kernel_ulong_t	driver_data;	/* Data private to the driver */
 };
 
 
@@ -28,13 +35,12 @@ struct pci_device_id {
 #define IEEE1394_MATCH_VERSION		0x0008
 
 struct ieee1394_device_id {
-	__u32 match_flags;
-	__u32 vendor_id;
-	__u32 model_id;
-	__u32 specifier_id;
-	__u32 version;
-	kernel_ulong_t driver_data
-		__attribute__((aligned(sizeof(kernel_ulong_t))));
+	kernel_u32	match_flags;
+	kernel_u32	vendor_id;
+	kernel_u32	model_id;
+	kernel_u32	specifier_id;
+	kernel_u32	version;
+	kernel_ulong_t	driver_data;
 };
 
 
@@ -97,23 +103,23 @@ struct ieee1394_device_id {
  */
 struct usb_device_id {
 	/* which fields to match against? */
-	__u16		match_flags;
+	kernel_u16	match_flags;
 
 	/* Used for product specific matches; range is inclusive */
-	__u16		idVendor;
-	__u16		idProduct;
-	__u16		bcdDevice_lo;
-	__u16		bcdDevice_hi;
+	kernel_u16	idVendor;
+	kernel_u16	idProduct;
+	kernel_u16	bcdDevice_lo;
+	kernel_u16	bcdDevice_hi;
 
 	/* Used for device class matches */
-	__u8		bDeviceClass;
-	__u8		bDeviceSubClass;
-	__u8		bDeviceProtocol;
+	kernel_u8	bDeviceClass;
+	kernel_u8	bDeviceSubClass;
+	kernel_u8	bDeviceProtocol;
 
 	/* Used for interface class matches */
-	__u8		bInterfaceClass;
-	__u8		bInterfaceSubClass;
-	__u8		bInterfaceProtocol;
+	kernel_u8	bInterfaceClass;
+	kernel_u8	bInterfaceSubClass;
+	kernel_u8	bInterfaceProtocol;
 
 	/* not matched against */
 	kernel_ulong_t	driver_info;
@@ -133,12 +139,12 @@ struct usb_device_id {
 
 /* s390 CCW devices */
 struct ccw_device_id {
-	__u16	match_flags;	/* which fields to match against */
+	kernel_u16	match_flags;	/* which fields to match against */
 
-	__u16	cu_type;	/* control unit type     */
-	__u16	dev_type;	/* device type           */
-	__u8	cu_model;	/* control unit model    */
-	__u8	dev_model;	/* device model          */
+	kernel_u16	cu_type;	/* control unit type     */
+	kernel_u16	dev_type;	/* device type           */
+	kernel_u8	cu_model;	/* control unit model    */
+	kernel_u8	dev_model;	/* device model          */
 
 	kernel_ulong_t driver_info;
 };
@@ -150,11 +156,11 @@ struct ccw_device_id {
 
 /* s390 AP bus devices */
 struct ap_device_id {
-	__u16 match_flags;	/* which fields to match against */
-	__u8 dev_type;		/* device type */
-	__u8 pad1;
-	__u32 pad2;
-	kernel_ulong_t driver_info;
+	kernel_u16	match_flags;	/* which fields to match against */
+	kernel_u8	dev_type;	/* device type */
+	kernel_u8	pad1;
+	kernel_u32	pad2;
+	kernel_ulong_t	driver_info;
 };
 
 #define AP_DEVICE_ID_MATCH_DEVICE_TYPE		0x01
@@ -163,23 +169,23 @@ struct ap_device_id {
 			   /* to workaround crosscompile issues */
 
 struct acpi_device_id {
-	__u8 id[ACPI_ID_LEN];
-	kernel_ulong_t driver_data;
+	kernel_u8	id[ACPI_ID_LEN];
+	kernel_ulong_t	driver_data;
 };
 
 #define PNP_ID_LEN	8
 #define PNP_MAX_DEVICES	8
 
 struct pnp_device_id {
-	__u8 id[PNP_ID_LEN];
-	kernel_ulong_t driver_data;
+	kernel_u8	id[PNP_ID_LEN];
+	kernel_ulong_t	driver_data;
 };
 
 struct pnp_card_device_id {
-	__u8 id[PNP_ID_LEN];
-	kernel_ulong_t driver_data;
+	kernel_u8	id[PNP_ID_LEN];
+	kernel_ulong_t	driver_data;
 	struct {
-		__u8 id[PNP_ID_LEN];
+		kernel_u8	id[PNP_ID_LEN];
 	} devs[PNP_MAX_DEVICES];
 };
 
@@ -187,10 +193,10 @@ struct pnp_card_device_id {
 #define SERIO_ANY	0xff
 
 struct serio_device_id {
-	__u8 type;
-	__u8 extra;
-	__u8 id;
-	__u8 proto;
+	kernel_u8	type;
+	kernel_u8	extra;
+	kernel_u8	id;
+	kernel_u8	proto;
 };
 
 /*
@@ -198,47 +204,45 @@ struct serio_device_id {
  */
 struct of_device_id
 {
-	char	name[32];
-	char	type[32];
-	char	compatible[128];
+	char		name[32];
+	char		type[32];
+	char		compatible[128];
 #ifdef __KERNEL__
-	void	*data;
+	void *		data;
 #else
-	kernel_ulong_t data;
+	kernel_ulong_t	data;
 #endif
 };
 
 /* VIO */
 struct vio_device_id {
-	char type[32];
-	char compat[32];
+	char		type[32];
+	char		compat[32];
 };
 
 /* PCMCIA */
 
 struct pcmcia_device_id {
-	__u16		match_flags;
+	kernel_u16	match_flags;
 
-	__u16		manf_id;
-	__u16 		card_id;
+	kernel_u16	manf_id;
+	kernel_u16	card_id;
 
-	__u8  		func_id;
+	kernel_u8	func_id;
 
 	/* for real multi-function devices */
-	__u8  		function;
+	kernel_u8	function;
 
 	/* for pseudo multi-function devices */
-	__u8  		device_no;
+	kernel_u8	device_no;
 
-	__u32 		prod_id_hash[4]
-		__attribute__((aligned(sizeof(__u32))));
+	kernel_u32	prod_id_hash[4];
 
 	/* not matched against in kernelspace*/
 #ifdef __KERNEL__
 	const char *	prod_id[4];
 #else
-	kernel_ulong_t	prod_id[4]
-		__attribute__((aligned(sizeof(kernel_ulong_t))));
+	kernel_ulong_t	prod_id[4];
 #endif
 
 	/* not matched against */
@@ -291,24 +295,24 @@ struct pcmcia_device_id {
 
 struct input_device_id {
 
-	kernel_ulong_t flags;
+	kernel_ulong_t	flags;
 
-	__u16 bustype;
-	__u16 vendor;
-	__u16 product;
-	__u16 version;
+	kernel_u16	bustype;
+	kernel_u16	vendor;
+	kernel_u16	product;
+	kernel_u16	version;
 
-	kernel_ulong_t evbit[INPUT_DEVICE_ID_EV_MAX / BITS_PER_LONG + 1];
-	kernel_ulong_t keybit[INPUT_DEVICE_ID_KEY_MAX / BITS_PER_LONG + 1];
-	kernel_ulong_t relbit[INPUT_DEVICE_ID_REL_MAX / BITS_PER_LONG + 1];
-	kernel_ulong_t absbit[INPUT_DEVICE_ID_ABS_MAX / BITS_PER_LONG + 1];
-	kernel_ulong_t mscbit[INPUT_DEVICE_ID_MSC_MAX / BITS_PER_LONG + 1];
-	kernel_ulong_t ledbit[INPUT_DEVICE_ID_LED_MAX / BITS_PER_LONG + 1];
-	kernel_ulong_t sndbit[INPUT_DEVICE_ID_SND_MAX / BITS_PER_LONG + 1];
-	kernel_ulong_t ffbit[INPUT_DEVICE_ID_FF_MAX / BITS_PER_LONG + 1];
-	kernel_ulong_t swbit[INPUT_DEVICE_ID_SW_MAX / BITS_PER_LONG + 1];
+	kernel_ulong_t	evbit[INPUT_DEVICE_ID_EV_MAX / BITS_PER_KERNEL_LONG + 1];
+	kernel_ulong_t	keybit[INPUT_DEVICE_ID_KEY_MAX / BITS_PER_KERNEL_LONG + 1];
+	kernel_ulong_t	relbit[INPUT_DEVICE_ID_REL_MAX / BITS_PER_KERNEL_LONG + 1];
+	kernel_ulong_t	absbit[INPUT_DEVICE_ID_ABS_MAX / BITS_PER_KERNEL_LONG + 1];
+	kernel_ulong_t	mscbit[INPUT_DEVICE_ID_MSC_MAX / BITS_PER_KERNEL_LONG + 1];
+	kernel_ulong_t	ledbit[INPUT_DEVICE_ID_LED_MAX / BITS_PER_KERNEL_LONG + 1];
+	kernel_ulong_t	sndbit[INPUT_DEVICE_ID_SND_MAX / BITS_PER_KERNEL_LONG + 1];
+	kernel_ulong_t	ffbit[INPUT_DEVICE_ID_FF_MAX / BITS_PER_KERNEL_LONG + 1];
+	kernel_ulong_t	swbit[INPUT_DEVICE_ID_SW_MAX / BITS_PER_KERNEL_LONG + 1];
 
-	kernel_ulong_t driver_info;
+	kernel_ulong_t	driver_info;
 };
 
 /* EISA */
@@ -317,17 +321,17 @@ struct input_device_id {
 
 /* The EISA signature, in ASCII form, null terminated */
 struct eisa_device_id {
-	char          sig[EISA_SIG_LEN];
-	kernel_ulong_t driver_data;
+	char		sig[EISA_SIG_LEN];
+	kernel_ulong_t	driver_data;
 };
 
 #define EISA_DEVICE_MODALIAS_FMT "eisa:s%s"
 
 struct parisc_device_id {
-	__u8	hw_type;	/* 5 bits used */
-	__u8	hversion_rev;	/* 4 bits */
-	__u16	hversion;	/* 12 bits */
-	__u32	sversion;	/* 20 bits */
+	kernel_u8	hw_type;	/* 5 bits used */
+	kernel_u8	hversion_rev;	/* 4 bits */
+	kernel_u16	hversion;	/* 12 bits */
+	kernel_u32	sversion;	/* 20 bits */
 };
 
 #define PA_HWTYPE_ANY_ID	0xff
@@ -340,17 +344,17 @@ struct parisc_device_id {
 #define SDIO_ANY_ID (~0)
 
 struct sdio_device_id {
-	__u8	class;			/* Standard interface or SDIO_ANY_ID */
-	__u16	vendor;			/* Vendor or SDIO_ANY_ID */
-	__u16	device;			/* Device ID or SDIO_ANY_ID */
-	kernel_ulong_t driver_data;	/* Data private to the driver */
+	kernel_u8	class;		/* Standard interface or SDIO_ANY_ID */
+	kernel_u16	vendor;		/* Vendor or SDIO_ANY_ID */
+	kernel_u16	device;		/* Device ID or SDIO_ANY_ID */
+	kernel_ulong_t	driver_data;	/* Data private to the driver */
 };
 
 /* SSB core, see drivers/ssb/ */
 struct ssb_device_id {
-	__u16	vendor;
-	__u16	coreid;
-	__u8	revision;
+	kernel_u16	vendor;
+	kernel_u16	coreid;
+	kernel_u8	revision;
 };
 #define SSB_DEVICE(_vendor, _coreid, _revision)  \
 	{ .vendor = _vendor, .coreid = _coreid, .revision = _revision, }
@@ -362,8 +366,8 @@ struct ssb_device_id {
 #define SSB_ANY_REV		0xFF
 
 struct virtio_device_id {
-	__u32 device;
-	__u32 vendor;
+	kernel_u32	device;
+	kernel_u32	vendor;
 };
 #define VIRTIO_DEV_ANY_ID	0xffffffff
 
scripts/mod/file2alias.c +6 -17
index d802b5a..4c95e53 100644
@@ -12,15 +12,6 @@
 
 #include "modpost.h"
 
-/* We use the ELF typedefs for kernel_ulong_t but bite the bullet and
- * use either stdint.h or inttypes.h for the rest. */
-#if KERNEL_ELFCLASS == ELFCLASS32
-typedef Elf32_Addr	kernel_ulong_t;
-#define BITS_PER_LONG 32
-#else
-typedef Elf64_Addr	kernel_ulong_t;
-#define BITS_PER_LONG 64
-#endif
 #ifdef __sun__
 #include <inttypes.h>
 #else
@@ -29,13 +20,10 @@ typedef Elf64_Addr	kernel_ulong_t;
 
 #include <ctype.h>
 
-typedef uint32_t	__u32;
-typedef uint16_t	__u16;
-typedef unsigned char	__u8;
-
 /* Big exception to the "don't include kernel headers into userspace, which
  * even potentially has different endianness and word sizes, since
  * we handle those differences explicitly below */
+#include "../../include/asm/kerneltypes.h"
 #include "../../include/linux/mod_devicetable.h"
 
 #define ADD(str, sep, cond, field)                              \
@@ -422,7 +410,8 @@ static void do_input(char *alias,
 	unsigned int i;
 
 	for (i = min; i < max; i++)
-		if (arr[i / BITS_PER_LONG] & (1L << (i%BITS_PER_LONG)))
+		if (arr[i / BITS_PER_KERNEL_LONG] &
+		    (1L << (i%BITS_PER_KERNEL_LONG)))
 			sprintf(alias + strlen(alias), "%X,*", i);
 }
 
@@ -504,9 +493,9 @@ static int do_sdio_entry(const char *filename,
 	id->device = TO_NATIVE(id->device);
 
 	strcpy(alias, "sdio:");
-	ADD(alias, "c", id->class != (__u8)SDIO_ANY_ID, id->class);
-	ADD(alias, "v", id->vendor != (__u16)SDIO_ANY_ID, id->vendor);
-	ADD(alias, "d", id->device != (__u16)SDIO_ANY_ID, id->device);
+	ADD(alias, "c", id->class != (kernel_u8)SDIO_ANY_ID, id->class);
+	ADD(alias, "v", id->vendor != (kernel_u16)SDIO_ANY_ID, id->vendor);
+	ADD(alias, "d", id->device != (kernel_u16)SDIO_ANY_ID, id->device);
 	return 1;
 }
 
include/asm-m68k/kerneltypes.h new file +17 -0
@@ -0,0 +1,17 @@
+#ifndef _ASM_M68K_KERNELTYPES_H
+#define _ASM_M68K_KERNELTYPES_H
+
+/*
+ * Architecture specific types and alignment, suitable for cross-compiling
+ */
+
+#include <stdint.h>
+
+typedef uint32_t __attribute__((aligned(2))) kernel_ulong_t;
+typedef uint8_t __attribute__((aligned(1))) kernel_u8;
+typedef uint16_t __attribute__((aligned(2))) kernel_u16;
+typedef uint32_t __attribute__((aligned(2))) kernel_u32;
+
+#define BITS_PER_KERNEL_LONG	32
+
+#endif /* _ASM_M68K_KERNELTYPES_H */

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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

#8 lore raw

Re: Correct types for mod_devicetable.h (was: Re: m68k build failure)

Quoted 7 lines · On Sunday 02 December 2007 22:22:31 Geert Uytterhoeven wrote:
Quoted 4 lines · Pierre Ossman

Yeah, that could work. Have a header with stuff like this:

typedef u16 __attribute__((aligned(2))) aligned_u16; typedef u32 __attribute__((aligned(4))) aligned_u32;

I gave it a try:

This seems to turn a molehill into a mountain.

We can change that mod_devicetable.h at any time; it's not supposed to be a userspace API (the kernel build system doesn't count).

So, just insert two bits of padding in sdio_device_id and insert a comment saying "/* Explicit padding: works even if we're cross-compiling */".

Thanks,
Rusty.

#9 lore raw

Re: Correct types for mod_devicetable.h (was: Re: m68k build failure)

Quoted 7 lines · Rusty Russell
Quoted 6 lines · On Sunday 02 December 2007 22:22:31 Geert Uytterhoeven wrote:
Quoted 4 lines · Pierre Ossman

Yeah, that could work. Have a header with stuff like this:

typedef u16 __attribute__((aligned(2))) aligned_u16; typedef u32 __attribute__((aligned(4))) aligned_u32;

Quoted 6 lines
Quoted 1 line

I gave it a try:

This seems to turn a molehill into a mountain.

We can change that mod_devicetable.h at any time; it's not supposed to be a userspace API (the kernel build system doesn't count).

module-init-tools is userspace and not shipped as part of the kernel build system...

Quoted 2 lines

So, just insert two bits of padding in sdio_device_id and insert a comment saying "/* Explicit padding: works even if we're cross-compiling */".

We had one such problem in 2.6.23 and now we had a similar one in 2.6.24.

Getting the alignment issues automatically right would really be an improvement...

Quoted 2 lines

Thanks,
Rusty.

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#10 lore raw

Re: Correct types for mod_devicetable.h (was: Re: m68k build failure)

Quoted 10 lines · Adrian Bunk
Quoted 9 lines · Rusty Russell
Quoted 7 lines · On Sunday 02 December 2007 22:22:31 Geert Uytterhoeven wrote:
Quoted 4 lines · Pierre Ossman

Yeah, that could work. Have a header with stuff like this:

typedef u16 __attribute__((aligned(2))) aligned_u16; typedef u32 __attribute__((aligned(4))) aligned_u32;

I gave it a try:

Quoted 7 lines
Quoted 4 lines

This seems to turn a molehill into a mountain.

We can change that mod_devicetable.h at any time; it's not supposed to be a userspace API (the kernel build system doesn't count).

module-init-tools is userspace and not shipped as part of the kernel build system...

Not really an issue, so long as I get a head's up, but we'll force users to upgrade so let's be sure we want to do this/everyone's happy.

Jon.

#11 lore raw

Re: Correct types for mod_devicetable.h (was: Re: m68k build failure)

In reply to Adrian Bunk
Quoted 9 lines · On Sat, 8 Dec 2007 22:58:11 +0100 Adrian Bunk <[email protected]> wrote:
Quoted 2 lines · Rusty Russell

So, just insert two bits of padding in sdio_device_id and insert a comment saying "/* Explicit padding: works even if we're cross-compiling */".

We had one such problem in 2.6.23 and now we had a similar one in 2.6.24.

Getting the alignment issues automatically right would really be an improvement...

Agreed. I won't veto a quick and dirty fix, but I would prefer if this could be solved properly.

Rgds
Pierre

#12 lore raw

Re: Correct types for mod_devicetable.h (was: Re: m68k build failure)

In reply to Adrian Bunk
Quoted 10 lines · On Sunday 09 December 2007 08:58:11 Adrian Bunk wrote:
Quoted 9 lines · Rusty Russell
Quoted 7 lines · On Sunday 02 December 2007 22:22:31 Geert Uytterhoeven wrote:
Quoted 4 lines · Pierre Ossman

Yeah, that could work. Have a header with stuff like this:

typedef u16 __attribute__((aligned(2))) aligned_u16; typedef u32 __attribute__((aligned(4))) aligned_u32;

I gave it a try:

Quoted 7 lines
Quoted 4 lines

This seems to turn a molehill into a mountain.

We can change that mod_devicetable.h at any time; it's not supposed to be a userspace API (the kernel build system doesn't count).

module-init-tools is userspace and not shipped as part of the kernel build system...

But module-init-tools is *not* supposed to read this; that code is a 2.4 backwards compatibility layer which should be removed (and certainly not enhanced to cover new types in mod_devicetable.h!).

I repeat: this is *only* for the internal modpost code.

Quoted 8 lines
Quoted 3 lines

So, just insert two bits of padding in sdio_device_id and insert a comment saying "/* Explicit padding: works even if we're cross-compiling */".

We had one such problem in 2.6.23 and now we had a similar one in 2.6.24.

Getting the alignment issues automatically right would really be an improvement...

Not if it makes the code (even) more obscure. Put an attribute((packed)) on every structure and add an explanation at the top of the file if it makes you feel safer (new additions to the file are likely to copy existing ones), and that's sufficient.

Hope that clarifies,
Rusty.

#13 lore raw

Re: Correct types for mod_devicetable.h (was: Re: m68k build failure)

In reply to Geert Uytterhoeven
Quoted 9 lines · On Sun, 2 Dec 2007 12:22:31 +0100 (CET) Geert Uytterhoeven…

I gave it a try:
- Remove existing alignment attributes from some device_id types
- Introduce kernel_* types with proper size and alignment for cross-compilation (sample <asm/kerneltypes.h> for m68k included)
- Introduce BITS_PER_KERNEL_LONG, to make it clearer it applies to the target

Apart from a cross-compile session for m68k, it's untested.

This still requires a bit of maintenance to set up a kerneltypes.h for every arch. It also means we have to be very careful that gcc's internal alignment settings matched the ones in our header.

Rgds
Pierre

#14 lore raw

Re: Correct types for mod_devicetable.h (was: Re: m68k build failure)

Quoted 10 lines · Pierre Ossman
Quoted 7 lines · On Sun, 2 Dec 2007 12:22:31 +0100 (CET) Geert Uytterhoeven…

I gave it a try:
- Remove existing alignment attributes from some device_id types
- Introduce kernel_* types with proper size and alignment for cross-compilation (sample <asm/kerneltypes.h> for m68k included)
- Introduce BITS_PER_KERNEL_LONG, to make it clearer it applies to the target

Quoted 4 lines
Quoted 2 lines

Apart from a cross-compile session for m68k, it's untested.

This still requires a bit of maintenance to set up a kerneltypes.h for every arch.

Better doing this work once than fixing similar issues again and again.

Quoted 1 line

It also means we have to be very careful that gcc's internal alignment settings matched the ones in our header.

There's nothing "gcc internal" about struct alignment - remember that any change in struct alignment would change our userspace ABI.

Quoted 2 lines

Rgds
Pierre

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#15 lore raw

Re: Correct types for mod_devicetable.h (was: Re: m68k build failure)

Quoted 6 lines · On Mon, 10 Dec 2007 19:11:12 +0100 Adrian Bunk <[email protected]> wrote:
Quoted 2 lines · Pierre Ossman

This still requires a bit of maintenance to set up a kerneltypes.h for every arch.

Better doing this work once than fixing similar issues again and again.

Agreed. But it raises the bar quite a bit to get this ready for upstream.

Quoted 5 lines
Quoted 1 line

It also means we have to be very careful that gcc's internal alignment settings matched the ones in our header.

There's nothing "gcc internal" about struct alignment - remember that any change in struct alignment would change our userspace ABI.

Oh? I would have guessed that everything going to and from userspace would be packed. Should probably consider myself lucky I have do deal with few such interactions. :)

Rgds
Pierre

#16 lore raw
In reply to Al Viro
Quoted 15 lines · On Wed, 28 Nov 2007 09:28:56 +0000 Al Viro <[email protected]> wrote:
Quoted 7 lines · Andrew Morton
Quoted 2 lines

No the slightest. 12 seems like the correct, padded size. A size of 10 is just weird as the unpadded size is 9 bytes. Could you dump the __mod_sdio_device_table section so we can determine if it is cropped or just oddly padded.

err, I'd rather not. I have no shortage of bugs to be going on with here.

http://userweb.kernel.org/~akpm/cross-compilers/ has the i386->m68k cross-compiler which I use.

Eh... m68k has 16bit alignment for unsigned long.

include/linux/mod_devicetable.h struct sdio_device_id { · line 350

Quoted 9 lines
include/linux/mod_devicetable.h +2 -1
@@ -343,7 +343,8 @@ struct sdio_device_id {
 	__u8	class;			/* Standard interface or SDIO_ANY_ID */
 	__u16	vendor;			/* Vendor or SDIO_ANY_ID */
 	__u16	device;			/* Device ID or SDIO_ANY_ID */
-	kernel_ulong_t driver_data;	/* Data private to the driver */
+	kernel_ulong_t driver_data	/* Data private to the driver */
+		__attribute__((aligned(sizeof(kernel_ulong_t))));
 };
 
 /* SSB core, see drivers/ssb/ */

That works, but it's a bit obscure.

sdio_device_id didn't exist in 2.6.23 so we still have time to turn it into some saner layout.

Who owns this code, anwyay?

#17 lore raw
Quoted 26 lines · Andrew Morton
Quoted 23 lines · On Wed, 28 Nov 2007 09:28:56 +0000 Al Viro <[email protected]> wrote:
Quoted 7 lines · Andrew Morton
Quoted 2 lines

No the slightest. 12 seems like the correct, padded size. A size of 10 is just weird as the unpadded size is 9 bytes. Could you dump the __mod_sdio_device_table section so we can determine if it is cropped or just oddly padded.

err, I'd rather not. I have no shortage of bugs to be going on with here.

http://userweb.kernel.org/~akpm/cross-compilers/ has the i386->m68k cross-compiler which I use.

Eh... m68k has 16bit alignment for unsigned long.

include/linux/mod_devicetable.h +2 -1
@@ -343,7 +343,8 @@ struct sdio_device_id {
 	__u8	class;			/* Standard interface or SDIO_ANY_ID */
 	__u16	vendor;			/* Vendor or SDIO_ANY_ID */
 	__u16	device;			/* Device ID or SDIO_ANY_ID */
-	kernel_ulong_t driver_data;	/* Data private to the driver */
+	kernel_ulong_t driver_data	/* Data private to the driver */
+		__attribute__((aligned(sizeof(kernel_ulong_t))));
 };
 
Quoted 8 lines

include/linux/mod_devicetable.h struct sdio_device_id { · line 350

Quoted 1 line
include/linux/mod_devicetable.h +0 -0
 /* SSB core, see drivers/ssb/ */

That works, but it's a bit obscure.

sdio_device_id didn't exist in 2.6.23 so we still have time to turn it into some saner layout.

Who owns this code, anwyay?

Rusty Russell (Cc'ed)

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#18 lore raw
In reply to Pierre Ossman
Quoted 10 lines · Pierre Ossman
Quoted 6 lines · On Tue, 27 Nov 2007 22:07:23 -0800 Andrew Morton <[email protected]>…

Current Linus tree give me this, with m68k allmodconfig:

FATAL: drivers/bluetooth/btsdio: sizeof(struct sdio_device_id)=12 is not a modulo of the size of section __mod_sdio_device_table=30. Fix definition of struct sdio_device_id in mod_devicetable.h

which I haven't seen before. Any ideas?

No the slightest. 12 seems like the correct, padded size. A size of 10 is just weird as the unpadded size is 9 bytes. Could you dump the __mod_sdio_device_table section so we can determine if it is cropped or just oddly padded.

10 is correct. On m68k, the natural alignment of quantities larger than one byte is 2 bytes, not 4 bytes.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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

#19 lore raw
Quoted 8 lines · Geert Uytterhoeven
Quoted 7 lines · Pierre Ossman
Quoted 5 lines · On Tue, 27 Nov 2007 22:07:23 -0800 Andrew Morton <[email protected]>…

Current Linus tree give me this, with m68k allmodconfig:

FATAL: drivers/bluetooth/btsdio: sizeof(struct sdio_device_id)=12 is not a modulo of the size of section __mod_sdio_device_table=30. Fix definition of struct sdio_device_id in mod_devicetable.h

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

which I haven't seen before. Any ideas?

No the slightest. 12 seems like the correct, padded size. A size of 10 is just weird as the unpadded size is 9 bytes. Could you dump the __mod_sdio_device_table section so we can determine if it is cropped or just oddly padded.

10 is correct. On m68k, the natural alignment of quantities larger than one byte is 2 bytes, not 4 bytes.

So the problem is in scripts/mod/file2alias.c, which gives a different sizeof(struct sdio_device_id) on the cross-compile host:
- sizeof(struct sdio_device_id) = 12 on ia32
- sizeof(struct sdio_device_id) = 10 on m68k

While file2alias.c has code to handle 32 vs. 64 bit correctly when cross-compiling, it doesn't handle alignment differences between host and target.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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

#20 lore raw
Quoted 10 lines · On Wed, 28 Nov 2007 10:27:18 +0100 (CET) Geert Uytterhoeven…

So the problem is in scripts/mod/file2alias.c, which gives a different sizeof(struct sdio_device_id) on the cross-compile host:
- sizeof(struct sdio_device_id) = 12 on ia32
- sizeof(struct sdio_device_id) = 10 on m68k

While file2alias.c has code to handle 32 vs. 64 bit correctly when cross-compiling, it doesn't handle alignment differences between host and target.

Delightful. So what are the options here? Start packing the device table structs is the obvious quick fix. Declaring cross-compilation unsupported isn't really viable, and I guess determining padding differences is far from easy.

Rgds
Pierre

#21 lore raw
Quoted 1 line

Delightful. So what are the options here? Start packing the device table structs is the obvious quick fix. Declaring cross-compilation unsupported isn't really viable, and I guess determining padding differences is far from easy.

There are some ugly options:

Cross compile a test object containing nothing but

	struct whatever fred;

then dump it with the relevant cross nm

#22 lore raw
Quoted 9 lines · Alan Cox
Quoted 1 line

Delightful. So what are the options here? Start packing the device table structs is the obvious quick fix. Declaring cross-compilation unsupported isn't really viable, and I guess determining padding differences is far from easy.

There are some ugly options:

Cross compile a test object containing nothing but

	struct whatever fred;

then dump it with the relevant cross nm

Everything would be much easier if all those driver_data members of the device table structs would not be there.

Andreas.

Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#23 lore raw
In reply to Pierre Ossman
Quoted 6 lines · Pierre Ossman
Quoted 3 lines · On Tue, 27 Nov 2007 22:07:23 -0800 Andrew Morton <[email protected]>…

Current Linus tree give me this, with m68k allmodconfig:

Quoted 7 lines
Quoted 5 lines

FATAL: drivers/bluetooth/btsdio: sizeof(struct sdio_device_id)=12 is not a modulo of the size of section __mod_sdio_device_table=30. Fix definition of struct sdio_device_id in mod_devicetable.h

which I haven't seen before. Any ideas?

No the slightest. 12 seems like the correct, padded size. A size of 10 is just weird as the unpadded size is 9 bytes. Could you dump the __mod_sdio_device_table section so we can determine if it is cropped or just oddly padded.

A size of 10 is correct. On m68k no type is aligned to more than 2 bytes.

Andreas.

Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."