[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / 3.2.16 / 0014-ia64-fix-futex_atomic_cmpxchg_inatomic.patch
1 From 31a9ac5149ad2b11b591eb704f3132d0d344e7e0 Mon Sep 17 00:00:00 2001
2 From: "Luck, Tony" <tony.luck@intel.com>
3 Date: Mon, 16 Apr 2012 16:28:01 -0700
4 Subject: [PATCH 14/69] ia64: fix futex_atomic_cmpxchg_inatomic()
6 commit c76f39bddb84f93f70a5520d9253ec0317bec216 upstream.
8 Michel Lespinasse cleaned up the futex calling conventions in commit
9 37a9d912b24f ("futex: Sanitize cmpxchg_futex_value_locked API").
11 But the ia64 implementation was subtly broken. Gcc does not know that
12 register "r8" will be updated by the fault handler if the cmpxchg
13 instruction takes an exception. So it feels safe in letting the
14 initialization of r8 slide to after the cmpxchg. Result: we always
15 return 0 whether the user address faulted or not.
17 Fix by moving the initialization of r8 into the __asm__ code so gcc
18 won't move it.
20 Reported-by: <emeric.maschino@gmail.com>
21 Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=42757
22 Tested-by: <emeric.maschino@gmail.com>
23 Acked-by: Michel Lespinasse <walken@google.com>
24 Signed-off-by: Tony Luck <tony.luck@intel.com>
25 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
26 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27 ---
28 arch/ia64/include/asm/futex.h | 9 +++++----
29 1 file changed, 5 insertions(+), 4 deletions(-)
31 diff --git a/arch/ia64/include/asm/futex.h b/arch/ia64/include/asm/futex.h
32 index 8428525..21ab376 100644
33 --- a/arch/ia64/include/asm/futex.h
34 +++ b/arch/ia64/include/asm/futex.h
35 @@ -107,15 +107,16 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
36 return -EFAULT;
38 {
39 - register unsigned long r8 __asm ("r8") = 0;
40 + register unsigned long r8 __asm ("r8");
41 unsigned long prev;
42 __asm__ __volatile__(
43 " mf;; \n"
44 - " mov ar.ccv=%3;; \n"
45 - "[1:] cmpxchg4.acq %0=[%1],%2,ar.ccv \n"
46 + " mov %0=r0 \n"
47 + " mov ar.ccv=%4;; \n"
48 + "[1:] cmpxchg4.acq %1=[%2],%3,ar.ccv \n"
49 " .xdata4 \"__ex_table\", 1b-., 2f-. \n"
50 "[2:]"
51 - : "=r" (prev)
52 + : "=r" (r8), "=r" (prev)
53 : "r" (uaddr), "r" (newval),
54 "rO" ((long) (unsigned) oldval)
55 : "memory");
56 --
57 1.7.9.5