This makes MULTIPROCESSOR kernels use copyin32(9) to guarantee
atomicity.  This will break m88k GENERIC.MP; shouldn't be too
difficult to fix for someone whu understands m88k assembly.

Long-term goal is to implement copyin32(9) on all our architectures
and remove the #define.

ok?


Index: kern/sys_futex.c
===================================================================
RCS file: /cvs/src/sys/kern/sys_futex.c,v
retrieving revision 1.2
diff -u -p -r1.2 sys_futex.c
--- kern/sys_futex.c    30 Apr 2017 10:10:21 -0000      1.2
+++ kern/sys_futex.c    27 May 2017 15:10:50 -0000
@@ -32,6 +32,15 @@
 #endif
 
 /*
+ * Atomicity is only needed on MULTIPROCESSOR kernels.  Fall back on
+ * copyin(9) until non-MULTIPROCESSOR architectures have a copyin32(9)
+ * implementation.
+ */
+#ifndef MULTIPROCESSOR
+#define copyin32(uaddr, kaddr) copyin((uaddr), (kaddr), sizeof(uint32_t))
+#endif
+
+/*
  * Kernel representation of a futex.
  */
 struct futex {
@@ -187,10 +196,8 @@ futex_wait(uint32_t *uaddr, uint32_t val
 
        /*
         * Read user space futex value
-        *
-        * XXX copyin(9) is not guaranteed to be atomic.
         */
-       if ((error = copyin(uaddr, &cval, sizeof(cval))))
+       if ((error = copyin32(uaddr, &cval)))
                return error;
 
        /* If the value changed, stop here. */

Reply via email to