[lkml]   [2011]   [Feb]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: ARM unaligned MMIO access with attribute((packed))
David Miller <> writes:

> From: Russell King - ARM Linux <>
> Date: Wed, 2 Feb 2011 16:37:02 +0000
>> 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 inline asm
> statement. Just make sure "typeof(pointer)" has a size matching the
> size of the load your are performing.

That should be "m"(*pointer).

>> 2. GCC will needlessly reload pointers from structures and other such
>> behaviour because it can't be told clearly what the inline assembly
>> is doing, so the inline asm needs to have a "memory" clobber.
> This behavior is correct, and in fact needed. Writing to chip registers
> can trigger changes to arbitrary main memory locations.
>> 3. It seems to misses out using the pre-index addressing, prefering to
>> create add/sub instructions prior to each inline assembly load/store.
> Yes, this is indeed a problem.

GCC has trouble doing anything more complicated than simple indexing.
Load/store instructions with writeback seem not to be in its
vocabulary at all.

> 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
is safe without the clobber as Russel says.

Måns Rullgård

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2011-02-03 00:11    [W:0.114 / U:0.936 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site