[PATCH] x86: fix inline assembly constraints

From: Jike Song
Date: Wed Oct 29 2008 - 12:32:54 EST


In atomic_set_mask, *addr should be both read and written.

Signed-off-by: Jike Song <albcamus@xxxxxxxxx>
---
arch/x86/include/asm/atomic_32.h | 8 ++++----
arch/x86/include/asm/atomic_64.h | 7 ++++---
2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/arch/x86/include/asm/atomic_32.h b/arch/x86/include/asm/atomic_32.h
index ad5b9f6..23a7c7f 100644
--- a/arch/x86/include/asm/atomic_32.h
+++ b/arch/x86/include/asm/atomic_32.h
@@ -242,12 +242,12 @@ static inline int atomic_add_unless(atomic_t *v, int a, int u)

/* These are x86-specific, used by some header files */
#define atomic_clear_mask(mask, addr) \
- asm volatile(LOCK_PREFIX "andl %0,%1" \
- : : "r" (~(mask)), "m" (*(addr)) : "memory")
+ asm volatile(LOCK_PREFIX "andl %1, %0" \
+ : "+m" (*(addr)) : "r" (~(mask)) : "memory")

#define atomic_set_mask(mask, addr) \
- asm volatile(LOCK_PREFIX "orl %0,%1" \
- : : "r" (mask), "m" (*(addr)) : "memory")
+ asm volatile(LOCK_PREFIX "orl %1, %0" \
+ : "+m" (*(addr)) : "r" (mask) : "memory")

/* Atomic operations are already serializing on x86 */
#define smp_mb__before_atomic_dec() barrier()
diff --git a/arch/x86/include/asm/atomic_64.h b/arch/x86/include/asm/atomic_64.h
index fa59212..31b34f3 100644
--- a/arch/x86/include/asm/atomic_64.h
+++ b/arch/x86/include/asm/atomic_64.h
@@ -451,12 +451,13 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)

/* These are x86-specific, used by some header files */
#define atomic_clear_mask(mask, addr) \
- asm volatile(LOCK_PREFIX "andl %0,%1" \
- : : "r" (~(mask)), "m" (*(addr)) : "memory")
+ asm volatile(LOCK_PREFIX "andl %1, %0" \
+ : "+m" (*(addr)) : "r" (~(mask)) : "memory")

#define atomic_set_mask(mask, addr) \
- asm volatile(LOCK_PREFIX "orl %0,%1" \
+ asm volatile(LOCK_PREFIX "orl %1, %0" \
: : "r" ((unsigned)(mask)), "m" (*(addr)) \
+ : "+m" (*(addr)) : "r" ((unsigned)(mask)) \
: "memory")

/* Atomic operations are already serializing on x86 */
--
1.6.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/