1 #ifndef _ASM_S390_FUTEX_H
2 #define _ASM_S390_FUTEX_H
6 #include <linux/futex.h>
8 #include <asm/uaccess.h>
11 #define __futex_atomic_fixup \
12 ".section __ex_table,\"a\"\n" \
14 " .long 0b,4b,2b,4b,3b,4b\n" \
17 #define __futex_atomic_fixup \
18 ".section __ex_table,\"a\"\n" \
20 " .quad 0b,4b,2b,4b,3b,4b\n" \
22 #endif /* __s390x__ */
24 #define __futex_atomic_op(insn, ret, oldval, newval, uaddr, oparg) \
25 asm volatile(" sacf 256\n" \
28 "2: cs %1,%2,0(%6)\n" \
32 __futex_atomic_fixup \
33 : "=d" (ret), "=&d" (oldval), "=&d" (newval), \
35 : "0" (-EFAULT), "d" (oparg), "a" (uaddr), \
36 "m" (*uaddr) : "cc" );
38 static inline int futex_atomic_op_inuser (int encoded_op
, int __user
*uaddr
)
40 int op
= (encoded_op
>> 28) & 7;
41 int cmp
= (encoded_op
>> 24) & 15;
42 int oparg
= (encoded_op
<< 8) >> 20;
43 int cmparg
= (encoded_op
<< 20) >> 20;
44 int oldval
= 0, newval
, ret
;
45 if (encoded_op
& (FUTEX_OP_OPARG_SHIFT
<< 28))
48 if (! access_ok (VERIFY_WRITE
, uaddr
, sizeof(int)))
55 __futex_atomic_op("lr %2,%5\n",
56 ret
, oldval
, newval
, uaddr
, oparg
);
59 __futex_atomic_op("lr %2,%1\nar %2,%5\n",
60 ret
, oldval
, newval
, uaddr
, oparg
);
63 __futex_atomic_op("lr %2,%1\nor %2,%5\n",
64 ret
, oldval
, newval
, uaddr
, oparg
);
67 __futex_atomic_op("lr %2,%1\nnr %2,%5\n",
68 ret
, oldval
, newval
, uaddr
, oparg
);
71 __futex_atomic_op("lr %2,%1\nxr %2,%5\n",
72 ret
, oldval
, newval
, uaddr
, oparg
);
82 case FUTEX_OP_CMP_EQ
: ret
= (oldval
== cmparg
); break;
83 case FUTEX_OP_CMP_NE
: ret
= (oldval
!= cmparg
); break;
84 case FUTEX_OP_CMP_LT
: ret
= (oldval
< cmparg
); break;
85 case FUTEX_OP_CMP_GE
: ret
= (oldval
>= cmparg
); break;
86 case FUTEX_OP_CMP_LE
: ret
= (oldval
<= cmparg
); break;
87 case FUTEX_OP_CMP_GT
: ret
= (oldval
> cmparg
); break;
88 default: ret
= -ENOSYS
;
95 futex_atomic_cmpxchg_inatomic(int __user
*uaddr
, int oldval
, int newval
)
99 if (! access_ok (VERIFY_WRITE
, uaddr
, sizeof(int)))
101 asm volatile(" cs %1,%4,0(%5)\n"
105 ".section __ex_table,\"a\"\n"
109 #else /* __s390x__ */
110 ".section __ex_table,\"a\"\n"
114 #endif /* __s390x__ */
115 : "=d" (ret
), "+d" (oldval
), "=m" (*uaddr
)
116 : "0" (-EFAULT
), "d" (newval
), "a" (uaddr
), "m" (*uaddr
)
121 #endif /* __KERNEL__ */
122 #endif /* _ASM_S390_FUTEX_H */