powerpc: mtspr/mtmsr should take an unsigned long
authorScott Wood <scottwood@freescale.com>
Mon, 25 Jul 2011 11:02:11 +0000 (11:02 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Fri, 5 Aug 2011 04:47:54 +0000 (14:47 +1000)
Add a cast in case the caller passes in a different type, as it would
if mtspr/mtmsr were functions.

Previously, if a 64-bit type was passed in on 32-bit, GCC would bind the
constraint to a pair of registers, and would substitute the first register
in the pair in the asm code.  This corresponds to the upper half of the
64-bit register, which is generally not the desired behavior.

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

index e8aaf6f..9561e60 100644 (file)
 #define mtmsrd(v)      __mtmsrd((v), 0)
 #define mtmsr(v)       mtmsrd(v)
 #else
 #define mtmsrd(v)      __mtmsrd((v), 0)
 #define mtmsr(v)       mtmsrd(v)
 #else
-#define mtmsr(v)       asm volatile("mtmsr %0" : : "r" (v) : "memory")
+#define mtmsr(v)       asm volatile("mtmsr %0" : \
+                                    : "r" ((unsigned long)(v)) \
+                                    : "memory")
 #endif
 
 #define mfspr(rn)      ({unsigned long rval; \
                        asm volatile("mfspr %0," __stringify(rn) \
                                : "=r" (rval)); rval;})
 #endif
 
 #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" ((unsigned long)(v)) \
                                     : "memory")
 
 #ifdef __powerpc64__
                                     : "memory")
 
 #ifdef __powerpc64__