aboutsummaryrefslogtreecommitdiffstats
path: root/arch/microblaze/include/asm/futex.h
diff options
context:
space:
mode:
authorMichel Lespinasse <walken@google.com>2011-03-10 21:48:51 -0500
committerThomas Gleixner <tglx@linutronix.de>2011-03-11 06:23:08 -0500
commit37a9d912b24f96a0591773e6e6c3642991ae5a70 (patch)
tree5c4d5b9a52e2c533269e589115afbd25b6c8534b /arch/microblaze/include/asm/futex.h
parent522d7decc0370070448a8c28982c8dfd8970489e (diff)
futex: Sanitize cmpxchg_futex_value_locked API
The cmpxchg_futex_value_locked API was funny in that it returned either the original, user-exposed futex value OR an error code such as -EFAULT. This was confusing at best, and could be a source of livelocks in places that retry the cmpxchg_futex_value_locked after trying to fix the issue by running fault_in_user_writeable(). This change makes the cmpxchg_futex_value_locked API more similar to the get_futex_value_locked one, returning an error code and updating the original value through a reference argument. Signed-off-by: Michel Lespinasse <walken@google.com> Acked-by: Chris Metcalf <cmetcalf@tilera.com> [tile] Acked-by: Tony Luck <tony.luck@intel.com> [ia64] Acked-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Michal Simek <monstr@monstr.eu> [microblaze] Acked-by: David Howells <dhowells@redhat.com> [frv] Cc: Darren Hart <darren@dvhart.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Matt Turner <mattst88@gmail.com> Cc: Russell King <linux@arm.linux.org.uk> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: "James E.J. Bottomley" <jejb@parisc-linux.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Paul Mundt <lethal@linux-sh.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: Linus Torvalds <torvalds@linux-foundation.org> LKML-Reference: <20110311024851.GC26122@google.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/microblaze/include/asm/futex.h')
-rw-r--r--arch/microblaze/include/asm/futex.h24
1 files changed, 13 insertions, 11 deletions
diff --git a/arch/microblaze/include/asm/futex.h b/arch/microblaze/include/asm/futex.h
index ad3fd61b2fe..fa019ed65df 100644
--- a/arch/microblaze/include/asm/futex.h
+++ b/arch/microblaze/include/asm/futex.h
@@ -94,31 +94,33 @@ futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
94} 94}
95 95
96static inline int 96static inline int
97futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) 97futex_atomic_cmpxchg_inatomic(int *uval, int __user *uaddr,
98 int oldval, int newval)
98{ 99{
99 int prev, cmp; 100 int ret = 0, prev, cmp;
100 101
101 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) 102 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
102 return -EFAULT; 103 return -EFAULT;
103 104
104 __asm__ __volatile__ ("1: lwx %0, %2, r0; \ 105 __asm__ __volatile__ ("1: lwx %1, %3, r0; \
105 cmp %1, %0, %3; \ 106 cmp %2, %1, %4; \
106 beqi %1, 3f; \ 107 beqi %2, 3f; \
107 2: swx %4, %2, r0; \ 108 2: swx %5, %3, r0; \
108 addic %1, r0, 0; \ 109 addic %2, r0, 0; \
109 bnei %1, 1b; \ 110 bnei %2, 1b; \
110 3: \ 111 3: \
111 .section .fixup,\"ax\"; \ 112 .section .fixup,\"ax\"; \
112 4: brid 3b; \ 113 4: brid 3b; \
113 addik %0, r0, %5; \ 114 addik %0, r0, %6; \
114 .previous; \ 115 .previous; \
115 .section __ex_table,\"a\"; \ 116 .section __ex_table,\"a\"; \
116 .word 1b,4b,2b,4b; \ 117 .word 1b,4b,2b,4b; \
117 .previous;" \ 118 .previous;" \
118 : "=&r" (prev), "=&r"(cmp) \ 119 : "+r" (ret), "=&r" (prev), "=&r"(cmp) \
119 : "r" (uaddr), "r" (oldval), "r" (newval), "i" (-EFAULT)); 120 : "r" (uaddr), "r" (oldval), "r" (newval), "i" (-EFAULT));
120 121
121 return prev; 122 *uval = prev;
123 return ret;
122} 124}
123 125
124#endif /* __KERNEL__ */ 126#endif /* __KERNEL__ */