Skip to contentSkip to conversation

s390: futex atomic operations part 2.

PATCH New Martin Schwidefsky 1 participant 1 message Apr 25, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390: futex atomic operations part 2.

From: Martin Schwidefsky <[email protected]>

[patch] s390: futex atomic operations part 2.

Add missing primitive futex_atomic_cmpxchg_inatomic. Remove incorrect type cast of uaddr memory constraint from __futex_atomic_op.

---
 include/asm-s390/futex.h |   31 +++++++++++++++++++++++++++++--
 1 files changed, 29 insertions(+), 2 deletions(-)
include/asm-s390/futex.h +29 -2
diff -urpN linux-2.6/include/asm-s390/futex.h linux-2.6-patched/include/asm-s390/futex.h
@@ -30,9 +30,9 @@
 		     "2:\n"						\
 		     __futex_atomic_fixup				\
 		     : "=d" (ret), "=&d" (oldval), "=&d" (newval),	\
-		       "=m" (*(unsigned long __user *) uaddr)		\
+		       "=m" (*uaddr)					\
 		     : "0" (-EFAULT), "d" (oparg), "a" (uaddr),		\
-		       "m" (*(unsigned long __user *) uaddr) : "cc" );
+		       "m" (*uaddr) : "cc" );
 
 static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
 {
@@ -90,5 +90,32 @@ static inline int futex_atomic_op_inuser
 	return ret;
 }
 
+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("   cs   %1,%4,0(%5)\n"
+		     "0: lr   %0,%1\n"
+		     "1:\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;
+}
+
 #endif /* __KERNEL__ */
 #endif /* _ASM_S390_FUTEX_H */