Re: ARM unaligned MMIO access with attribute((packed))

2011-04-28 Thread Arnd Bergmann
On Thursday 28 April 2011, Alan Stern wrote: > > The compiler does not complain, it just silently assumes that it needs > > to do byte accesses. There is no way to tell the compiler to ignore > > what it knows about the alignment, other than using inline assembly > > for the actual pointer derefere

Re: ARM unaligned MMIO access with attribute((packed))

2011-04-28 Thread Alan Stern
On Wed, 27 Apr 2011, Arnd Bergmann wrote: > On Wednesday 27 April 2011 18:25:40 Alan Stern wrote: > > On Wed, 27 Apr 2011, Rabin Vincent wrote: > > > > > On Wed, Apr 27, 2011 at 00:21, Alan Stern > > > wrote: > > > > On Tue, 26 Apr 2011, Rabin Vincent wrote: > > > >> In my case it's this writel

Re: ARM unaligned MMIO access with attribute((packed))

2011-04-27 Thread Arnd Bergmann
On Wednesday 27 April 2011 18:25:40 Alan Stern wrote: > On Wed, 27 Apr 2011, Rabin Vincent wrote: > > > On Wed, Apr 27, 2011 at 00:21, Alan Stern wrote: > > > On Tue, 26 Apr 2011, Rabin Vincent wrote: > > >> In my case it's this writel() in ehci-hub.c that gets chopped into > > >> strbs: > > >> >

Re: ARM unaligned MMIO access with attribute((packed))

2011-04-27 Thread Alan Stern
On Wed, 27 Apr 2011, Rabin Vincent wrote: > On Wed, Apr 27, 2011 at 00:21, Alan Stern wrote: > > On Tue, 26 Apr 2011, Rabin Vincent wrote: > >> In my case it's this writel() in ehci-hub.c that gets chopped into > >> strbs: > >> > >> � � � /* force reset to complete */ > >> � � � ehci_writel(ehci,

Re: ARM unaligned MMIO access with attribute((packed))

2011-04-27 Thread Rabin Vincent
On Wed, Apr 27, 2011 at 00:21, Alan Stern wrote: > On Tue, 26 Apr 2011, Rabin Vincent wrote: >> In my case it's this writel() in ehci-hub.c that gets chopped into >> strbs: >> >>       /* force reset to complete */ >>       ehci_writel(ehci, temp & ~(PORT_RWC_BITS | PORT_RESET), >>                

Re: ARM unaligned MMIO access with attribute((packed))

2011-04-26 Thread Alan Stern
On Tue, 26 Apr 2011, Rabin Vincent wrote: > On Wed, Feb 2, 2011 at 21:30, Arnd Bergmann wrote: > > As noticed by Peter Maydell, the EHCI device driver in Linux gets > > miscompiled by some versions of arm-gcc (still need to find out which) > > due to a combination of problems: > > > > 1. In inclu

Re: ARM unaligned MMIO access with attribute((packed))

2011-04-26 Thread Rabin Vincent
On Wed, Feb 2, 2011 at 21:30, Arnd Bergmann wrote: > As noticed by Peter Maydell, the EHCI device driver in Linux gets > miscompiled by some versions of arm-gcc (still need to find out which) > due to a combination of problems: > > 1. In include/linux/usb/ehci_def.h, struct ehci_caps is defined >

Re: ARM unaligned MMIO access with attribute((packed))

2011-02-03 Thread Arnd Bergmann
On Wednesday 02 February 2011, Russell King - ARM Linux wrote: > On Wed, Feb 02, 2011 at 05:00:20PM +0100, Arnd Bergmann wrote: > > I would suggest fixing this by: > > > > 2. Changing the ARM MMIO functions to use inline assembly instead of > > direct pointer dereference. > > We used to use inline

Re: ARM unaligned MMIO access with attribute((packed))

2011-02-03 Thread Arnd Bergmann
On Thursday 03 February 2011 00:08:01 Måns Rullgård wrote: > > But you really need that memory clobber there whether you like it or > > not, see above. > > I don't know of any device where the side-effects are not explicitly > indicated by other means in the code triggering them, so it probably >

Re: ARM unaligned MMIO access with attribute((packed))

