]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - arch/ia64/include/asm/futex.h
4 #include <linux/futex.h>
5 #include <linux/uaccess.h>
8 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
10 register unsigned long r8 __asm ("r8") = 0; \
11 __asm__ __volatile__( \
13 "[1:] " insn ";; \n" \
14 " .xdata4 \"__ex_table\", 1b-., 2f-. \n" \
16 : "+r" (r8), "=r" (oldval) \
17 : "r" (uaddr), "r" (oparg) \
22 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
24 register unsigned long r8 __asm ("r8") = 0; \
27 __asm__ __volatile__( \
29 "[1:] ld4 %3=[%4];; \n" \
32 " mov ar.ccv=%2;; \n" \
33 "[2:] cmpxchg4.acq %1=[%4],%3,ar.ccv;; \n" \
34 " .xdata4 \"__ex_table\", 1b-., 3f-.\n" \
35 " .xdata4 \"__ex_table\", 2b-., 3f-.\n" \
37 : "+r" (r8), "=r" (val), "=&r" (oldval), \
39 : "r" (uaddr), "r" (oparg) \
43 } while (unlikely (val != oldval)); \
48 futex_atomic_op_inuser (int encoded_op
, u32 __user
*uaddr
)
50 int op
= (encoded_op
>> 28) & 7;
51 int cmp
= (encoded_op
>> 24) & 15;
52 int oparg
= (encoded_op
<< 8) >> 20;
53 int cmparg
= (encoded_op
<< 20) >> 20;
55 if (encoded_op
& (FUTEX_OP_OPARG_SHIFT
<< 28))
58 if (! access_ok (VERIFY_WRITE
, uaddr
, sizeof(u32
)))
65 __futex_atomic_op1("xchg4 %1=[%2],%3", ret
, oldval
, uaddr
,
69 __futex_atomic_op2("add %3=%3,%5", ret
, oldval
, uaddr
, oparg
);
72 __futex_atomic_op2("or %3=%3,%5", ret
, oldval
, uaddr
, oparg
);
75 __futex_atomic_op2("and %3=%3,%5", ret
, oldval
, uaddr
,
79 __futex_atomic_op2("xor %3=%3,%5", ret
, oldval
, uaddr
, oparg
);
89 case FUTEX_OP_CMP_EQ
: ret
= (oldval
== cmparg
); break;
90 case FUTEX_OP_CMP_NE
: ret
= (oldval
!= cmparg
); break;
91 case FUTEX_OP_CMP_LT
: ret
= (oldval
< cmparg
); break;
92 case FUTEX_OP_CMP_GE
: ret
= (oldval
>= cmparg
); break;
93 case FUTEX_OP_CMP_LE
: ret
= (oldval
<= cmparg
); break;
94 case FUTEX_OP_CMP_GT
: ret
= (oldval
> cmparg
); break;
95 default: ret
= -ENOSYS
;
102 futex_atomic_cmpxchg_inatomic(u32
*uval
, u32 __user
*uaddr
,
103 u32 oldval
, u32 newval
)
105 if (!access_ok(VERIFY_WRITE
, uaddr
, sizeof(u32
)))
109 register unsigned long r8
__asm ("r8") = 0;
111 __asm__
__volatile__(
113 " mov ar.ccv=%4;; \n"
114 "[1:] cmpxchg4.acq %1=[%2],%3,ar.ccv \n"
115 " .xdata4 \"__ex_table\", 1b-., 2f-. \n"
117 : "+r" (r8
), "=&r" (prev
)
118 : "r" (uaddr
), "r" (newval
),
119 "rO" ((long) (unsigned) oldval
)
126 #endif /* _ASM_FUTEX_H */