1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_FUTEX_H
3 #define _ASM_POWERPC_FUTEX_H
7 #include <linux/futex.h>
8 #include <linux/uaccess.h>
10 #include <asm/synch.h>
11 #include <asm/asm-compat.h>
13 #define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
14 __asm__ __volatile ( \
15 PPC_ATOMIC_ENTRY_BARRIER \
16 "1: lwarx %0,0,%2\n" \
19 "2: stwcx. %1,0,%2\n" \
21 PPC_ATOMIC_EXIT_BARRIER \
23 "3: .section .fixup,\"ax\"\n" \
29 : "=&r" (oldval), "=&r" (ret) \
30 : "b" (uaddr), "i" (-EFAULT), "r" (oparg) \
33 static inline int arch_futex_atomic_op_inuser(int op
, int oparg
, int *oval
,
42 __futex_atomic_op("mr %1,%4\n", ret
, oldval
, uaddr
, oparg
);
45 __futex_atomic_op("add %1,%0,%4\n", ret
, oldval
, uaddr
, oparg
);
48 __futex_atomic_op("or %1,%0,%4\n", ret
, oldval
, uaddr
, oparg
);
51 __futex_atomic_op("andc %1,%0,%4\n", ret
, oldval
, uaddr
, oparg
);
54 __futex_atomic_op("xor %1,%0,%4\n", ret
, oldval
, uaddr
, oparg
);
69 futex_atomic_cmpxchg_inatomic(u32
*uval
, u32 __user
*uaddr
,
70 u32 oldval
, u32 newval
)
75 if (!access_ok(VERIFY_WRITE
, uaddr
, sizeof(u32
)))
78 __asm__
__volatile__ (
79 PPC_ATOMIC_ENTRY_BARRIER
80 "1: lwarx %1,0,%3 # futex_atomic_cmpxchg_inatomic\n\
86 PPC_ATOMIC_EXIT_BARRIER
87 "3: .section .fixup,\"ax\"\n\
93 : "+r" (ret
), "=&r" (prev
), "+m" (*uaddr
)
94 : "r" (uaddr
), "r" (oldval
), "r" (newval
), "i" (-EFAULT
)
101 #endif /* __KERNEL__ */
102 #endif /* _ASM_POWERPC_FUTEX_H */