2011-02-02 Thread Måns Rullgård
David Miller writes: > From: Russell King - ARM Linux > Date: Wed, 2 Feb 2011 16:37:02 + > >> 1. there's no way to tell GCC that the inline assembly is a load >>instruction and therefore it needs to schedule the following >>instructions appropriately. > > Just add a dummy '"m" (point

Re: ARM unaligned MMIO access with attribute((packed))

2011-02-02 Thread David Miller
From: Måns Rullgård Date: Wed, 02 Feb 2011 23:08:01 + > David Miller writes: > >> From: Russell King - ARM Linux >> Date: Wed, 2 Feb 2011 16:37:02 + >> >>> 1. there's no way to tell GCC that the inline assembly is a load >>>instruction and therefore it needs to schedule the followi

Re: ARM unaligned MMIO access with attribute((packed))

2011-02-02 Thread David Miller
From: Russell King - ARM Linux Date: Wed, 2 Feb 2011 21:45:22 + > On Wed, Feb 02, 2011 at 01:38:31PM -0800, David Miller wrote: >> From: Russell King - ARM Linux >> Date: Wed, 2 Feb 2011 16:37:02 + >> >> > 1. there's no way to tell GCC that the inline assembly is a load >> >instruct

Re: ARM unaligned MMIO access with attribute((packed))

2011-02-02 Thread Russell King - ARM Linux
On Wed, Feb 02, 2011 at 01:38:31PM -0800, David Miller wrote: > From: Russell King - ARM Linux > Date: Wed, 2 Feb 2011 16:37:02 + > > > 1. there's no way to tell GCC that the inline assembly is a load > >instruction and therefore it needs to schedule the following > >instructions appr

Re: ARM unaligned MMIO access with attribute((packed))

2011-02-02 Thread David Miller
From: Russell King - ARM Linux Date: Wed, 2 Feb 2011 16:37:02 + > 1. there's no way to tell GCC that the inline assembly is a load >instruction and therefore it needs to schedule the following >instructions appropriately. Just add a dummy '"m" (pointer)' asm input argument to the inl

Re: ARM unaligned MMIO access with attribute((packed))

2011-02-02 Thread Ian Lance Taylor
Arnd Bergmann writes: > On Wednesday 02 February 2011 17:37:02 Russell King - ARM Linux wrote: >> We used to use inline assembly at one point, but that got chucked out. >> The problem is that using asm() for this causes GCC to generate horrid >> code. >> >> 1. there's no way to tell GCC that the

Re: ARM unaligned MMIO access with attribute((packed))

2011-02-02 Thread Arnd Bergmann
On Wednesday 02 February 2011 17:37:02 Russell King - ARM Linux wrote: > We used to use inline assembly at one point, but that got chucked out. > The problem is that using asm() for this causes GCC to generate horrid > code. > > 1. there's no way to tell GCC that the inline assembly is a load >

Re: ARM unaligned MMIO access with attribute((packed))

2011-02-02 Thread Joseph S. Myers
On Wed, 2 Feb 2011, Richard Guenther wrote: > The pointer conversions already invoke undefined behavior as specified by the > C standard (6.3.2.3/7). I would say: the conversions are undefined if the pointer is insufficiently aligned for any of the pointer types involved (source, destination or

Re: ARM unaligned MMIO access with attribute((packed))

2011-02-02 Thread Russell King - ARM Linux
On Wed, Feb 02, 2011 at 05:51:27PM +0100, Richard Guenther wrote: > > I would suggest fixing this by: > > > > 1. auditing all uses of __attribute__((packed)) in the Linux USB code > > and other drivers, removing the ones that are potentially harmful. > > > > 2. Changing the ARM MMIO functions to us

Re: ARM unaligned MMIO access with attribute((packed))

2011-02-02 Thread Richard Guenther
On Wed, Feb 2, 2011 at 5:00 PM, Arnd Bergmann wrote: > As noticed by Peter Maydell, the EHCI device driver in Linux gets > miscompiled by some versions of arm-gcc (still need to find out which) > due to a combination of problems: > > 1. In include/linux/usb/ehci_def.h, struct ehci_caps is defined

Re: ARM unaligned MMIO access with attribute((packed))

2011-02-02 Thread Russell King - ARM Linux
On Wed, Feb 02, 2011 at 05:00:20PM +0100, Arnd Bergmann wrote: > I would suggest fixing this by: > > 1. auditing all uses of __attribute__((packed)) in the Linux USB code > and other drivers, removing the ones that are potentially harmful. > > 2. Changing the ARM MMIO functions to use inline asse

ARM unaligned MMIO access with attribute((packed))

2011-02-02 Thread Arnd Bergmann
As noticed by Peter Maydell, the EHCI device driver in Linux gets miscompiled by some versions of arm-gcc (still need to find out which) due to a combination of problems: 1. In include/linux/usb/ehci_def.h, struct ehci_caps is defined with __attribute__((packed)), for no good reason. This is clear