1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_MICROBLAZE_FUTEX_H
3 #define _ASM_MICROBLAZE_FUTEX_H
7 #include <linux/futex.h>
8 #include <linux/uaccess.h>
11 #define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
13 __asm__ __volatile__ ( \
14 "1: lwx %0, %2, r0; " \
20 .section .fixup,\"ax\"; \
24 .section __ex_table,\"a\"; \
27 : "=&r" (oldval), "=&r" (ret) \
28 : "r" (uaddr), "i" (-EFAULT), "r" (oparg) \
33 arch_futex_atomic_op_inuser(int op
, int oparg
, int *oval
, u32 __user
*uaddr
)
41 __futex_atomic_op("or %1,%4,%4;", ret
, oldval
, uaddr
, oparg
);
44 __futex_atomic_op("add %1,%0,%4;", ret
, oldval
, uaddr
, oparg
);
47 __futex_atomic_op("or %1,%0,%4;", ret
, oldval
, uaddr
, oparg
);
50 __futex_atomic_op("andn %1,%0,%4;", ret
, oldval
, uaddr
, oparg
);
53 __futex_atomic_op("xor %1,%0,%4;", ret
, oldval
, uaddr
, oparg
);
68 futex_atomic_cmpxchg_inatomic(u32
*uval
, u32 __user
*uaddr
,
69 u32 oldval
, u32 newval
)
74 if (!access_ok(VERIFY_WRITE
, uaddr
, sizeof(u32
)))
77 __asm__
__volatile__ ("1: lwx %1, %3, r0; \
84 .section .fixup,\"ax\"; \
88 .section __ex_table,\"a\"; \
91 : "+r" (ret
), "=&r" (prev
), "=&r"(cmp
) \
92 : "r" (uaddr
), "r" (oldval
), "r" (newval
), "i" (-EFAULT
));
98 #endif /* __KERNEL__ */