1 #ifndef _ASM_S390_FUTEX_H
2 #define _ASM_S390_FUTEX_H
4 #include <linux/uaccess.h>
5 #include <linux/futex.h>
6 #include <asm/mmu_context.h>
9 #define __futex_atomic_op(insn, ret, oldval, newval, uaddr, oparg) \
14 "2: cs %1,%2,0(%6)\n" \
18 EX_TABLE(0b,4b) EX_TABLE(2b,4b) EX_TABLE(3b,4b) \
19 : "=d" (ret), "=&d" (oldval), "=&d" (newval), \
21 : "0" (-EFAULT), "d" (oparg), "a" (uaddr), \
24 static inline int futex_atomic_op_inuser(int encoded_op
, u32 __user
*uaddr
)
26 int op
= (encoded_op
>> 28) & 7;
27 int cmp
= (encoded_op
>> 24) & 15;
28 int oparg
= (encoded_op
<< 8) >> 20;
29 int cmparg
= (encoded_op
<< 20) >> 20;
30 int oldval
= 0, newval
, ret
;
33 if (encoded_op
& (FUTEX_OP_OPARG_SHIFT
<< 28))
39 __futex_atomic_op("lr %2,%5\n",
40 ret
, oldval
, newval
, uaddr
, oparg
);
43 __futex_atomic_op("lr %2,%1\nar %2,%5\n",
44 ret
, oldval
, newval
, uaddr
, oparg
);
47 __futex_atomic_op("lr %2,%1\nor %2,%5\n",
48 ret
, oldval
, newval
, uaddr
, oparg
);
51 __futex_atomic_op("lr %2,%1\nnr %2,%5\n",
52 ret
, oldval
, newval
, uaddr
, oparg
);
55 __futex_atomic_op("lr %2,%1\nxr %2,%5\n",
56 ret
, oldval
, newval
, uaddr
, oparg
);
65 case FUTEX_OP_CMP_EQ
: ret
= (oldval
== cmparg
); break;
66 case FUTEX_OP_CMP_NE
: ret
= (oldval
!= cmparg
); break;
67 case FUTEX_OP_CMP_LT
: ret
= (oldval
< cmparg
); break;
68 case FUTEX_OP_CMP_GE
: ret
= (oldval
>= cmparg
); break;
69 case FUTEX_OP_CMP_LE
: ret
= (oldval
<= cmparg
); break;
70 case FUTEX_OP_CMP_GT
: ret
= (oldval
> cmparg
); break;
71 default: ret
= -ENOSYS
;
77 static inline int futex_atomic_cmpxchg_inatomic(u32
*uval
, u32 __user
*uaddr
,
78 u32 oldval
, u32 newval
)
88 EX_TABLE(0b
,2b
) EX_TABLE(1b
,2b
)
89 : "=d" (ret
), "+d" (oldval
), "=m" (*uaddr
)
90 : "0" (-EFAULT
), "d" (newval
), "a" (uaddr
), "m" (*uaddr
)
96 #endif /* _ASM_S390_FUTEX_H */