]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
powerpc: Add memory clobber to mtspr()
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Sun, 14 Jun 2009 16:16:10 +0000 (16:16 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Tue, 16 Jun 2009 04:15:46 +0000 (14:15 +1000)
Without this clobber, mtspr can be re-ordered by gcc vs. surrounding
memory accesses. While this might be ok for some cases, it's not in
others and I'm not confident that all callers get it right (In fact
I'm sure some of them don't).

So for now, let's make mtspr() itself contain a memory clobber until
we can audit and fix everything, at which point we can remove it
if we think it's worth doing so.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/include/asm/reg.h

index a3c28e46947c7e30f3690c8cb00ee985090b1082..1170267736d3adaf5c8f2d793b3cef4cba19c65c 100644 (file)
 #define mfspr(rn)      ({unsigned long rval; \
                        asm volatile("mfspr %0," __stringify(rn) \
                                : "=r" (rval)); rval;})
-#define mtspr(rn, v)   asm volatile("mtspr " __stringify(rn) ",%0" : : "r" (v))
+#define mtspr(rn, v)   asm volatile("mtspr " __stringify(rn) ",%0" : : "r" (v)\
+                                    : "memory")
 
 #ifdef __powerpc64__
 #ifdef CONFIG_PPC_CELL