alignment faults in 3.6
Eric Dumazet
eric.dumazet at gmail.com
Thu Oct 11 12:15:45 EDT 2012
On Thu, 2012-10-11 at 10:23 -0500, Rob Herring wrote:
> On 10/11/2012 08:47 AM, Eric Dumazet wrote:
> > Compiler is asked to perform a 32bit load, it does it.
>
> Not exactly. It is asked to to perform 2 32-bit loads which are combined
> into a single ldm (load multiple) which cannot handle unaligned
> accesses. Here's a simple example that does the same thing:
Thats simply not true. You are severely mistaken.
ldm does a load of seeral 32bit words.
And the compiler would not use it if the alignment was not matching the
prereq (alignment >= 4)
>
> void test(char * buf)
> {
> printf("%d, %d\n", *((unsigned int *)&buf[0]), *((unsigned int *)&buf[4]));
> }
But you completely miss the fact that network doesnt pass a "char *buf"
but a "be32 *buf". Your example is not relevant at all.
So the compiler is absolutely right, and network stack is _right_ too.
The prereq is that IP header are aligned to 4 bytes boundary.
Denying this fact is not going to help you
>
> So I guess the only ABI legal unaligned access is in a packed struct.
>
> > There is no questionable optimization here. Really.
> > Please stop pretending this, this makes no sense.
>
> I'm not the one calling the networking stack bad code.
Once you understand the issues, you can explain us where is the bad
code. But given you say "Bug is in compiler, and/or network stack, but
my driver is fine", its not very wise.
For the moment, the bug is in your driver.
>
> I can fix my h/w, so I'll stop caring about this. Others can all get
> bitten by this new behavior in gcc 4.7.
Again compiler is fine. How should we say that so that you stop your
rants ?
Stop trying to find an excuse, dont try to fool us, this is really
embarrassing. Just fix the driver, there is no shame to fix an error.
More information about the linux-arm-kernel
mailing list