summaryrefslogtreecommitdiffstats
path: root/include/asm-s390/futex.h
diff options
context:
space:
mode:
authorGerald Schaefer <geraldsc@de.ibm.com>2006-09-20 15:59:42 +0200
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2006-09-20 15:59:42 +0200
commitd02765d1af743567398eb6d523dea0ba5e5e7e8e (patch)
tree9a39c21d9924a8d81ce85254cd3d013dbe50d23e /include/asm-s390/futex.h
parent6837a8c352efcc5efc70424e9bfd94ff9bfa9a47 (diff)
downloadop-kernel-dev-d02765d1af743567398eb6d523dea0ba5e5e7e8e.zip
op-kernel-dev-d02765d1af743567398eb6d523dea0ba5e5e7e8e.tar.gz
[S390] Make user-copy operations run-time configurable.
Introduces a struct uaccess_ops which allows setting user-copy operations at run-time. Signed-off-by: Gerald Schaefer <geraldsc@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'include/asm-s390/futex.h')
-rw-r--r--include/asm-s390/futex.h87
1 files changed, 7 insertions, 80 deletions
diff --git a/include/asm-s390/futex.h b/include/asm-s390/futex.h
index ffedf14..5e261e1 100644
--- a/include/asm-s390/futex.h
+++ b/include/asm-s390/futex.h
@@ -7,75 +7,21 @@
#include <asm/errno.h>
#include <asm/uaccess.h>
-#ifndef __s390x__
-#define __futex_atomic_fixup \
- ".section __ex_table,\"a\"\n" \
- " .align 4\n" \
- " .long 0b,4b,2b,4b,3b,4b\n" \
- ".previous"
-#else /* __s390x__ */
-#define __futex_atomic_fixup \
- ".section __ex_table,\"a\"\n" \
- " .align 8\n" \
- " .quad 0b,4b,2b,4b,3b,4b\n" \
- ".previous"
-#endif /* __s390x__ */
-
-#define __futex_atomic_op(insn, ret, oldval, newval, uaddr, oparg) \
- asm volatile(" sacf 256\n" \
- "0: l %1,0(%6)\n" \
- "1: " insn \
- "2: cs %1,%2,0(%6)\n" \
- "3: jl 1b\n" \
- " lhi %0,0\n" \
- "4: sacf 0\n" \
- __futex_atomic_fixup \
- : "=d" (ret), "=&d" (oldval), "=&d" (newval), \
- "=m" (*uaddr) \
- : "0" (-EFAULT), "d" (oparg), "a" (uaddr), \
- "m" (*uaddr) : "cc" );
-
static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
{
int op = (encoded_op >> 28) & 7;
int cmp = (encoded_op >> 24) & 15;
int oparg = (encoded_op << 8) >> 20;
int cmparg = (encoded_op << 20) >> 20;
- int oldval = 0, newval, ret;
+ int oldval, ret;
+
if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
oparg = 1 << oparg;
if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
return -EFAULT;
- inc_preempt_count();
-
- switch (op) {
- case FUTEX_OP_SET:
- __futex_atomic_op("lr %2,%5\n",
- ret, oldval, newval, uaddr, oparg);
- break;
- case FUTEX_OP_ADD:
- __futex_atomic_op("lr %2,%1\nar %2,%5\n",
- ret, oldval, newval, uaddr, oparg);
- break;
- case FUTEX_OP_OR:
- __futex_atomic_op("lr %2,%1\nor %2,%5\n",
- ret, oldval, newval, uaddr, oparg);
- break;
- case FUTEX_OP_ANDN:
- __futex_atomic_op("lr %2,%1\nnr %2,%5\n",
- ret, oldval, newval, uaddr, oparg);
- break;
- case FUTEX_OP_XOR:
- __futex_atomic_op("lr %2,%1\nxr %2,%5\n",
- ret, oldval, newval, uaddr, oparg);
- break;
- default:
- ret = -ENOSYS;
- }
-
- dec_preempt_count();
+ ret = uaccess.futex_atomic_op(op, uaddr, oparg, &oldval);
if (!ret) {
switch (cmp) {
@@ -91,32 +37,13 @@ static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
return ret;
}
-static inline int
-futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
+static inline int futex_atomic_cmpxchg_inatomic(int __user *uaddr,
+ int oldval, int newval)
{
- int ret;
-
if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
return -EFAULT;
- asm volatile(" sacf 256\n"
- " cs %1,%4,0(%5)\n"
- "0: lr %0,%1\n"
- "1: sacf 0\n"
-#ifndef __s390x__
- ".section __ex_table,\"a\"\n"
- " .align 4\n"
- " .long 0b,1b\n"
- ".previous"
-#else /* __s390x__ */
- ".section __ex_table,\"a\"\n"
- " .align 8\n"
- " .quad 0b,1b\n"
- ".previous"
-#endif /* __s390x__ */
- : "=d" (ret), "+d" (oldval), "=m" (*uaddr)
- : "0" (-EFAULT), "d" (newval), "a" (uaddr), "m" (*uaddr)
- : "cc", "memory" );
- return oldval;
+
+ return uaccess.futex_atomic_cmpxchg(uaddr, oldval, newval);
}
#endif /* __KERNEL__ */
OpenPOWER on IntegriCloud