From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
"H. Peter Anvin" <hpa@zytor.com>,
Glauber Costa <glommer@redhat.com>, Avi Kivity <avi@redhat.com>,
Peter Palfrader <peter@palfrader.org>,
Zachary Amsden <zamsden@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>
Subject: [06/54] x86: Add memory modify constraints to xchg() and cmpxchg()
Date: Wed, 11 Aug 2010 17:00:21 -0700 [thread overview]
Message-ID: <20100812000123.856318732@clark.site> (raw)
In-Reply-To: <20100812000249.GA30948@kroah.com>
2.6.34-stable review patch. If anyone has any objections, please let us know.
------------------
From: H. Peter Anvin <hpa@zytor.com>
commit 113fc5a6e8c2288619ff7e8187a6f556b7e0d372 upstream.
xchg() and cmpxchg() modify their memory operands, not merely read
them. For some versions of gcc the "memory" clobber has apparently
dealt with the situation, but not for all.
Originally-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Glauber Costa <glommer@redhat.com>
Cc: Avi Kivity <avi@redhat.com>
Cc: Peter Palfrader <peter@palfrader.org>
Cc: Greg KH <gregkh@suse.de>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Zachary Amsden <zamsden@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
LKML-Reference: <4C4F7277.8050306@zytor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
arch/x86/include/asm/cmpxchg_32.h | 68 +++++++++++++++++++-------------------
arch/x86/include/asm/cmpxchg_64.h | 40 +++++++++++-----------
2 files changed, 54 insertions(+), 54 deletions(-)
--- a/arch/x86/include/asm/cmpxchg_32.h
+++ b/arch/x86/include/asm/cmpxchg_32.h
@@ -27,20 +27,20 @@ struct __xchg_dummy {
switch (size) { \
case 1: \
asm volatile("xchgb %b0,%1" \
- : "=q" (__x) \
- : "m" (*__xg(ptr)), "0" (__x) \
+ : "=q" (__x), "+m" (*__xg(ptr)) \
+ : "0" (__x) \
: "memory"); \
break; \
case 2: \
asm volatile("xchgw %w0,%1" \
- : "=r" (__x) \
- : "m" (*__xg(ptr)), "0" (__x) \
+ : "=r" (__x), "+m" (*__xg(ptr)) \
+ : "0" (__x) \
: "memory"); \
break; \
case 4: \
asm volatile("xchgl %0,%1" \
- : "=r" (__x) \
- : "m" (*__xg(ptr)), "0" (__x) \
+ : "=r" (__x), "+m" (*__xg(ptr)) \
+ : "0" (__x) \
: "memory"); \
break; \
default: \
@@ -70,14 +70,14 @@ static inline void __set_64bit(unsigned
unsigned int low, unsigned int high)
{
asm volatile("\n1:\t"
- "movl (%0), %%eax\n\t"
- "movl 4(%0), %%edx\n\t"
- LOCK_PREFIX "cmpxchg8b (%0)\n\t"
+ "movl (%1), %%eax\n\t"
+ "movl 4(%1), %%edx\n\t"
+ LOCK_PREFIX "cmpxchg8b (%1)\n\t"
"jnz 1b"
- : /* no outputs */
- : "D"(ptr),
- "b"(low),
- "c"(high)
+ : "=m" (*ptr)
+ : "D" (ptr),
+ "b" (low),
+ "c" (high)
: "ax", "dx", "memory");
}
@@ -121,21 +121,21 @@ extern void __cmpxchg_wrong_size(void);
__typeof__(*(ptr)) __new = (new); \
switch (size) { \
case 1: \
- asm volatile(lock "cmpxchgb %b1,%2" \
- : "=a"(__ret) \
- : "q"(__new), "m"(*__xg(ptr)), "0"(__old) \
+ asm volatile(lock "cmpxchgb %b2,%1" \
+ : "=a" (__ret), "+m" (*__xg(ptr)) \
+ : "q" (__new), "0" (__old) \
: "memory"); \
break; \
case 2: \
- asm volatile(lock "cmpxchgw %w1,%2" \
- : "=a"(__ret) \
- : "r"(__new), "m"(*__xg(ptr)), "0"(__old) \
+ asm volatile(lock "cmpxchgw %w2,%1" \
+ : "=a" (__ret), "+m" (*__xg(ptr)) \
+ : "r" (__new), "0" (__old) \
: "memory"); \
break; \
case 4: \
- asm volatile(lock "cmpxchgl %1,%2" \
- : "=a"(__ret) \
- : "r"(__new), "m"(*__xg(ptr)), "0"(__old) \
+ asm volatile(lock "cmpxchgl %2,%1" \
+ : "=a" (__ret), "+m" (*__xg(ptr)) \
+ : "r" (__new), "0" (__old) \
: "memory"); \
break; \
default: \
@@ -180,12 +180,12 @@ static inline unsigned long long __cmpxc
unsigned long long new)
{
unsigned long long prev;
- asm volatile(LOCK_PREFIX "cmpxchg8b %3"
- : "=A"(prev)
- : "b"((unsigned long)new),
- "c"((unsigned long)(new >> 32)),
- "m"(*__xg(ptr)),
- "0"(old)
+ asm volatile(LOCK_PREFIX "cmpxchg8b %1"
+ : "=A" (prev),
+ "+m" (*__xg(ptr))
+ : "b" ((unsigned long)new),
+ "c" ((unsigned long)(new >> 32)),
+ "0" (old)
: "memory");
return prev;
}
@@ -195,12 +195,12 @@ static inline unsigned long long __cmpxc
unsigned long long new)
{
unsigned long long prev;
- asm volatile("cmpxchg8b %3"
- : "=A"(prev)
- : "b"((unsigned long)new),
- "c"((unsigned long)(new >> 32)),
- "m"(*__xg(ptr)),
- "0"(old)
+ asm volatile("cmpxchg8b %1"
+ : "=A" (prev),
+ "+m" (*__xg(ptr))
+ : "b" ((unsigned long)new),
+ "c" ((unsigned long)(new >> 32)),
+ "0" (old)
: "memory");
return prev;
}
--- a/arch/x86/include/asm/cmpxchg_64.h
+++ b/arch/x86/include/asm/cmpxchg_64.h
@@ -26,26 +26,26 @@ extern void __cmpxchg_wrong_size(void);
switch (size) { \
case 1: \
asm volatile("xchgb %b0,%1" \
- : "=q" (__x) \
- : "m" (*__xg(ptr)), "0" (__x) \
+ : "=q" (__x), "+m" (*__xg(ptr)) \
+ : "0" (__x) \
: "memory"); \
break; \
case 2: \
asm volatile("xchgw %w0,%1" \
- : "=r" (__x) \
- : "m" (*__xg(ptr)), "0" (__x) \
+ : "=r" (__x), "+m" (*__xg(ptr)) \
+ : "0" (__x) \
: "memory"); \
break; \
case 4: \
asm volatile("xchgl %k0,%1" \
- : "=r" (__x) \
- : "m" (*__xg(ptr)), "0" (__x) \
+ : "=r" (__x), "+m" (*__xg(ptr)) \
+ : "0" (__x) \
: "memory"); \
break; \
case 8: \
asm volatile("xchgq %0,%1" \
- : "=r" (__x) \
- : "m" (*__xg(ptr)), "0" (__x) \
+ : "=r" (__x), "+m" (*__xg(ptr)) \
+ : "0" (__x) \
: "memory"); \
break; \
default: \
@@ -71,27 +71,27 @@ extern void __cmpxchg_wrong_size(void);
__typeof__(*(ptr)) __new = (new); \
switch (size) { \
case 1: \
- asm volatile(lock "cmpxchgb %b1,%2" \
- : "=a"(__ret) \
- : "q"(__new), "m"(*__xg(ptr)), "0"(__old) \
+ asm volatile(lock "cmpxchgb %b2,%1" \
+ : "=a" (__ret), "+m" (*__xg(ptr)) \
+ : "q" (__new), "0" (__old) \
: "memory"); \
break; \
case 2: \
- asm volatile(lock "cmpxchgw %w1,%2" \
- : "=a"(__ret) \
- : "r"(__new), "m"(*__xg(ptr)), "0"(__old) \
+ asm volatile(lock "cmpxchgw %w2,%1" \
+ : "=a" (__ret), "+m" (*__xg(ptr)) \
+ : "r" (__new), "0" (__old) \
: "memory"); \
break; \
case 4: \
- asm volatile(lock "cmpxchgl %k1,%2" \
- : "=a"(__ret) \
- : "r"(__new), "m"(*__xg(ptr)), "0"(__old) \
+ asm volatile(lock "cmpxchgl %k2,%1" \
+ : "=a" (__ret), "+m" (*__xg(ptr)) \
+ : "r" (__new), "0" (__old) \
: "memory"); \
break; \
case 8: \
- asm volatile(lock "cmpxchgq %1,%2" \
- : "=a"(__ret) \
- : "r"(__new), "m"(*__xg(ptr)), "0"(__old) \
+ asm volatile(lock "cmpxchgq %2,%1" \
+ : "=a" (__ret), "+m" (*__xg(ptr)) \
+ : "r" (__new), "0" (__old) \
: "memory"); \
break; \
default: \
next prev parent reply other threads:[~2010-08-12 0:04 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-12 0:02 [00/54] 2.6.34.4 -stable review Greg KH
2010-08-12 0:00 ` [01/54] x86, vmware: Preset lpj values when on VMware Greg KH
2010-08-14 12:22 ` Sven Joachim
2010-08-14 16:21 ` Alok Kataria
2010-08-12 0:00 ` [02/54] ata_piix: fix locking around SIDPR access Greg KH
2010-08-12 0:00 ` [03/54] powerpc: fix build with make 3.82 Greg KH
2010-08-12 0:00 ` [04/54] x86, kmmio/mmiotrace: Fix double free of kmmio_fault_pages Greg KH
2010-08-12 0:00 ` [05/54] x86/PCI: use host bridge _CRS info on ASRock ALiveSATA2-GLAN Greg KH
2010-08-12 0:00 ` Greg KH [this message]
2010-08-12 0:00 ` [07/54] staging: rt2870: Add USB ID for Belkin F6D4050 v2 Greg KH
2010-08-12 0:00 ` [08/54] Staging: line6: needs to select SND_PCM Greg KH
2010-08-12 0:00 ` [09/54] Staging: panel: Prevent double-calling of parport_release - fix oops Greg KH
2010-08-12 0:00 ` [10/54] PCI: Do not run NVidia quirks related to MSI with MSI disabled Greg KH
2010-08-12 0:00 ` [11/54] PCI: disable MSI on VIA K8M800 Greg KH
2010-08-12 0:00 ` [12/54] solos-pci: Fix race condition in tasklet RX handling Greg KH
2010-08-12 0:00 ` [13/54] splice: fix misuse of SPLICE_F_NONBLOCK Greg KH
2010-08-12 0:00 ` [14/54] Char: nozomi, fix tty->count counting Greg KH
2010-08-12 0:00 ` [15/54] Char: nozomi, set tty->driver_data appropriately Greg KH
2010-08-12 0:00 ` [16/54] mm: fix corruption of hibernation caused by reusing swap during image saving Greg KH
2010-08-12 0:00 ` [17/54] drivers/video/w100fb.c: ignore void return value / fix build failure Greg KH
2010-08-12 0:00 ` [18/54] iwlwifi: fix TX tracer Greg KH
2010-08-12 0:00 ` [19/54] ide-cd: Do not access completed requests in the irq handler Greg KH
2010-08-12 0:00 ` [20/54] md/raid10: fix deadlock with unaligned read during resync Greg KH
2010-08-12 0:00 ` [21/54] blkdev: cgroup whitelist permission fix Greg KH
2010-08-12 0:00 ` [22/54] eCryptfs: Handle ioctl calls with unlocked and compat functions Greg KH
2010-08-12 0:00 ` [23/54] ecryptfs: release reference to lower mount if interpose fails Greg KH
2010-08-12 0:00 ` [24/54] fs/ecryptfs/file.c: introduce missing free Greg KH
2010-08-12 0:00 ` [25/54] [ARM] pxa/cm-x300: fix ffuart registration Greg KH
2010-08-12 0:00 ` [26/54] signalfd: fill in ssi_int for posix timers and message queues Greg KH
2010-08-12 0:00 ` [27/54] bio, fs: update RWA_MASK, READA and SWRITE to match the corresponding BIO_RW_* bits Greg KH
2010-08-12 0:00 ` [28/54] smsc911x: Add spinlocks around registers access Greg KH
2010-08-12 0:00 ` [29/54] ARM: 6299/1: errata: TLBIASIDIS and TLBIMVAIS operations can broadcast a faulty ASID Greg KH
2010-08-12 0:00 ` [30/54] ARM: 6280/1: imx: Fix build failure when including <mach/gpio.h> without <linux/spinlock.h> Greg KH
2010-08-12 0:00 ` [31/54] USB: EHCI: remove PCI assumption Greg KH
2010-08-12 0:00 ` [32/54] USB: resizing usbmon binary interface buffer causes protection faults Greg KH
2010-08-12 0:00 ` [33/54] USB delay init quirk for logitech Harmony 700-series devices Greg KH
2010-08-12 0:00 ` [34/54] USB: serial: enabling support for Segway RMP in ftdi_sio Greg KH
2010-08-12 0:00 ` [35/54] USB: option: Huawei ETS 1220 support added Greg KH
2010-08-12 0:00 ` [36/54] USB: option: add huawei k3765 k4505 devices to work properly Greg KH
2010-08-12 0:00 ` [37/54] USB: ftdi_sio: device id for Navitator Greg KH
2010-08-12 0:00 ` [38/54] USB: cp210x: Add four new device IDs Greg KH
2010-08-12 0:00 ` [39/54] USB: usbtest: avoid to free coherent buffer in atomic context Greg KH
2010-08-12 0:00 ` [40/54] USB: fix thread-unsafe anchor utiliy routines Greg KH
2010-08-12 0:00 ` [41/54] drm/edid: Fix the HDTV hack sync adjustment Greg KH
2010-08-12 0:00 ` [42/54] Bluetooth: Added support for controller shipped with iMac i5 Greg KH
2010-08-12 0:00 ` [43/54] mtd: gen_nand: fix support for multiple chips Greg KH
2010-08-12 0:00 ` [44/54] jfs: dont allow os2 xattr namespace overlap with others Greg KH
2010-08-12 0:01 ` [45/54] arp_notify: allow drivers to explicitly request a notification event Greg KH
2010-08-12 0:01 ` [46/54] xen: netfront: explicitly generate arp_notify event after migration Greg KH
2010-08-12 0:01 ` [47/54] net: Fix NETDEV_NOTIFY_PEERS to not conflict with NETDEV_BONDING_DESLAVE Greg KH
2010-08-12 0:01 ` [48/54] irq: Add new IRQ flag IRQF_NO_SUSPEND Greg KH
2010-08-12 0:01 ` [49/54] xen: Do not suspend IPI IRQs Greg KH
2010-08-12 0:01 ` [50/54] drm/i915: Use RSEN instead of HTPLG for tfp410 monitor detection Greg KH
2010-08-12 0:01 ` [51/54] i915: fix ironlake edp panel setup (v4) Greg KH
2010-08-12 0:01 ` [52/54] [SCSI] ibmvfc: Fix command completion handling Greg KH
2010-08-12 0:01 ` [53/54] [SCSI] ibmvfc: Reduce error recovery timeout Greg KH
2010-08-12 0:01 ` [54/54] md/raid1: delay reads that could overtake behind-writes Greg KH
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=20100812000123.856318732@clark.site \
--to=gregkh@suse.de \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=avi@redhat.com \
--cc=glommer@redhat.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=peter@palfrader.org \
--cc=stable-review@kernel.org \
--cc=stable@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=zamsden@redhat.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).