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
)
37 if (!access_ok(uaddr
, sizeof(u32
)))
42 __futex_atomic_op("or %1,%4,%4;", ret
, oldval
, uaddr
, oparg
);
45 __futex_atomic_op("add %1,%0,%4;", ret
, oldval
, uaddr
, oparg
);
48 __futex_atomic_op("or %1,%0,%4;", ret
, oldval
, uaddr
, oparg
);
51 __futex_atomic_op("andn %1,%0,%4;", ret
, oldval
, uaddr
, oparg
);
54 __futex_atomic_op("xor %1,%0,%4;", ret
, oldval
, uaddr
, oparg
);
67 futex_atomic_cmpxchg_inatomic(u32
*uval
, u32 __user
*uaddr
,
68 u32 oldval
, u32 newval
)
73 if (!access_ok(uaddr
, sizeof(u32
)))
76 __asm__
__volatile__ ("1: lwx %1, %3, r0; \
83 .section .fixup,\"ax\"; \
87 .section __ex_table,\"a\"; \
90 : "+r" (ret
), "=&r" (prev
), "=&r"(cmp
) \
91 : "r" (uaddr
), "r" (oldval
), "r" (newval
), "i" (-EFAULT
));
97 #endif /* __KERNEL__ */