1 #ifndef _ASM_ARM_FUTEX_H
2 #define _ASM_ARM_FUTEX_H
8 #include <asm-generic/futex.h>
10 #else /* !SMP, we can work around lack of atomic ops by disabling preemption */
12 #include <linux/futex.h>
13 #include <linux/preempt.h>
14 #include <linux/uaccess.h>
15 #include <asm/errno.h>
16 #include <asm/domain.h>
18 #define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
19 __asm__ __volatile__( \
20 "1: " T(ldr) " %1, [%2]\n" \
22 "2: " T(str) " %0, [%2]\n" \
25 " .pushsection __ex_table,\"a\"\n" \
27 " .long 1b, 4f, 2b, 4f\n" \
29 " .pushsection .fixup,\"ax\"\n" \
33 : "=&r" (ret), "=&r" (oldval) \
34 : "r" (uaddr), "r" (oparg), "Ir" (-EFAULT) \
38 futex_atomic_op_inuser (int encoded_op
, u32 __user
*uaddr
)
40 int op
= (encoded_op
>> 28) & 7;
41 int cmp
= (encoded_op
>> 24) & 15;
42 int oparg
= (encoded_op
<< 8) >> 20;
43 int cmparg
= (encoded_op
<< 20) >> 20;
46 if (encoded_op
& (FUTEX_OP_OPARG_SHIFT
<< 28))
49 if (!access_ok(VERIFY_WRITE
, uaddr
, sizeof(u32
)))
52 pagefault_disable(); /* implies preempt_disable() */
56 __futex_atomic_op("mov %0, %3", ret
, oldval
, uaddr
, oparg
);
59 __futex_atomic_op("add %0, %1, %3", ret
, oldval
, uaddr
, oparg
);
62 __futex_atomic_op("orr %0, %1, %3", ret
, oldval
, uaddr
, oparg
);
65 __futex_atomic_op("and %0, %1, %3", ret
, oldval
, uaddr
, ~oparg
);
68 __futex_atomic_op("eor %0, %1, %3", ret
, oldval
, uaddr
, oparg
);
74 pagefault_enable(); /* subsumes preempt_enable() */
78 case FUTEX_OP_CMP_EQ
: ret
= (oldval
== cmparg
); break;
79 case FUTEX_OP_CMP_NE
: ret
= (oldval
!= cmparg
); break;
80 case FUTEX_OP_CMP_LT
: ret
= (oldval
< cmparg
); break;
81 case FUTEX_OP_CMP_GE
: ret
= (oldval
>= cmparg
); break;
82 case FUTEX_OP_CMP_LE
: ret
= (oldval
<= cmparg
); break;
83 case FUTEX_OP_CMP_GT
: ret
= (oldval
> cmparg
); break;
84 default: ret
= -ENOSYS
;
91 futex_atomic_cmpxchg_inatomic(u32
*uval
, u32 __user
*uaddr
,
92 u32 oldval
, u32 newval
)
97 if (!access_ok(VERIFY_WRITE
, uaddr
, sizeof(u32
)))
100 /* Note that preemption is disabled by futex_atomic_cmpxchg_inatomic
103 __asm__
__volatile__("@futex_atomic_cmpxchg_inatomic\n"
104 "1: " T(ldr
) " %1, [%4]\n"
106 " it eq @ explicit IT needed for the 2b label\n"
107 "2: " T(streq
) " %3, [%4]\n"
109 " .pushsection __ex_table,\"a\"\n"
111 " .long 1b, 4f, 2b, 4f\n"
113 " .pushsection .fixup,\"ax\"\n"
117 : "+r" (ret
), "=&r" (val
)
118 : "r" (oldval
), "r" (newval
), "r" (uaddr
), "Ir" (-EFAULT
)
127 #endif /* __KERNEL__ */
128 #endif /* _ASM_ARM_FUTEX_H */