Skip to contentSkip to conversation

linux-user: implement m68k atomic syscalls

RFC PATCH Superseded [email protected] 2 participants 2 messages Jul 24, 2013

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 linux-user: implement m68k atomic syscalls

From: Riku Voipio <[email protected]>

With nptl enabled, atomic_cmpxchg_32 and atomic_barrier system calls are needed. This patch enabled really dummy versions of the system calls, modeled after the m68k kernel code.

With this patch I am able to execute m68k binaries with qemu linux-user (busybox compiled for coldfire).

Cc Laurent Vivier <[email protected]>
---
 linux-user/strace.list |  6 ++++++
 linux-user/syscall.c   | 20 ++++++++++++++++++++
 2 files changed, 26 insertions(+)
linux-user/strace.list +6 -0
index 08f115d..4377365 100644
@@ -1524,3 +1524,9 @@
 #ifdef TARGET_NR_pipe2
 { TARGET_NR_pipe2, "pipe2", NULL, NULL, NULL },
 #endif
+#ifdef TARGET_NR_atomic_cmpxchg_32
+{ TARGET_NR_atomic_cmpxchg_32, "atomic_cmpxchg_32", NULL, NULL, NULL },
+#endif
+#ifdef TARGET_NR_atomic_barrier
+{ TARGET_NR_atomic_barrier, "atomic_barrier", NULL, NULL, NULL },
+#endif
linux-user/syscall.c +20 -0
index 3f6db4b..a98cec5 100644
@@ -8990,6 +8990,26 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
         break;
     }
 #endif
+#ifdef TARGET_NR_atomic_cmpxchg_32
+    case TARGET_NR_atomic_cmpxchg_32:
+    {
+        /* should use start_exclusive from main.c */
+        abi_ulong mem_value;
+        if (get_user_u32(mem_value, arg6))
+            ret = -TARGET_EFAULT;
+        if (mem_value == arg2)
+            put_user_u32(arg1, arg6);
+        ret = mem_value;
+        break;
+    }
+#endif
+#ifdef TARGET_NR_atomic_barrier
+    case TARGET_NR_atomic_barrier:
+    {
+        /* Like the kernel implementation and the qemu arm barrier, no-op this? */
+        break;
+    }
+#endif
     default:
     unimplemented:
         gemu_log("qemu: Unsupported syscall: %d\n", num);
Signature · 1 line
1.8.1.2
#1 lore raw

linux-user/syscall.c abi_long do_syscall(void *cpu_env, int num, abi_long arg1, · line 9004

Quoted 12 lines · On 07/23/2013 09:10 PM, [email protected] wrote:
linux-user/syscall.c +12 -0
+#ifdef TARGET_NR_atomic_cmpxchg_32
+    case TARGET_NR_atomic_cmpxchg_32:
+    {
+        /* should use start_exclusive from main.c */
+        abi_ulong mem_value;
+        if (get_user_u32(mem_value, arg6))
+            ret = -TARGET_EFAULT;
+        if (mem_value == arg2)
+            put_user_u32(arg1, arg6);
+        ret = mem_value;
+        break;
+    }

The ret = -TARGET_FAULT doesn't do anything useful without an associated break.

The kernel queues the expected SIGSEGV for this sort of failure. Would that happen here?

r~