LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jike Song <albcamus@gmail.com>
To: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com
Cc: linux-kernel@vger.kernel.org, Jike Song <albcamus@gmail.com>
Subject: [PATCH] x86: fix inline assembly constraints
Date: Thu, 30 Oct 2008 00:32:17 +0800	[thread overview]
Message-ID: <1225297937-2917-2-git-send-email-albcamus@gmail.com> (raw)
In-Reply-To: <1225297937-2917-1-git-send-email-albcamus@gmail.com>

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

Signed-off-by: Jike Song <albcamus@gmail.com>
---
 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


  reply	other threads:[~2008-10-29 16:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-29 16:32 Jike Song
2008-10-29 16:32 ` Jike Song [this message]
2008-10-29 16:34 ` Ingo Molnar
2008-10-30  2:31   ` Jike Song
2008-10-30  3:54     ` H. Peter Anvin
2008-10-30  6:40       ` Jike Song
2008-10-30 14:51         ` H. Peter Anvin
2008-10-30 19:29     ` Ingo Molnar
2008-10-31  2:12       ` Jike Song
     [not found] <fa.IZJ3RdF6xWbbMqWVWyYRstzZBsk@ifi.uio.no>
     [not found] ` <fa.L4yER0Vo1brqQzpHIySgWqUN5UM@ifi.uio.no>
     [not found]   ` <fa.rs0w7okAn1If1ilwD81OTzT4rKg@ifi.uio.no>
2008-10-30  3:52     ` Robert Hancock

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1225297937-2917-2-git-send-email-albcamus@gmail.com \
    --to=albcamus@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --subject='Re: [PATCH] x86: fix inline assembly constraints' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).