1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_S390_FUTEX_H
3 #define _ASM_S390_FUTEX_H
5 #include <linux/uaccess.h>
6 #include <linux/futex.h>
7 #include <asm/mmu_context.h>
10 #define __futex_atomic_op(insn, ret, oldval, newval, uaddr, oparg) \
15 "2: cs %1,%2,0(%6)\n" \
19 EX_TABLE(0b,4b) EX_TABLE(2b,4b) EX_TABLE(3b,4b) \
20 : "=d" (ret), "=&d" (oldval), "=&d" (newval), \
22 : "0" (-EFAULT), "d" (oparg), "a" (uaddr), \
25 static inline int arch_futex_atomic_op_inuser(int op
, int oparg
, int *oval
,
28 int oldval
= 0, newval
, ret
;
31 old_fs
= enable_sacf_uaccess();
35 __futex_atomic_op("lr %2,%5\n",
36 ret
, oldval
, newval
, uaddr
, oparg
);
39 __futex_atomic_op("lr %2,%1\nar %2,%5\n",
40 ret
, oldval
, newval
, uaddr
, oparg
);
43 __futex_atomic_op("lr %2,%1\nor %2,%5\n",
44 ret
, oldval
, newval
, uaddr
, oparg
);
47 __futex_atomic_op("lr %2,%1\nnr %2,%5\n",
48 ret
, oldval
, newval
, uaddr
, oparg
);
51 __futex_atomic_op("lr %2,%1\nxr %2,%5\n",
52 ret
, oldval
, newval
, uaddr
, oparg
);
58 disable_sacf_uaccess(old_fs
);
66 static inline int futex_atomic_cmpxchg_inatomic(u32
*uval
, u32 __user
*uaddr
,
67 u32 oldval
, u32 newval
)
72 old_fs
= enable_sacf_uaccess();
78 EX_TABLE(0b
,2b
) EX_TABLE(1b
,2b
)
79 : "=d" (ret
), "+d" (oldval
), "=m" (*uaddr
)
80 : "0" (-EFAULT
), "d" (newval
), "a" (uaddr
), "m" (*uaddr
)
82 disable_sacf_uaccess(old_fs
);
87 #endif /* _ASM_S390_FUTEX_H */