1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _SPARC64_FUTEX_H
3 #define _SPARC64_FUTEX_H
5 #include <linux/futex.h>
6 #include <linux/uaccess.h>
9 #define __futex_cas_op(insn, ret, oldval, uaddr, oparg) \
10 __asm__ __volatile__( \
11 "\n1: lduwa [%3] %%asi, %2\n" \
13 "2: casa [%3] %%asi, %2, %1\n" \
15 " bne,pn %%icc, 1b\n" \
18 " .section .fixup,#alloc,#execinstr\n" \
20 "4: sethi %%hi(3b), %0\n" \
21 " jmpl %0 + %%lo(3b), %%g0\n" \
24 " .section __ex_table,\"a\"\n" \
29 : "=&r" (ret), "=&r" (oldval), "=&r" (tem) \
30 : "r" (uaddr), "r" (oparg), "i" (-EFAULT) \
33 static inline int arch_futex_atomic_op_inuser(int op
, int oparg
, int *oval
,
36 int oldval
= 0, ret
, tem
;
38 if (unlikely((((unsigned long) uaddr
) & 0x3UL
)))
45 __futex_cas_op("mov\t%4, %1", ret
, oldval
, uaddr
, oparg
);
48 __futex_cas_op("add\t%2, %4, %1", ret
, oldval
, uaddr
, oparg
);
51 __futex_cas_op("or\t%2, %4, %1", ret
, oldval
, uaddr
, oparg
);
54 __futex_cas_op("andn\t%2, %4, %1", ret
, oldval
, uaddr
, oparg
);
57 __futex_cas_op("xor\t%2, %4, %1", ret
, oldval
, uaddr
, oparg
);
72 futex_atomic_cmpxchg_inatomic(u32
*uval
, u32 __user
*uaddr
,
73 u32 oldval
, u32 newval
)
78 "\n1: casa [%4] %%asi, %3, %1\n"
80 " .section .fixup,#alloc,#execinstr\n"
82 "3: sethi %%hi(2b), %0\n"
83 " jmpl %0 + %%lo(2b), %%g0\n"
86 " .section __ex_table,\"a\"\n"
90 : "+r" (ret
), "=r" (newval
)
91 : "1" (newval
), "r" (oldval
), "r" (uaddr
), "i" (-EFAULT
)
98 #endif /* !(_SPARC64_FUTEX_H) */