All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall
@ 2018-06-01  7:30 Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 01/33] linux-user: Split out do_syscall1 Richard Henderson
                   ` (34 more replies)
  0 siblings, 35 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

This function is, as I think everyone will agree, way too large.
This is about a third of the complete change, but I thought I'd
get some feedback on the method and form before I go any farther.


r~


Richard Henderson (33):
  linux-user: Split out do_syscall1
  linux-user: Relax single exit from "break"
  linux-user: Propagate goto ebadf to return
  linux-user: Propagate goto efault to return
  linux-user: Propagate goto unimplemented_nowarn to return
  linux-user: Split out goto unimplemented to do_unimplemented
  linux-user: Propagate goto fail to return
  linux-user: Make syscall number unsigned
  linux-user: Set up infrastructure for table-izing syscalls
  linux-user: Split out brk, close, exit, read, write
  linux-user: Split out execve
  linux-user: Split out open, openat
  linux-user: Split out name_to_handle_at
  linux-user: Split out open_to_handle_at
  linux-user: Split out creat, fork, waitid, waitpid
  linux-user: Split out link, linkat
  linux-user: Split out unlink, unlinkat
  linux-user: Split out chdir, mknod, mknodat, time, chmod
  linux-user: Remove all unimplemented entries
  linux-user: Split out getpid, getxpid, lseek
  linux-user: Split out mount, umount
  linux-user: Split out alarm, pause, stime, utime, utimes
  linux-user: Split out access, faccessat, futimesat, kill, nice, sync,
    syncfs
  linux-user: Split out rename, renameat, renameat2
  linux-user: Split out dup, mkdir, mkdirat, rmdir
  linux-user: Split out acct, pipe, pipe2, times, umount2
  linux-user: Split out ioctl
  linux-user: Split out chroot, dup2, dup3, fcntl, setpgid, umask
  linux-user: Split out getpgrp, getppid, setsid
  linux-user: Split out rt_sigaction, sigaction
  linux-user: Split out rt_sigprocmask, sgetmask, sigprocmask, ssetmask
  linux-user: Split out rt_sigpending, rt_sigsuspend, sigpending,
    sigsuspend
  linux-user: Split out rt_sigqueueinfo, rt_sigtimedwait,
    rt_tgsigqueueinfo

 linux-user/qemu.h    |    2 +-
 linux-user/syscall.c | 4651 ++++++++++++++++++++++--------------------
 2 files changed, 2394 insertions(+), 2259 deletions(-)

-- 
2.17.0

^ permalink raw reply	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 01/33] linux-user: Split out do_syscall1
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:36   ` Laurent Vivier
  2018-06-01 14:00   ` Eric Blake
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 02/33] linux-user: Relax single exit from "break" Richard Henderson
                   ` (33 subsequent siblings)
  34 siblings, 2 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

There was supposed to be a single point of return for do_syscall
so that tracing works properly.  However, there are a few bugs
in that area.  It is significantly simpler to simply split out
an inner function to enforce this.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 89 +++++++++++++++++++++++++++-----------------
 1 file changed, 54 insertions(+), 35 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index b75dd9a5bc..ebaefebcc2 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7962,13 +7962,15 @@ static int host_to_target_cpu_mask(const unsigned long *host_mask,
     return 0;
 }
 
-/* do_syscall() should always have a single exit point at the end so
-   that actions, such as logging of syscall results, can be performed.
-   All errnos that do_syscall() returns must be -TARGET_<errcode>. */
-abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
-                    abi_long arg2, abi_long arg3, abi_long arg4,
-                    abi_long arg5, abi_long arg6, abi_long arg7,
-                    abi_long arg8)
+/* This is an internal helper for do_syscall so that it is easier
+ * to have a single return point, so that actions, such as logging
+ * of syscall results, can be performed.
+ * All errnos that do_syscall() returns must be -TARGET_<errcode>.
+ */
+static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
+                            abi_long arg2, abi_long arg3, abi_long arg4,
+                            abi_long arg5, abi_long arg6, abi_long arg7,
+                            abi_long arg8)
 {
     CPUState *cpu = ENV_GET_CPU(cpu_env);
     abi_long ret;
@@ -7977,28 +7979,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
     void *p;
     char *fn;
 
-#if defined(DEBUG_ERESTARTSYS)
-    /* Debug-only code for exercising the syscall-restart code paths
-     * in the per-architecture cpu main loops: restart every syscall
-     * the guest makes once before letting it through.
-     */
-    {
-        static int flag;
-
-        flag = !flag;
-        if (flag) {
-            return -TARGET_ERESTARTSYS;
-        }
-    }
-#endif
-
-#ifdef DEBUG
-    gemu_log("syscall %d", num);
-#endif
-    trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
-    if(do_strace)
-        print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
-
     switch(num) {
     case TARGET_NR_exit:
         /* In old applications this may be used to implement _exit(2).
@@ -13101,12 +13081,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
         break;
     }
 fail:
-#ifdef DEBUG
-    gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret);
-#endif
-    if(do_strace)
-        print_syscall_ret(num, ret);
-    trace_guest_user_syscall_ret(cpu, num, ret);
     return ret;
 efault:
     ret = -TARGET_EFAULT;
@@ -13115,3 +13089,48 @@ ebadf:
     ret = -TARGET_EBADF;
     goto fail;
 }
+
+abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
+                    abi_long arg2, abi_long arg3, abi_long arg4,
+                    abi_long arg5, abi_long arg6, abi_long arg7,
+                    abi_long arg8)
+{
+    CPUState *cpu = ENV_GET_CPU(cpu_env);
+    abi_long ret;
+
+#if defined(DEBUG_ERESTARTSYS)
+    /* Debug-only code for exercising the syscall-restart code paths
+     * in the per-architecture cpu main loops: restart every syscall
+     * the guest makes once before letting it through.
+     */
+    {
+        static bool flag;
+        flag = !flag;
+        if (flag) {
+            return -TARGET_ERESTARTSYS;
+        }
+    }
+#endif
+#ifdef DEBUG
+    gemu_log("syscall %d", num);
+#endif
+
+    trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4,
+                             arg5, arg6, arg7, arg8);
+
+    if (unlikely(do_strace)) {
+        print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
+        ret = do_syscall1(cpu_env, num, arg1, arg2, arg3, arg4,
+                          arg5, arg6, arg7, arg8);
+        print_syscall_ret(num, ret);
+    } else {
+        ret = do_syscall1(cpu_env, num, arg1, arg2, arg3, arg4,
+                          arg5, arg6, arg7, arg8);
+    }
+
+#ifdef DEBUG
+    gemu_log(" = " TARGET_ABI_FMT_ld "\n", ret);
+#endif
+    trace_guest_user_syscall_ret(cpu, num, ret);
+    return ret;
+}
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 02/33] linux-user: Relax single exit from "break"
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 01/33] linux-user: Split out do_syscall1 Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-04 19:29   ` Laurent Vivier
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 03/33] linux-user: Propagate goto ebadf to return Richard Henderson
                   ` (32 subsequent siblings)
  34 siblings, 1 reply; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Transform outermost "break" to "return ret".  If the immediately
preceeding statement was an assignment to ret, return the value
directly.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 969 +++++++++++++++++--------------------------
 1 file changed, 390 insertions(+), 579 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index ebaefebcc2..258aff0411 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7987,8 +7987,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
            Do thread termination if we have more then one thread.  */
 
         if (block_signals()) {
-            ret = -TARGET_ERESTARTSYS;
-            break;
+            return -TARGET_ERESTARTSYS;
         }
 
         cpu_list_lock();
@@ -8020,12 +8019,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
         gdb_exit(cpu_env, arg1);
         _exit(arg1);
-        ret = 0; /* avoid warning */
-        break;
+        return 0; /* avoid warning */
     case TARGET_NR_read:
-        if (arg3 == 0)
-            ret = 0;
-        else {
+        if (arg3 == 0) {
+            return 0;
+        } else {
             if (is_hostfd(arg1)) {
                 goto ebadf;
             }
@@ -8038,7 +8036,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             }
             unlock_user(p, arg2, ret);
         }
-        break;
+        return ret;
     case TARGET_NR_write:
         if (is_hostfd(arg1)) {
             goto ebadf;
@@ -8057,7 +8055,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(safe_write(arg1, p, arg3));
         }
         unlock_user(p, arg2, 0);
-        break;
+        return ret;
+
 #ifdef TARGET_NR_open
     case TARGET_NR_open:
         if (!(p = lock_user_string(arg1)))
@@ -8067,7 +8066,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                                   arg3));
         fd_trans_unregister(ret);
         unlock_user(p, arg1, 0);
-        break;
+        return ret;
 #endif
     case TARGET_NR_openat:
         if (is_hostfd(arg1)) {
@@ -8080,14 +8079,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                                   arg4));
         fd_trans_unregister(ret);
         unlock_user(p, arg2, 0);
-        break;
+        return ret;
 #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
     case TARGET_NR_name_to_handle_at:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
         ret = do_name_to_handle_at(arg1, arg2, arg3, arg4, arg5);
-        break;
+        return ret;
 #endif
 #if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
     case TARGET_NR_open_by_handle_at:
@@ -8096,22 +8095,20 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         }
         ret = do_open_by_handle_at(arg1, arg2, arg3);
         fd_trans_unregister(ret);
-        break;
+        return ret;
 #endif
     case TARGET_NR_close:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
         fd_trans_unregister(arg1);
-        ret = get_errno(close(arg1));
-        break;
+        return get_errno(close(arg1));
+
     case TARGET_NR_brk:
-        ret = do_brk(arg1);
-        break;
+        return do_brk(arg1);
 #ifdef TARGET_NR_fork
     case TARGET_NR_fork:
-        ret = get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0));
-        break;
+        return get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0));
 #endif
 #ifdef TARGET_NR_waitpid
     case TARGET_NR_waitpid:
@@ -8122,7 +8119,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 && put_user_s32(host_to_target_waitstatus(status), arg2))
                 goto efault;
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_waitid
     case TARGET_NR_waitid:
@@ -8137,7 +8134,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 unlock_user(p, arg3, sizeof(target_siginfo_t));
             }
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_creat /* not on alpha */
     case TARGET_NR_creat:
@@ -8146,7 +8143,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         ret = get_errno(creat(p, arg2));
         fd_trans_unregister(ret);
         unlock_user(p, arg1, 0);
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_link
     case TARGET_NR_link:
@@ -8161,7 +8158,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             unlock_user(p2, arg2, 0);
             unlock_user(p, arg1, 0);
         }
-        break;
+        return ret;
 #endif
 #if defined(TARGET_NR_linkat)
     case TARGET_NR_linkat:
@@ -8180,7 +8177,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             unlock_user(p, arg2, 0);
             unlock_user(p2, arg4, 0);
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_unlink
     case TARGET_NR_unlink:
@@ -8188,7 +8185,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             goto efault;
         ret = get_errno(unlink(p));
         unlock_user(p, arg1, 0);
-        break;
+        return ret;
 #endif
 #if defined(TARGET_NR_unlinkat)
     case TARGET_NR_unlinkat:
@@ -8199,7 +8196,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             goto efault;
         ret = get_errno(unlinkat(arg1, p, arg3));
         unlock_user(p, arg2, 0);
-        break;
+        return ret;
 #endif
     case TARGET_NR_execve:
         {
@@ -8297,13 +8294,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             g_free(argp);
             g_free(envp);
         }
-        break;
+        return ret;
     case TARGET_NR_chdir:
         if (!(p = lock_user_string(arg1)))
             goto efault;
         ret = get_errno(chdir(p));
         unlock_user(p, arg1, 0);
-        break;
+        return ret;
 #ifdef TARGET_NR_time
     case TARGET_NR_time:
         {
@@ -8314,7 +8311,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 && put_user_sal(host_time, arg1))
                 goto efault;
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_mknod
     case TARGET_NR_mknod:
@@ -8322,7 +8319,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             goto efault;
         ret = get_errno(mknod(p, arg2, arg3));
         unlock_user(p, arg1, 0);
-        break;
+        return ret;
 #endif
 #if defined(TARGET_NR_mknodat)
     case TARGET_NR_mknodat:
@@ -8333,7 +8330,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             goto efault;
         ret = get_errno(mknodat(arg1, p, arg3, arg4));
         unlock_user(p, arg2, 0);
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_chmod
     case TARGET_NR_chmod:
@@ -8341,7 +8338,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             goto efault;
         ret = get_errno(chmod(p, arg2));
         unlock_user(p, arg1, 0);
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_break
     case TARGET_NR_break:
@@ -8355,19 +8352,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = get_errno(lseek(arg1, arg2, arg3));
-        break;
+        return get_errno(lseek(arg1, arg2, arg3));
 #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA)
     /* Alpha specific */
     case TARGET_NR_getxpid:
         ((CPUAlphaState *)cpu_env)->ir[IR_A4] = getppid();
-        ret = get_errno(getpid());
-        break;
+        return get_errno(getpid());
 #endif
 #ifdef TARGET_NR_getpid
     case TARGET_NR_getpid:
-        ret = get_errno(getpid());
-        break;
+        return get_errno(getpid());
 #endif
     case TARGET_NR_mount:
         {
@@ -8423,14 +8417,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 unlock_user(p3, arg3, 0);
             }
         }
-        break;
+        return ret;
 #ifdef TARGET_NR_umount
     case TARGET_NR_umount:
         if (!(p = lock_user_string(arg1)))
             goto efault;
         ret = get_errno(umount(p));
         unlock_user(p, arg1, 0);
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_stime /* not on alpha */
     case TARGET_NR_stime:
@@ -8438,16 +8432,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             time_t host_time;
             if (get_user_sal(host_time, arg1))
                 goto efault;
-            ret = get_errno(stime(&host_time));
+            return get_errno(stime(&host_time));
         }
-        break;
 #endif
     case TARGET_NR_ptrace:
         goto unimplemented;
 #ifdef TARGET_NR_alarm /* not on alpha */
     case TARGET_NR_alarm:
-        ret = alarm(arg1);
-        break;
+        return alarm(arg1);
 #endif
 #ifdef TARGET_NR_oldfstat
     case TARGET_NR_oldfstat:
@@ -8458,8 +8450,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         if (!block_signals()) {
             sigsuspend(&((TaskState *)cpu->opaque)->signal_mask);
         }
-        ret = -TARGET_EINTR;
-        break;
+        return -TARGET_EINTR;
 #endif
 #ifdef TARGET_NR_utime
     case TARGET_NR_utime:
@@ -8481,7 +8472,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(utime(p, host_tbuf));
             unlock_user(p, arg1, 0);
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_utimes
     case TARGET_NR_utimes:
@@ -8501,7 +8492,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(utimes(p, tvp));
             unlock_user(p, arg1, 0);
         }
-        break;
+        return ret;
 #endif
 #if defined(TARGET_NR_futimesat)
     case TARGET_NR_futimesat:
@@ -8527,7 +8518,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(ret);
             unlock_user(fn, arg2, 0);
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_stty
     case TARGET_NR_stty:
@@ -8547,7 +8538,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                       access(fn, arg2));
         ret = get_errno(ret);
         unlock_user(fn, arg1, 0);
-        break;
+        return ret;
 #endif
 #if defined(TARGET_NR_faccessat) && defined(__NR_faccessat)
     case TARGET_NR_faccessat:
@@ -8562,12 +8553,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                       faccessat(arg1, fn, arg3, 0));
         ret = get_errno(ret);
         unlock_user(fn, arg2, 0);
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_nice /* not on alpha */
     case TARGET_NR_nice:
-        ret = get_errno(nice(arg1));
-        break;
+        return get_errno(nice(arg1));
 #endif
 #ifdef TARGET_NR_ftime
     case TARGET_NR_ftime:
@@ -8575,16 +8565,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
     case TARGET_NR_sync:
         sync();
-        ret = 0;
-        break;
+        return 0;
 #if defined(TARGET_NR_syncfs) && defined(CONFIG_SYNCFS)
     case TARGET_NR_syncfs:
-        ret = get_errno(syncfs(arg1));
-        break;
+        return get_errno(syncfs(arg1));
 #endif
     case TARGET_NR_kill:
-        ret = get_errno(safe_kill(arg1, target_to_host_signal(arg2)));
-        break;
+        return get_errno(safe_kill(arg1, target_to_host_signal(arg2)));
 #ifdef TARGET_NR_rename
     case TARGET_NR_rename:
         {
@@ -8598,7 +8585,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             unlock_user(p2, arg2, 0);
             unlock_user(p, arg1, 0);
         }
-        break;
+        return ret;
 #endif
 #if defined(TARGET_NR_renameat)
     case TARGET_NR_renameat:
@@ -8615,7 +8602,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             unlock_user(p2, arg4, 0);
             unlock_user(p, arg2, 0);
         }
-        break;
+        return ret;
 #endif
 #if defined(TARGET_NR_renameat2)
     case TARGET_NR_renameat2:
@@ -8633,7 +8620,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             unlock_user(p2, arg4, 0);
             unlock_user(p, arg2, 0);
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_mkdir
     case TARGET_NR_mkdir:
@@ -8641,7 +8628,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             goto efault;
         ret = get_errno(mkdir(p, arg2));
         unlock_user(p, arg1, 0);
-        break;
+        return ret;
 #endif
 #if defined(TARGET_NR_mkdirat)
     case TARGET_NR_mkdirat:
@@ -8652,7 +8639,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             goto efault;
         ret = get_errno(mkdirat(arg1, p, arg3));
         unlock_user(p, arg2, 0);
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_rmdir
     case TARGET_NR_rmdir:
@@ -8660,7 +8647,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             goto efault;
         ret = get_errno(rmdir(p));
         unlock_user(p, arg1, 0);
-        break;
+        return ret;
 #endif
     case TARGET_NR_dup:
         if (is_hostfd(arg1)) {
@@ -8670,17 +8657,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         if (ret >= 0) {
             fd_trans_dup(arg1, ret);
         }
-        break;
+        return ret;
 #ifdef TARGET_NR_pipe
     case TARGET_NR_pipe:
-        ret = do_pipe(cpu_env, arg1, 0, 0);
-        break;
+        return do_pipe(cpu_env, arg1, 0, 0);
 #endif
 #ifdef TARGET_NR_pipe2
     case TARGET_NR_pipe2:
-        ret = do_pipe(cpu_env, arg1,
-                      target_to_host_bitmask(arg2, fcntl_flags_tbl), 1);
-        break;
+        return do_pipe(cpu_env, arg1,
+                       target_to_host_bitmask(arg2, fcntl_flags_tbl), 1);
 #endif
     case TARGET_NR_times:
         {
@@ -8699,7 +8684,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             if (!is_error(ret))
                 ret = host_to_target_clock_t(ret);
         }
-        break;
+        return ret;
 #ifdef TARGET_NR_prof
     case TARGET_NR_prof:
         goto unimplemented;
@@ -8719,34 +8704,31 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(ret);
             unlock_user(fn, arg1, 0);
         }
-        break;
+        return ret;
 #ifdef TARGET_NR_umount2
     case TARGET_NR_umount2:
         if (!(p = lock_user_string(arg1)))
             goto efault;
         ret = get_errno(umount2(p, arg2));
         unlock_user(p, arg1, 0);
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_lock
     case TARGET_NR_lock:
         goto unimplemented;
 #endif
     case TARGET_NR_ioctl:
-        ret = do_ioctl(arg1, arg2, arg3);
-        break;
+        return do_ioctl(arg1, arg2, arg3);
 #ifdef TARGET_NR_fcntl
     case TARGET_NR_fcntl:
-        ret = do_fcntl(arg1, arg2, arg3);
-        break;
+        return do_fcntl(arg1, arg2, arg3);
 #endif
 #ifdef TARGET_NR_mpx
     case TARGET_NR_mpx:
         goto unimplemented;
 #endif
     case TARGET_NR_setpgid:
-        ret = get_errno(setpgid(arg1, arg2));
-        break;
+        return get_errno(setpgid(arg1, arg2));
 #ifdef TARGET_NR_ulimit
     case TARGET_NR_ulimit:
         goto unimplemented;
@@ -8756,14 +8738,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         goto unimplemented;
 #endif
     case TARGET_NR_umask:
-        ret = get_errno(umask(arg1));
-        break;
+        return get_errno(umask(arg1));
     case TARGET_NR_chroot:
         if (!(p = lock_user_string(arg1)))
             goto efault;
         ret = get_errno(chroot(p));
         unlock_user(p, arg1, 0);
-        break;
+        return ret;
 #ifdef TARGET_NR_ustat
     case TARGET_NR_ustat:
         goto unimplemented;
@@ -8777,7 +8758,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         if (ret >= 0) {
             fd_trans_dup(arg1, arg2);
         }
-        break;
+        return ret;
 #endif
 #if defined(CONFIG_DUP3) && defined(TARGET_NR_dup3)
     case TARGET_NR_dup3:
@@ -8795,22 +8776,19 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         if (ret >= 0) {
             fd_trans_dup(arg1, arg2);
         }
-        break;
+        return ret;
     }
 #endif
 #ifdef TARGET_NR_getppid /* not on alpha */
     case TARGET_NR_getppid:
-        ret = get_errno(getppid());
-        break;
+        return get_errno(getppid());
 #endif
 #ifdef TARGET_NR_getpgrp
     case TARGET_NR_getpgrp:
-        ret = get_errno(getpgrp());
-        break;
+        return get_errno(getpgrp());
 #endif
     case TARGET_NR_setsid:
-        ret = get_errno(setsid());
-        break;
+        return get_errno(setsid());
 #ifdef TARGET_NR_sigaction
     case TARGET_NR_sigaction:
         {
@@ -8894,7 +8872,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             }
 #endif
         }
-        break;
+        return ret;
 #endif
     case TARGET_NR_rt_sigaction:
         {
@@ -8911,8 +8889,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             struct target_sigaction act, oact, *pact = 0;
 
             if (arg4 != sizeof(target_sigset_t)) {
-                ret = -TARGET_EINVAL;
-                break;
+                return -TARGET_EINVAL;
             }
             if (arg2) {
                 if (!lock_user_struct(VERIFY_READ, rt_act, arg2, 1))
@@ -8944,8 +8921,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             struct target_sigaction *oact;
 
             if (sigsetsize != sizeof(target_sigset_t)) {
-                ret = -TARGET_EINVAL;
-                break;
+                return -TARGET_EINVAL;
             }
             if (arg2) {
                 if (!lock_user_struct(VERIFY_READ, act, arg2, 1)) {
@@ -8972,7 +8948,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 unlock_user_struct(oact, arg3, 1);
 #endif
         }
-        break;
+        return ret;
 #ifdef TARGET_NR_sgetmask /* not on alpha */
     case TARGET_NR_sgetmask:
         {
@@ -8984,7 +8960,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 ret = target_set;
             }
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_ssetmask /* not on alpha */
     case TARGET_NR_ssetmask:
@@ -8998,7 +8974,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 ret = target_set;
             }
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_sigprocmask
     case TARGET_NR_sigprocmask:
@@ -9068,7 +9044,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             }
 #endif
         }
-        break;
+        return ret;
 #endif
     case TARGET_NR_rt_sigprocmask:
         {
@@ -9076,8 +9052,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             sigset_t set, oldset, *set_ptr;
 
             if (arg4 != sizeof(target_sigset_t)) {
-                ret = -TARGET_EINVAL;
-                break;
+                return -TARGET_EINVAL;
             }
 
             if (arg2) {
@@ -9112,7 +9087,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 unlock_user(p, arg3, sizeof(target_sigset_t));
             }
         }
-        break;
+        return ret;
 #ifdef TARGET_NR_sigpending
     case TARGET_NR_sigpending:
         {
@@ -9125,7 +9100,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 unlock_user(p, arg1, sizeof(target_sigset_t));
             }
         }
-        break;
+        return ret;
 #endif
     case TARGET_NR_rt_sigpending:
         {
@@ -9137,8 +9112,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
              * the old_sigset_t is smaller in size.
              */
             if (arg2 > sizeof(target_sigset_t)) {
-                ret = -TARGET_EINVAL;
-                break;
+                return -TARGET_EINVAL;
             }
 
             ret = get_errno(sigpending(&set));
@@ -9149,7 +9123,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 unlock_user(p, arg1, sizeof(target_sigset_t));
             }
         }
-        break;
+        return ret;
 #ifdef TARGET_NR_sigsuspend
     case TARGET_NR_sigsuspend:
         {
@@ -9169,15 +9143,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 ts->in_sigsuspend = 1;
             }
         }
-        break;
+        return ret;
 #endif
     case TARGET_NR_rt_sigsuspend:
         {
             TaskState *ts = cpu->opaque;
 
             if (arg2 != sizeof(target_sigset_t)) {
-                ret = -TARGET_EINVAL;
-                break;
+                return -TARGET_EINVAL;
             }
             if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))
                 goto efault;
@@ -9189,7 +9162,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 ts->in_sigsuspend = 1;
             }
         }
-        break;
+        return ret;
     case TARGET_NR_rt_sigtimedwait:
         {
             sigset_t set;
@@ -9197,8 +9170,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             siginfo_t uinfo;
 
             if (arg4 != sizeof(target_sigset_t)) {
-                ret = -TARGET_EINVAL;
-                break;
+                return -TARGET_EINVAL;
             }
 
             if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))
@@ -9226,7 +9198,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 ret = host_to_target_signal(ret);
             }
         }
-        break;
+        return ret;
     case TARGET_NR_rt_sigqueueinfo:
         {
             siginfo_t uinfo;
@@ -9239,7 +9211,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             unlock_user(p, arg3, 0);
             ret = get_errno(sys_rt_sigqueueinfo(arg1, arg2, &uinfo));
         }
-        break;
+        return ret;
     case TARGET_NR_rt_tgsigqueueinfo:
         {
             siginfo_t uinfo;
@@ -9252,7 +9224,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             unlock_user(p, arg4, 0);
             ret = get_errno(sys_rt_tgsigqueueinfo(arg1, arg2, arg3, &uinfo));
         }
-        break;
+        return ret;
 #ifdef TARGET_NR_sigreturn
     case TARGET_NR_sigreturn:
         if (block_signals()) {
@@ -9260,21 +9232,20 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         } else {
             ret = do_sigreturn(cpu_env);
         }
-        break;
+        return ret;
 #endif
     case TARGET_NR_rt_sigreturn:
         if (block_signals()) {
-            ret = -TARGET_ERESTARTSYS;
+            return -TARGET_ERESTARTSYS;
         } else {
-            ret = do_rt_sigreturn(cpu_env);
+            return do_rt_sigreturn(cpu_env);
         }
-        break;
     case TARGET_NR_sethostname:
         if (!(p = lock_user_string(arg1)))
             goto efault;
         ret = get_errno(sethostname(p, arg2));
         unlock_user(p, arg1, 0);
-        break;
+        return ret;
     case TARGET_NR_setrlimit:
         {
             int resource = target_to_host_resource(arg1);
@@ -9285,9 +9256,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             rlim.rlim_cur = target_to_host_rlim(target_rlim->rlim_cur);
             rlim.rlim_max = target_to_host_rlim(target_rlim->rlim_max);
             unlock_user_struct(target_rlim, arg2, 0);
-            ret = get_errno(setrlimit(resource, &rlim));
+            return get_errno(setrlimit(resource, &rlim));
         }
-        break;
     case TARGET_NR_getrlimit:
         {
             int resource = target_to_host_resource(arg1);
@@ -9303,7 +9273,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 unlock_user_struct(target_rlim, arg2, 1);
             }
         }
-        break;
+        return ret;
     case TARGET_NR_getrusage:
         {
             struct rusage rusage;
@@ -9312,7 +9282,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 ret = host_to_target_rusage(arg2, &rusage);
             }
         }
-        break;
+        return ret;
     case TARGET_NR_gettimeofday:
         {
             struct timeval tv;
@@ -9322,7 +9292,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                     goto efault;
             }
         }
-        break;
+        return ret;
     case TARGET_NR_settimeofday:
         {
             struct timeval tv, *ptv = NULL;
@@ -9342,9 +9312,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 ptz = &tz;
             }
 
-            ret = get_errno(settimeofday(ptv, ptz));
+            return get_errno(settimeofday(ptv, ptz));
         }
-        break;
 #if defined(TARGET_NR_select)
     case TARGET_NR_select:
 #if defined(TARGET_WANT_NI_OLD_SELECT)
@@ -9357,7 +9326,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #else
         ret = do_select(arg1, arg2, arg3, arg4, arg5);
 #endif
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_pselect6
     case TARGET_NR_pselect6:
@@ -9466,7 +9435,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                     goto efault;
             }
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_symlink
     case TARGET_NR_symlink:
@@ -9481,7 +9450,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             unlock_user(p2, arg2, 0);
             unlock_user(p, arg1, 0);
         }
-        break;
+        return ret;
 #endif
 #if defined(TARGET_NR_symlinkat)
     case TARGET_NR_symlinkat:
@@ -9498,7 +9467,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             unlock_user(p2, arg3, 0);
             unlock_user(p, arg1, 0);
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_oldlstat
     case TARGET_NR_oldlstat:
@@ -9537,7 +9506,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             unlock_user(p2, arg2, ret);
             unlock_user(fn, arg1, 0);
         }
-        break;
+        return ret;
 #endif
 #if defined(TARGET_NR_readlinkat)
     case TARGET_NR_readlinkat:
@@ -9563,7 +9532,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             unlock_user(p2, arg3, ret);
             unlock_user(fn, arg2, 0);
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_uselib
     case TARGET_NR_uselib:
@@ -9575,7 +9544,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             goto efault;
         ret = get_errno(swapon(p, arg2));
         unlock_user(p, arg1, 0);
-        break;
+        return ret;
 #endif
     case TARGET_NR_reboot:
         if (arg3 == LINUX_REBOOT_CMD_RESTART2) {
@@ -9589,7 +9558,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         } else {
            ret = get_errno(reboot(arg1, arg2, arg3, NULL));
         }
-        break;
+        return ret;
 #ifdef TARGET_NR_readdir
     case TARGET_NR_readdir:
         goto unimplemented;
@@ -9628,7 +9597,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                                     arg5,
                                     arg6));
 #endif
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_mmap2
     case TARGET_NR_mmap2:
@@ -9638,15 +9607,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         if (is_hostfd(arg5)) {
             goto ebadf;
         }
-        ret = get_errno(target_mmap(arg1, arg2, arg3,
-                                    target_to_host_bitmask(arg4, mmap_flags_tbl),
-                                    arg5,
-                                    arg6 << MMAP_SHIFT));
-        break;
+        ret = target_mmap(arg1, arg2, arg3,
+                          target_to_host_bitmask(arg4, mmap_flags_tbl),
+                          arg5, arg6 << MMAP_SHIFT);
+        return get_errno(ret);
 #endif
     case TARGET_NR_munmap:
-        ret = get_errno(target_munmap(arg1, arg2));
-        break;
+        return get_errno(target_munmap(arg1, arg2));
     case TARGET_NR_mprotect:
         {
             TaskState *ts = cpu->opaque;
@@ -9659,57 +9626,48 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 arg1 = ts->info->stack_limit;
             }
         }
-        ret = get_errno(target_mprotect(arg1, arg2, arg3));
-        break;
+        return get_errno(target_mprotect(arg1, arg2, arg3));
 #ifdef TARGET_NR_mremap
     case TARGET_NR_mremap:
-        ret = get_errno(target_mremap(arg1, arg2, arg3, arg4, arg5));
-        break;
+        return get_errno(target_mremap(arg1, arg2, arg3, arg4, arg5));
 #endif
         /* ??? msync/mlock/munlock are broken for softmmu.  */
 #ifdef TARGET_NR_msync
     case TARGET_NR_msync:
-        ret = get_errno(msync(g2h(arg1), arg2, arg3));
-        break;
+        return get_errno(msync(g2h(arg1), arg2, arg3));
 #endif
 #ifdef TARGET_NR_mlock
     case TARGET_NR_mlock:
-        ret = get_errno(mlock(g2h(arg1), arg2));
-        break;
+        return get_errno(mlock(g2h(arg1), arg2));
 #endif
 #ifdef TARGET_NR_munlock
     case TARGET_NR_munlock:
-        ret = get_errno(munlock(g2h(arg1), arg2));
-        break;
+        return get_errno(munlock(g2h(arg1), arg2));
 #endif
 #ifdef TARGET_NR_mlockall
     case TARGET_NR_mlockall:
-        ret = get_errno(mlockall(target_to_host_mlockall_arg(arg1)));
-        break;
+        return get_errno(mlockall(target_to_host_mlockall_arg(arg1)));
 #endif
 #ifdef TARGET_NR_munlockall
     case TARGET_NR_munlockall:
-        ret = get_errno(munlockall());
-        break;
+        return get_errno(munlockall());
 #endif
     case TARGET_NR_truncate:
         if (!(p = lock_user_string(arg1)))
             goto efault;
         ret = get_errno(truncate(p, arg2));
         unlock_user(p, arg1, 0);
-        break;
+        return ret;
     case TARGET_NR_ftruncate:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = get_errno(ftruncate(arg1, arg2));
-        break;
+        return get_errno(ftruncate(arg1, arg2));
     case TARGET_NR_fchmod:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = get_errno(fchmod(arg1, arg2));
-        break;
+        return get_errno(fchmod(arg1, arg2));
 #if defined(TARGET_NR_fchmodat)
     case TARGET_NR_fchmodat:
         if (is_hostfd(arg1)) {
@@ -9719,7 +9677,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             goto efault;
         ret = get_errno(fchmodat(arg1, p, arg3, 0));
         unlock_user(p, arg2, 0);
-        break;
+        return ret;
 #endif
     case TARGET_NR_getpriority:
         /* Note that negative values are valid for getpriority, so we must
@@ -9727,8 +9685,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         errno = 0;
         ret = getpriority(arg1, arg2);
         if (ret == -1 && errno != 0) {
-            ret = -host_to_target_errno(errno);
-            break;
+            return -host_to_target_errno(errno);
         }
 #ifdef TARGET_ALPHA
         /* Return value is the unbiased priority.  Signal no error.  */
@@ -9737,10 +9694,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         /* Return value is a biased priority to avoid negative numbers.  */
         ret = 20 - ret;
 #endif
-        break;
+        return ret;
     case TARGET_NR_setpriority:
-        ret = get_errno(setpriority(arg1, arg2, arg3));
-        break;
+        return get_errno(setpriority(arg1, arg2, arg3));
 #ifdef TARGET_NR_profil
     case TARGET_NR_profil:
         goto unimplemented;
@@ -9777,7 +9733,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             memset(target_stfs->f_spare, 0, sizeof(target_stfs->f_spare));
             unlock_user_struct(target_stfs, arg2, 1);
         }
-        break;
+        return ret;
     case TARGET_NR_fstatfs:
         if (is_hostfd(arg1)) {
             goto ebadf;
@@ -9812,7 +9768,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             memset(target_stfs->f_spare, 0, sizeof(target_stfs->f_spare));
             unlock_user_struct(target_stfs, arg3, 1);
         }
-        break;
+        return ret;
     case TARGET_NR_fstatfs64:
         if (is_hostfd(arg1)) {
             goto ebadf;
@@ -9826,142 +9782,124 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
 #ifdef TARGET_NR_socketcall
     case TARGET_NR_socketcall:
-        ret = do_socketcall(arg1, arg2);
-        break;
+        return do_socketcall(arg1, arg2);
 #endif
 #ifdef TARGET_NR_accept
     case TARGET_NR_accept:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = do_accept4(arg1, arg2, arg3, 0);
-        break;
+        return do_accept4(arg1, arg2, arg3, 0);
 #endif
 #ifdef TARGET_NR_accept4
     case TARGET_NR_accept4:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = do_accept4(arg1, arg2, arg3, arg4);
-        break;
+        return do_accept4(arg1, arg2, arg3, arg4);
 #endif
 #ifdef TARGET_NR_bind
     case TARGET_NR_bind:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = do_bind(arg1, arg2, arg3);
-        break;
+        return do_bind(arg1, arg2, arg3);
 #endif
 #ifdef TARGET_NR_connect
     case TARGET_NR_connect:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = do_connect(arg1, arg2, arg3);
-        break;
+        return do_connect(arg1, arg2, arg3);
 #endif
 #ifdef TARGET_NR_getpeername
     case TARGET_NR_getpeername:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = do_getpeername(arg1, arg2, arg3);
-        break;
+        return do_getpeername(arg1, arg2, arg3);
 #endif
 #ifdef TARGET_NR_getsockname
     case TARGET_NR_getsockname:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = do_getsockname(arg1, arg2, arg3);
-        break;
+        return do_getsockname(arg1, arg2, arg3);
 #endif
 #ifdef TARGET_NR_getsockopt
     case TARGET_NR_getsockopt:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = do_getsockopt(arg1, arg2, arg3, arg4, arg5);
-        break;
+        return do_getsockopt(arg1, arg2, arg3, arg4, arg5);
 #endif
 #ifdef TARGET_NR_listen
     case TARGET_NR_listen:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = get_errno(listen(arg1, arg2));
-        break;
+        return get_errno(listen(arg1, arg2));
 #endif
 #ifdef TARGET_NR_recv
     case TARGET_NR_recv:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = do_recvfrom(arg1, arg2, arg3, arg4, 0, 0);
-        break;
+        return do_recvfrom(arg1, arg2, arg3, arg4, 0, 0);
 #endif
 #ifdef TARGET_NR_recvfrom
     case TARGET_NR_recvfrom:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = do_recvfrom(arg1, arg2, arg3, arg4, arg5, arg6);
-        break;
+        return do_recvfrom(arg1, arg2, arg3, arg4, arg5, arg6);
 #endif
 #ifdef TARGET_NR_recvmsg
     case TARGET_NR_recvmsg:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = do_sendrecvmsg(arg1, arg2, arg3, 0);
-        break;
+        return do_sendrecvmsg(arg1, arg2, arg3, 0);
 #endif
 #ifdef TARGET_NR_send
     case TARGET_NR_send:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = do_sendto(arg1, arg2, arg3, arg4, 0, 0);
-        break;
+        return do_sendto(arg1, arg2, arg3, arg4, 0, 0);
 #endif
 #ifdef TARGET_NR_sendmsg
     case TARGET_NR_sendmsg:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = do_sendrecvmsg(arg1, arg2, arg3, 1);
-        break;
+        return do_sendrecvmsg(arg1, arg2, arg3, 1);
 #endif
 #ifdef TARGET_NR_sendmmsg
     case TARGET_NR_sendmmsg:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = do_sendrecvmmsg(arg1, arg2, arg3, arg4, 1);
-        break;
+        return do_sendrecvmmsg(arg1, arg2, arg3, arg4, 1);
     case TARGET_NR_recvmmsg:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = do_sendrecvmmsg(arg1, arg2, arg3, arg4, 0);
-        break;
+        return do_sendrecvmmsg(arg1, arg2, arg3, arg4, 0);
 #endif
 #ifdef TARGET_NR_sendto
     case TARGET_NR_sendto:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = do_sendto(arg1, arg2, arg3, arg4, arg5, arg6);
-        break;
+        return do_sendto(arg1, arg2, arg3, arg4, arg5, arg6);
 #endif
 #ifdef TARGET_NR_shutdown
     case TARGET_NR_shutdown:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = get_errno(shutdown(arg1, arg2));
-        break;
+        return get_errno(shutdown(arg1, arg2));
 #endif
 #if defined(TARGET_NR_getrandom) && defined(__NR_getrandom)
     case TARGET_NR_getrandom:
@@ -9971,25 +9909,22 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         }
         ret = get_errno(getrandom(p, arg2, arg3));
         unlock_user(p, arg1, ret);
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_socket
     case TARGET_NR_socket:
-        ret = do_socket(arg1, arg2, arg3);
-        break;
+        return do_socket(arg1, arg2, arg3);
 #endif
 #ifdef TARGET_NR_socketpair
     case TARGET_NR_socketpair:
-        ret = do_socketpair(arg1, arg2, arg3, arg4);
-        break;
+        return do_socketpair(arg1, arg2, arg3, arg4);
 #endif
 #ifdef TARGET_NR_setsockopt
     case TARGET_NR_setsockopt:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = do_setsockopt(arg1, arg2, arg3, arg4, (socklen_t) arg5);
-        break;
+        return do_setsockopt(arg1, arg2, arg3, arg4, (socklen_t) arg5);
 #endif
 #if defined(TARGET_NR_syslog)
     case TARGET_NR_syslog:
@@ -10005,10 +9940,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL: /* Set messages level */
             case TARGET_SYSLOG_ACTION_SIZE_UNREAD:   /* Number of chars */
             case TARGET_SYSLOG_ACTION_SIZE_BUFFER:   /* Size of the buffer */
-                {
-                    ret = get_errno(sys_syslog((int)arg1, NULL, (int)arg3));
-                }
-                break;
+                return get_errno(sys_syslog((int)arg1, NULL, (int)arg3));
             case TARGET_SYSLOG_ACTION_READ:          /* Read from log */
             case TARGET_SYSLOG_ACTION_READ_CLEAR:    /* Read/clear msgs */
             case TARGET_SYSLOG_ACTION_READ_ALL:      /* Read last messages */
@@ -10019,7 +9951,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                     }
                     ret = 0;
                     if (len == 0) {
-                        break;
+                        return ret;
                     }
                     p = lock_user(VERIFY_WRITE, arg2, arg3, 0);
                     if (!p) {
@@ -10029,10 +9961,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                     ret = get_errno(sys_syslog((int)arg1, p, (int)arg3));
                     unlock_user(p, arg2, arg3);
                 }
-                break;
+                return ret;
             default:
-                ret = -EINVAL;
-                break;
+                return -TARGET_EINVAL;
             }
         }
         break;
@@ -10059,7 +9990,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                     goto efault;
             }
         }
-        break;
+        return ret;
     case TARGET_NR_getitimer:
         {
             struct itimerval value;
@@ -10073,7 +10004,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                     goto efault;
             }
         }
-        break;
+        return ret;
 #ifdef TARGET_NR_stat
     case TARGET_NR_stat:
         if (!(fn = lock_user_string(arg1))) {
@@ -10128,7 +10059,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 unlock_user_struct(target_st, arg2, 1);
             }
         }
-        break;
+        return ret;
 #ifdef TARGET_NR_olduname
     case TARGET_NR_olduname:
         goto unimplemented;
@@ -10138,17 +10069,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         goto unimplemented;
 #endif
     case TARGET_NR_vhangup:
-        ret = get_errno(vhangup());
-        break;
+        return get_errno(vhangup());
 #ifdef TARGET_NR_idle
     case TARGET_NR_idle:
         goto unimplemented;
 #endif
 #ifdef TARGET_NR_syscall
     case TARGET_NR_syscall:
-        ret = do_syscall(cpu_env, arg1 & 0xffff, arg2, arg3, arg4, arg5,
-                         arg6, arg7, arg8, 0);
-        break;
+        return do_syscall(cpu_env, arg1 & 0xffff, arg2, arg3, arg4, arg5,
+                          arg6, arg7, arg8, 0);
 #endif
     case TARGET_NR_wait4:
         {
@@ -10176,14 +10105,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 }
             }
         }
-        break;
+        return ret;
 #ifdef TARGET_NR_swapoff
     case TARGET_NR_swapoff:
         if (!(p = lock_user_string(arg1)))
             goto efault;
         ret = get_errno(swapoff(p));
         unlock_user(p, arg1, 0);
-        break;
+        return ret;
 #endif
     case TARGET_NR_sysinfo:
         {
@@ -10211,73 +10140,60 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 unlock_user_struct(target_value, arg1, 1);
             }
         }
-        break;
+        return ret;
 #ifdef TARGET_NR_ipc
     case TARGET_NR_ipc:
-        ret = do_ipc(cpu_env, arg1, arg2, arg3, arg4, arg5, arg6);
-        break;
+        return do_ipc(cpu_env, arg1, arg2, arg3, arg4, arg5, arg6);
 #endif
 #ifdef TARGET_NR_semget
     case TARGET_NR_semget:
-        ret = get_errno(semget(arg1, arg2, arg3));
-        break;
+        return get_errno(semget(arg1, arg2, arg3));
 #endif
 #ifdef TARGET_NR_semop
     case TARGET_NR_semop:
-        ret = do_semop(arg1, arg2, arg3);
-        break;
+        return do_semop(arg1, arg2, arg3);
 #endif
 #ifdef TARGET_NR_semctl
     case TARGET_NR_semctl:
-        ret = do_semctl(arg1, arg2, arg3, arg4);
-        break;
+        return do_semctl(arg1, arg2, arg3, arg4);
 #endif
 #ifdef TARGET_NR_msgctl
     case TARGET_NR_msgctl:
-        ret = do_msgctl(arg1, arg2, arg3);
-        break;
+        return do_msgctl(arg1, arg2, arg3);
 #endif
 #ifdef TARGET_NR_msgget
     case TARGET_NR_msgget:
-        ret = get_errno(msgget(arg1, arg2));
-        break;
+        return get_errno(msgget(arg1, arg2));
 #endif
 #ifdef TARGET_NR_msgrcv
     case TARGET_NR_msgrcv:
-        ret = do_msgrcv(arg1, arg2, arg3, arg4, arg5);
-        break;
+        return do_msgrcv(arg1, arg2, arg3, arg4, arg5);
 #endif
 #ifdef TARGET_NR_msgsnd
     case TARGET_NR_msgsnd:
-        ret = do_msgsnd(arg1, arg2, arg3, arg4);
-        break;
+        return do_msgsnd(arg1, arg2, arg3, arg4);
 #endif
 #ifdef TARGET_NR_shmget
     case TARGET_NR_shmget:
-        ret = get_errno(shmget(arg1, arg2, arg3));
-        break;
+        return get_errno(shmget(arg1, arg2, arg3));
 #endif
 #ifdef TARGET_NR_shmctl
     case TARGET_NR_shmctl:
-        ret = do_shmctl(arg1, arg2, arg3);
-        break;
+        return do_shmctl(arg1, arg2, arg3);
 #endif
 #ifdef TARGET_NR_shmat
     case TARGET_NR_shmat:
-        ret = do_shmat(cpu_env, arg1, arg2, arg3);
-        break;
+        return do_shmat(cpu_env, arg1, arg2, arg3);
 #endif
 #ifdef TARGET_NR_shmdt
     case TARGET_NR_shmdt:
-        ret = do_shmdt(arg1);
-        break;
+        return do_shmdt(arg1);
 #endif
     case TARGET_NR_fsync:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = get_errno(fsync(arg1));
-        break;
+        return get_errno(fsync(arg1));
     case TARGET_NR_clone:
         /* Linux manages to have three different orderings for its
          * arguments to clone(); the BACKWARDS and BACKWARDS2 defines
@@ -10294,7 +10210,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #else
         ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg5, arg4));
 #endif
-        break;
+        return ret;
 #ifdef __NR_exit_group
         /* new thread calls */
     case TARGET_NR_exit_group:
@@ -10302,15 +10218,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         _mcleanup();
 #endif
         gdb_exit(cpu_env, arg1);
-        ret = get_errno(exit_group(arg1));
-        break;
+        return get_errno(exit_group(arg1));
 #endif
     case TARGET_NR_setdomainname:
         if (!(p = lock_user_string(arg1)))
             goto efault;
         ret = get_errno(setdomainname(p, arg2));
         unlock_user(p, arg1, 0);
-        break;
+        return ret;
     case TARGET_NR_uname:
         /* no need to transcode because we use the linux syscall */
         {
@@ -10331,17 +10246,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             }
             unlock_user_struct(buf, arg1, 1);
         }
-        break;
+        return ret;
 #ifdef TARGET_I386
     case TARGET_NR_modify_ldt:
-        ret = do_modify_ldt(cpu_env, arg1, arg2, arg3);
-        break;
+        return do_modify_ldt(cpu_env, arg1, arg2, arg3);
 #if !defined(TARGET_X86_64)
     case TARGET_NR_vm86old:
         goto unimplemented;
     case TARGET_NR_vm86:
-        ret = do_vm86(cpu_env, arg1, arg2);
-        break;
+        return do_vm86(cpu_env, arg1, arg2);
 #endif
 #endif
     case TARGET_NR_adjtimex:
@@ -10358,7 +10271,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 }
             }
         }
-        break;
+        return ret;
 #if defined(TARGET_NR_clock_adjtime) && defined(CONFIG_CLOCK_ADJTIME)
     case TARGET_NR_clock_adjtime:
         {
@@ -10374,7 +10287,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 }
             }
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_create_module
     case TARGET_NR_create_module:
@@ -10388,14 +10301,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
     case TARGET_NR_quotactl:
         goto unimplemented;
     case TARGET_NR_getpgid:
-        ret = get_errno(getpgid(arg1));
-        break;
+        return get_errno(getpgid(arg1));
     case TARGET_NR_fchdir:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = get_errno(fchdir(arg1));
-        break;
+        return get_errno(fchdir(arg1));
 #ifdef TARGET_NR_bdflush /* not on x86_64 */
     case TARGET_NR_bdflush:
         goto unimplemented;
@@ -10405,8 +10316,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         goto unimplemented;
 #endif
     case TARGET_NR_personality:
-        ret = get_errno(personality(arg1));
-        break;
+        return get_errno(personality(arg1));
 #ifdef TARGET_NR_afs_syscall
     case TARGET_NR_afs_syscall:
         goto unimplemented;
@@ -10431,7 +10341,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 goto efault;
             }
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_getdents
     case TARGET_NR_getdents:
@@ -10566,7 +10476,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             unlock_user(dirp, arg2, ret);
         }
 #endif
-        break;
+        return ret;
 #endif /* TARGET_NR_getdents */
 #if defined(TARGET_NR_getdents64) && defined(__NR_getdents64)
     case TARGET_NR_getdents64:
@@ -10596,12 +10506,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             }
             unlock_user(dirp, arg2, ret);
         }
-        break;
+        return ret;
 #endif /* TARGET_NR_getdents64 */
 #if defined(TARGET_NR__newselect)
     case TARGET_NR__newselect:
-        ret = do_select(arg1, arg2, arg3, arg4, arg5);
-        break;
+        return do_select(arg1, arg2, arg3, arg4, arg5);
 #endif
 #if defined(TARGET_NR_poll) || defined(TARGET_NR_ppoll)
 # ifdef TARGET_NR_poll
@@ -10620,8 +10529,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             target_pfd = NULL;
             if (nfds) {
                 if (nfds > (INT_MAX / sizeof(struct target_pollfd))) {
-                    ret = -TARGET_EINVAL;
-                    break;
+                    return -TARGET_EINVAL;
                 }
 
                 target_pfd = lock_user(VERIFY_WRITE, arg1,
@@ -10666,8 +10574,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 if (arg4) {
                     if (arg5 != sizeof(target_sigset_t)) {
                         unlock_user(target_pfd, arg1, 0);
-                        ret = -TARGET_EINVAL;
-                        break;
+                        return -TARGET_EINVAL;
                     }
 
                     target_set = lock_user(VERIFY_READ, arg4, sizeof(target_sigset_t), 1);
@@ -10689,7 +10596,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 if (arg4) {
                     unlock_user(target_set, arg4, 0);
                 }
-                break;
+                return ret;
             }
 # endif
 # ifdef TARGET_NR_poll
@@ -10706,8 +10613,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                     /* -ve poll() timeout means "infinite" */
                     pts = NULL;
                 }
-                ret = get_errno(safe_ppoll(pfd, nfds, pts, NULL, 0));
-                break;
+                return get_errno(safe_ppoll(pfd, nfds, pts, NULL, 0));
             }
 # endif
             default:
@@ -10721,7 +10627,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             }
             unlock_user(target_pfd, arg1, sizeof(struct target_pollfd) * nfds);
         }
-        break;
+        return ret;
 #endif
     case TARGET_NR_flock:
         /* NOTE: the flock constant seems to be the same for every
@@ -10729,8 +10635,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = get_errno(safe_flock(arg1, arg2));
-        break;
+        return get_errno(safe_flock(arg1, arg2));
     case TARGET_NR_readv:
         if (is_hostfd(arg1)) {
             goto ebadf;
@@ -10743,7 +10648,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 ret = -host_to_target_errno(errno);
             }
         }
-        break;
+        return ret;
     case TARGET_NR_writev:
         if (is_hostfd(arg1)) {
             goto ebadf;
@@ -10756,7 +10661,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 ret = -host_to_target_errno(errno);
             }
         }
-        break;
+        return ret;
 #if defined(TARGET_NR_preadv)
     case TARGET_NR_preadv:
         if (is_hostfd(arg1)) {
@@ -10773,7 +10678,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 ret = -host_to_target_errno(errno);
            }
         }
-        break;
+        return ret;
 #endif
 #if defined(TARGET_NR_pwritev)
     case TARGET_NR_pwritev:
@@ -10791,25 +10696,22 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 ret = -host_to_target_errno(errno);
            }
         }
-        break;
+        return ret;
 #endif
     case TARGET_NR_getsid:
-        ret = get_errno(getsid(arg1));
-        break;
+        return get_errno(getsid(arg1));
 #if defined(TARGET_NR_fdatasync) /* Not on alpha (osf_datasync ?) */
     case TARGET_NR_fdatasync:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = get_errno(fdatasync(arg1));
-        break;
+        return get_errno(fdatasync(arg1));
 #endif
 #ifdef TARGET_NR__sysctl
     case TARGET_NR__sysctl:
         /* We don't implement this, but ENOTDIR is always a safe
            return value. */
-        ret = -TARGET_ENOTDIR;
-        break;
+        return -TARGET_ENOTDIR;
 #endif
     case TARGET_NR_sched_getaffinity:
         {
@@ -10821,8 +10723,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
              * care of mismatches between target ulong and host ulong sizes.
              */
             if (arg2 & (sizeof(abi_ulong) - 1)) {
-                ret = -TARGET_EINVAL;
-                break;
+                return -TARGET_EINVAL;
             }
             mask_size = (arg2 + (sizeof(*mask) - 1)) & ~(sizeof(*mask) - 1);
 
@@ -10841,8 +10742,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                      */
                     int numcpus = sysconf(_SC_NPROCESSORS_CONF);
                     if (numcpus > arg2 * 8) {
-                        ret = -TARGET_EINVAL;
-                        break;
+                        return -TARGET_EINVAL;
                     }
                     ret = arg2;
                 }
@@ -10852,7 +10752,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 }
             }
         }
-        break;
+        return ret;
     case TARGET_NR_sched_setaffinity:
         {
             unsigned int mask_size;
@@ -10863,20 +10763,18 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
              * care of mismatches between target ulong and host ulong sizes.
              */
             if (arg2 & (sizeof(abi_ulong) - 1)) {
-                ret = -TARGET_EINVAL;
-                break;
+                return -TARGET_EINVAL;
             }
             mask_size = (arg2 + (sizeof(*mask) - 1)) & ~(sizeof(*mask) - 1);
             mask = alloca(mask_size);
 
             ret = target_to_host_cpu_mask(mask, mask_size, arg3, arg2);
             if (ret) {
-                break;
+                return ret;
             }
 
-            ret = get_errno(sys_sched_setaffinity(arg1, mask_size, mask));
+            return get_errno(sys_sched_setaffinity(arg1, mask_size, mask));
         }
-        break;
     case TARGET_NR_getcpu:
         {
             unsigned cpu, node;
@@ -10893,7 +10791,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 goto efault;
             }
         }
-        break;
+        return ret;
     case TARGET_NR_sched_setparam:
         {
             struct sched_param *target_schp;
@@ -10906,9 +10804,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 goto efault;
             schp.sched_priority = tswap32(target_schp->sched_priority);
             unlock_user_struct(target_schp, arg2, 0);
-            ret = get_errno(sched_setparam(arg1, &schp));
+            return get_errno(sched_setparam(arg1, &schp));
         }
-        break;
     case TARGET_NR_sched_getparam:
         {
             struct sched_param *target_schp;
@@ -10925,7 +10822,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 unlock_user_struct(target_schp, arg2, 1);
             }
         }
-        break;
+        return ret;
     case TARGET_NR_sched_setscheduler:
         {
             struct sched_param *target_schp;
@@ -10937,21 +10834,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 goto efault;
             schp.sched_priority = tswap32(target_schp->sched_priority);
             unlock_user_struct(target_schp, arg3, 0);
-            ret = get_errno(sched_setscheduler(arg1, arg2, &schp));
+            return get_errno(sched_setscheduler(arg1, arg2, &schp));
         }
-        break;
     case TARGET_NR_sched_getscheduler:
-        ret = get_errno(sched_getscheduler(arg1));
-        break;
+        return get_errno(sched_getscheduler(arg1));
     case TARGET_NR_sched_yield:
-        ret = get_errno(sched_yield());
-        break;
+        return get_errno(sched_yield());
     case TARGET_NR_sched_get_priority_max:
-        ret = get_errno(sched_get_priority_max(arg1));
-        break;
+        return get_errno(sched_get_priority_max(arg1));
     case TARGET_NR_sched_get_priority_min:
-        ret = get_errno(sched_get_priority_min(arg1));
-        break;
+        return get_errno(sched_get_priority_min(arg1));
     case TARGET_NR_sched_rr_get_interval:
         {
             struct timespec ts;
@@ -10960,7 +10852,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 ret = host_to_target_timespec(arg2, &ts);
             }
         }
-        break;
+        return ret;
     case TARGET_NR_nanosleep:
         {
             struct timespec req, rem;
@@ -10970,7 +10862,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 host_to_target_timespec(arg2, &rem);
             }
         }
-        break;
+        return ret;
 #ifdef TARGET_NR_query_module
     case TARGET_NR_query_module:
         goto unimplemented;
@@ -10989,7 +10881,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 && put_user_ual(deathsig, arg2)) {
                 goto efault;
             }
-            break;
+            return ret;
         }
 #ifdef PR_GET_NAME
         case PR_GET_NAME:
@@ -11001,7 +10893,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(prctl(arg1, (unsigned long)name,
                                   arg3, arg4, arg5));
             unlock_user(name, arg2, 16);
-            break;
+            return ret;
         }
         case PR_SET_NAME:
         {
@@ -11012,7 +10904,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(prctl(arg1, (unsigned long)name,
                                   arg3, arg4, arg5));
             unlock_user(name, arg2, 0);
-            break;
+            return ret;
         }
 #endif
 #ifdef TARGET_AARCH64
@@ -11033,32 +10925,29 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 env->vfp.zcr_el[1] = vq - 1;
                 ret = vq * 16;
             }
-            break;
+            return ret;
         case TARGET_PR_SVE_GET_VL:
             ret = -TARGET_EINVAL;
             if (arm_feature(cpu_env, ARM_FEATURE_SVE)) {
                 CPUARMState *env = cpu_env;
                 ret = ((env->vfp.zcr_el[1] & 0xf) + 1) * 16;
             }
-            break;
+            return ret;
 #endif /* AARCH64 */
         case PR_GET_SECCOMP:
         case PR_SET_SECCOMP:
             /* Disable seccomp to prevent the target disabling syscalls we
              * need. */
-            ret = -TARGET_EINVAL;
-            break;
+            return -TARGET_EINVAL;
         default:
             /* Most prctl options have no pointer arguments */
-            ret = get_errno(prctl(arg1, arg2, arg3, arg4, arg5));
-            break;
+            return get_errno(prctl(arg1, arg2, arg3, arg4, arg5));
         }
         break;
 #ifdef TARGET_NR_arch_prctl
     case TARGET_NR_arch_prctl:
 #if defined(TARGET_I386) && !defined(TARGET_ABI32)
-        ret = do_arch_prctl(cpu_env, arg1, arg2);
-        break;
+        return do_arch_prctl(cpu_env, arg1, arg2);
 #else
         goto unimplemented;
 #endif
@@ -11076,7 +10965,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             goto efault;
         ret = get_errno(pread64(arg1, p, arg3, target_offset64(arg4, arg5)));
         unlock_user(p, arg2, ret);
-        break;
+        return ret;
     case TARGET_NR_pwrite64:
         if (is_hostfd(arg1)) {
             goto ebadf;
@@ -11089,14 +10978,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             goto efault;
         ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5)));
         unlock_user(p, arg2, 0);
-        break;
+        return ret;
 #endif
     case TARGET_NR_getcwd:
         if (!(p = lock_user(VERIFY_WRITE, arg1, arg2, 0)))
             goto efault;
         ret = get_errno(sys_getcwd1(p, arg2));
         unlock_user(p, arg1, ret);
-        break;
+        return ret;
     case TARGET_NR_capget:
     case TARGET_NR_capset:
     {
@@ -11165,11 +11054,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 unlock_user(target_data, arg2, 0);
             }
         }
-        break;
+        return ret;
     }
     case TARGET_NR_sigaltstack:
-        ret = do_sigaltstack(arg1, arg2, get_sp_from_cpustate((CPUArchState *)cpu_env));
-        break;
+        return do_sigaltstack(arg1, arg2,
+                              get_sp_from_cpustate((CPUArchState *)cpu_env));
 
 #ifdef CONFIG_SENDFILE
     case TARGET_NR_sendfile:
@@ -11183,7 +11072,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         if (arg3) {
             ret = get_user_sal(off, arg3);
             if (is_error(ret)) {
-                break;
+                return ret;
             }
             offp = &off;
         }
@@ -11194,7 +11083,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 ret = ret2;
             }
         }
-        break;
+        return ret;
     }
 #ifdef TARGET_NR_sendfile64
     case TARGET_NR_sendfile64:
@@ -11208,7 +11097,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         if (arg3) {
             ret = get_user_s64(off, arg3);
             if (is_error(ret)) {
-                break;
+                return ret;
             }
             offp = &off;
         }
@@ -11219,7 +11108,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 ret = ret2;
             }
         }
-        break;
+        return ret;
     }
 #endif
 #else
@@ -11240,10 +11129,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
 #ifdef TARGET_NR_vfork
     case TARGET_NR_vfork:
-        ret = get_errno(do_fork(cpu_env,
-                        CLONE_VFORK | CLONE_VM | TARGET_SIGCHLD,
-                        0, 0, 0, 0));
-        break;
+        return get_errno(do_fork(cpu_env,
+                         CLONE_VFORK | CLONE_VM | TARGET_SIGCHLD,
+                         0, 0, 0, 0));
 #endif
 #ifdef TARGET_NR_ugetrlimit
     case TARGET_NR_ugetrlimit:
@@ -11259,7 +11147,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 	    target_rlim->rlim_max = host_to_target_rlim(rlim.rlim_max);
             unlock_user_struct(target_rlim, arg2, 1);
 	}
-	break;
+	return ret;
     }
 #endif
 #ifdef TARGET_NR_truncate64
@@ -11268,15 +11156,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             goto efault;
 	ret = target_truncate64(cpu_env, p, arg2, arg3, arg4);
         unlock_user(p, arg1, 0);
-	break;
+	return ret;
 #endif
 #ifdef TARGET_NR_ftruncate64
     case TARGET_NR_ftruncate64:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-	ret = target_ftruncate64(cpu_env, arg1, arg2, arg3, arg4);
-	break;
+	return target_ftruncate64(cpu_env, arg1, arg2, arg3, arg4);
 #endif
 #ifdef TARGET_NR_stat64
     case TARGET_NR_stat64:
@@ -11290,7 +11177,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         unlock_user(fn, arg1, 0);
         if (!is_error(ret))
             ret = host_to_target_stat64(cpu_env, arg2, &st);
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_lstat64
     case TARGET_NR_lstat64:
@@ -11304,7 +11191,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         unlock_user(fn, arg1, 0);
         if (!is_error(ret))
             ret = host_to_target_stat64(cpu_env, arg2, &st);
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_fstat64
     case TARGET_NR_fstat64:
@@ -11314,7 +11201,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         ret = get_errno(fstat(arg1, &st));
         if (!is_error(ret))
             ret = host_to_target_stat64(cpu_env, arg2, &st);
-        break;
+        return ret;
 #endif
 #if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat))
 #ifdef TARGET_NR_fstatat64
@@ -11336,7 +11223,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         unlock_user(fn, arg2, 0);
         if (!is_error(ret))
             ret = host_to_target_stat64(cpu_env, arg3, &st);
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_lchown
     case TARGET_NR_lchown:
@@ -11344,34 +11231,28 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             goto efault;
         ret = get_errno(lchown(p, low2highuid(arg2), low2highgid(arg3)));
         unlock_user(p, arg1, 0);
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_getuid
     case TARGET_NR_getuid:
-        ret = get_errno(high2lowuid(getuid()));
-        break;
+        return get_errno(high2lowuid(getuid()));
 #endif
 #ifdef TARGET_NR_getgid
     case TARGET_NR_getgid:
-        ret = get_errno(high2lowgid(getgid()));
-        break;
+        return get_errno(high2lowgid(getgid()));
 #endif
 #ifdef TARGET_NR_geteuid
     case TARGET_NR_geteuid:
-        ret = get_errno(high2lowuid(geteuid()));
-        break;
+        return get_errno(high2lowuid(geteuid()));
 #endif
 #ifdef TARGET_NR_getegid
     case TARGET_NR_getegid:
-        ret = get_errno(high2lowgid(getegid()));
-        break;
+        return get_errno(high2lowgid(getegid()));
 #endif
     case TARGET_NR_setreuid:
-        ret = get_errno(setreuid(low2highuid(arg1), low2highuid(arg2)));
-        break;
+        return get_errno(setreuid(low2highuid(arg1), low2highuid(arg2)));
     case TARGET_NR_setregid:
-        ret = get_errno(setregid(low2highgid(arg1), low2highgid(arg2)));
-        break;
+        return get_errno(setregid(low2highgid(arg1), low2highgid(arg2)));
     case TARGET_NR_getgroups:
         {
             int gidsetsize = arg1;
@@ -11382,7 +11263,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             grouplist = alloca(gidsetsize * sizeof(gid_t));
             ret = get_errno(getgroups(gidsetsize, grouplist));
             if (gidsetsize == 0)
-                break;
+                return ret;
             if (!is_error(ret)) {
                 target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * sizeof(target_id), 0);
                 if (!target_grouplist)
@@ -11392,7 +11273,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 unlock_user(target_grouplist, arg2, gidsetsize * sizeof(target_id));
             }
         }
-        break;
+        return ret;
     case TARGET_NR_setgroups:
         {
             int gidsetsize = arg1;
@@ -11411,12 +11292,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 }
                 unlock_user(target_grouplist, arg2, 0);
             }
-            ret = get_errno(setgroups(gidsetsize, grouplist));
+            return get_errno(setgroups(gidsetsize, grouplist));
         }
-        break;
     case TARGET_NR_fchown:
-        ret = get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3)));
-        break;
+        return get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3)));
 #if defined(TARGET_NR_fchownat)
     case TARGET_NR_fchownat:
         if (is_hostfd(arg1)) {
@@ -11427,14 +11306,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         ret = get_errno(fchownat(arg1, p, low2highuid(arg3),
                                  low2highgid(arg4), arg5));
         unlock_user(p, arg2, 0);
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_setresuid
     case TARGET_NR_setresuid:
-        ret = get_errno(sys_setresuid(low2highuid(arg1),
-                                      low2highuid(arg2),
-                                      low2highuid(arg3)));
-        break;
+        return get_errno(sys_setresuid(low2highuid(arg1),
+                                       low2highuid(arg2),
+                                       low2highuid(arg3)));
 #endif
 #ifdef TARGET_NR_getresuid
     case TARGET_NR_getresuid:
@@ -11448,14 +11326,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                     goto efault;
             }
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_getresgid
     case TARGET_NR_setresgid:
-        ret = get_errno(sys_setresgid(low2highgid(arg1),
-                                      low2highgid(arg2),
-                                      low2highgid(arg3)));
-        break;
+        return get_errno(sys_setresgid(low2highgid(arg1),
+                                       low2highgid(arg2),
+                                       low2highgid(arg3)));
 #endif
 #ifdef TARGET_NR_getresgid
     case TARGET_NR_getresgid:
@@ -11469,7 +11346,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                     goto efault;
             }
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_chown
     case TARGET_NR_chown:
@@ -11477,20 +11354,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             goto efault;
         ret = get_errno(chown(p, low2highuid(arg2), low2highgid(arg3)));
         unlock_user(p, arg1, 0);
-        break;
+        return ret;
 #endif
     case TARGET_NR_setuid:
-        ret = get_errno(sys_setuid(low2highuid(arg1)));
-        break;
+        return get_errno(sys_setuid(low2highuid(arg1)));
     case TARGET_NR_setgid:
-        ret = get_errno(sys_setgid(low2highgid(arg1)));
-        break;
+        return get_errno(sys_setgid(low2highgid(arg1)));
     case TARGET_NR_setfsuid:
-        ret = get_errno(setfsuid(arg1));
-        break;
+        return get_errno(setfsuid(arg1));
     case TARGET_NR_setfsgid:
-        ret = get_errno(setfsgid(arg1));
-        break;
+        return get_errno(setfsgid(arg1));
 
 #ifdef TARGET_NR_lchown32
     case TARGET_NR_lchown32:
@@ -11498,12 +11371,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             goto efault;
         ret = get_errno(lchown(p, arg2, arg3));
         unlock_user(p, arg1, 0);
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_getuid32
     case TARGET_NR_getuid32:
-        ret = get_errno(getuid());
-        break;
+        return get_errno(getuid());
 #endif
 
 #if defined(TARGET_NR_getxuid) && defined(TARGET_ALPHA)
@@ -11514,8 +11386,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             euid=geteuid();
             ((CPUAlphaState *)cpu_env)->ir[IR_A4]=euid;
          }
-        ret = get_errno(getuid());
-        break;
+        return get_errno(getuid());
 #endif
 #if defined(TARGET_NR_getxgid) && defined(TARGET_ALPHA)
    /* Alpha specific */
@@ -11525,8 +11396,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             egid=getegid();
             ((CPUAlphaState *)cpu_env)->ir[IR_A4]=egid;
          }
-        ret = get_errno(getgid());
-        break;
+        return get_errno(getgid());
 #endif
 #if defined(TARGET_NR_osf_getsysinfo) && defined(TARGET_ALPHA)
     /* Alpha specific */
@@ -11564,7 +11434,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
              -- Grabs a copy of the HWRPB; surely not used.
           */
         }
-        break;
+        return ret;
 #endif
 #if defined(TARGET_NR_osf_setsysinfo) && defined(TARGET_ALPHA)
     /* Alpha specific */
@@ -11655,7 +11525,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
              -- Not implemented in linux kernel
           */
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_osf_sigprocmask
     /* Alpha specific.  */
@@ -11687,33 +11557,28 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 ret = mask;
             }
         }
-        break;
+        return ret;
 #endif
 
 #ifdef TARGET_NR_getgid32
     case TARGET_NR_getgid32:
-        ret = get_errno(getgid());
-        break;
+        return get_errno(getgid());
 #endif
 #ifdef TARGET_NR_geteuid32
     case TARGET_NR_geteuid32:
-        ret = get_errno(geteuid());
-        break;
+        return get_errno(geteuid());
 #endif
 #ifdef TARGET_NR_getegid32
     case TARGET_NR_getegid32:
-        ret = get_errno(getegid());
-        break;
+        return get_errno(getegid());
 #endif
 #ifdef TARGET_NR_setreuid32
     case TARGET_NR_setreuid32:
-        ret = get_errno(setreuid(arg1, arg2));
-        break;
+        return get_errno(setreuid(arg1, arg2));
 #endif
 #ifdef TARGET_NR_setregid32
     case TARGET_NR_setregid32:
-        ret = get_errno(setregid(arg1, arg2));
-        break;
+        return get_errno(setregid(arg1, arg2));
 #endif
 #ifdef TARGET_NR_getgroups32
     case TARGET_NR_getgroups32:
@@ -11726,7 +11591,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             grouplist = alloca(gidsetsize * sizeof(gid_t));
             ret = get_errno(getgroups(gidsetsize, grouplist));
             if (gidsetsize == 0)
-                break;
+                return ret;
             if (!is_error(ret)) {
                 target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 4, 0);
                 if (!target_grouplist) {
@@ -11738,7 +11603,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 unlock_user(target_grouplist, arg2, gidsetsize * 4);
             }
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_setgroups32
     case TARGET_NR_setgroups32:
@@ -11757,22 +11622,19 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             for(i = 0;i < gidsetsize; i++)
                 grouplist[i] = tswap32(target_grouplist[i]);
             unlock_user(target_grouplist, arg2, 0);
-            ret = get_errno(setgroups(gidsetsize, grouplist));
+            return get_errno(setgroups(gidsetsize, grouplist));
         }
-        break;
 #endif
 #ifdef TARGET_NR_fchown32
     case TARGET_NR_fchown32:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = get_errno(fchown(arg1, arg2, arg3));
-        break;
+        return get_errno(fchown(arg1, arg2, arg3));
 #endif
 #ifdef TARGET_NR_setresuid32
     case TARGET_NR_setresuid32:
-        ret = get_errno(sys_setresuid(arg1, arg2, arg3));
-        break;
+        return get_errno(sys_setresuid(arg1, arg2, arg3));
 #endif
 #ifdef TARGET_NR_getresuid32
     case TARGET_NR_getresuid32:
@@ -11786,12 +11648,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                     goto efault;
             }
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_setresgid32
     case TARGET_NR_setresgid32:
-        ret = get_errno(sys_setresgid(arg1, arg2, arg3));
-        break;
+        return get_errno(sys_setresgid(arg1, arg2, arg3));
 #endif
 #ifdef TARGET_NR_getresgid32
     case TARGET_NR_getresgid32:
@@ -11805,7 +11666,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                     goto efault;
             }
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_chown32
     case TARGET_NR_chown32:
@@ -11813,27 +11674,23 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             goto efault;
         ret = get_errno(chown(p, arg2, arg3));
         unlock_user(p, arg1, 0);
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_setuid32
     case TARGET_NR_setuid32:
-        ret = get_errno(sys_setuid(arg1));
-        break;
+        return get_errno(sys_setuid(arg1));
 #endif
 #ifdef TARGET_NR_setgid32
     case TARGET_NR_setgid32:
-        ret = get_errno(sys_setgid(arg1));
-        break;
+        return get_errno(sys_setgid(arg1));
 #endif
 #ifdef TARGET_NR_setfsuid32
     case TARGET_NR_setfsuid32:
-        ret = get_errno(setfsuid(arg1));
-        break;
+        return get_errno(setfsuid(arg1));
 #endif
 #ifdef TARGET_NR_setfsgid32
     case TARGET_NR_setfsgid32:
-        ret = get_errno(setfsgid(arg1));
-        break;
+        return get_errno(setfsgid(arg1));
 #endif
 
     case TARGET_NR_pivot_root:
@@ -11857,7 +11714,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             mincore_fail:
             unlock_user(a, arg1, 0);
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_arm_fadvise64_64
     case TARGET_NR_arm_fadvise64_64:
@@ -11872,8 +11729,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         }
         ret = posix_fadvise(arg1, target_offset64(arg3, arg4),
                             target_offset64(arg5, arg6), arg2);
-        ret = -host_to_target_errno(ret);
-        break;
+        return -host_to_target_errno(ret);
 #endif
 
 #if TARGET_ABI_BITS == 32
@@ -11902,11 +11758,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             arg6 = arg7;
         }
 #endif
-        ret = -host_to_target_errno(posix_fadvise(arg1,
-                                                  target_offset64(arg2, arg3),
-                                                  target_offset64(arg4, arg5),
-                                                  arg6));
-        break;
+        ret = posix_fadvise(arg1, target_offset64(arg2, arg3),
+                            target_offset64(arg4, arg5), arg6);
+        return -host_to_target_errno(ret);
 #endif
 
 #ifdef TARGET_NR_fadvise64
@@ -11922,10 +11776,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             arg4 = arg5;
             arg5 = arg6;
         }
-        ret = -host_to_target_errno(posix_fadvise(arg1,
-                                                  target_offset64(arg2, arg3),
-                                                  arg4, arg5));
-        break;
+        ret = posix_fadvise(arg1, target_offset64(arg2, arg3), arg4, arg5);
+        return -host_to_target_errno(ret);
 #endif
 
 #else /* not a 32-bit ABI */
@@ -11948,8 +11800,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         default: break;
         }
 #endif
-        ret = -host_to_target_errno(posix_fadvise(arg1, arg2, arg3, arg4));
-        break;
+        return -host_to_target_errno(posix_fadvise(arg1, arg2, arg3, arg4));
 #endif
 #endif /* end of 64-bit ABI fadvise handling */
 
@@ -11959,8 +11810,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
            turns private file-backed mappings into anonymous mappings.
            This will break MADV_DONTNEED.
            This is a hint, so ignoring and returning success is ok.  */
-        ret = get_errno(0);
-        break;
+        return 0;
 #endif
 #if TARGET_ABI_BITS == 32
     case TARGET_NR_fcntl64:
@@ -11982,8 +11832,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 
 	cmd = target_to_host_fcntl_cmd(arg2);
         if (cmd == -TARGET_EINVAL) {
-            ret = cmd;
-            break;
+            return cmd;
         }
 
         switch(arg2) {
@@ -12010,14 +11859,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = do_fcntl(arg1, arg2, arg3);
             break;
         }
-	break;
+	return ret;
     }
 #endif
 #ifdef TARGET_NR_cacheflush
     case TARGET_NR_cacheflush:
         /* self-modifying code is handled automatically, so nothing needed */
-        ret = 0;
-        break;
+        return 0;
 #endif
 #ifdef TARGET_NR_security
     case TARGET_NR_security:
@@ -12025,12 +11873,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
 #ifdef TARGET_NR_getpagesize
     case TARGET_NR_getpagesize:
-        ret = TARGET_PAGE_SIZE;
-        break;
+        return TARGET_PAGE_SIZE;
 #endif
     case TARGET_NR_gettid:
-        ret = get_errno(gettid());
-        break;
+        return get_errno(gettid());
 #ifdef TARGET_NR_readahead
     case TARGET_NR_readahead:
 #if TARGET_ABI_BITS == 32
@@ -12043,7 +11889,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #else
         ret = get_errno(readahead(arg1, arg2, arg3));
 #endif
-        break;
+        return ret;
 #endif
 #ifdef CONFIG_ATTR
 #ifdef TARGET_NR_setxattr
@@ -12054,8 +11900,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         if (arg2) {
             b = lock_user(VERIFY_WRITE, arg2, arg3, 0);
             if (!b) {
-                ret = -TARGET_EFAULT;
-                break;
+                return -TARGET_EFAULT;
             }
         }
         p = lock_user_string(arg1);
@@ -12070,7 +11915,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         }
         unlock_user(p, arg1, 0);
         unlock_user(b, arg2, arg3);
-        break;
+        return ret;
     }
     case TARGET_NR_flistxattr:
     {
@@ -12078,13 +11923,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         if (arg2) {
             b = lock_user(VERIFY_WRITE, arg2, arg3, 0);
             if (!b) {
-                ret = -TARGET_EFAULT;
-                break;
+                return -TARGET_EFAULT;
             }
         }
         ret = get_errno(flistxattr(arg1, b, arg3));
         unlock_user(b, arg2, arg3);
-        break;
+        return ret;
     }
     case TARGET_NR_setxattr:
     case TARGET_NR_lsetxattr:
@@ -12093,8 +11937,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             if (arg3) {
                 v = lock_user(VERIFY_READ, arg3, arg4, 1);
                 if (!v) {
-                    ret = -TARGET_EFAULT;
-                    break;
+                    return -TARGET_EFAULT;
                 }
             }
             p = lock_user_string(arg1);
@@ -12112,7 +11955,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             unlock_user(n, arg2, 0);
             unlock_user(v, arg3, 0);
         }
-        break;
+        return ret;
     case TARGET_NR_fsetxattr:
         if (is_hostfd(arg1)) {
             goto ebadf;
@@ -12121,8 +11964,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             if (arg3) {
                 v = lock_user(VERIFY_READ, arg3, arg4, 1);
                 if (!v) {
-                    ret = -TARGET_EFAULT;
-                    break;
+                    return -TARGET_EFAULT;
                 }
             }
             n = lock_user_string(arg2);
@@ -12134,7 +11976,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             unlock_user(n, arg2, 0);
             unlock_user(v, arg3, 0);
         }
-        break;
+        return ret;
     case TARGET_NR_getxattr:
     case TARGET_NR_lgetxattr:
         {
@@ -12142,8 +11984,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             if (arg3) {
                 v = lock_user(VERIFY_WRITE, arg3, arg4, 0);
                 if (!v) {
-                    ret = -TARGET_EFAULT;
-                    break;
+                    return -TARGET_EFAULT;
                 }
             }
             p = lock_user_string(arg1);
@@ -12161,7 +12002,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             unlock_user(n, arg2, 0);
             unlock_user(v, arg3, arg4);
         }
-        break;
+        return ret;
     case TARGET_NR_fgetxattr:
         if (is_hostfd(arg1)) {
             goto ebadf;
@@ -12170,8 +12011,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             if (arg3) {
                 v = lock_user(VERIFY_WRITE, arg3, arg4, 0);
                 if (!v) {
-                    ret = -TARGET_EFAULT;
-                    break;
+                    return -TARGET_EFAULT;
                 }
             }
             n = lock_user_string(arg2);
@@ -12183,7 +12023,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             unlock_user(n, arg2, 0);
             unlock_user(v, arg3, arg4);
         }
-        break;
+        return ret;
     case TARGET_NR_removexattr:
     case TARGET_NR_lremovexattr:
         {
@@ -12202,7 +12042,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             unlock_user(p, arg1, 0);
             unlock_user(n, arg2, 0);
         }
-        break;
+        return ret;
     case TARGET_NR_fremovexattr:
         if (is_hostfd(arg1)) {
             goto ebadf;
@@ -12216,15 +12056,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             }
             unlock_user(n, arg2, 0);
         }
-        break;
+        return ret;
 #endif
 #endif /* CONFIG_ATTR */
 #ifdef TARGET_NR_set_thread_area
     case TARGET_NR_set_thread_area:
 #if defined(TARGET_MIPS)
       ((CPUMIPSState *) cpu_env)->active_tc.CP0_UserLocal = arg1;
-      ret = 0;
-      break;
+      return 0;
 #elif defined(TARGET_CRIS)
       if (arg1 & 0xff)
           ret = -TARGET_EINVAL;
@@ -12232,16 +12071,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
           ((CPUCRISState *) cpu_env)->pregs[PR_PID] = arg1;
           ret = 0;
       }
-      break;
+      return ret;
 #elif defined(TARGET_I386) && defined(TARGET_ABI32)
-      ret = do_set_thread_area(cpu_env, arg1);
-      break;
+      return do_set_thread_area(cpu_env, arg1);
 #elif defined(TARGET_M68K)
       {
           TaskState *ts = cpu->opaque;
           ts->tp_value = arg1;
-          ret = 0;
-          break;
+          return 0;
       }
 #else
       goto unimplemented_nowarn;
@@ -12250,13 +12087,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_get_thread_area
     case TARGET_NR_get_thread_area:
 #if defined(TARGET_I386) && defined(TARGET_ABI32)
-        ret = do_get_thread_area(cpu_env, arg1);
-        break;
+        return do_get_thread_area(cpu_env, arg1);
 #elif defined(TARGET_M68K)
         {
             TaskState *ts = cpu->opaque;
-            ret = ts->tp_value;
-            break;
+            return ts->tp_value;
         }
 #else
         goto unimplemented_nowarn;
@@ -12276,7 +12111,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         if (!is_error(ret)) {
             ret = get_errno(clock_settime(arg1, &ts));
         }
-        break;
+        return ret;
     }
 #endif
 #ifdef TARGET_NR_clock_gettime
@@ -12287,7 +12122,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         if (!is_error(ret)) {
             ret = host_to_target_timespec(arg2, &ts);
         }
-        break;
+        return ret;
     }
 #endif
 #ifdef TARGET_NR_clock_getres
@@ -12298,7 +12133,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         if (!is_error(ret)) {
             host_to_target_timespec(arg2, &ts);
         }
-        break;
+        return ret;
     }
 #endif
 #ifdef TARGET_NR_clock_nanosleep
@@ -12318,24 +12153,21 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ((CPUPPCState *)cpu_env)->crf[0] |= 1;
         }
 #endif
-        break;
+        return ret;
     }
 #endif
 
 #if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address)
     case TARGET_NR_set_tid_address:
-        ret = get_errno(set_tid_address((int *)g2h(arg1)));
-        break;
+        return get_errno(set_tid_address((int *)g2h(arg1)));
 #endif
 
     case TARGET_NR_tkill:
-        ret = get_errno(safe_tkill((int)arg1, target_to_host_signal(arg2)));
-        break;
+        return get_errno(safe_tkill((int)arg1, target_to_host_signal(arg2)));
 
     case TARGET_NR_tgkill:
-        ret = get_errno(safe_tgkill((int)arg1, (int)arg2,
-                        target_to_host_signal(arg3)));
-        break;
+        return get_errno(safe_tgkill((int)arg1, (int)arg2,
+                         target_to_host_signal(arg3)));
 
 #ifdef TARGET_NR_set_robust_list
     case TARGET_NR_set_robust_list:
@@ -12381,18 +12213,17 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 unlock_user(fn, arg2, 0);
             }
         }
-	break;
+	return ret;
 #endif
     case TARGET_NR_futex:
-        ret = do_futex(arg1, arg2, arg3, arg4, arg5, arg6);
-        break;
+        return do_futex(arg1, arg2, arg3, arg4, arg5, arg6);
 #if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)
     case TARGET_NR_inotify_init:
         ret = get_errno(sys_inotify_init());
         if (ret >= 0) {
             fd_trans_register(ret, &target_inotify_trans);
         }
-        break;
+        return ret;
 #endif
 #ifdef CONFIG_INOTIFY1
 #if defined(TARGET_NR_inotify_init1) && defined(__NR_inotify_init1)
@@ -12402,7 +12233,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         if (ret >= 0) {
             fd_trans_register(ret, &target_inotify_trans);
         }
-        break;
+        return ret;
 #endif
 #endif
 #if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch)
@@ -12416,15 +12247,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         TRY_INTERP_PATH(ret, fn, sys_inotify_add_watch(arg1, fn, arg3));
         ret = get_errno(ret);
         unlock_user(fn, arg2, 0);
-        break;
+        return ret;
 #endif
 #if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch)
     case TARGET_NR_inotify_rm_watch:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = get_errno(sys_inotify_rm_watch(arg1, arg2));
-        break;
+        return get_errno(sys_inotify_rm_watch(arg1, arg2));
 #endif
 
 #if defined(TARGET_NR_mq_open) && defined(__NR_mq_open)
@@ -12449,17 +12279,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(mq_open(p, host_flags, arg3, pposix_mq_attr));
             unlock_user (p, arg1, 0);
         }
-        break;
+        return ret;
 
     case TARGET_NR_mq_unlink:
         p = lock_user_string(arg1 - 1);
         if (!p) {
-            ret = -TARGET_EFAULT;
-            break;
+            return -TARGET_EFAULT;
         }
         ret = get_errno(mq_unlink(p));
         unlock_user (p, arg1, 0);
-        break;
+        return ret;
 
     case TARGET_NR_mq_timedsend:
         {
@@ -12475,7 +12304,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             }
             unlock_user (p, arg2, arg3);
         }
-        break;
+        return ret;
 
     case TARGET_NR_mq_timedreceive:
         {
@@ -12496,7 +12325,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             if (arg4 != 0)
                 put_user_u32(prio, arg4);
         }
-        break;
+        return ret;
 
     /* Not implemented for now... */
 /*     case TARGET_NR_mq_notify: */
@@ -12517,7 +12346,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 copy_to_user_mq_attr(arg3, &posix_mq_attr_out);
             }
         }
-        break;
+        return ret;
 #endif
 
 #ifdef CONFIG_SPLICE
@@ -12528,7 +12357,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         } else {
             ret = get_errno(tee(arg1,arg2,arg3,arg4));
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_splice
     case TARGET_NR_splice:
@@ -12561,7 +12390,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 }
             }
         }
-        break;
+        return ret;
 #endif
 #ifdef TARGET_NR_vmsplice
     case TARGET_NR_vmsplice:
@@ -12576,7 +12405,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 ret = -host_to_target_errno(errno);
             }
         }
-        break;
+        return ret;
 #endif
 #endif /* CONFIG_SPLICE */
 #ifdef CONFIG_EVENTFD
@@ -12586,7 +12415,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         if (ret >= 0) {
             fd_trans_register(ret, &target_eventfd_trans);
         }
-        break;
+        return ret;
 #endif
 #if defined(TARGET_NR_eventfd2)
     case TARGET_NR_eventfd2:
@@ -12602,7 +12431,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         if (ret >= 0) {
             fd_trans_register(ret, &target_eventfd_trans);
         }
-        break;
+        return ret;
     }
 #endif
 #endif /* CONFIG_EVENTFD  */
@@ -12617,7 +12446,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #else
         ret = get_errno(fallocate(arg1, arg2, arg3, arg4));
 #endif
-        break;
+        return ret;
 #endif
 #if defined(CONFIG_SYNC_FILE_RANGE)
 #if defined(TARGET_NR_sync_file_range)
@@ -12636,7 +12465,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #else
         ret = get_errno(sync_file_range(arg1, arg2, arg3, arg4));
 #endif
-        break;
+        return ret;
 #endif
 #if defined(TARGET_NR_sync_file_range2)
     case TARGET_NR_sync_file_range2:
@@ -12650,7 +12479,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #else
         ret = get_errno(sync_file_range(arg1, arg3, arg4, arg2));
 #endif
-        break;
+        return ret;
 #endif
 #endif
 #if defined(TARGET_NR_signalfd4)
@@ -12658,27 +12487,23 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = do_signalfd4(arg1, arg2, arg4);
-        break;
+        return do_signalfd4(arg1, arg2, arg4);
 #endif
 #if defined(TARGET_NR_signalfd)
     case TARGET_NR_signalfd:
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = do_signalfd4(arg1, arg2, 0);
-        break;
+        return do_signalfd4(arg1, arg2, 0);
 #endif
 #if defined(CONFIG_EPOLL)
 #if defined(TARGET_NR_epoll_create)
     case TARGET_NR_epoll_create:
-        ret = get_errno(epoll_create(arg1));
-        break;
+        return get_errno(epoll_create(arg1));
 #endif
 #if defined(TARGET_NR_epoll_create1) && defined(CONFIG_EPOLL_CREATE1)
     case TARGET_NR_epoll_create1:
-        ret = get_errno(epoll_create1(arg1));
-        break;
+        return get_errno(epoll_create1(arg1));
 #endif
 #if defined(TARGET_NR_epoll_ctl)
     case TARGET_NR_epoll_ctl:
@@ -12703,8 +12528,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             unlock_user_struct(target_ep, arg4, 0);
             epp = &ep;
         }
-        ret = get_errno(epoll_ctl(arg1, arg2, arg3, epp));
-        break;
+        return get_errno(epoll_ctl(arg1, arg2, arg3, epp));
     }
 #endif
 
@@ -12726,8 +12550,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             goto ebadf;
         }
         if (maxevents <= 0 || maxevents > TARGET_EP_MAX_EVENTS) {
-            ret = -TARGET_EINVAL;
-            break;
+            return -TARGET_EINVAL;
         }
 
         target_ep = lock_user(VERIFY_WRITE, arg2,
@@ -12739,8 +12562,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         ep = g_try_new(struct epoll_event, maxevents);
         if (!ep) {
             unlock_user(target_ep, arg2, 0);
-            ret = -TARGET_ENOMEM;
-            break;
+            return -TARGET_ENOMEM;
         }
 
         switch (num) {
@@ -12770,7 +12592,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 
             ret = get_errno(safe_epoll_pwait(epfd, ep, maxevents, timeout,
                                              set, SIGSET_T_SIZE));
-            break;
         }
 #endif
 #if defined(TARGET_NR_epoll_wait)
@@ -12794,7 +12615,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             unlock_user(target_ep, arg2, 0);
         }
         g_free(ep);
-        break;
+        return ret;
     }
 #endif
 #endif
@@ -12824,7 +12645,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             target_rold->rlim_max = tswap64(rold.rlim_max);
             unlock_user_struct(target_rold, arg4, 1);
         }
-        break;
+        return ret;
     }
 #endif
 #ifdef TARGET_NR_gethostname
@@ -12837,7 +12658,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         } else {
             ret = -TARGET_EFAULT;
         }
-        break;
+        return ret;
     }
 #endif
 #ifdef TARGET_NR_atomic_cmpxchg_32
@@ -12858,17 +12679,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         }
         if (mem_value == arg2)
             put_user_u32(arg1, arg6);
-        ret = mem_value;
-        break;
+        return mem_value;
     }
 #endif
 #ifdef TARGET_NR_atomic_barrier
     case TARGET_NR_atomic_barrier:
-    {
-        /* Like the kernel implementation and the qemu arm barrier, no-op this? */
-        ret = 0;
-        break;
-    }
+        /* Like the kernel implementation and the
+           qemu arm barrier, no-op this? */
+        return 0;
 #endif
 
 #ifdef TARGET_NR_timer_create
@@ -12890,7 +12708,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 phost_sevp = &host_sevp;
                 ret = target_to_host_sigevent(phost_sevp, arg2);
                 if (ret != 0) {
-                    break;
+                    return ret;
                 }
             }
 
@@ -12903,7 +12721,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 }
             }
         }
-        break;
+        return ret;
     }
 #endif
 
@@ -12931,7 +12749,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 goto efault;
             }
         }
-        break;
+        return ret;
     }
 #endif
 
@@ -12954,7 +12772,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 ret = -TARGET_EFAULT;
             }
         }
-        break;
+        return ret;
     }
 #endif
 
@@ -12971,7 +12789,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(timer_getoverrun(htimer));
         }
         fd_trans_unregister(ret);
-        break;
+        return ret;
     }
 #endif
 
@@ -12988,15 +12806,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(timer_delete(htimer));
             g_posix_timers[timerid] = 0;
         }
-        break;
+        return ret;
     }
 #endif
 
 #if defined(TARGET_NR_timerfd_create) && defined(CONFIG_TIMERFD)
     case TARGET_NR_timerfd_create:
-        ret = get_errno(timerfd_create(arg1,
-                target_to_host_bitmask(arg2, fcntl_flags_tbl)));
-        break;
+        return get_errno(timerfd_create(arg1,
+                          target_to_host_bitmask(arg2, fcntl_flags_tbl)));
 #endif
 
 #if defined(TARGET_NR_timerfd_gettime) && defined(CONFIG_TIMERFD)
@@ -13012,7 +12829,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 goto efault;
             }
         }
-        break;
+        return ret;
 #endif
 
 #if defined(TARGET_NR_timerfd_settime) && defined(CONFIG_TIMERFD)
@@ -13037,19 +12854,17 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 goto efault;
             }
         }
-        break;
+        return ret;
 #endif
 
 #if defined(TARGET_NR_ioprio_get) && defined(__NR_ioprio_get)
     case TARGET_NR_ioprio_get:
-        ret = get_errno(ioprio_get(arg1, arg2));
-        break;
+        return get_errno(ioprio_get(arg1, arg2));
 #endif
 
 #if defined(TARGET_NR_ioprio_set) && defined(__NR_ioprio_set)
     case TARGET_NR_ioprio_set:
-        ret = get_errno(ioprio_set(arg1, arg2, arg3));
-        break;
+        return get_errno(ioprio_set(arg1, arg2, arg3));
 #endif
 
 #if defined(TARGET_NR_setns) && defined(CONFIG_SETNS)
@@ -13057,18 +12872,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         if (is_hostfd(arg1)) {
             goto ebadf;
         }
-        ret = get_errno(setns(arg1, arg2));
-        break;
+        return get_errno(setns(arg1, arg2));
 #endif
 #if defined(TARGET_NR_unshare) && defined(CONFIG_SETNS)
     case TARGET_NR_unshare:
-        ret = get_errno(unshare(arg1));
-        break;
+        return get_errno(unshare(arg1));
 #endif
 #if defined(TARGET_NR_kcmp) && defined(__NR_kcmp)
     case TARGET_NR_kcmp:
-        ret = get_errno(kcmp(arg1, arg2, arg3, arg4, arg5));
-        break;
+        return get_errno(kcmp(arg1, arg2, arg3, arg4, arg5));
 #endif
 
     default:
@@ -13077,8 +12889,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_setxattr) || defined(TARGET_NR_get_thread_area) || defined(TARGET_NR_getdomainname) || defined(TARGET_NR_set_robust_list)
     unimplemented_nowarn:
 #endif
-        ret = -TARGET_ENOSYS;
-        break;
+        return -TARGET_ENOSYS;
     }
 fail:
     return ret;
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 03/33] linux-user: Propagate goto ebadf to return
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 01/33] linux-user: Split out do_syscall1 Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 02/33] linux-user: Relax single exit from "break" Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-04 19:33   ` Laurent Vivier
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 04/33] linux-user: Propagate goto efault " Richard Henderson
                   ` (31 subsequent siblings)
  34 siblings, 1 reply; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 187 +++++++++++++++++++++----------------------
 1 file changed, 92 insertions(+), 95 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 258aff0411..d0bf650c62 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8025,7 +8025,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             return 0;
         } else {
             if (is_hostfd(arg1)) {
-                goto ebadf;
+                return -TARGET_EBADF;
             }
             if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
                 goto efault;
@@ -8039,7 +8039,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return ret;
     case TARGET_NR_write:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
             goto efault;
@@ -8070,7 +8070,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
     case TARGET_NR_openat:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         if (!(p = lock_user_string(arg2)))
             goto efault;
@@ -8083,7 +8083,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
     case TARGET_NR_name_to_handle_at:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         ret = do_name_to_handle_at(arg1, arg2, arg3, arg4, arg5);
         return ret;
@@ -8091,7 +8091,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
     case TARGET_NR_open_by_handle_at:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         ret = do_open_by_handle_at(arg1, arg2, arg3);
         fd_trans_unregister(ret);
@@ -8099,7 +8099,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
     case TARGET_NR_close:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         fd_trans_unregister(arg1);
         return get_errno(close(arg1));
@@ -8163,7 +8163,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_linkat)
     case TARGET_NR_linkat:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         } else {
             void * p2 = NULL;
             if (!arg2 || !arg4)
@@ -8190,7 +8190,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_unlinkat)
     case TARGET_NR_unlinkat:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         if (!(p = lock_user_string(arg2)))
             goto efault;
@@ -8324,7 +8324,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_mknodat)
     case TARGET_NR_mknodat:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         if (!(p = lock_user_string(arg2)))
             goto efault;
@@ -8350,7 +8350,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
     case TARGET_NR_lseek:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return get_errno(lseek(arg1, arg2, arg3));
 #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA)
@@ -8497,7 +8497,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_futimesat)
     case TARGET_NR_futimesat:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         } else {
             struct timeval *tvp, tv[2];
             if (arg3) {
@@ -8543,7 +8543,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_faccessat) && defined(__NR_faccessat)
     case TARGET_NR_faccessat:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         if (!(fn = lock_user_string(arg2))) {
             goto efault;
@@ -8590,7 +8590,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_renameat)
     case TARGET_NR_renameat:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         } else {
             void *p2;
             p  = lock_user_string(arg2);
@@ -8607,7 +8607,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_renameat2)
     case TARGET_NR_renameat2:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         } else {
             void *p2;
             p  = lock_user_string(arg2);
@@ -8633,7 +8633,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_mkdirat)
     case TARGET_NR_mkdirat:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         if (!(p = lock_user_string(arg2)))
             goto efault;
@@ -8651,7 +8651,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
     case TARGET_NR_dup:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         ret = get_errno(dup(arg1));
         if (ret >= 0) {
@@ -8752,7 +8752,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_dup2
     case TARGET_NR_dup2:
         if (is_hostfd(arg1) || is_hostfd(arg2)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         ret = get_errno(dup2(arg1, arg2));
         if (ret >= 0) {
@@ -8766,7 +8766,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         int host_flags;
 
         if (is_hostfd(arg1) || is_hostfd(arg2)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         if ((arg3 & ~TARGET_O_CLOEXEC) != 0) {
             return -EINVAL;
@@ -9370,7 +9370,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             if (contains_hostfd(&rfds) ||
                 contains_hostfd(&wfds) ||
                 contains_hostfd(&efds)) {
-                goto ebadf;
+                return -TARGET_EBADF;
             }
 
             /*
@@ -9455,7 +9455,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_symlinkat)
     case TARGET_NR_symlinkat:
         if (is_hostfd(arg2)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         } else {
             void *p2;
             p  = lock_user_string(arg1);
@@ -9511,7 +9511,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_readlinkat)
     case TARGET_NR_readlinkat:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         } else {
             void *p2;
             fn = lock_user_string(arg2);
@@ -9582,7 +9582,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             v6 = tswapal(v[5]);
             unlock_user(v, arg1, 0);
             if (is_hostfd(v5)) {
-                goto ebadf;
+                return -TARGET_EBADF;
             }
             ret = get_errno(target_mmap(v1, v2, v3,
                                         target_to_host_bitmask(v4, mmap_flags_tbl),
@@ -9590,7 +9590,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         }
 #else
         if (is_hostfd(arg5)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         ret = get_errno(target_mmap(arg1, arg2, arg3,
                                     target_to_host_bitmask(arg4, mmap_flags_tbl),
@@ -9605,7 +9605,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #define MMAP_SHIFT 12
 #endif
         if (is_hostfd(arg5)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         ret = target_mmap(arg1, arg2, arg3,
                           target_to_host_bitmask(arg4, mmap_flags_tbl),
@@ -9660,18 +9660,18 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return ret;
     case TARGET_NR_ftruncate:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return get_errno(ftruncate(arg1, arg2));
     case TARGET_NR_fchmod:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return get_errno(fchmod(arg1, arg2));
 #if defined(TARGET_NR_fchmodat)
     case TARGET_NR_fchmodat:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         if (!(p = lock_user_string(arg2)))
             goto efault;
@@ -9736,7 +9736,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return ret;
     case TARGET_NR_fstatfs:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         ret = get_errno(fstatfs(arg1, &stfs));
         goto convert_statfs;
@@ -9771,7 +9771,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return ret;
     case TARGET_NR_fstatfs64:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         ret = get_errno(fstatfs(arg1, &stfs));
         goto convert_statfs64;
@@ -9787,117 +9787,117 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_accept
     case TARGET_NR_accept:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return do_accept4(arg1, arg2, arg3, 0);
 #endif
 #ifdef TARGET_NR_accept4
     case TARGET_NR_accept4:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return do_accept4(arg1, arg2, arg3, arg4);
 #endif
 #ifdef TARGET_NR_bind
     case TARGET_NR_bind:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return do_bind(arg1, arg2, arg3);
 #endif
 #ifdef TARGET_NR_connect
     case TARGET_NR_connect:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return do_connect(arg1, arg2, arg3);
 #endif
 #ifdef TARGET_NR_getpeername
     case TARGET_NR_getpeername:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return do_getpeername(arg1, arg2, arg3);
 #endif
 #ifdef TARGET_NR_getsockname
     case TARGET_NR_getsockname:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return do_getsockname(arg1, arg2, arg3);
 #endif
 #ifdef TARGET_NR_getsockopt
     case TARGET_NR_getsockopt:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return do_getsockopt(arg1, arg2, arg3, arg4, arg5);
 #endif
 #ifdef TARGET_NR_listen
     case TARGET_NR_listen:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return get_errno(listen(arg1, arg2));
 #endif
 #ifdef TARGET_NR_recv
     case TARGET_NR_recv:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return do_recvfrom(arg1, arg2, arg3, arg4, 0, 0);
 #endif
 #ifdef TARGET_NR_recvfrom
     case TARGET_NR_recvfrom:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return do_recvfrom(arg1, arg2, arg3, arg4, arg5, arg6);
 #endif
 #ifdef TARGET_NR_recvmsg
     case TARGET_NR_recvmsg:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return do_sendrecvmsg(arg1, arg2, arg3, 0);
 #endif
 #ifdef TARGET_NR_send
     case TARGET_NR_send:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return do_sendto(arg1, arg2, arg3, arg4, 0, 0);
 #endif
 #ifdef TARGET_NR_sendmsg
     case TARGET_NR_sendmsg:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return do_sendrecvmsg(arg1, arg2, arg3, 1);
 #endif
 #ifdef TARGET_NR_sendmmsg
     case TARGET_NR_sendmmsg:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return do_sendrecvmmsg(arg1, arg2, arg3, arg4, 1);
     case TARGET_NR_recvmmsg:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return do_sendrecvmmsg(arg1, arg2, arg3, arg4, 0);
 #endif
 #ifdef TARGET_NR_sendto
     case TARGET_NR_sendto:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return do_sendto(arg1, arg2, arg3, arg4, arg5, arg6);
 #endif
 #ifdef TARGET_NR_shutdown
     case TARGET_NR_shutdown:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return get_errno(shutdown(arg1, arg2));
 #endif
@@ -9922,7 +9922,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_setsockopt
     case TARGET_NR_setsockopt:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return do_setsockopt(arg1, arg2, arg3, arg4, (socklen_t) arg5);
 #endif
@@ -10031,7 +10031,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
     case TARGET_NR_fstat:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         } else {
             ret = get_errno(fstat(arg1, &st));
 #if defined(TARGET_NR_stat) || defined(TARGET_NR_lstat)
@@ -10191,7 +10191,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
     case TARGET_NR_fsync:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return get_errno(fsync(arg1));
     case TARGET_NR_clone:
@@ -10304,7 +10304,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return get_errno(getpgid(arg1));
     case TARGET_NR_fchdir:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return get_errno(fchdir(arg1));
 #ifdef TARGET_NR_bdflush /* not on x86_64 */
@@ -10324,7 +10324,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR__llseek /* Not on alpha */
     case TARGET_NR__llseek:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         } else {
             int64_t res;
 #if !defined(__NR_llseek)
@@ -10346,7 +10346,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_getdents
     case TARGET_NR_getdents:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
 #ifdef EMULATE_GETDENTS_WITH_GETDENTS
 #if TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64
@@ -10481,7 +10481,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_getdents64) && defined(__NR_getdents64)
     case TARGET_NR_getdents64:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         } else {
             struct linux_dirent64 *dirp;
             abi_long count = arg3;
@@ -10633,12 +10633,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         /* NOTE: the flock constant seems to be the same for every
            Linux platform */
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return get_errno(safe_flock(arg1, arg2));
     case TARGET_NR_readv:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         } else {
             struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0);
             if (vec != NULL) {
@@ -10651,7 +10651,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return ret;
     case TARGET_NR_writev:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         } else {
             struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1);
             if (vec != NULL) {
@@ -10665,7 +10665,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_preadv)
     case TARGET_NR_preadv:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         } else {
             struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0);
             if (vec != NULL) {
@@ -10683,7 +10683,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_pwritev)
     case TARGET_NR_pwritev:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         } else {
             struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1);
             if (vec != NULL) {
@@ -10703,7 +10703,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_fdatasync) /* Not on alpha (osf_datasync ?) */
     case TARGET_NR_fdatasync:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return get_errno(fdatasync(arg1));
 #endif
@@ -10955,7 +10955,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_pread64
     case TARGET_NR_pread64:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         if (regpairs_aligned(cpu_env, num)) {
             arg4 = arg5;
@@ -10968,7 +10968,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return ret;
     case TARGET_NR_pwrite64:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         if (regpairs_aligned(cpu_env, num)) {
             arg4 = arg5;
@@ -11067,7 +11067,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         off_t off;
 
         if (is_hostfd(arg1) || is_hostfd(arg2)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         if (arg3) {
             ret = get_user_sal(off, arg3);
@@ -11092,7 +11092,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         off_t off;
 
         if (is_hostfd(arg1) || is_hostfd(arg2)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         if (arg3) {
             ret = get_user_s64(off, arg3);
@@ -11161,7 +11161,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_ftruncate64
     case TARGET_NR_ftruncate64:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
 	return target_ftruncate64(cpu_env, arg1, arg2, arg3, arg4);
 #endif
@@ -11196,7 +11196,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_fstat64
     case TARGET_NR_fstat64:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         ret = get_errno(fstat(arg1, &st));
         if (!is_error(ret))
@@ -11211,7 +11211,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
     case TARGET_NR_newfstatat:
 #endif
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         if (!(fn = lock_user_string(arg2))) {
             goto efault;
@@ -11299,7 +11299,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_fchownat)
     case TARGET_NR_fchownat:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         if (!(p = lock_user_string(arg2))) 
             goto efault;
@@ -11628,7 +11628,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_fchown32
     case TARGET_NR_fchown32:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return get_errno(fchown(arg1, arg2, arg3));
 #endif
@@ -11725,7 +11725,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
          * pairs of 32-bit registers.
          */
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         ret = posix_fadvise(arg1, target_offset64(arg3, arg4),
                             target_offset64(arg5, arg6), arg2);
@@ -11737,7 +11737,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_fadvise64_64
     case TARGET_NR_fadvise64_64:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
 #if defined(TARGET_PPC) || defined(TARGET_XTENSA)
         /* 6 args: fd, advice, offset (high, low), len (high, low) */
@@ -11766,7 +11766,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_fadvise64
     case TARGET_NR_fadvise64:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         /* 5 args: fd, offset (high, low), len, advice */
         if (regpairs_aligned(cpu_env, num)) {
@@ -11789,7 +11789,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
     case TARGET_NR_fadvise64:
 #endif
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
 #ifdef TARGET_S390X
         switch (arg4) {
@@ -11815,7 +11815,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if TARGET_ABI_BITS == 32
     case TARGET_NR_fcntl64:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
     {
 	int cmd;
@@ -11958,7 +11958,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return ret;
     case TARGET_NR_fsetxattr:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         } else {
             void *n, *v = 0;
             if (arg3) {
@@ -12005,7 +12005,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return ret;
     case TARGET_NR_fgetxattr:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         } else {
             void *n, *v = 0;
             if (arg3) {
@@ -12045,7 +12045,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return ret;
     case TARGET_NR_fremovexattr:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         } else {
             void *n;
             n = lock_user_string(arg2);
@@ -12190,7 +12190,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_utimensat)
     case TARGET_NR_utimensat:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         } else {
             struct timespec *tsp, ts[2];
             if (!arg3) {
@@ -12239,7 +12239,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_inotify_add_watch) && defined(__NR_inotify_add_watch)
     case TARGET_NR_inotify_add_watch:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         if (!(fn = lock_user_string(arg2))) {
             goto efault;
@@ -12252,7 +12252,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_inotify_rm_watch) && defined(__NR_inotify_rm_watch)
     case TARGET_NR_inotify_rm_watch:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return get_errno(sys_inotify_rm_watch(arg1, arg2));
 #endif
@@ -12353,7 +12353,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_tee
     case TARGET_NR_tee:
         if (is_hostfd(arg1) || is_hostfd(arg2)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         } else {
             ret = get_errno(tee(arg1,arg2,arg3,arg4));
         }
@@ -12362,7 +12362,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_splice
     case TARGET_NR_splice:
         if (is_hostfd(arg1) || is_hostfd(arg3)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         } else {
             loff_t loff_in, loff_out;
             loff_t *ploff_in = NULL, *ploff_out = NULL;
@@ -12395,7 +12395,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_vmsplice
     case TARGET_NR_vmsplice:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         } else {
             struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1);
             if (vec != NULL) {
@@ -12438,7 +12438,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(CONFIG_FALLOCATE) && defined(TARGET_NR_fallocate)
     case TARGET_NR_fallocate:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
 #if TARGET_ABI_BITS == 32
         ret = get_errno(fallocate(arg1, arg2, target_offset64(arg3, arg4),
@@ -12452,7 +12452,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_sync_file_range)
     case TARGET_NR_sync_file_range:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
 #if TARGET_ABI_BITS == 32
 #if defined(TARGET_MIPS)
@@ -12471,7 +12471,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
     case TARGET_NR_sync_file_range2:
         /* This is like sync_file_range but the arguments are reordered */
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
 #if TARGET_ABI_BITS == 32
         ret = get_errno(sync_file_range(arg1, target_offset64(arg3, arg4),
@@ -12485,14 +12485,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_signalfd4)
     case TARGET_NR_signalfd4:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return do_signalfd4(arg1, arg2, arg4);
 #endif
 #if defined(TARGET_NR_signalfd)
     case TARGET_NR_signalfd:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return do_signalfd4(arg1, arg2, 0);
 #endif
@@ -12512,7 +12512,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         struct epoll_event *epp = 0;
 
         if (is_hostfd(arg1) || is_hostfd(arg3)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         if (arg4) {
             struct target_epoll_event *target_ep;
@@ -12547,7 +12547,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         int timeout = arg4;
 
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         if (maxevents <= 0 || maxevents > TARGET_EP_MAX_EVENTS) {
             return -TARGET_EINVAL;
@@ -12819,7 +12819,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_timerfd_gettime) && defined(CONFIG_TIMERFD)
     case TARGET_NR_timerfd_gettime:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         } else {
             struct itimerspec its_curr;
 
@@ -12835,7 +12835,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_timerfd_settime) && defined(CONFIG_TIMERFD)
     case TARGET_NR_timerfd_settime:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         } else {
             struct itimerspec its_new, its_old, *p_new;
 
@@ -12870,7 +12870,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_NR_setns) && defined(CONFIG_SETNS)
     case TARGET_NR_setns:
         if (is_hostfd(arg1)) {
-            goto ebadf;
+            return -TARGET_EBADF;
         }
         return get_errno(setns(arg1, arg2));
 #endif
@@ -12896,9 +12896,6 @@ fail:
 efault:
     ret = -TARGET_EFAULT;
     goto fail;
-ebadf:
-    ret = -TARGET_EBADF;
-    goto fail;
 }
 
 abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 04/33] linux-user: Propagate goto efault to return
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (2 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 03/33] linux-user: Propagate goto ebadf to return Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-04 19:35   ` Laurent Vivier
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 05/33] linux-user: Propagate goto unimplemented_nowarn " Richard Henderson
                   ` (30 subsequent siblings)
  34 siblings, 1 reply; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 311 +++++++++++++++++++++----------------------
 1 file changed, 154 insertions(+), 157 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index d0bf650c62..8ea2099001 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8028,7 +8028,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 return -TARGET_EBADF;
             }
             if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
-                goto efault;
+                return -TARGET_EFAULT;
             ret = get_errno(safe_read(arg1, p, arg3));
             if (ret >= 0 &&
                 fd_trans_host_to_target_data(arg1)) {
@@ -8042,7 +8042,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             return -TARGET_EBADF;
         }
         if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
-            goto efault;
+            return -TARGET_EFAULT;
         if (fd_trans_target_to_host_data(arg1)) {
             void *copy = g_malloc(arg3);
             memcpy(copy, p, arg3);
@@ -8060,7 +8060,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_open
     case TARGET_NR_open:
         if (!(p = lock_user_string(arg1)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(do_openat(cpu_env, AT_FDCWD, p,
                                   target_to_host_bitmask(arg2, fcntl_flags_tbl),
                                   arg3));
@@ -8073,7 +8073,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             return -TARGET_EBADF;
         }
         if (!(p = lock_user_string(arg2)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(do_openat(cpu_env, arg1, p,
                                   target_to_host_bitmask(arg3, fcntl_flags_tbl),
                                   arg4));
@@ -8117,7 +8117,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(safe_wait4(arg1, &status, arg3, 0));
             if (!is_error(ret) && arg2 && ret
                 && put_user_s32(host_to_target_waitstatus(status), arg2))
-                goto efault;
+                return -TARGET_EFAULT;
         }
         return ret;
 #endif
@@ -8129,7 +8129,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(safe_waitid(arg1, arg2, &info, arg4, NULL));
             if (!is_error(ret) && arg3 && info.si_pid != 0) {
                 if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_siginfo_t), 0)))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 host_to_target_siginfo(p, &info);
                 unlock_user(p, arg3, sizeof(target_siginfo_t));
             }
@@ -8139,7 +8139,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_creat /* not on alpha */
     case TARGET_NR_creat:
         if (!(p = lock_user_string(arg1)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(creat(p, arg2));
         fd_trans_unregister(ret);
         unlock_user(p, arg1, 0);
@@ -8167,7 +8167,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         } else {
             void * p2 = NULL;
             if (!arg2 || !arg4)
-                goto efault;
+                return -TARGET_EFAULT;
             p  = lock_user_string(arg2);
             p2 = lock_user_string(arg4);
             if (!p || !p2)
@@ -8182,7 +8182,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_unlink
     case TARGET_NR_unlink:
         if (!(p = lock_user_string(arg1)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(unlink(p));
         unlock_user(p, arg1, 0);
         return ret;
@@ -8193,7 +8193,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             return -TARGET_EBADF;
         }
         if (!(p = lock_user_string(arg2)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(unlinkat(arg1, p, arg3));
         unlock_user(p, arg2, 0);
         return ret;
@@ -8213,7 +8213,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             guest_argp = arg2;
             for (gp = guest_argp; gp; gp += sizeof(abi_ulong)) {
                 if (get_user_ual(addr, gp))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 if (!addr)
                     break;
                 argc++;
@@ -8222,7 +8222,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             guest_envp = arg3;
             for (gp = guest_envp; gp; gp += sizeof(abi_ulong)) {
                 if (get_user_ual(addr, gp))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 if (!addr)
                     break;
                 envc++;
@@ -8297,7 +8297,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return ret;
     case TARGET_NR_chdir:
         if (!(p = lock_user_string(arg1)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(chdir(p));
         unlock_user(p, arg1, 0);
         return ret;
@@ -8309,14 +8309,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             if (!is_error(ret)
                 && arg1
                 && put_user_sal(host_time, arg1))
-                goto efault;
+                return -TARGET_EFAULT;
         }
         return ret;
 #endif
 #ifdef TARGET_NR_mknod
     case TARGET_NR_mknod:
         if (!(p = lock_user_string(arg1)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(mknod(p, arg2, arg3));
         unlock_user(p, arg1, 0);
         return ret;
@@ -8327,7 +8327,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             return -TARGET_EBADF;
         }
         if (!(p = lock_user_string(arg2)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(mknodat(arg1, p, arg3, arg4));
         unlock_user(p, arg2, 0);
         return ret;
@@ -8335,7 +8335,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_chmod
     case TARGET_NR_chmod:
         if (!(p = lock_user_string(arg1)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(chmod(p, arg2));
         unlock_user(p, arg1, 0);
         return ret;
@@ -8371,7 +8371,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             if (arg1) {
                 p = lock_user_string(arg1);
                 if (!p) {
-                    goto efault;
+                    return -TARGET_EFAULT;
                 }
             } else {
                 p = NULL;
@@ -8382,7 +8382,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 if (arg1) {
                     unlock_user(p, arg1, 0);
                 }
-                goto efault;
+                return -TARGET_EFAULT;
             }
 
             if (arg3) {
@@ -8392,7 +8392,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                         unlock_user(p, arg1, 0);
                     }
                     unlock_user(p2, arg2, 0);
-                    goto efault;
+                    return -TARGET_EFAULT;
                 }
             } else {
                 p3 = NULL;
@@ -8421,7 +8421,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_umount
     case TARGET_NR_umount:
         if (!(p = lock_user_string(arg1)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(umount(p));
         unlock_user(p, arg1, 0);
         return ret;
@@ -8431,7 +8431,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         {
             time_t host_time;
             if (get_user_sal(host_time, arg1))
-                goto efault;
+                return -TARGET_EFAULT;
             return get_errno(stime(&host_time));
         }
 #endif
@@ -8459,7 +8459,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             struct target_utimbuf *target_tbuf;
             if (arg2) {
                 if (!lock_user_struct(VERIFY_READ, target_tbuf, arg2, 1))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 tbuf.actime = tswapal(target_tbuf->actime);
                 tbuf.modtime = tswapal(target_tbuf->modtime);
                 unlock_user_struct(target_tbuf, arg2, 0);
@@ -8468,7 +8468,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 host_tbuf = NULL;
             }
             if (!(p = lock_user_string(arg1)))
-                goto efault;
+                return -TARGET_EFAULT;
             ret = get_errno(utime(p, host_tbuf));
             unlock_user(p, arg1, 0);
         }
@@ -8482,13 +8482,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 if (copy_from_user_timeval(&tv[0], arg2)
                     || copy_from_user_timeval(&tv[1],
                                               arg2 + sizeof(struct target_timeval)))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 tvp = tv;
             } else {
                 tvp = NULL;
             }
             if (!(p = lock_user_string(arg1)))
-                goto efault;
+                return -TARGET_EFAULT;
             ret = get_errno(utimes(p, tvp));
             unlock_user(p, arg1, 0);
         }
@@ -8504,13 +8504,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 if (copy_from_user_timeval(&tv[0], arg3)
                     || copy_from_user_timeval(&tv[1],
                                               arg3 + sizeof(struct target_timeval)))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 tvp = tv;
             } else {
                 tvp = NULL;
             }
             if (!(fn = lock_user_string(arg2))) {
-                goto efault;
+                return -TARGET_EFAULT;
             }
             TRY_INTERP_FD(ret, fn,
                           futimesat(interp_dirfd, fn + 1, tvp),
@@ -8531,7 +8531,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_access
     case TARGET_NR_access:
         if (!(fn = lock_user_string(arg1))) {
-            goto efault;
+            return -TARGET_EFAULT;
         }
         TRY_INTERP_FD(ret, fn,
                       faccessat(interp_dirfd, fn + 1, arg2, 0),
@@ -8546,7 +8546,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             return -TARGET_EBADF;
         }
         if (!(fn = lock_user_string(arg2))) {
-            goto efault;
+            return -TARGET_EFAULT;
         }
         TRY_INTERP_FD(ret, fn,
                       faccessat(interp_dirfd, fn + 1, arg3, 0),
@@ -8625,7 +8625,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_mkdir
     case TARGET_NR_mkdir:
         if (!(p = lock_user_string(arg1)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(mkdir(p, arg2));
         unlock_user(p, arg1, 0);
         return ret;
@@ -8636,7 +8636,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             return -TARGET_EBADF;
         }
         if (!(p = lock_user_string(arg2)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(mkdirat(arg1, p, arg3));
         unlock_user(p, arg2, 0);
         return ret;
@@ -8644,7 +8644,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_rmdir
     case TARGET_NR_rmdir:
         if (!(p = lock_user_string(arg1)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(rmdir(p));
         unlock_user(p, arg1, 0);
         return ret;
@@ -8675,7 +8675,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             if (arg1) {
                 tmsp = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_tms), 0);
                 if (!tmsp)
-                    goto efault;
+                    return -TARGET_EFAULT;
                 tmsp->tms_utime = tswapal(host_to_target_clock_t(tms.tms_utime));
                 tmsp->tms_stime = tswapal(host_to_target_clock_t(tms.tms_stime));
                 tmsp->tms_cutime = tswapal(host_to_target_clock_t(tms.tms_cutime));
@@ -8698,7 +8698,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(acct(NULL));
         } else {
             if (!(fn = lock_user_string(arg1))) {
-                goto efault;
+                return -TARGET_EFAULT;
             }
             TRY_INTERP_PATH(ret, fn, acct(fn));
             ret = get_errno(ret);
@@ -8708,7 +8708,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_umount2
     case TARGET_NR_umount2:
         if (!(p = lock_user_string(arg1)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(umount2(p, arg2));
         unlock_user(p, arg1, 0);
         return ret;
@@ -8741,7 +8741,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return get_errno(umask(arg1));
     case TARGET_NR_chroot:
         if (!(p = lock_user_string(arg1)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(chroot(p));
         unlock_user(p, arg1, 0);
         return ret;
@@ -8797,7 +8797,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             struct target_old_sigaction *old_act;
             if (arg2) {
                 if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 act._sa_handler = old_act->_sa_handler;
                 target_siginitset(&act.sa_mask, old_act->sa_mask);
                 act.sa_flags = old_act->sa_flags;
@@ -8808,7 +8808,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(do_sigaction(arg1, pact, &oact));
             if (!is_error(ret) && arg3) {
                 if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 old_act->_sa_handler = oact._sa_handler;
                 old_act->sa_mask = oact.sa_mask.sig[0];
                 old_act->sa_flags = oact.sa_flags;
@@ -8819,7 +8819,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 
 	    if (arg2) {
                 if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1))
-                    goto efault;
+                    return -TARGET_EFAULT;
 		act._sa_handler = old_act->_sa_handler;
 		target_siginitset(&act.sa_mask, old_act->sa_mask.sig[0]);
 		act.sa_flags = old_act->sa_flags;
@@ -8833,7 +8833,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 
 	    if (!is_error(ret) && arg3) {
                 if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))
-                    goto efault;
+                    return -TARGET_EFAULT;
 		old_act->_sa_handler = oact._sa_handler;
 		old_act->sa_flags = oact.sa_flags;
 		old_act->sa_mask.sig[0] = oact.sa_mask.sig[0];
@@ -8847,7 +8847,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             struct target_sigaction act, oact, *pact;
             if (arg2) {
                 if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 act._sa_handler = old_act->_sa_handler;
                 target_siginitset(&act.sa_mask, old_act->sa_mask);
                 act.sa_flags = old_act->sa_flags;
@@ -8863,7 +8863,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(do_sigaction(arg1, pact, &oact));
             if (!is_error(ret) && arg3) {
                 if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 old_act->_sa_handler = oact._sa_handler;
                 old_act->sa_mask = oact.sa_mask.sig[0];
                 old_act->sa_flags = oact.sa_flags;
@@ -8893,7 +8893,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             }
             if (arg2) {
                 if (!lock_user_struct(VERIFY_READ, rt_act, arg2, 1))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 act._sa_handler = rt_act->_sa_handler;
                 act.sa_mask = rt_act->sa_mask;
                 act.sa_flags = rt_act->sa_flags;
@@ -8904,7 +8904,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(do_sigaction(arg1, pact, &oact));
             if (!is_error(ret) && arg3) {
                 if (!lock_user_struct(VERIFY_WRITE, rt_act, arg3, 0))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 rt_act->_sa_handler = oact._sa_handler;
                 rt_act->sa_mask = oact.sa_mask;
                 rt_act->sa_flags = oact.sa_flags;
@@ -8925,7 +8925,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             }
             if (arg2) {
                 if (!lock_user_struct(VERIFY_READ, act, arg2, 1)) {
-                    goto efault;
+                    return -TARGET_EFAULT;
                 }
 #ifdef TARGET_ARCH_HAS_KA_RESTORER
                 act->ka_restorer = restorer;
@@ -9027,7 +9027,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                     goto fail;
                 }
                 if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 target_to_host_old_sigset(&set, p);
                 unlock_user(p, arg2, 0);
                 set_ptr = &set;
@@ -9038,7 +9038,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = do_sigprocmask(how, set_ptr, &oldset);
             if (!is_error(ret) && arg3) {
                 if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0)))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 host_to_target_old_sigset(p, &oldset);
                 unlock_user(p, arg3, sizeof(target_sigset_t));
             }
@@ -9071,7 +9071,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                     goto fail;
                 }
                 if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 target_to_host_sigset(&set, p);
                 unlock_user(p, arg2, 0);
                 set_ptr = &set;
@@ -9082,7 +9082,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = do_sigprocmask(how, set_ptr, &oldset);
             if (!is_error(ret) && arg3) {
                 if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0)))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 host_to_target_sigset(p, &oldset);
                 unlock_user(p, arg3, sizeof(target_sigset_t));
             }
@@ -9095,7 +9095,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(sigpending(&set));
             if (!is_error(ret)) {
                 if (!(p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0)))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 host_to_target_old_sigset(p, &set);
                 unlock_user(p, arg1, sizeof(target_sigset_t));
             }
@@ -9118,7 +9118,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(sigpending(&set));
             if (!is_error(ret)) {
                 if (!(p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0)))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 host_to_target_sigset(p, &set);
                 unlock_user(p, arg1, sizeof(target_sigset_t));
             }
@@ -9133,7 +9133,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             target_to_host_old_sigset(&ts->sigsuspend_mask, &mask);
 #else
             if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))
-                goto efault;
+                return -TARGET_EFAULT;
             target_to_host_old_sigset(&ts->sigsuspend_mask, p);
             unlock_user(p, arg1, 0);
 #endif
@@ -9153,7 +9153,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 return -TARGET_EINVAL;
             }
             if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))
-                goto efault;
+                return -TARGET_EFAULT;
             target_to_host_sigset(&ts->sigsuspend_mask, p);
             unlock_user(p, arg1, 0);
             ret = get_errno(safe_rt_sigsuspend(&ts->sigsuspend_mask,
@@ -9174,7 +9174,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             }
 
             if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))
-                goto efault;
+                return -TARGET_EFAULT;
             target_to_host_sigset(&set, p);
             unlock_user(p, arg1, 0);
             if (arg3) {
@@ -9190,7 +9190,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                     p = lock_user(VERIFY_WRITE, arg2, sizeof(target_siginfo_t),
                                   0);
                     if (!p) {
-                        goto efault;
+                        return -TARGET_EFAULT;
                     }
                     host_to_target_siginfo(p, &uinfo);
                     unlock_user(p, arg2, sizeof(target_siginfo_t));
@@ -9205,7 +9205,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 
             p = lock_user(VERIFY_READ, arg3, sizeof(target_siginfo_t), 1);
             if (!p) {
-                goto efault;
+                return -TARGET_EFAULT;
             }
             target_to_host_siginfo(&uinfo, p);
             unlock_user(p, arg3, 0);
@@ -9218,7 +9218,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 
             p = lock_user(VERIFY_READ, arg4, sizeof(target_siginfo_t), 1);
             if (!p) {
-                goto efault;
+                return -TARGET_EFAULT;
             }
             target_to_host_siginfo(&uinfo, p);
             unlock_user(p, arg4, 0);
@@ -9242,7 +9242,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         }
     case TARGET_NR_sethostname:
         if (!(p = lock_user_string(arg1)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(sethostname(p, arg2));
         unlock_user(p, arg1, 0);
         return ret;
@@ -9252,7 +9252,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             struct target_rlimit *target_rlim;
             struct rlimit rlim;
             if (!lock_user_struct(VERIFY_READ, target_rlim, arg2, 1))
-                goto efault;
+                return -TARGET_EFAULT;
             rlim.rlim_cur = target_to_host_rlim(target_rlim->rlim_cur);
             rlim.rlim_max = target_to_host_rlim(target_rlim->rlim_max);
             unlock_user_struct(target_rlim, arg2, 0);
@@ -9267,7 +9267,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(getrlimit(resource, &rlim));
             if (!is_error(ret)) {
                 if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 target_rlim->rlim_cur = host_to_target_rlim(rlim.rlim_cur);
                 target_rlim->rlim_max = host_to_target_rlim(rlim.rlim_max);
                 unlock_user_struct(target_rlim, arg2, 1);
@@ -9289,7 +9289,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(gettimeofday(&tv, NULL));
             if (!is_error(ret)) {
                 if (copy_to_user_timeval(arg1, &tv))
-                    goto efault;
+                    return -TARGET_EFAULT;
             }
         }
         return ret;
@@ -9300,14 +9300,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 
             if (arg1) {
                 if (copy_from_user_timeval(&tv, arg1)) {
-                    goto efault;
+                    return -TARGET_EFAULT;
                 }
                 ptv = &tv;
             }
 
             if (arg2) {
                 if (copy_from_user_timezone(&tz, arg2)) {
-                    goto efault;
+                    return -TARGET_EFAULT;
                 }
                 ptz = &tz;
             }
@@ -9379,7 +9379,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
              */
             if (ts_addr) {
                 if (target_to_host_timespec(&ts, ts_addr)) {
-                    goto efault;
+                    return -TARGET_EFAULT;
                 }
                 ts_ptr = &ts;
             } else {
@@ -9393,7 +9393,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 
                 arg7 = lock_user(VERIFY_READ, arg6, sizeof(*arg7) * 2, 1);
                 if (!arg7) {
-                    goto efault;
+                    return -TARGET_EFAULT;
                 }
                 arg_sigset = tswapal(arg7[0]);
                 arg_sigsize = tswapal(arg7[1]);
@@ -9409,7 +9409,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                     target_sigset = lock_user(VERIFY_READ, arg_sigset,
                                               sizeof(*target_sigset), 1);
                     if (!target_sigset) {
-                        goto efault;
+                        return -TARGET_EFAULT;
                     }
                     target_to_host_sigset(&set, target_sigset);
                     unlock_user(target_sigset, arg_sigset, 0);
@@ -9425,14 +9425,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 
             if (!is_error(ret)) {
                 if (rfd_addr && copy_to_user_fdset(rfd_addr, &rfds, n))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 if (wfd_addr && copy_to_user_fdset(wfd_addr, &wfds, n))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 if (efd_addr && copy_to_user_fdset(efd_addr, &efds, n))
-                    goto efault;
+                    return -TARGET_EFAULT;
 
                 if (ts_addr && host_to_target_timespec(ts_addr, &ts))
-                    goto efault;
+                    return -TARGET_EFAULT;
             }
         }
         return ret;
@@ -9541,7 +9541,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_swapon
     case TARGET_NR_swapon:
         if (!(p = lock_user_string(arg1)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(swapon(p, arg2));
         unlock_user(p, arg1, 0);
         return ret;
@@ -9551,7 +9551,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
            /* arg4 must be ignored in all other cases */
            p = lock_user_string(arg4);
            if (!p) {
-              goto efault;
+              return -TARGET_EFAULT;
            }
            ret = get_errno(reboot(arg1, arg2, arg3, p));
            unlock_user(p, arg4, 0);
@@ -9573,7 +9573,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             abi_ulong *v;
             abi_ulong v1, v2, v3, v4, v5, v6;
             if (!(v = lock_user(VERIFY_READ, arg1, 6 * sizeof(abi_ulong), 1)))
-                goto efault;
+                return -TARGET_EFAULT;
             v1 = tswapal(v[0]);
             v2 = tswapal(v[1]);
             v3 = tswapal(v[2]);
@@ -9654,7 +9654,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
     case TARGET_NR_truncate:
         if (!(p = lock_user_string(arg1)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(truncate(p, arg2));
         unlock_user(p, arg1, 0);
         return ret;
@@ -9674,7 +9674,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             return -TARGET_EBADF;
         }
         if (!(p = lock_user_string(arg2)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(fchmodat(arg1, p, arg3, 0));
         unlock_user(p, arg2, 0);
         return ret;
@@ -9703,7 +9703,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
     case TARGET_NR_statfs:
         if (!(fn = lock_user_string(arg1))) {
-            goto efault;
+            return -TARGET_EFAULT;
         }
         TRY_INTERP_PATH(ret, fn, statfs(fn, &stfs));
         ret = get_errno(ret);
@@ -9713,7 +9713,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             struct target_statfs *target_stfs;
 
             if (!lock_user_struct(VERIFY_WRITE, target_stfs, arg2, 0))
-                goto efault;
+                return -TARGET_EFAULT;
             __put_user(stfs.f_type, &target_stfs->f_type);
             __put_user(stfs.f_bsize, &target_stfs->f_bsize);
             __put_user(stfs.f_blocks, &target_stfs->f_blocks);
@@ -9743,7 +9743,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_statfs64
     case TARGET_NR_statfs64:
         if (!(fn = lock_user_string(arg1))) {
-            goto efault;
+            return -TARGET_EFAULT;
         }
         TRY_INTERP_PATH(ret, fn, statfs(fn, &stfs));
         ret = get_errno(ret);
@@ -9753,7 +9753,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             struct target_statfs64 *target_stfs;
 
             if (!lock_user_struct(VERIFY_WRITE, target_stfs, arg3, 0))
-                goto efault;
+                return -TARGET_EFAULT;
             __put_user(stfs.f_type, &target_stfs->f_type);
             __put_user(stfs.f_bsize, &target_stfs->f_bsize);
             __put_user(stfs.f_blocks, &target_stfs->f_blocks);
@@ -9905,7 +9905,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
     case TARGET_NR_getrandom:
         p = lock_user(VERIFY_WRITE, arg1, arg2, 0);
         if (!p) {
-            goto efault;
+            return -TARGET_EFAULT;
         }
         ret = get_errno(getrandom(p, arg2, arg3));
         unlock_user(p, arg1, ret);
@@ -9977,7 +9977,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 if (copy_from_user_timeval(&pvalue->it_interval, arg2)
                     || copy_from_user_timeval(&pvalue->it_value,
                                               arg2 + sizeof(struct target_timeval)))
-                    goto efault;
+                    return -TARGET_EFAULT;
             } else {
                 pvalue = NULL;
             }
@@ -9987,7 +9987,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                                          &ovalue.it_interval)
                     || copy_to_user_timeval(arg3 + sizeof(struct target_timeval),
                                             &ovalue.it_value))
-                    goto efault;
+                    return -TARGET_EFAULT;
             }
         }
         return ret;
@@ -10001,14 +10001,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                                          &value.it_interval)
                     || copy_to_user_timeval(arg2 + sizeof(struct target_timeval),
                                             &value.it_value))
-                    goto efault;
+                    return -TARGET_EFAULT;
             }
         }
         return ret;
 #ifdef TARGET_NR_stat
     case TARGET_NR_stat:
         if (!(fn = lock_user_string(arg1))) {
-            goto efault;
+            return -TARGET_EFAULT;
         }
         TRY_INTERP_FD(ret, fn,
                       fstatat(interp_dirfd, fn + 1, &st, 0),
@@ -10020,7 +10020,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_lstat
     case TARGET_NR_lstat:
         if (!(fn = lock_user_string(arg1))) {
-            goto efault;
+            return -TARGET_EFAULT;
         }
         TRY_INTERP_FD(ret, fn,
                       fstatat(interp_dirfd, fn + 1, &st, AT_SYMLINK_NOFOLLOW),
@@ -10041,7 +10041,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 struct target_stat *target_st;
 
                 if (!lock_user_struct(VERIFY_WRITE, target_st, arg2, 0))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 memset(target_st, 0, sizeof(*target_st));
                 __put_user(st.st_dev, &target_st->st_dev);
                 __put_user(st.st_ino, &target_st->st_ino);
@@ -10095,7 +10095,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 if (status_ptr && ret) {
                     status = host_to_target_waitstatus(status);
                     if (put_user_s32(status, status_ptr))
-                        goto efault;
+                        return -TARGET_EFAULT;
                 }
                 if (target_rusage) {
                     rusage_err = host_to_target_rusage(target_rusage, &rusage);
@@ -10109,7 +10109,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_swapoff
     case TARGET_NR_swapoff:
         if (!(p = lock_user_string(arg1)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(swapoff(p));
         unlock_user(p, arg1, 0);
         return ret;
@@ -10122,7 +10122,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             if (!is_error(ret) && arg1)
             {
                 if (!lock_user_struct(VERIFY_WRITE, target_value, arg1, 0))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 __put_user(value.uptime, &target_value->uptime);
                 __put_user(value.loads[0], &target_value->loads[0]);
                 __put_user(value.loads[1], &target_value->loads[1]);
@@ -10222,7 +10222,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
     case TARGET_NR_setdomainname:
         if (!(p = lock_user_string(arg1)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(setdomainname(p, arg2));
         unlock_user(p, arg1, 0);
         return ret;
@@ -10232,7 +10232,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             struct new_utsname * buf;
 
             if (!lock_user_struct(VERIFY_WRITE, buf, arg1, 0))
-                goto efault;
+                return -TARGET_EFAULT;
             ret = get_errno(sys_uname(buf));
             if (!is_error(ret)) {
                 /* Overwrite the native machine name with whatever is being
@@ -10262,12 +10262,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             struct timex host_buf;
 
             if (target_to_host_timex(&host_buf, arg1) != 0) {
-                goto efault;
+                return -TARGET_EFAULT;
             }
             ret = get_errno(adjtimex(&host_buf));
             if (!is_error(ret)) {
                 if (host_to_target_timex(arg1, &host_buf) != 0) {
-                    goto efault;
+                    return -TARGET_EFAULT;
                 }
             }
         }
@@ -10278,12 +10278,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             struct timex htx, *phtx = &htx;
 
             if (target_to_host_timex(phtx, arg2) != 0) {
-                goto efault;
+                return -TARGET_EFAULT;
             }
             ret = get_errno(clock_adjtime(arg1, phtx));
             if (!is_error(ret) && phtx) {
                 if (host_to_target_timex(arg2, phtx) != 0) {
-                    goto efault;
+                    return -TARGET_EFAULT;
                 }
             }
         }
@@ -10338,7 +10338,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(_llseek(arg1, arg2, arg3, &res, arg5));
 #endif
             if ((ret == 0) && put_user_s64(res, arg4)) {
-                goto efault;
+                return -TARGET_EFAULT;
             }
         }
         return ret;
@@ -10372,7 +10372,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 		count1 = 0;
                 de = dirp;
                 if (!(target_dirp = lock_user(VERIFY_WRITE, arg2, count, 0)))
-                    goto efault;
+                    return -TARGET_EFAULT;
 		tde = target_dirp;
                 while (len > 0) {
                     reclen = de->d_reclen;
@@ -10400,7 +10400,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             abi_long count = arg3;
 
             if (!(dirp = lock_user(VERIFY_WRITE, arg2, count, 0)))
-                goto efault;
+                return -TARGET_EFAULT;
             ret = get_errno(sys_getdents(arg1, dirp, count));
             if (!is_error(ret)) {
                 struct linux_dirent *de;
@@ -10429,7 +10429,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 
             dirp = lock_user(VERIFY_WRITE, arg2, count, 0);
             if (!dirp) {
-                goto efault;
+                return -TARGET_EFAULT;
             }
             ret = get_errno(sys_getdents64(arg1, dirp, count));
             if (!is_error(ret)) {
@@ -10486,7 +10486,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             struct linux_dirent64 *dirp;
             abi_long count = arg3;
             if (!(dirp = lock_user(VERIFY_WRITE, arg2, count, 0)))
-                goto efault;
+                return -TARGET_EFAULT;
             ret = get_errno(sys_getdents64(arg1, dirp, count));
             if (!is_error(ret)) {
                 struct linux_dirent64 *de;
@@ -10535,7 +10535,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 target_pfd = lock_user(VERIFY_WRITE, arg1,
                                        sizeof(struct target_pollfd) * nfds, 1);
                 if (!target_pfd) {
-                    goto efault;
+                    return -TARGET_EFAULT;
                 }
 
                 ret = 0;
@@ -10565,7 +10565,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 if (arg3) {
                     if (target_to_host_timespec(timeout_ts, arg3)) {
                         unlock_user(target_pfd, arg1, 0);
-                        goto efault;
+                        return -TARGET_EFAULT;
                     }
                 } else {
                     timeout_ts = NULL;
@@ -10580,7 +10580,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                     target_set = lock_user(VERIFY_READ, arg4, sizeof(target_sigset_t), 1);
                     if (!target_set) {
                         unlock_user(target_pfd, arg1, 0);
-                        goto efault;
+                        return -TARGET_EFAULT;
                     }
                     target_to_host_sigset(set, target_set);
                 } else {
@@ -10748,7 +10748,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 }
 
                 if (host_to_target_cpu_mask(mask, mask_size, arg3, ret)) {
-                    goto efault;
+                    return -TARGET_EFAULT;
                 }
             }
         }
@@ -10785,10 +10785,10 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 goto fail;
             }
             if (arg1 && put_user_u32(cpu, arg1)) {
-                goto efault;
+                return -TARGET_EFAULT;
             }
             if (arg2 && put_user_u32(node, arg2)) {
-                goto efault;
+                return -TARGET_EFAULT;
             }
         }
         return ret;
@@ -10801,7 +10801,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 return -TARGET_EINVAL;
             }
             if (!lock_user_struct(VERIFY_READ, target_schp, arg2, 1))
-                goto efault;
+                return -TARGET_EFAULT;
             schp.sched_priority = tswap32(target_schp->sched_priority);
             unlock_user_struct(target_schp, arg2, 0);
             return get_errno(sched_setparam(arg1, &schp));
@@ -10817,7 +10817,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(sched_getparam(arg1, &schp));
             if (!is_error(ret)) {
                 if (!lock_user_struct(VERIFY_WRITE, target_schp, arg2, 0))
-                    goto efault;
+                    return -TARGET_EFAULT;
                 target_schp->sched_priority = tswap32(schp.sched_priority);
                 unlock_user_struct(target_schp, arg2, 1);
             }
@@ -10831,7 +10831,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 return -TARGET_EINVAL;
             }
             if (!lock_user_struct(VERIFY_READ, target_schp, arg3, 1))
-                goto efault;
+                return -TARGET_EFAULT;
             schp.sched_priority = tswap32(target_schp->sched_priority);
             unlock_user_struct(target_schp, arg3, 0);
             return get_errno(sched_setscheduler(arg1, arg2, &schp));
@@ -10879,7 +10879,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(prctl(arg1, &deathsig, arg3, arg4, arg5));
             if (!is_error(ret) && arg2
                 && put_user_ual(deathsig, arg2)) {
-                goto efault;
+                return -TARGET_EFAULT;
             }
             return ret;
         }
@@ -10888,7 +10888,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         {
             void *name = lock_user(VERIFY_WRITE, arg2, 16, 1);
             if (!name) {
-                goto efault;
+                return -TARGET_EFAULT;
             }
             ret = get_errno(prctl(arg1, (unsigned long)name,
                                   arg3, arg4, arg5));
@@ -10899,7 +10899,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         {
             void *name = lock_user(VERIFY_READ, arg2, 16, 1);
             if (!name) {
-                goto efault;
+                return -TARGET_EFAULT;
             }
             ret = get_errno(prctl(arg1, (unsigned long)name,
                                   arg3, arg4, arg5));
@@ -10962,7 +10962,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             arg5 = arg6;
         }
         if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(pread64(arg1, p, arg3, target_offset64(arg4, arg5)));
         unlock_user(p, arg2, ret);
         return ret;
@@ -10975,14 +10975,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             arg5 = arg6;
         }
         if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5)));
         unlock_user(p, arg2, 0);
         return ret;
 #endif
     case TARGET_NR_getcwd:
         if (!(p = lock_user(VERIFY_WRITE, arg1, arg2, 0)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(sys_getcwd1(p, arg2));
         unlock_user(p, arg1, ret);
         return ret;
@@ -10998,7 +10998,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         int data_items = 1;
 
         if (!lock_user_struct(VERIFY_WRITE, target_header, arg1, 1)) {
-            goto efault;
+            return -TARGET_EFAULT;
         }
         header.version = tswap32(target_header->version);
         header.pid = tswap32(target_header->pid);
@@ -11018,7 +11018,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             }
             if (!target_data) {
                 unlock_user_struct(target_header, arg1, 0);
-                goto efault;
+                return -TARGET_EFAULT;
             }
 
             if (num == TARGET_NR_capset) {
@@ -11142,7 +11142,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 	if (!is_error(ret)) {
 	    struct target_rlimit *target_rlim;
             if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0))
-                goto efault;
+                return -TARGET_EFAULT;
 	    target_rlim->rlim_cur = host_to_target_rlim(rlim.rlim_cur);
 	    target_rlim->rlim_max = host_to_target_rlim(rlim.rlim_max);
             unlock_user_struct(target_rlim, arg2, 1);
@@ -11153,7 +11153,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_truncate64
     case TARGET_NR_truncate64:
         if (!(p = lock_user_string(arg1)))
-            goto efault;
+            return -TARGET_EFAULT;
 	ret = target_truncate64(cpu_env, p, arg2, arg3, arg4);
         unlock_user(p, arg1, 0);
 	return ret;
@@ -11168,7 +11168,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_stat64
     case TARGET_NR_stat64:
         if (!(fn = lock_user_string(arg1))) {
-            goto efault;
+            return -TARGET_EFAULT;
         }
         TRY_INTERP_FD(ret, fn,
                       fstatat(interp_dirfd, fn + 1, &st, 0),
@@ -11182,7 +11182,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_lstat64
     case TARGET_NR_lstat64:
         if (!(fn = lock_user_string(arg1))) {
-            goto efault;
+            return -TARGET_EFAULT;
         }
         TRY_INTERP_FD(ret, fn,
                       fstatat(interp_dirfd, fn + 1, &st, AT_SYMLINK_NOFOLLOW),
@@ -11214,7 +11214,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             return -TARGET_EBADF;
         }
         if (!(fn = lock_user_string(arg2))) {
-            goto efault;
+            return -TARGET_EFAULT;
         }
         TRY_INTERP_FD(ret, fn,
                       fstatat(interp_dirfd, fn + 1, &st, arg4),
@@ -11228,7 +11228,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_lchown
     case TARGET_NR_lchown:
         if (!(p = lock_user_string(arg1)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(lchown(p, low2highuid(arg2), low2highgid(arg3)));
         unlock_user(p, arg1, 0);
         return ret;
@@ -11267,7 +11267,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             if (!is_error(ret)) {
                 target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * sizeof(target_id), 0);
                 if (!target_grouplist)
-                    goto efault;
+                    return -TARGET_EFAULT;
                 for(i = 0;i < ret; i++)
                     target_grouplist[i] = tswapid(high2lowgid(grouplist[i]));
                 unlock_user(target_grouplist, arg2, gidsetsize * sizeof(target_id));
@@ -11302,7 +11302,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             return -TARGET_EBADF;
         }
         if (!(p = lock_user_string(arg2))) 
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(fchownat(arg1, p, low2highuid(arg3),
                                  low2highgid(arg4), arg5));
         unlock_user(p, arg2, 0);
@@ -11323,7 +11323,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 if (put_user_id(high2lowuid(ruid), arg1)
                     || put_user_id(high2lowuid(euid), arg2)
                     || put_user_id(high2lowuid(suid), arg3))
-                    goto efault;
+                    return -TARGET_EFAULT;
             }
         }
         return ret;
@@ -11343,7 +11343,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 if (put_user_id(high2lowgid(rgid), arg1)
                     || put_user_id(high2lowgid(egid), arg2)
                     || put_user_id(high2lowgid(sgid), arg3))
-                    goto efault;
+                    return -TARGET_EFAULT;
             }
         }
         return ret;
@@ -11351,7 +11351,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_chown
     case TARGET_NR_chown:
         if (!(p = lock_user_string(arg1)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(chown(p, low2highuid(arg2), low2highgid(arg3)));
         unlock_user(p, arg1, 0);
         return ret;
@@ -11368,7 +11368,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_lchown32
     case TARGET_NR_lchown32:
         if (!(p = lock_user_string(arg1)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(lchown(p, arg2, arg3));
         unlock_user(p, arg1, 0);
         return ret;
@@ -11419,7 +11419,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 swcr |= (~fpcr >> 41) & SWCR_TRAP_ENABLE_DNO;
 
                 if (put_user_u64 (swcr, arg2))
-                        goto efault;
+                        return -TARGET_EFAULT;
                 ret = 0;
             }
             break;
@@ -11446,7 +11446,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 uint64_t swcr, fpcr, orig_fpcr;
 
                 if (get_user_u64 (swcr, arg2)) {
-                    goto efault;
+                    return -TARGET_EFAULT;
                 }
                 orig_fpcr = cpu_alpha_load_fpcr(cpu_env);
                 fpcr = orig_fpcr & FPCR_DYN_MASK;
@@ -11473,7 +11473,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 int si_code;
 
                 if (get_user_u64(exc, arg2)) {
-                    goto efault;
+                    return -TARGET_EFAULT;
                 }
 
                 orig_fpcr = cpu_alpha_load_fpcr(cpu_env);
@@ -11645,7 +11645,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 if (put_user_u32(ruid, arg1)
                     || put_user_u32(euid, arg2)
                     || put_user_u32(suid, arg3))
-                    goto efault;
+                    return -TARGET_EFAULT;
             }
         }
         return ret;
@@ -11663,7 +11663,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 if (put_user_u32(rgid, arg1)
                     || put_user_u32(egid, arg2)
                     || put_user_u32(sgid, arg3))
-                    goto efault;
+                    return -TARGET_EFAULT;
             }
         }
         return ret;
@@ -11671,7 +11671,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_chown32
     case TARGET_NR_chown32:
         if (!(p = lock_user_string(arg1)))
-            goto efault;
+            return -TARGET_EFAULT;
         ret = get_errno(chown(p, arg2, arg3));
         unlock_user(p, arg1, 0);
         return ret;
@@ -12204,7 +12204,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 ret = get_errno(sys_utimensat(arg1, NULL, tsp, arg4));
             else {
                 if (!(fn = lock_user_string(arg2))) {
-                    goto efault;
+                    return -TARGET_EFAULT;
                 }
                 TRY_INTERP_FD(ret, fn,
                               sys_utimensat(interp_dirfd, fn + 1, tsp, arg4),
@@ -12242,7 +12242,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             return -TARGET_EBADF;
         }
         if (!(fn = lock_user_string(arg2))) {
-            goto efault;
+            return -TARGET_EFAULT;
         }
         TRY_INTERP_PATH(ret, fn, sys_inotify_add_watch(arg1, fn, arg3));
         ret = get_errno(ret);
@@ -12268,13 +12268,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             pposix_mq_attr = NULL;
             if (arg4) {
                 if (copy_from_user_mq_attr(&posix_mq_attr, arg4) != 0) {
-                    goto efault;
+                    return -TARGET_EFAULT;
                 }
                 pposix_mq_attr = &posix_mq_attr;
             }
             p = lock_user_string(arg1 - 1);
             if (!p) {
-                goto efault;
+                return -TARGET_EFAULT;
             }
             ret = get_errno(mq_open(p, host_flags, arg3, pposix_mq_attr));
             unlock_user (p, arg1, 0);
@@ -12368,25 +12368,25 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             loff_t *ploff_in = NULL, *ploff_out = NULL;
             if (arg2) {
                 if (get_user_u64(loff_in, arg2)) {
-                    goto efault;
+                    return -TARGET_EFAULT;
                 }
                 ploff_in = &loff_in;
             }
             if (arg4) {
                 if (get_user_u64(loff_out, arg4)) {
-                    goto efault;
+                    return -TARGET_EFAULT;
                 }
                 ploff_out = &loff_out;
             }
             ret = get_errno(splice(arg1, ploff_in, arg3, ploff_out, arg5, arg6));
             if (arg2) {
                 if (put_user_u64(loff_in, arg2)) {
-                    goto efault;
+                    return -TARGET_EFAULT;
                 }
             }
             if (arg4) {
                 if (put_user_u64(loff_out, arg4)) {
-                    goto efault;
+                    return -TARGET_EFAULT;
                 }
             }
         }
@@ -12517,7 +12517,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         if (arg4) {
             struct target_epoll_event *target_ep;
             if (!lock_user_struct(VERIFY_READ, target_ep, arg4, 1)) {
-                goto efault;
+                return -TARGET_EFAULT;
             }
             ep.events = tswap32(target_ep->events);
             /* The epoll_data_t union is just opaque data to the kernel,
@@ -12556,7 +12556,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         target_ep = lock_user(VERIFY_WRITE, arg2,
                               maxevents * sizeof(struct target_epoll_event), 1);
         if (!target_ep) {
-            goto efault;
+            return -TARGET_EFAULT;
         }
 
         ep = g_try_new(struct epoll_event, maxevents);
@@ -12628,7 +12628,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         int resource = target_to_host_resource(arg2);
         if (arg3) {
             if (!lock_user_struct(VERIFY_READ, target_rnew, arg3, 1)) {
-                goto efault;
+                return -TARGET_EFAULT;
             }
             rnew.rlim_cur = tswap64(target_rnew->rlim_cur);
             rnew.rlim_max = tswap64(target_rnew->rlim_max);
@@ -12639,7 +12639,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         ret = get_errno(sys_prlimit64(arg1, resource, rnewp, arg4 ? &rold : 0));
         if (!is_error(ret) && arg4) {
             if (!lock_user_struct(VERIFY_WRITE, target_rold, arg4, 1)) {
-                goto efault;
+                return -TARGET_EFAULT;
             }
             target_rold->rlim_cur = tswap64(rold.rlim_cur);
             target_rold->rlim_max = tswap64(rold.rlim_max);
@@ -12717,7 +12717,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 phtimer = NULL;
             } else {
                 if (put_user(TIMER_MAGIC | timer_index, arg3, target_timer_t)) {
-                    goto efault;
+                    return -TARGET_EFAULT;
                 }
             }
         }
@@ -12741,12 +12741,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             struct itimerspec hspec_new = {{0},}, hspec_old = {{0},};
 
             if (target_to_host_itimerspec(&hspec_new, arg3)) {
-                goto efault;
+                return -TARGET_EFAULT;
             }
             ret = get_errno(
                           timer_settime(htimer, arg2, &hspec_new, &hspec_old));
             if (arg4 && host_to_target_itimerspec(arg4, &hspec_old)) {
-                goto efault;
+                return -TARGET_EFAULT;
             }
         }
         return ret;
@@ -12826,7 +12826,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(timerfd_gettime(arg1, &its_curr));
 
             if (arg2 && host_to_target_itimerspec(arg2, &its_curr)) {
-                goto efault;
+                return -TARGET_EFAULT;
             }
         }
         return ret;
@@ -12841,7 +12841,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 
             if (arg3) {
                 if (target_to_host_itimerspec(&its_new, arg3)) {
-                    goto efault;
+                    return -TARGET_EFAULT;
                 }
                 p_new = &its_new;
             } else {
@@ -12851,7 +12851,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             ret = get_errno(timerfd_settime(arg1, arg2, p_new, &its_old));
 
             if (arg4 && host_to_target_itimerspec(arg4, &its_old)) {
-                goto efault;
+                return -TARGET_EFAULT;
             }
         }
         return ret;
@@ -12893,9 +12893,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
     }
 fail:
     return ret;
-efault:
-    ret = -TARGET_EFAULT;
-    goto fail;
 }
 
 abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 05/33] linux-user: Propagate goto unimplemented_nowarn to return
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (3 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 04/33] linux-user: Propagate goto efault " Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-04 19:36   ` Laurent Vivier
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 06/33] linux-user: Split out goto unimplemented to do_unimplemented Richard Henderson
                   ` (29 subsequent siblings)
  34 siblings, 1 reply; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8ea2099001..f7b7051c1c 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -12081,7 +12081,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
           return 0;
       }
 #else
-      goto unimplemented_nowarn;
+      return -TARGET_ENOSYS;
 #endif
 #endif
 #ifdef TARGET_NR_get_thread_area
@@ -12094,12 +12094,12 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             return ts->tp_value;
         }
 #else
-        goto unimplemented_nowarn;
+        return -TARGET_ENOSYS;
 #endif
 #endif
 #ifdef TARGET_NR_getdomainname
     case TARGET_NR_getdomainname:
-        goto unimplemented_nowarn;
+        return -TARGET_ENOSYS;
 #endif
 
 #ifdef TARGET_NR_clock_settime
@@ -12184,7 +12184,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
          * holding a mutex that is shared with another process via
          * shared memory).
          */
-        goto unimplemented_nowarn;
+        return -TARGET_ENOSYS;
 #endif
 
 #if defined(TARGET_NR_utimensat)
@@ -12886,9 +12886,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
     default:
     unimplemented:
         gemu_log("qemu: Unsupported syscall: %d\n", num);
-#if defined(TARGET_NR_setxattr) || defined(TARGET_NR_get_thread_area) || defined(TARGET_NR_getdomainname) || defined(TARGET_NR_set_robust_list)
-    unimplemented_nowarn:
-#endif
         return -TARGET_ENOSYS;
     }
 fail:
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 06/33] linux-user: Split out goto unimplemented to do_unimplemented
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (4 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 05/33] linux-user: Propagate goto unimplemented_nowarn " Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-04 19:38   ` Laurent Vivier
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 07/33] linux-user: Propagate goto fail to return Richard Henderson
                   ` (28 subsequent siblings)
  34 siblings, 1 reply; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 82 +++++++++++++++++++++++---------------------
 1 file changed, 43 insertions(+), 39 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index f7b7051c1c..4269ec2c23 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7962,6 +7962,12 @@ static int host_to_target_cpu_mask(const unsigned long *host_mask,
     return 0;
 }
 
+static abi_long do_unimplemented(int num)
+{
+    gemu_log("qemu: Unsupported syscall: %d\n", num);
+    return -TARGET_ENOSYS;
+}
+
 /* This is an internal helper for do_syscall so that it is easier
  * to have a single return point, so that actions, such as logging
  * of syscall results, can be performed.
@@ -8342,11 +8348,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
 #ifdef TARGET_NR_break
     case TARGET_NR_break:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
 #ifdef TARGET_NR_oldstat
     case TARGET_NR_oldstat:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
     case TARGET_NR_lseek:
         if (is_hostfd(arg1)) {
@@ -8436,14 +8442,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         }
 #endif
     case TARGET_NR_ptrace:
-        goto unimplemented;
+        return do_unimplemented(num);
 #ifdef TARGET_NR_alarm /* not on alpha */
     case TARGET_NR_alarm:
         return alarm(arg1);
 #endif
 #ifdef TARGET_NR_oldfstat
     case TARGET_NR_oldfstat:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
 #ifdef TARGET_NR_pause /* not on alpha */
     case TARGET_NR_pause:
@@ -8522,11 +8528,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
 #ifdef TARGET_NR_stty
     case TARGET_NR_stty:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
 #ifdef TARGET_NR_gtty
     case TARGET_NR_gtty:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
 #ifdef TARGET_NR_access
     case TARGET_NR_access:
@@ -8561,7 +8567,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
 #ifdef TARGET_NR_ftime
     case TARGET_NR_ftime:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
     case TARGET_NR_sync:
         sync();
@@ -8687,11 +8693,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return ret;
 #ifdef TARGET_NR_prof
     case TARGET_NR_prof:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
 #ifdef TARGET_NR_signal
     case TARGET_NR_signal:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
     case TARGET_NR_acct:
         if (arg1 == 0) {
@@ -8715,7 +8721,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
 #ifdef TARGET_NR_lock
     case TARGET_NR_lock:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
     case TARGET_NR_ioctl:
         return do_ioctl(arg1, arg2, arg3);
@@ -8725,17 +8731,17 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
 #ifdef TARGET_NR_mpx
     case TARGET_NR_mpx:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
     case TARGET_NR_setpgid:
         return get_errno(setpgid(arg1, arg2));
 #ifdef TARGET_NR_ulimit
     case TARGET_NR_ulimit:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
 #ifdef TARGET_NR_oldolduname
     case TARGET_NR_oldolduname:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
     case TARGET_NR_umask:
         return get_errno(umask(arg1));
@@ -8747,7 +8753,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return ret;
 #ifdef TARGET_NR_ustat
     case TARGET_NR_ustat:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
 #ifdef TARGET_NR_dup2
     case TARGET_NR_dup2:
@@ -9471,7 +9477,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
 #ifdef TARGET_NR_oldlstat
     case TARGET_NR_oldlstat:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
 #ifdef TARGET_NR_readlink
     case TARGET_NR_readlink:
@@ -9536,7 +9542,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
 #ifdef TARGET_NR_uselib
     case TARGET_NR_uselib:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
 #ifdef TARGET_NR_swapon
     case TARGET_NR_swapon:
@@ -9561,7 +9567,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return ret;
 #ifdef TARGET_NR_readdir
     case TARGET_NR_readdir:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
 #ifdef TARGET_NR_mmap
     case TARGET_NR_mmap:
@@ -9699,7 +9705,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return get_errno(setpriority(arg1, arg2, arg3));
 #ifdef TARGET_NR_profil
     case TARGET_NR_profil:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
     case TARGET_NR_statfs:
         if (!(fn = lock_user_string(arg1))) {
@@ -9778,7 +9784,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
 #ifdef TARGET_NR_ioperm
     case TARGET_NR_ioperm:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
 #ifdef TARGET_NR_socketcall
     case TARGET_NR_socketcall:
@@ -10062,17 +10068,17 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return ret;
 #ifdef TARGET_NR_olduname
     case TARGET_NR_olduname:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
 #ifdef TARGET_NR_iopl
     case TARGET_NR_iopl:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
     case TARGET_NR_vhangup:
         return get_errno(vhangup());
 #ifdef TARGET_NR_idle
     case TARGET_NR_idle:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
 #ifdef TARGET_NR_syscall
     case TARGET_NR_syscall:
@@ -10252,7 +10258,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return do_modify_ldt(cpu_env, arg1, arg2, arg3);
 #if !defined(TARGET_X86_64)
     case TARGET_NR_vm86old:
-        goto unimplemented;
+        return do_unimplemented(num);
     case TARGET_NR_vm86:
         return do_vm86(cpu_env, arg1, arg2);
 #endif
@@ -10297,9 +10303,9 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_get_kernel_syms
     case TARGET_NR_get_kernel_syms:
 #endif
-        goto unimplemented;
+        return do_unimplemented(num);
     case TARGET_NR_quotactl:
-        goto unimplemented;
+        return do_unimplemented(num);
     case TARGET_NR_getpgid:
         return get_errno(getpgid(arg1));
     case TARGET_NR_fchdir:
@@ -10309,17 +10315,17 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return get_errno(fchdir(arg1));
 #ifdef TARGET_NR_bdflush /* not on x86_64 */
     case TARGET_NR_bdflush:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
 #ifdef TARGET_NR_sysfs
     case TARGET_NR_sysfs:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
     case TARGET_NR_personality:
         return get_errno(personality(arg1));
 #ifdef TARGET_NR_afs_syscall
     case TARGET_NR_afs_syscall:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
 #ifdef TARGET_NR__llseek /* Not on alpha */
     case TARGET_NR__llseek:
@@ -10865,11 +10871,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return ret;
 #ifdef TARGET_NR_query_module
     case TARGET_NR_query_module:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
 #ifdef TARGET_NR_nfsservctl
     case TARGET_NR_nfsservctl:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
     case TARGET_NR_prctl:
         switch (arg1) {
@@ -10949,7 +10955,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_I386) && !defined(TARGET_ABI32)
         return do_arch_prctl(cpu_env, arg1, arg2);
 #else
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
 #endif
 #ifdef TARGET_NR_pread64
@@ -11116,16 +11122,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_sendfile64
     case TARGET_NR_sendfile64:
 #endif
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
 
 #ifdef TARGET_NR_getpmsg
     case TARGET_NR_getpmsg:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
 #ifdef TARGET_NR_putpmsg
     case TARGET_NR_putpmsg:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
 #ifdef TARGET_NR_vfork
     case TARGET_NR_vfork:
@@ -11694,7 +11700,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
 
     case TARGET_NR_pivot_root:
-        goto unimplemented;
+        return do_unimplemented(num);
 #ifdef TARGET_NR_mincore
     case TARGET_NR_mincore:
         {
@@ -11869,7 +11875,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
 #ifdef TARGET_NR_security
     case TARGET_NR_security:
-        goto unimplemented;
+        return do_unimplemented(num);
 #endif
 #ifdef TARGET_NR_getpagesize
     case TARGET_NR_getpagesize:
@@ -12884,9 +12890,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #endif
 
     default:
-    unimplemented:
-        gemu_log("qemu: Unsupported syscall: %d\n", num);
-        return -TARGET_ENOSYS;
+        return do_unimplemented(num);
     }
 fail:
     return ret;
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 07/33] linux-user: Propagate goto fail to return
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (5 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 06/33] linux-user: Split out goto unimplemented to do_unimplemented Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-04 19:48   ` Laurent Vivier
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 08/33] linux-user: Make syscall number unsigned Richard Henderson
                   ` (27 subsequent siblings)
  34 siblings, 1 reply; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 62 ++++++++++++++++----------------------------
 1 file changed, 23 insertions(+), 39 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 4269ec2c23..a413aad658 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -9001,8 +9001,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 how = SIG_SETMASK;
                 break;
             default:
-                ret = -TARGET_EINVAL;
-                goto fail;
+                return -TARGET_EINVAL;
             }
             mask = arg2;
             target_to_host_old_sigset(&set, &mask);
@@ -9029,8 +9028,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                     how = SIG_SETMASK;
                     break;
                 default:
-                    ret = -TARGET_EINVAL;
-                    goto fail;
+                    return -TARGET_EINVAL;
                 }
                 if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))
                     return -TARGET_EFAULT;
@@ -9073,8 +9071,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                     how = SIG_SETMASK;
                     break;
                 default:
-                    ret = -TARGET_EINVAL;
-                    goto fail;
+                    return -TARGET_EINVAL;
                 }
                 if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))
                     return -TARGET_EFAULT;
@@ -9363,15 +9360,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 
             ret = copy_from_user_fdset_ptr(&rfds, &rfds_ptr, rfd_addr, n);
             if (ret) {
-                goto fail;
+                return ret;
             }
             ret = copy_from_user_fdset_ptr(&wfds, &wfds_ptr, wfd_addr, n);
             if (ret) {
-                goto fail;
+                return ret;
             }
             ret = copy_from_user_fdset_ptr(&efds, &efds_ptr, efd_addr, n);
             if (ret) {
-                goto fail;
+                return ret;
             }
             if (contains_hostfd(&rfds) ||
                 contains_hostfd(&wfds) ||
@@ -9409,8 +9406,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                     sig.set = &set;
                     if (arg_sigsize != sizeof(*target_sigset)) {
                         /* Like the kernel, we enforce correct size sigsets */
-                        ret = -TARGET_EINVAL;
-                        goto fail;
+                        return -TARGET_EINVAL;
                     }
                     target_sigset = lock_user(VERIFY_READ, arg_sigset,
                                               sizeof(*target_sigset), 1);
@@ -9951,18 +9947,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             case TARGET_SYSLOG_ACTION_READ_CLEAR:    /* Read/clear msgs */
             case TARGET_SYSLOG_ACTION_READ_ALL:      /* Read last messages */
                 {
-                    ret = -TARGET_EINVAL;
                     if (len < 0) {
-                        goto fail;
+                        return -TARGET_EINVAL;
                     }
-                    ret = 0;
                     if (len == 0) {
-                        return ret;
+                        return 0;
                     }
                     p = lock_user(VERIFY_WRITE, arg2, arg3, 0);
                     if (!p) {
-                        ret = -TARGET_EFAULT;
-                        goto fail;
+                        return -TARGET_EFAULT;
                     }
                     ret = get_errno(sys_syslog((int)arg1, p, (int)arg3));
                     unlock_user(p, arg2, arg3);
@@ -10363,8 +10356,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 
             dirp = g_try_malloc(count);
             if (!dirp) {
-                ret = -TARGET_ENOMEM;
-                goto fail;
+                return -TARGET_ENOMEM;
             }
 
             ret = get_errno(sys_getdents(arg1, dirp, count));
@@ -10556,7 +10548,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 if (ret < 0) {
                     unlock_user(target_pfd, arg1,
                                 sizeof(struct target_pollfd) * nfds);
-                    goto fail;
+                    return ret;
                 }
             }
 
@@ -10788,7 +10780,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                                        arg2 ? &node : NULL,
                                        NULL));
             if (is_error(ret)) {
-                goto fail;
+                return ret;
             }
             if (arg1 && put_user_u32(cpu, arg1)) {
                 return -TARGET_EFAULT;
@@ -11290,8 +11282,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 grouplist = alloca(gidsetsize * sizeof(gid_t));
                 target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * sizeof(target_id), 1);
                 if (!target_grouplist) {
-                    ret = -TARGET_EFAULT;
-                    goto fail;
+                    return -TARGET_EFAULT;
                 }
                 for (i = 0; i < gidsetsize; i++) {
                     grouplist[i] = low2highgid(tswapid(target_grouplist[i]));
@@ -11552,8 +11543,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
                 how = SIG_SETMASK;
                 break;
             default:
-                ret = -TARGET_EINVAL;
-                goto fail;
+                return -TARGET_EINVAL;
             }
             mask = arg2;
             target_to_host_old_sigset(&set, &mask);
@@ -11601,8 +11591,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             if (!is_error(ret)) {
                 target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 4, 0);
                 if (!target_grouplist) {
-                    ret = -TARGET_EFAULT;
-                    goto fail;
+                    return -TARGET_EFAULT;
                 }
                 for(i = 0;i < ret; i++)
                     target_grouplist[i] = tswap32(grouplist[i]);
@@ -11622,8 +11611,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
             grouplist = alloca(gidsetsize * sizeof(gid_t));
             target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 4, 1);
             if (!target_grouplist) {
-                ret = -TARGET_EFAULT;
-                goto fail;
+                return -TARGET_EFAULT;
             }
             for(i = 0;i < gidsetsize; i++)
                 grouplist[i] = tswap32(target_grouplist[i]);
@@ -11704,20 +11692,17 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
 #ifdef TARGET_NR_mincore
     case TARGET_NR_mincore:
         {
-            void *a;
-            ret = -TARGET_ENOMEM;
-            a = lock_user(VERIFY_READ, arg1, arg2, 0);
+            void *a = lock_user(VERIFY_READ, arg1, arg2, 0);
             if (!a) {
-                goto fail;
+                return -TARGET_ENOMEM;
             }
-            ret = -TARGET_EFAULT;
             p = lock_user_string(arg3);
             if (!p) {
-                goto mincore_fail;
+                ret = -TARGET_EFAULT;
+            } else {
+                ret = get_errno(mincore(a, arg2, p));
+                unlock_user(p, arg3, ret);
             }
-            ret = get_errno(mincore(a, arg2, p));
-            unlock_user(p, arg3, ret);
-            mincore_fail:
             unlock_user(a, arg1, 0);
         }
         return ret;
@@ -12892,7 +12877,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
     default:
         return do_unimplemented(num);
     }
-fail:
     return ret;
 }
 
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 08/33] linux-user: Make syscall number unsigned
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (6 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 07/33] linux-user: Propagate goto fail to return Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-04 19:50   ` Laurent Vivier
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 09/33] linux-user: Set up infrastructure for table-izing syscalls Richard Henderson
                   ` (26 subsequent siblings)
  34 siblings, 1 reply; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/qemu.h    |  2 +-
 linux-user/syscall.c | 20 ++++++++++----------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/linux-user/qemu.h b/linux-user/qemu.h
index 05a82a3628..623a8d8b7a 100644
--- a/linux-user/qemu.h
+++ b/linux-user/qemu.h
@@ -231,7 +231,7 @@ abi_long memcpy_to_target(abi_ulong dest, const void *src,
 void target_set_brk(abi_ulong new_brk);
 abi_long do_brk(abi_ulong new_brk);
 void syscall_init(void);
-abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
+abi_long do_syscall(void *cpu_env, unsigned num, abi_long arg1,
                     abi_long arg2, abi_long arg3, abi_long arg4,
                     abi_long arg5, abi_long arg6, abi_long arg7,
                     abi_long arg8);
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index a413aad658..e2e2d58e84 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -719,20 +719,20 @@ static inline int next_free_host_timer(void)
 
 /* ARM EABI and MIPS expect 64bit types aligned even on pairs or registers */
 #ifdef TARGET_ARM
-static inline int regpairs_aligned(void *cpu_env, int num)
+static inline int regpairs_aligned(void *cpu_env, unsigned num)
 {
     return ((((CPUARMState *)cpu_env)->eabi) == 1) ;
 }
 #elif defined(TARGET_MIPS) && (TARGET_ABI_BITS == 32)
-static inline int regpairs_aligned(void *cpu_env, int num) { return 1; }
+static inline int regpairs_aligned(void *cpu_env, unsigned num) { return 1; }
 #elif defined(TARGET_PPC) && !defined(TARGET_PPC64)
 /* SysV AVI for PPC32 expects 64bit parameters to be passed on odd/even pairs
  * of registers which translates to the same as ARM/MIPS, because we start with
  * r3 as arg1 */
-static inline int regpairs_aligned(void *cpu_env, int num) { return 1; }
+static inline int regpairs_aligned(void *cpu_env, unsigned num) { return 1; }
 #elif defined(TARGET_SH4)
 /* SH4 doesn't align register pairs, except for p{read,write}64 */
-static inline int regpairs_aligned(void *cpu_env, int num)
+static inline int regpairs_aligned(void *cpu_env, unsigned num)
 {
     switch (num) {
     case TARGET_NR_pread64:
@@ -744,9 +744,9 @@ static inline int regpairs_aligned(void *cpu_env, int num)
     }
 }
 #elif defined(TARGET_XTENSA)
-static inline int regpairs_aligned(void *cpu_env, int num) { return 1; }
+static inline int regpairs_aligned(void *cpu_env, unsigned num) { return 1; }
 #else
-static inline int regpairs_aligned(void *cpu_env, int num) { return 0; }
+static inline int regpairs_aligned(void *cpu_env, unsigned num) { return 0; }
 #endif
 
 #define ERRNO_TABLE_SIZE 1200
@@ -7962,9 +7962,9 @@ static int host_to_target_cpu_mask(const unsigned long *host_mask,
     return 0;
 }
 
-static abi_long do_unimplemented(int num)
+static abi_long do_unimplemented(unsigned num)
 {
-    gemu_log("qemu: Unsupported syscall: %d\n", num);
+    gemu_log("qemu: Unsupported syscall: %u\n", num);
     return -TARGET_ENOSYS;
 }
 
@@ -7973,7 +7973,7 @@ static abi_long do_unimplemented(int num)
  * of syscall results, can be performed.
  * All errnos that do_syscall() returns must be -TARGET_<errcode>.
  */
-static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
+static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1,
                             abi_long arg2, abi_long arg3, abi_long arg4,
                             abi_long arg5, abi_long arg6, abi_long arg7,
                             abi_long arg8)
@@ -12880,7 +12880,7 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
     return ret;
 }
 
-abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
+abi_long do_syscall(void *cpu_env, unsigned num, abi_long arg1,
                     abi_long arg2, abi_long arg3, abi_long arg4,
                     abi_long arg5, abi_long arg6, abi_long arg7,
                     abi_long arg8)
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 09/33] linux-user: Set up infrastructure for table-izing syscalls
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (7 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 08/33] linux-user: Make syscall number unsigned Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-04 19:55   ` Laurent Vivier
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 10/33] linux-user: Split out brk, close, exit, read, write Richard Henderson
                   ` (25 subsequent siblings)
  34 siblings, 1 reply; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 42 ++++++++++++++++++++++++++++++++++--------
 1 file changed, 34 insertions(+), 8 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index e2e2d58e84..fc3dc3f40d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7962,21 +7962,34 @@ static int host_to_target_cpu_mask(const unsigned long *host_mask,
     return 0;
 }
 
+typedef abi_long impl_fn(void *cpu_env, unsigned num, abi_long arg1,
+                         abi_long arg2, abi_long arg3, abi_long arg4,
+                         abi_long arg5, abi_long arg6, abi_long arg7,
+                         abi_long arg8);
+
 static abi_long do_unimplemented(unsigned num)
 {
     gemu_log("qemu: Unsupported syscall: %u\n", num);
     return -TARGET_ENOSYS;
 }
 
+#define IMPL(NAME) \
+static abi_long impl_##NAME(void *cpu_env, unsigned num, abi_long arg1,   \
+                            abi_long arg2, abi_long arg3, abi_long arg4,  \
+                            abi_long arg5, abi_long arg6, abi_long arg7,  \
+                            abi_long arg8)
+
+IMPL(enosys)
+{
+    return do_unimplemented(num);
+}
+
 /* This is an internal helper for do_syscall so that it is easier
  * to have a single return point, so that actions, such as logging
  * of syscall results, can be performed.
  * All errnos that do_syscall() returns must be -TARGET_<errcode>.
  */
-static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1,
-                            abi_long arg2, abi_long arg3, abi_long arg4,
-                            abi_long arg5, abi_long arg6, abi_long arg7,
-                            abi_long arg8)
+IMPL(everything_else)
 {
     CPUState *cpu = ENV_GET_CPU(cpu_env);
     abi_long ret;
@@ -12880,6 +12893,10 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1,
     return ret;
 }
 
+static impl_fn * const syscall_table[] = {
+    impl_everything_else,
+};
+
 abi_long do_syscall(void *cpu_env, unsigned num, abi_long arg1,
                     abi_long arg2, abi_long arg3, abi_long arg4,
                     abi_long arg5, abi_long arg6, abi_long arg7,
@@ -12908,14 +12925,23 @@ abi_long do_syscall(void *cpu_env, unsigned num, abi_long arg1,
     trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4,
                              arg5, arg6, arg7, arg8);
 
+    /* ??? After impl_everything_else is fully split, initialize with NULL.  */
+    impl_fn *fn = impl_everything_else;
+    if (num < ARRAY_SIZE(syscall_table)) {
+        fn = syscall_table[num];
+    }
+    if (fn == NULL) {
+        fn = impl_enosys;
+    }
+
     if (unlikely(do_strace)) {
         print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
-        ret = do_syscall1(cpu_env, num, arg1, arg2, arg3, arg4,
-                          arg5, arg6, arg7, arg8);
+        ret = fn(cpu_env, num, arg1, arg2, arg3, arg4,
+                 arg5, arg6, arg7, arg8);
         print_syscall_ret(num, ret);
     } else {
-        ret = do_syscall1(cpu_env, num, arg1, arg2, arg3, arg4,
-                          arg5, arg6, arg7, arg8);
+        ret = fn(cpu_env, num, arg1, arg2, arg3, arg4,
+                 arg5, arg6, arg7, arg8);
     }
 
 #ifdef DEBUG
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 10/33] linux-user: Split out brk, close, exit, read, write
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (8 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 09/33] linux-user: Set up infrastructure for table-izing syscalls Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-04 20:17   ` Laurent Vivier
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 11/33] linux-user: Split out execve Richard Henderson
                   ` (24 subsequent siblings)
  34 siblings, 1 reply; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

These are relatively simple unconditionally defined syscalls.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 198 ++++++++++++++++++++++++-------------------
 1 file changed, 111 insertions(+), 87 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index fc3dc3f40d..b0d268dab7 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7984,6 +7984,112 @@ IMPL(enosys)
     return do_unimplemented(num);
 }
 
+IMPL(brk)
+{
+    return do_brk(arg1);
+}
+
+IMPL(close)
+{
+    if (is_hostfd(arg1)) {
+        return -TARGET_EBADF;
+    }
+    fd_trans_unregister(arg1);
+    return get_errno(close(arg1));
+}
+
+IMPL(exit)
+{
+    CPUState *cpu = ENV_GET_CPU(cpu_env);
+
+    /* In old applications this may be used to implement _exit(2).
+       However in threaded applictions it is used for thread termination,
+       and _exit_group is used for application termination.
+       Do thread termination if we have more then one thread.  */
+    if (block_signals()) {
+        return -TARGET_ERESTARTSYS;
+    }
+
+    cpu_list_lock();
+
+    if (CPU_NEXT(first_cpu)) {
+        /* Remove the CPU from the list.  */
+        QTAILQ_REMOVE(&cpus, cpu, node);
+        cpu_list_unlock();
+
+        TaskState *ts = cpu->opaque;
+        if (ts->child_tidptr) {
+            put_user_u32(0, ts->child_tidptr);
+            sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX,
+                      NULL, NULL, 0);
+        }
+        thread_cpu = NULL;
+        object_unref(OBJECT(cpu));
+        g_free(ts);
+        rcu_unregister_thread();
+        pthread_exit(NULL);
+    } else {
+        cpu_list_unlock();
+
+#ifdef TARGET_GPROF
+        _mcleanup();
+#endif
+        gdb_exit(cpu_env, arg1);
+        _exit(arg1);
+    }
+    g_assert_not_reached();
+}
+
+IMPL(read)
+{
+    abi_long ret;
+    char *fn;
+
+    if (arg3 == 0) {
+        return 0;
+    }
+    if (is_hostfd(arg1)) {
+        return -TARGET_EBADF;
+    }
+    fn = lock_user(VERIFY_WRITE, arg2, arg3, 0);
+    if (!fn) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(safe_read(arg1, fn, arg3));
+    if (ret >= 0 && fd_trans_host_to_target_data(arg1)) {
+        ret = fd_trans_host_to_target_data(arg1)(fn, ret);
+    }
+    unlock_user(fn, arg2, ret);
+    return ret;
+}
+
+IMPL(write)
+{
+    abi_long ret;
+    char *fn;
+
+    if (is_hostfd(arg1)) {
+        return -TARGET_EBADF;
+    }
+    fn = lock_user(VERIFY_READ, arg2, arg3, 1);
+    if (!fn) {
+        return -TARGET_EFAULT;
+    }
+    if (fd_trans_target_to_host_data(arg1)) {
+        void *copy = g_malloc(arg3);
+        memcpy(copy, fn, arg3);
+        ret = fd_trans_target_to_host_data(arg1)(copy, arg3);
+        if (ret >= 0) {
+            ret = get_errno(safe_write(arg1, copy, ret));
+        }
+        g_free(copy);
+    } else {
+        ret = get_errno(safe_write(arg1, fn, arg3));
+    }
+    unlock_user(fn, arg2, ret);
+    return ret;
+}
+
 /* This is an internal helper for do_syscall so that it is easier
  * to have a single return point, so that actions, such as logging
  * of syscall results, can be performed.
@@ -7999,83 +8105,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-    case TARGET_NR_exit:
-        /* In old applications this may be used to implement _exit(2).
-           However in threaded applictions it is used for thread termination,
-           and _exit_group is used for application termination.
-           Do thread termination if we have more then one thread.  */
-
-        if (block_signals()) {
-            return -TARGET_ERESTARTSYS;
-        }
-
-        cpu_list_lock();
-
-        if (CPU_NEXT(first_cpu)) {
-            TaskState *ts;
-
-            /* Remove the CPU from the list.  */
-            QTAILQ_REMOVE(&cpus, cpu, node);
-
-            cpu_list_unlock();
-
-            ts = cpu->opaque;
-            if (ts->child_tidptr) {
-                put_user_u32(0, ts->child_tidptr);
-                sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX,
-                          NULL, NULL, 0);
-            }
-            thread_cpu = NULL;
-            object_unref(OBJECT(cpu));
-            g_free(ts);
-            rcu_unregister_thread();
-            pthread_exit(NULL);
-        }
-
-        cpu_list_unlock();
-#ifdef TARGET_GPROF
-        _mcleanup();
-#endif
-        gdb_exit(cpu_env, arg1);
-        _exit(arg1);
-        return 0; /* avoid warning */
-    case TARGET_NR_read:
-        if (arg3 == 0) {
-            return 0;
-        } else {
-            if (is_hostfd(arg1)) {
-                return -TARGET_EBADF;
-            }
-            if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
-                return -TARGET_EFAULT;
-            ret = get_errno(safe_read(arg1, p, arg3));
-            if (ret >= 0 &&
-                fd_trans_host_to_target_data(arg1)) {
-                ret = fd_trans_host_to_target_data(arg1)(p, ret);
-            }
-            unlock_user(p, arg2, ret);
-        }
-        return ret;
-    case TARGET_NR_write:
-        if (is_hostfd(arg1)) {
-            return -TARGET_EBADF;
-        }
-        if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
-            return -TARGET_EFAULT;
-        if (fd_trans_target_to_host_data(arg1)) {
-            void *copy = g_malloc(arg3);
-            memcpy(copy, p, arg3);
-            ret = fd_trans_target_to_host_data(arg1)(copy, arg3);
-            if (ret >= 0) {
-                ret = get_errno(safe_write(arg1, copy, ret));
-            }
-            g_free(copy);
-        } else {
-            ret = get_errno(safe_write(arg1, p, arg3));
-        }
-        unlock_user(p, arg2, 0);
-        return ret;
-
 #ifdef TARGET_NR_open
     case TARGET_NR_open:
         if (!(p = lock_user_string(arg1)))
@@ -8116,15 +8145,6 @@ IMPL(everything_else)
         fd_trans_unregister(ret);
         return ret;
 #endif
-    case TARGET_NR_close:
-        if (is_hostfd(arg1)) {
-            return -TARGET_EBADF;
-        }
-        fd_trans_unregister(arg1);
-        return get_errno(close(arg1));
-
-    case TARGET_NR_brk:
-        return do_brk(arg1);
 #ifdef TARGET_NR_fork
     case TARGET_NR_fork:
         return get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0));
@@ -12894,7 +12914,11 @@ IMPL(everything_else)
 }
 
 static impl_fn * const syscall_table[] = {
-    impl_everything_else,
+    [TARGET_NR_brk] = impl_brk,
+    [TARGET_NR_close] = impl_close,
+    [TARGET_NR_exit] = impl_exit,
+    [TARGET_NR_read] = impl_read,
+    [TARGET_NR_write] = impl_write,
 };
 
 abi_long do_syscall(void *cpu_env, unsigned num, abi_long arg1,
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 11/33] linux-user: Split out execve
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (9 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 10/33] linux-user: Split out brk, close, exit, read, write Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 12/33] linux-user: Split out open, openat Richard Henderson
                   ` (23 subsequent siblings)
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

At the same time, fix the repeated re-reading of the argv and env
arrays from guest memory.  Instead read into a unified array once.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 203 ++++++++++++++++++++++---------------------
 1 file changed, 106 insertions(+), 97 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index b0d268dab7..a9b59a8658 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7998,6 +7998,111 @@ IMPL(close)
     return get_errno(close(arg1));
 }
 
+IMPL(execve)
+{
+    abi_ulong *guest_ptrs;
+    char **host_ptrs;
+    int argc, envc, alloc, i;
+    abi_ulong gp;
+    abi_ulong guest_argp = arg2;
+    abi_ulong guest_envp = arg3;
+    char *filename;
+    abi_long ret;
+
+    /* Initial estimate of number of guest pointers required.  */
+    alloc = 32;
+    guest_ptrs = g_new(abi_ulong, alloc);
+
+    /* Iterate through argp and envp, counting entries, and
+     * reading guest addresses from the arrays.
+     */
+    for (gp = guest_argp, argc = 0; gp; gp += sizeof(abi_ulong)) {
+        abi_ulong addr;
+        if (get_user_ual(addr, gp)) {
+            return -TARGET_EFAULT;
+        }
+        if (!addr) {
+            break;
+        }
+        if (argc >= alloc) {
+            alloc *= 2;
+            guest_ptrs = g_renew(abi_ulong, guest_ptrs, alloc);
+        }
+        guest_ptrs[argc++] = addr;
+    }
+    for (gp = guest_envp, envc = 0; gp; gp += sizeof(abi_ulong)) {
+        abi_ulong addr;
+        if (get_user_ual(addr, gp)) {
+            return -TARGET_EFAULT;
+        }
+        if (!addr) {
+            break;
+        }
+        if (argc + envc >= alloc) {
+            alloc *= 2;
+            guest_ptrs = g_renew(abi_ulong, guest_ptrs, alloc);
+        }
+        guest_ptrs[argc + envc++] = addr;
+    }
+
+    /* Exact number of host pointers required.  */
+    host_ptrs = g_new0(char *, argc + envc + 2);
+
+    /* Iterate through the argp and envp that we already read
+     * and convert the guest pointers to host pointers.
+     */
+    ret = -TARGET_EFAULT;
+    for (i = 0; i < argc; ++i) {
+        char *p = lock_user_string(guest_ptrs[i]);
+        if (!p) {
+            goto fini;
+        }
+        host_ptrs[i] = p;
+    }
+    for (i = 0; i < envc; ++i) {
+        char *p = lock_user_string(guest_ptrs[argc + i]);
+        if (!p) {
+            goto fini;
+        }
+        host_ptrs[argc + 1 + i] = p;
+    }
+
+    /* Read the executable filename.  */
+    filename = lock_user_string(arg1);
+    if (!filename) {
+        goto fini;
+    }
+
+    /* Although execve() is not an interruptible syscall it is
+     * a special case where we must use the safe_syscall wrapper:
+     * if we allow a signal to happen before we make the host
+     * syscall then we will 'lose' it, because at the point of
+     * execve the process leaves QEMU's control. So we use the
+     * safe syscall wrapper to ensure that we either take the
+     * signal as a guest signal, or else it does not happen
+     * before the execve completes and makes it the other
+     * program's problem.
+     */
+    ret = get_errno(safe_execve(filename, host_ptrs, host_ptrs + argc + 1));
+    unlock_user(filename, arg1, 0);
+
+ fini:
+    /* Deallocate everything we allocated above.  */
+    for (i = 0; i < argc; ++i) {
+        if (host_ptrs[i]) {
+            unlock_user(host_ptrs[i], guest_ptrs[i], 0);
+        }
+    }
+    for (i = 0; i < envc; ++i) {
+        if (host_ptrs[argc + 1 + i]) {
+            unlock_user(host_ptrs[argc + 1 + i], guest_ptrs[argc + i], 0);
+        }
+    }
+    g_free(host_ptrs);
+    g_free(guest_ptrs);
+    return ret;
+}
+
 IMPL(exit)
 {
     CPUState *cpu = ENV_GET_CPU(cpu_env);
@@ -8237,103 +8342,6 @@ IMPL(everything_else)
         unlock_user(p, arg2, 0);
         return ret;
 #endif
-    case TARGET_NR_execve:
-        {
-            char **argp, **envp;
-            int argc, envc;
-            abi_ulong gp;
-            abi_ulong guest_argp;
-            abi_ulong guest_envp;
-            abi_ulong addr;
-            char **q;
-            int total_size = 0;
-
-            argc = 0;
-            guest_argp = arg2;
-            for (gp = guest_argp; gp; gp += sizeof(abi_ulong)) {
-                if (get_user_ual(addr, gp))
-                    return -TARGET_EFAULT;
-                if (!addr)
-                    break;
-                argc++;
-            }
-            envc = 0;
-            guest_envp = arg3;
-            for (gp = guest_envp; gp; gp += sizeof(abi_ulong)) {
-                if (get_user_ual(addr, gp))
-                    return -TARGET_EFAULT;
-                if (!addr)
-                    break;
-                envc++;
-            }
-
-            argp = g_new0(char *, argc + 1);
-            envp = g_new0(char *, envc + 1);
-
-            for (gp = guest_argp, q = argp; gp;
-                  gp += sizeof(abi_ulong), q++) {
-                if (get_user_ual(addr, gp))
-                    goto execve_efault;
-                if (!addr)
-                    break;
-                if (!(*q = lock_user_string(addr)))
-                    goto execve_efault;
-                total_size += strlen(*q) + 1;
-            }
-            *q = NULL;
-
-            for (gp = guest_envp, q = envp; gp;
-                  gp += sizeof(abi_ulong), q++) {
-                if (get_user_ual(addr, gp))
-                    goto execve_efault;
-                if (!addr)
-                    break;
-                if (!(*q = lock_user_string(addr)))
-                    goto execve_efault;
-                total_size += strlen(*q) + 1;
-            }
-            *q = NULL;
-
-            if (!(p = lock_user_string(arg1)))
-                goto execve_efault;
-            /* Although execve() is not an interruptible syscall it is
-             * a special case where we must use the safe_syscall wrapper:
-             * if we allow a signal to happen before we make the host
-             * syscall then we will 'lose' it, because at the point of
-             * execve the process leaves QEMU's control. So we use the
-             * safe syscall wrapper to ensure that we either take the
-             * signal as a guest signal, or else it does not happen
-             * before the execve completes and makes it the other
-             * program's problem.
-             */
-            ret = get_errno(safe_execve(p, argp, envp));
-            unlock_user(p, arg1, 0);
-
-            goto execve_end;
-
-        execve_efault:
-            ret = -TARGET_EFAULT;
-
-        execve_end:
-            for (gp = guest_argp, q = argp; *q;
-                  gp += sizeof(abi_ulong), q++) {
-                if (get_user_ual(addr, gp)
-                    || !addr)
-                    break;
-                unlock_user(*q, addr, 0);
-            }
-            for (gp = guest_envp, q = envp; *q;
-                  gp += sizeof(abi_ulong), q++) {
-                if (get_user_ual(addr, gp)
-                    || !addr)
-                    break;
-                unlock_user(*q, addr, 0);
-            }
-
-            g_free(argp);
-            g_free(envp);
-        }
-        return ret;
     case TARGET_NR_chdir:
         if (!(p = lock_user_string(arg1)))
             return -TARGET_EFAULT;
@@ -12916,6 +12924,7 @@ IMPL(everything_else)
 static impl_fn * const syscall_table[] = {
     [TARGET_NR_brk] = impl_brk,
     [TARGET_NR_close] = impl_close,
+    [TARGET_NR_execve] = impl_execve,
     [TARGET_NR_exit] = impl_exit,
     [TARGET_NR_read] = impl_read,
     [TARGET_NR_write] = impl_write,
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 12/33] linux-user: Split out open, openat
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (10 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 11/33] linux-user: Split out execve Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 13/33] linux-user: Split out name_to_handle_at Richard Henderson
                   ` (22 subsequent siblings)
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 65 ++++++++++++++++++++++++++++----------------
 1 file changed, 42 insertions(+), 23 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index a9b59a8658..fb1a8a4e7e 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8145,6 +8145,44 @@ IMPL(exit)
     g_assert_not_reached();
 }
 
+#ifdef TARGET_NR_open
+IMPL(open)
+{
+    char *fn = lock_user_string(arg1);
+    abi_long ret;
+
+    if (!fn) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(do_openat(cpu_env, AT_FDCWD, fn,
+                              target_to_host_bitmask(arg2, fcntl_flags_tbl),
+                              arg3));
+    fd_trans_unregister(ret);
+    unlock_user(fn, arg1, 0);
+    return ret;
+}
+#endif
+
+IMPL(openat)
+{
+    char *fn;
+    abi_long ret;
+
+    if (is_hostfd(arg1)) {
+        return -TARGET_EBADF;
+    }
+    fn = lock_user_string(arg2);
+    if (!fn) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(do_openat(cpu_env, arg1, fn,
+                              target_to_host_bitmask(arg3, fcntl_flags_tbl),
+                              arg4));
+    fd_trans_unregister(ret);
+    unlock_user(fn, arg2, 0);
+    return ret;
+}
+
 IMPL(read)
 {
     abi_long ret;
@@ -8210,29 +8248,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-#ifdef TARGET_NR_open
-    case TARGET_NR_open:
-        if (!(p = lock_user_string(arg1)))
-            return -TARGET_EFAULT;
-        ret = get_errno(do_openat(cpu_env, AT_FDCWD, p,
-                                  target_to_host_bitmask(arg2, fcntl_flags_tbl),
-                                  arg3));
-        fd_trans_unregister(ret);
-        unlock_user(p, arg1, 0);
-        return ret;
-#endif
-    case TARGET_NR_openat:
-        if (is_hostfd(arg1)) {
-            return -TARGET_EBADF;
-        }
-        if (!(p = lock_user_string(arg2)))
-            return -TARGET_EFAULT;
-        ret = get_errno(do_openat(cpu_env, arg1, p,
-                                  target_to_host_bitmask(arg3, fcntl_flags_tbl),
-                                  arg4));
-        fd_trans_unregister(ret);
-        unlock_user(p, arg2, 0);
-        return ret;
 #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
     case TARGET_NR_name_to_handle_at:
         if (is_hostfd(arg1)) {
@@ -12926,6 +12941,10 @@ static impl_fn * const syscall_table[] = {
     [TARGET_NR_close] = impl_close,
     [TARGET_NR_execve] = impl_execve,
     [TARGET_NR_exit] = impl_exit,
+#ifdef TARGET_NR_open
+    [TARGET_NR_open] = impl_open,
+#endif
+    [TARGET_NR_openat] = impl_openat,
     [TARGET_NR_read] = impl_read,
     [TARGET_NR_write] = impl_write,
 };
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 13/33] linux-user: Split out name_to_handle_at
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (11 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 12/33] linux-user: Split out open, openat Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 14/33] linux-user: Split out open_to_handle_at Richard Henderson
                   ` (21 subsequent siblings)
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

At the same time, merge do_name_to_handle_at into the new function.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 129 +++++++++++++++++++++----------------------
 1 file changed, 64 insertions(+), 65 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index fb1a8a4e7e..4afc22c20c 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7369,63 +7369,6 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout,
         return -TARGET_ENOSYS;
     }
 }
-#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
-static abi_long do_name_to_handle_at(abi_long dirfd, abi_long pathname,
-                                     abi_long handle, abi_long mount_id,
-                                     abi_long flags)
-{
-    struct file_handle *target_fh;
-    struct file_handle *fh;
-    int mid = 0;
-    abi_long ret;
-    char *name;
-    unsigned int size, total_size;
-
-    if (get_user_s32(size, handle)) {
-        return -TARGET_EFAULT;
-    }
-
-    name = lock_user_string(pathname);
-    if (!name) {
-        return -TARGET_EFAULT;
-    }
-
-    total_size = sizeof(struct file_handle) + size;
-    target_fh = lock_user(VERIFY_WRITE, handle, total_size, 0);
-    if (!target_fh) {
-        unlock_user(name, pathname, 0);
-        return -TARGET_EFAULT;
-    }
-
-    fh = g_malloc0(total_size);
-    fh->handle_bytes = size;
-
-    TRY_INTERP_FD(ret, name,
-                  name_to_handle_at(interp_dirfd, name + 1, fh, &mid, flags),
-                  name_to_handle_at(dirfd, name, fh, &mid, flags));
-    ret = get_errno(ret);
-    unlock_user(name, pathname, 0);
-
-    /* man name_to_handle_at(2):
-     * Other than the use of the handle_bytes field, the caller should treat
-     * the file_handle structure as an opaque data type
-     */
-
-    memcpy(target_fh, fh, total_size);
-    target_fh->handle_bytes = tswap32(fh->handle_bytes);
-    target_fh->handle_type = tswap32(fh->handle_type);
-    g_free(fh);
-    unlock_user(target_fh, handle, total_size);
-
-    if (put_user_s32(mid, mount_id)) {
-        return -TARGET_EFAULT;
-    }
-
-    return ret;
-
-}
-#endif
-
 #if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
 static abi_long do_open_by_handle_at(abi_long mount_fd, abi_long handle,
                                      abi_long flags)
@@ -8145,6 +8088,67 @@ IMPL(exit)
     g_assert_not_reached();
 }
 
+#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
+IMPL(name_to_handle_at)
+{
+    abi_long dirfd = arg1;
+    abi_long pathname = arg2;
+    abi_long handle = arg3;
+    abi_long mount_id = arg4;
+    abi_long flags = arg5;
+    struct file_handle *target_fh;
+    struct file_handle *fh;
+    int mid = 0;
+    abi_long ret;
+    char *name;
+    unsigned int size, total_size;
+
+    if (is_hostfd(dirfd)) {
+        return -TARGET_EBADF;
+    }
+    if (get_user_s32(size, handle)) {
+        return -TARGET_EFAULT;
+    }
+
+    name = lock_user_string(pathname);
+    if (!name) {
+        return -TARGET_EFAULT;
+    }
+
+    total_size = sizeof(struct file_handle) + size;
+    target_fh = lock_user(VERIFY_WRITE, handle, total_size, 0);
+    if (!target_fh) {
+        unlock_user(name, pathname, 0);
+        return -TARGET_EFAULT;
+    }
+
+    fh = g_malloc0(total_size);
+    fh->handle_bytes = size;
+
+    TRY_INTERP_FD(ret, name,
+                  name_to_handle_at(interp_dirfd, name + 1, fh, &mid, flags),
+                  name_to_handle_at(dirfd, name, fh, &mid, flags));
+    ret = get_errno(ret);
+    unlock_user(name, pathname, 0);
+
+    /* man name_to_handle_at(2):
+     * Other than the use of the handle_bytes field, the caller should treat
+     * the file_handle structure as an opaque data type
+     */
+
+    memcpy(target_fh, fh, total_size);
+    target_fh->handle_bytes = tswap32(fh->handle_bytes);
+    target_fh->handle_type = tswap32(fh->handle_type);
+    g_free(fh);
+    unlock_user(target_fh, handle, total_size);
+
+    if (put_user_s32(mid, mount_id)) {
+        return -TARGET_EFAULT;
+    }
+    return ret;
+}
+#endif
+
 #ifdef TARGET_NR_open
 IMPL(open)
 {
@@ -8248,14 +8252,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
-    case TARGET_NR_name_to_handle_at:
-        if (is_hostfd(arg1)) {
-            return -TARGET_EBADF;
-        }
-        ret = do_name_to_handle_at(arg1, arg2, arg3, arg4, arg5);
-        return ret;
-#endif
 #if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
     case TARGET_NR_open_by_handle_at:
         if (is_hostfd(arg1)) {
@@ -12941,6 +12937,9 @@ static impl_fn * const syscall_table[] = {
     [TARGET_NR_close] = impl_close,
     [TARGET_NR_execve] = impl_execve,
     [TARGET_NR_exit] = impl_exit,
+#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
+    [TARGET_NR_name_to_handle_at] = impl_name_to_handle_at,
+#endif
 #ifdef TARGET_NR_open
     [TARGET_NR_open] = impl_open,
 #endif
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 14/33] linux-user: Split out open_to_handle_at
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (12 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 13/33] linux-user: Split out name_to_handle_at Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 15/33] linux-user: Split out creat, fork, waitid, waitpid Richard Henderson
                   ` (20 subsequent siblings)
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

At the same time, merge do_open_to_handle_at into the new function.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 84 ++++++++++++++++++++++----------------------
 1 file changed, 42 insertions(+), 42 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 4afc22c20c..48bb1c0231 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7369,39 +7369,6 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout,
         return -TARGET_ENOSYS;
     }
 }
-#if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
-static abi_long do_open_by_handle_at(abi_long mount_fd, abi_long handle,
-                                     abi_long flags)
-{
-    struct file_handle *target_fh;
-    struct file_handle *fh;
-    unsigned int size, total_size;
-    abi_long ret;
-
-    if (get_user_s32(size, handle)) {
-        return -TARGET_EFAULT;
-    }
-
-    total_size = sizeof(struct file_handle) + size;
-    target_fh = lock_user(VERIFY_READ, handle, total_size, 1);
-    if (!target_fh) {
-        return -TARGET_EFAULT;
-    }
-
-    fh = g_memdup(target_fh, total_size);
-    fh->handle_bytes = size;
-    fh->handle_type = tswap32(target_fh->handle_type);
-
-    ret = get_errno(open_by_handle_at(mount_fd, fh,
-                    target_to_host_bitmask(flags, fcntl_flags_tbl)));
-
-    g_free(fh);
-
-    unlock_user(target_fh, handle, total_size);
-
-    return ret;
-}
-#endif
 
 #if defined(TARGET_NR_signalfd) || defined(TARGET_NR_signalfd4)
 
@@ -8187,6 +8154,45 @@ IMPL(openat)
     return ret;
 }
 
+#if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
+IMPL(open_by_handle_at)
+{
+    abi_long mount_fd = arg1;
+    abi_long handle = arg2;
+    abi_long flags = arg3;
+    struct file_handle *target_fh;
+    struct file_handle *fh;
+    unsigned int size, total_size;
+    abi_long ret;
+
+    if (is_hostfd(mount_fd)) {
+        return -TARGET_EBADF;
+    }
+    if (get_user_s32(size, handle)) {
+        return -TARGET_EFAULT;
+    }
+
+    total_size = sizeof(struct file_handle) + size;
+    target_fh = lock_user(VERIFY_READ, handle, total_size, 1);
+    if (!target_fh) {
+        return -TARGET_EFAULT;
+    }
+
+    fh = g_memdup(target_fh, total_size);
+    fh->handle_bytes = size;
+    fh->handle_type = tswap32(target_fh->handle_type);
+
+    ret = get_errno(open_by_handle_at(mount_fd, fh,
+                    target_to_host_bitmask(flags, fcntl_flags_tbl)));
+
+    g_free(fh);
+    unlock_user(target_fh, handle, total_size);
+
+    fd_trans_unregister(ret);
+    return ret;
+}
+#endif
+
 IMPL(read)
 {
     abi_long ret;
@@ -8252,15 +8258,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-#if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
-    case TARGET_NR_open_by_handle_at:
-        if (is_hostfd(arg1)) {
-            return -TARGET_EBADF;
-        }
-        ret = do_open_by_handle_at(arg1, arg2, arg3);
-        fd_trans_unregister(ret);
-        return ret;
-#endif
 #ifdef TARGET_NR_fork
     case TARGET_NR_fork:
         return get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0));
@@ -12944,6 +12941,9 @@ static impl_fn * const syscall_table[] = {
     [TARGET_NR_open] = impl_open,
 #endif
     [TARGET_NR_openat] = impl_openat,
+#if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
+    [TARGET_NR_open_by_handle_at] = impl_open_by_handle_at,
+#endif
     [TARGET_NR_read] = impl_read,
     [TARGET_NR_write] = impl_write,
 };
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 15/33] linux-user: Split out creat, fork, waitid, waitpid
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (13 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 14/33] linux-user: Split out open_to_handle_at Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 16/33] linux-user: Split out link, linkat Richard Henderson
                   ` (19 subsequent siblings)
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 108 +++++++++++++++++++++++++++----------------
 1 file changed, 69 insertions(+), 39 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 48bb1c0231..e208f8647a 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7908,6 +7908,22 @@ IMPL(close)
     return get_errno(close(arg1));
 }
 
+#ifdef TARGET_NR_creat
+IMPL(creat)
+{
+    char *p = lock_user_string(arg1);
+    abi_long ret;
+
+    if (!p) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(creat(p, arg2));
+    fd_trans_unregister(ret);
+    unlock_user(p, arg1, 0);
+    return ret;
+}
+#endif
+
 IMPL(execve)
 {
     abi_ulong *guest_ptrs;
@@ -8055,6 +8071,13 @@ IMPL(exit)
     g_assert_not_reached();
 }
 
+#ifdef TARGET_NR_fork
+IMPL(fork)
+{
+    return get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0));
+}
+#endif
+
 #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
 IMPL(name_to_handle_at)
 {
@@ -8216,6 +8239,40 @@ IMPL(read)
     return ret;
 }
 
+#ifdef TARGET_NR_waitid
+IMPL(waitid)
+{
+    siginfo_t info;
+    abi_long ret;
+
+    info.si_pid = 0;
+    ret = get_errno(safe_waitid(arg1, arg2, &info, arg4, NULL));
+    if (!is_error(ret) && arg3 && info.si_pid != 0) {
+        target_siginfo_t *p
+            = lock_user(VERIFY_WRITE, arg3, sizeof(target_siginfo_t), 0);
+        if (!p) {
+            return -TARGET_EFAULT;
+        }
+        host_to_target_siginfo(p, &info);
+        unlock_user(p, arg3, sizeof(target_siginfo_t));
+    }
+    return ret;
+}
+#endif
+
+#ifdef TARGET_NR_waitpid
+IMPL(waitpid)
+{
+    int status;
+    abi_long ret = get_errno(safe_wait4(arg1, &status, arg3, 0));
+    if (!is_error(ret) && arg2 && ret &&
+        put_user_s32(host_to_target_waitstatus(status), arg2)) {
+        return -TARGET_EFAULT;
+    }
+    return ret;
+}
+#endif
+
 IMPL(write)
 {
     abi_long ret;
@@ -8258,45 +8315,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-#ifdef TARGET_NR_fork
-    case TARGET_NR_fork:
-        return get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0));
-#endif
-#ifdef TARGET_NR_waitpid
-    case TARGET_NR_waitpid:
-        {
-            int status;
-            ret = get_errno(safe_wait4(arg1, &status, arg3, 0));
-            if (!is_error(ret) && arg2 && ret
-                && put_user_s32(host_to_target_waitstatus(status), arg2))
-                return -TARGET_EFAULT;
-        }
-        return ret;
-#endif
-#ifdef TARGET_NR_waitid
-    case TARGET_NR_waitid:
-        {
-            siginfo_t info;
-            info.si_pid = 0;
-            ret = get_errno(safe_waitid(arg1, arg2, &info, arg4, NULL));
-            if (!is_error(ret) && arg3 && info.si_pid != 0) {
-                if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_siginfo_t), 0)))
-                    return -TARGET_EFAULT;
-                host_to_target_siginfo(p, &info);
-                unlock_user(p, arg3, sizeof(target_siginfo_t));
-            }
-        }
-        return ret;
-#endif
-#ifdef TARGET_NR_creat /* not on alpha */
-    case TARGET_NR_creat:
-        if (!(p = lock_user_string(arg1)))
-            return -TARGET_EFAULT;
-        ret = get_errno(creat(p, arg2));
-        fd_trans_unregister(ret);
-        unlock_user(p, arg1, 0);
-        return ret;
-#endif
 #ifdef TARGET_NR_link
     case TARGET_NR_link:
         {
@@ -12932,8 +12950,14 @@ IMPL(everything_else)
 static impl_fn * const syscall_table[] = {
     [TARGET_NR_brk] = impl_brk,
     [TARGET_NR_close] = impl_close,
+#ifdef TARGET_NR_creat
+    [TARGET_NR_creat] = impl_creat,
+#endif
     [TARGET_NR_execve] = impl_execve,
     [TARGET_NR_exit] = impl_exit,
+#ifdef TARGET_NR_fork
+    [TARGET_NR_fork] = impl_fork,
+#endif
 #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
     [TARGET_NR_name_to_handle_at] = impl_name_to_handle_at,
 #endif
@@ -12945,6 +12969,12 @@ static impl_fn * const syscall_table[] = {
     [TARGET_NR_open_by_handle_at] = impl_open_by_handle_at,
 #endif
     [TARGET_NR_read] = impl_read,
+#ifdef TARGET_NR_waitid
+    [TARGET_NR_waitid] = impl_waitid,
+#endif
+#ifdef TARGET_NR_waitpid
+    [TARGET_NR_waitpid] = impl_waitpid,
+#endif
     [TARGET_NR_write] = impl_write,
 };
 
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 16/33] linux-user: Split out link, linkat
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (14 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 15/33] linux-user: Split out creat, fork, waitid, waitpid Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 17/33] linux-user: Split out unlink, unlinkat Richard Henderson
                   ` (18 subsequent siblings)
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 77 +++++++++++++++++++++++++-------------------
 1 file changed, 43 insertions(+), 34 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index e208f8647a..b5736436f8 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8078,6 +8078,43 @@ IMPL(fork)
 }
 #endif
 
+#ifdef TARGET_NR_link
+IMPL(link)
+{
+    char *p1 = lock_user_string(arg1);
+    char *p2 = lock_user_string(arg2);
+    abi_long ret = -TARGET_EFAULT;
+
+    if (p1 && p2) {
+        ret = get_errno(link(p1, p2));
+    }
+    unlock_user(p1, arg1, 0);
+    unlock_user(p2, arg2, 0);
+    return ret;
+}
+#endif
+
+#if defined(TARGET_NR_linkat)
+IMPL(linkat)
+{
+    char *p1, *p2;
+    abi_long ret;
+
+    if (is_hostfd(arg1)) {
+        return -TARGET_EBADF;
+    }
+    p1 = lock_user_string(arg2);
+    p2 = lock_user_string(arg4);
+    ret = -TARGET_EFAULT;
+    if (p1 && p2) {
+        ret = get_errno(linkat(arg1, p1, arg3, p2, arg5));
+    }
+    unlock_user(p1, arg2, 0);
+    unlock_user(p2, arg4, 0);
+    return ret;
+}
+#endif
+
 #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
 IMPL(name_to_handle_at)
 {
@@ -8315,40 +8352,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-#ifdef TARGET_NR_link
-    case TARGET_NR_link:
-        {
-            void * p2;
-            p = lock_user_string(arg1);
-            p2 = lock_user_string(arg2);
-            if (!p || !p2)
-                ret = -TARGET_EFAULT;
-            else
-                ret = get_errno(link(p, p2));
-            unlock_user(p2, arg2, 0);
-            unlock_user(p, arg1, 0);
-        }
-        return ret;
-#endif
-#if defined(TARGET_NR_linkat)
-    case TARGET_NR_linkat:
-        if (is_hostfd(arg1)) {
-            return -TARGET_EBADF;
-        } else {
-            void * p2 = NULL;
-            if (!arg2 || !arg4)
-                return -TARGET_EFAULT;
-            p  = lock_user_string(arg2);
-            p2 = lock_user_string(arg4);
-            if (!p || !p2)
-                ret = -TARGET_EFAULT;
-            else
-                ret = get_errno(linkat(arg1, p, arg3, p2, arg5));
-            unlock_user(p, arg2, 0);
-            unlock_user(p2, arg4, 0);
-        }
-        return ret;
-#endif
 #ifdef TARGET_NR_unlink
     case TARGET_NR_unlink:
         if (!(p = lock_user_string(arg1)))
@@ -12958,6 +12961,12 @@ static impl_fn * const syscall_table[] = {
 #ifdef TARGET_NR_fork
     [TARGET_NR_fork] = impl_fork,
 #endif
+#ifdef TARGET_NR_link
+    [TARGET_NR_link] = impl_link,
+#endif
+#if defined(TARGET_NR_linkat)
+    [TARGET_NR_linkat] = impl_linkat,
+#endif
 #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
     [TARGET_NR_name_to_handle_at] = impl_name_to_handle_at,
 #endif
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 17/33] linux-user: Split out unlink, unlinkat
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (15 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 16/33] linux-user: Split out link, linkat Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 18/33] linux-user: Split out chdir, mknod, mknodat, time, chmod Richard Henderson
                   ` (17 subsequent siblings)
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 59 ++++++++++++++++++++++++++++++--------------
 1 file changed, 40 insertions(+), 19 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index b5736436f8..bbe9d6d9fb 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8276,6 +8276,40 @@ IMPL(read)
     return ret;
 }
 
+#ifdef TARGET_NR_unlink
+IMPL(unlink)
+{
+    char *p = lock_user_string(arg1);
+    abi_long ret;
+
+    if (!p) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(unlink(p));
+    unlock_user(p, arg1, 0);
+    return ret;
+}
+#endif
+
+#ifdef TARGET_NR_unlinkat
+IMPL(unlinkat)
+{
+    char *p;
+    abi_long ret;
+
+    if (is_hostfd(arg1)) {
+        return -TARGET_EBADF;
+    }
+    p = lock_user_string(arg2);
+    if (!p) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(unlinkat(arg1, p, arg3));
+    unlock_user(p, arg2, 0);
+    return ret;
+}
+#endif
+
 #ifdef TARGET_NR_waitid
 IMPL(waitid)
 {
@@ -8352,25 +8386,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-#ifdef TARGET_NR_unlink
-    case TARGET_NR_unlink:
-        if (!(p = lock_user_string(arg1)))
-            return -TARGET_EFAULT;
-        ret = get_errno(unlink(p));
-        unlock_user(p, arg1, 0);
-        return ret;
-#endif
-#if defined(TARGET_NR_unlinkat)
-    case TARGET_NR_unlinkat:
-        if (is_hostfd(arg1)) {
-            return -TARGET_EBADF;
-        }
-        if (!(p = lock_user_string(arg2)))
-            return -TARGET_EFAULT;
-        ret = get_errno(unlinkat(arg1, p, arg3));
-        unlock_user(p, arg2, 0);
-        return ret;
-#endif
     case TARGET_NR_chdir:
         if (!(p = lock_user_string(arg1)))
             return -TARGET_EFAULT;
@@ -12978,6 +12993,12 @@ static impl_fn * const syscall_table[] = {
     [TARGET_NR_open_by_handle_at] = impl_open_by_handle_at,
 #endif
     [TARGET_NR_read] = impl_read,
+#ifdef TARGET_NR_unlink
+    [TARGET_NR_unlink] = impl_unlink,
+#endif
+#if TARGET_NR_unlinkat
+    [TARGET_NR_unlinkat] = impl_unlinkat,
+#endif
 #ifdef TARGET_NR_waitid
     [TARGET_NR_waitid] = impl_waitid,
 #endif
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 18/33] linux-user: Split out chdir, mknod, mknodat, time, chmod
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (16 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 17/33] linux-user: Split out unlink, unlinkat Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 19/33] linux-user: Remove all unimplemented entries Richard Henderson
                   ` (16 subsequent siblings)
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 132 ++++++++++++++++++++++++++++---------------
 1 file changed, 87 insertions(+), 45 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index bbe9d6d9fb..88e0da31ba 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7899,6 +7899,34 @@ IMPL(brk)
     return do_brk(arg1);
 }
 
+IMPL(chdir)
+{
+    char *p = lock_user_string(arg1);
+    abi_long ret;
+
+    if (!p) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(chdir(p));
+    unlock_user(p, arg1, 0);
+    return ret;
+}
+
+#ifdef TARGET_NR_chmod
+IMPL(chmod)
+{
+    char *p = lock_user_string(arg1);
+    abi_long ret;
+
+    if (!p) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(chmod(p, arg2));
+    unlock_user(p, arg1, 0);
+    return ret;
+}
+#endif
+
 IMPL(close)
 {
     if (is_hostfd(arg1)) {
@@ -8115,6 +8143,40 @@ IMPL(linkat)
 }
 #endif
 
+#ifdef TARGET_NR_mknod
+IMPL(mknod)
+{
+    char *p = lock_user_string(arg1);
+    abi_long ret;
+
+    if (!p) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(mknod(p, arg2, arg3));
+    unlock_user(p, arg1, 0);
+    return ret;
+}
+#endif
+
+#ifdef TARGET_NR_mknodat
+IMPL(mknodat)
+{
+    char *p;
+    abi_long ret;
+
+    if (is_hostfd(arg1)) {
+        return -TARGET_EBADF;
+    }
+    p = lock_user_string(arg2);
+    if (!p) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(mknodat(arg1, p, arg3, arg4));
+    unlock_user(p, arg2, 0);
+    return ret;
+}
+#endif
+
 #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
 IMPL(name_to_handle_at)
 {
@@ -8276,6 +8338,18 @@ IMPL(read)
     return ret;
 }
 
+#ifdef TARGET_NR_time
+IMPL(time)
+{
+    time_t host_time;
+    abi_long ret = get_errno(time(&host_time));
+    if (!is_error(ret) && arg1 && put_user_sal(host_time, arg1)) {
+        return -TARGET_EFAULT;
+    }
+    return ret;
+}
+#endif
+
 #ifdef TARGET_NR_unlink
 IMPL(unlink)
 {
@@ -8386,51 +8460,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-    case TARGET_NR_chdir:
-        if (!(p = lock_user_string(arg1)))
-            return -TARGET_EFAULT;
-        ret = get_errno(chdir(p));
-        unlock_user(p, arg1, 0);
-        return ret;
-#ifdef TARGET_NR_time
-    case TARGET_NR_time:
-        {
-            time_t host_time;
-            ret = get_errno(time(&host_time));
-            if (!is_error(ret)
-                && arg1
-                && put_user_sal(host_time, arg1))
-                return -TARGET_EFAULT;
-        }
-        return ret;
-#endif
-#ifdef TARGET_NR_mknod
-    case TARGET_NR_mknod:
-        if (!(p = lock_user_string(arg1)))
-            return -TARGET_EFAULT;
-        ret = get_errno(mknod(p, arg2, arg3));
-        unlock_user(p, arg1, 0);
-        return ret;
-#endif
-#if defined(TARGET_NR_mknodat)
-    case TARGET_NR_mknodat:
-        if (is_hostfd(arg1)) {
-            return -TARGET_EBADF;
-        }
-        if (!(p = lock_user_string(arg2)))
-            return -TARGET_EFAULT;
-        ret = get_errno(mknodat(arg1, p, arg3, arg4));
-        unlock_user(p, arg2, 0);
-        return ret;
-#endif
-#ifdef TARGET_NR_chmod
-    case TARGET_NR_chmod:
-        if (!(p = lock_user_string(arg1)))
-            return -TARGET_EFAULT;
-        ret = get_errno(chmod(p, arg2));
-        unlock_user(p, arg1, 0);
-        return ret;
-#endif
 #ifdef TARGET_NR_break
     case TARGET_NR_break:
         return do_unimplemented(num);
@@ -12968,6 +12997,10 @@ IMPL(everything_else)
 static impl_fn * const syscall_table[] = {
     [TARGET_NR_brk] = impl_brk,
     [TARGET_NR_close] = impl_close,
+    [TARGET_NR_chdir] = impl_chdir,
+#ifdef TARGET_NR_chmod
+    [TARGET_NR_chmod] = impl_chmod,
+#endif
 #ifdef TARGET_NR_creat
     [TARGET_NR_creat] = impl_creat,
 #endif
@@ -12982,6 +13015,12 @@ static impl_fn * const syscall_table[] = {
 #if defined(TARGET_NR_linkat)
     [TARGET_NR_linkat] = impl_linkat,
 #endif
+#ifdef TARGET_NR_mknod
+    [TARGET_NR_mknod] = impl_mknod,
+#endif
+#ifdef TARGET_NR_mknodat
+    [TARGET_NR_mknodat] = impl_mknodat,
+#endif
 #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
     [TARGET_NR_name_to_handle_at] = impl_name_to_handle_at,
 #endif
@@ -12993,6 +13032,9 @@ static impl_fn * const syscall_table[] = {
     [TARGET_NR_open_by_handle_at] = impl_open_by_handle_at,
 #endif
     [TARGET_NR_read] = impl_read,
+#ifdef TARGET_NR_time
+    [TARGET_NR_time] = impl_time,
+#endif
 #ifdef TARGET_NR_unlink
     [TARGET_NR_unlink] = impl_unlink,
 #endif
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 19/33] linux-user: Remove all unimplemented entries
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (17 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 18/33] linux-user: Split out chdir, mknod, mknodat, time, chmod Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 20/33] linux-user: Split out getpid, getxpid, lseek Richard Henderson
                   ` (15 subsequent siblings)
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

There is no reason to list these, since -ENOSYS is the default.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 140 -------------------------------------------
 1 file changed, 140 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 88e0da31ba..6a701ea8f6 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8460,14 +8460,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-#ifdef TARGET_NR_break
-    case TARGET_NR_break:
-        return do_unimplemented(num);
-#endif
-#ifdef TARGET_NR_oldstat
-    case TARGET_NR_oldstat:
-        return do_unimplemented(num);
-#endif
     case TARGET_NR_lseek:
         if (is_hostfd(arg1)) {
             return -TARGET_EBADF;
@@ -8555,16 +8547,10 @@ IMPL(everything_else)
             return get_errno(stime(&host_time));
         }
 #endif
-    case TARGET_NR_ptrace:
-        return do_unimplemented(num);
 #ifdef TARGET_NR_alarm /* not on alpha */
     case TARGET_NR_alarm:
         return alarm(arg1);
 #endif
-#ifdef TARGET_NR_oldfstat
-    case TARGET_NR_oldfstat:
-        return do_unimplemented(num);
-#endif
 #ifdef TARGET_NR_pause /* not on alpha */
     case TARGET_NR_pause:
         if (!block_signals()) {
@@ -8640,14 +8626,6 @@ IMPL(everything_else)
         }
         return ret;
 #endif
-#ifdef TARGET_NR_stty
-    case TARGET_NR_stty:
-        return do_unimplemented(num);
-#endif
-#ifdef TARGET_NR_gtty
-    case TARGET_NR_gtty:
-        return do_unimplemented(num);
-#endif
 #ifdef TARGET_NR_access
     case TARGET_NR_access:
         if (!(fn = lock_user_string(arg1))) {
@@ -8678,10 +8656,6 @@ IMPL(everything_else)
 #ifdef TARGET_NR_nice /* not on alpha */
     case TARGET_NR_nice:
         return get_errno(nice(arg1));
-#endif
-#ifdef TARGET_NR_ftime
-    case TARGET_NR_ftime:
-        return do_unimplemented(num);
 #endif
     case TARGET_NR_sync:
         sync();
@@ -8805,14 +8779,6 @@ IMPL(everything_else)
                 ret = host_to_target_clock_t(ret);
         }
         return ret;
-#ifdef TARGET_NR_prof
-    case TARGET_NR_prof:
-        return do_unimplemented(num);
-#endif
-#ifdef TARGET_NR_signal
-    case TARGET_NR_signal:
-        return do_unimplemented(num);
-#endif
     case TARGET_NR_acct:
         if (arg1 == 0) {
             ret = get_errno(acct(NULL));
@@ -8832,31 +8798,15 @@ IMPL(everything_else)
         ret = get_errno(umount2(p, arg2));
         unlock_user(p, arg1, 0);
         return ret;
-#endif
-#ifdef TARGET_NR_lock
-    case TARGET_NR_lock:
-        return do_unimplemented(num);
 #endif
     case TARGET_NR_ioctl:
         return do_ioctl(arg1, arg2, arg3);
 #ifdef TARGET_NR_fcntl
     case TARGET_NR_fcntl:
         return do_fcntl(arg1, arg2, arg3);
-#endif
-#ifdef TARGET_NR_mpx
-    case TARGET_NR_mpx:
-        return do_unimplemented(num);
 #endif
     case TARGET_NR_setpgid:
         return get_errno(setpgid(arg1, arg2));
-#ifdef TARGET_NR_ulimit
-    case TARGET_NR_ulimit:
-        return do_unimplemented(num);
-#endif
-#ifdef TARGET_NR_oldolduname
-    case TARGET_NR_oldolduname:
-        return do_unimplemented(num);
-#endif
     case TARGET_NR_umask:
         return get_errno(umask(arg1));
     case TARGET_NR_chroot:
@@ -8865,10 +8815,6 @@ IMPL(everything_else)
         ret = get_errno(chroot(p));
         unlock_user(p, arg1, 0);
         return ret;
-#ifdef TARGET_NR_ustat
-    case TARGET_NR_ustat:
-        return do_unimplemented(num);
-#endif
 #ifdef TARGET_NR_dup2
     case TARGET_NR_dup2:
         if (is_hostfd(arg1) || is_hostfd(arg2)) {
@@ -9585,10 +9531,6 @@ IMPL(everything_else)
         }
         return ret;
 #endif
-#ifdef TARGET_NR_oldlstat
-    case TARGET_NR_oldlstat:
-        return do_unimplemented(num);
-#endif
 #ifdef TARGET_NR_readlink
     case TARGET_NR_readlink:
         {
@@ -9650,10 +9592,6 @@ IMPL(everything_else)
         }
         return ret;
 #endif
-#ifdef TARGET_NR_uselib
-    case TARGET_NR_uselib:
-        return do_unimplemented(num);
-#endif
 #ifdef TARGET_NR_swapon
     case TARGET_NR_swapon:
         if (!(p = lock_user_string(arg1)))
@@ -9675,10 +9613,6 @@ IMPL(everything_else)
            ret = get_errno(reboot(arg1, arg2, arg3, NULL));
         }
         return ret;
-#ifdef TARGET_NR_readdir
-    case TARGET_NR_readdir:
-        return do_unimplemented(num);
-#endif
 #ifdef TARGET_NR_mmap
     case TARGET_NR_mmap:
 #if (defined(TARGET_I386) && defined(TARGET_ABI32)) || \
@@ -9813,10 +9747,6 @@ IMPL(everything_else)
         return ret;
     case TARGET_NR_setpriority:
         return get_errno(setpriority(arg1, arg2, arg3));
-#ifdef TARGET_NR_profil
-    case TARGET_NR_profil:
-        return do_unimplemented(num);
-#endif
     case TARGET_NR_statfs:
         if (!(fn = lock_user_string(arg1))) {
             return -TARGET_EFAULT;
@@ -9892,10 +9822,6 @@ IMPL(everything_else)
         ret = get_errno(fstatfs(arg1, &stfs));
         goto convert_statfs64;
 #endif
-#ifdef TARGET_NR_ioperm
-    case TARGET_NR_ioperm:
-        return do_unimplemented(num);
-#endif
 #ifdef TARGET_NR_socketcall
     case TARGET_NR_socketcall:
         return do_socketcall(arg1, arg2);
@@ -10173,20 +10099,8 @@ IMPL(everything_else)
             }
         }
         return ret;
-#ifdef TARGET_NR_olduname
-    case TARGET_NR_olduname:
-        return do_unimplemented(num);
-#endif
-#ifdef TARGET_NR_iopl
-    case TARGET_NR_iopl:
-        return do_unimplemented(num);
-#endif
     case TARGET_NR_vhangup:
         return get_errno(vhangup());
-#ifdef TARGET_NR_idle
-    case TARGET_NR_idle:
-        return do_unimplemented(num);
-#endif
 #ifdef TARGET_NR_syscall
     case TARGET_NR_syscall:
         return do_syscall(cpu_env, arg1 & 0xffff, arg2, arg3, arg4, arg5,
@@ -10364,8 +10278,6 @@ IMPL(everything_else)
     case TARGET_NR_modify_ldt:
         return do_modify_ldt(cpu_env, arg1, arg2, arg3);
 #if !defined(TARGET_X86_64)
-    case TARGET_NR_vm86old:
-        return do_unimplemented(num);
     case TARGET_NR_vm86:
         return do_vm86(cpu_env, arg1, arg2);
 #endif
@@ -10402,17 +10314,6 @@ IMPL(everything_else)
         }
         return ret;
 #endif
-#ifdef TARGET_NR_create_module
-    case TARGET_NR_create_module:
-#endif
-    case TARGET_NR_init_module:
-    case TARGET_NR_delete_module:
-#ifdef TARGET_NR_get_kernel_syms
-    case TARGET_NR_get_kernel_syms:
-#endif
-        return do_unimplemented(num);
-    case TARGET_NR_quotactl:
-        return do_unimplemented(num);
     case TARGET_NR_getpgid:
         return get_errno(getpgid(arg1));
     case TARGET_NR_fchdir:
@@ -10420,20 +10321,8 @@ IMPL(everything_else)
             return -TARGET_EBADF;
         }
         return get_errno(fchdir(arg1));
-#ifdef TARGET_NR_bdflush /* not on x86_64 */
-    case TARGET_NR_bdflush:
-        return do_unimplemented(num);
-#endif
-#ifdef TARGET_NR_sysfs
-    case TARGET_NR_sysfs:
-        return do_unimplemented(num);
-#endif
     case TARGET_NR_personality:
         return get_errno(personality(arg1));
-#ifdef TARGET_NR_afs_syscall
-    case TARGET_NR_afs_syscall:
-        return do_unimplemented(num);
-#endif
 #ifdef TARGET_NR__llseek /* Not on alpha */
     case TARGET_NR__llseek:
         if (is_hostfd(arg1)) {
@@ -10975,14 +10864,6 @@ IMPL(everything_else)
             }
         }
         return ret;
-#ifdef TARGET_NR_query_module
-    case TARGET_NR_query_module:
-        return do_unimplemented(num);
-#endif
-#ifdef TARGET_NR_nfsservctl
-    case TARGET_NR_nfsservctl:
-        return do_unimplemented(num);
-#endif
     case TARGET_NR_prctl:
         switch (arg1) {
         case PR_GET_PDEATHSIG:
@@ -11223,21 +11104,6 @@ IMPL(everything_else)
         return ret;
     }
 #endif
-#else
-    case TARGET_NR_sendfile:
-#ifdef TARGET_NR_sendfile64
-    case TARGET_NR_sendfile64:
-#endif
-        return do_unimplemented(num);
-#endif
-
-#ifdef TARGET_NR_getpmsg
-    case TARGET_NR_getpmsg:
-        return do_unimplemented(num);
-#endif
-#ifdef TARGET_NR_putpmsg
-    case TARGET_NR_putpmsg:
-        return do_unimplemented(num);
 #endif
 #ifdef TARGET_NR_vfork
     case TARGET_NR_vfork:
@@ -11801,8 +11667,6 @@ IMPL(everything_else)
         return get_errno(setfsgid(arg1));
 #endif
 
-    case TARGET_NR_pivot_root:
-        return do_unimplemented(num);
 #ifdef TARGET_NR_mincore
     case TARGET_NR_mincore:
         {
@@ -11972,10 +11836,6 @@ IMPL(everything_else)
         /* self-modifying code is handled automatically, so nothing needed */
         return 0;
 #endif
-#ifdef TARGET_NR_security
-    case TARGET_NR_security:
-        return do_unimplemented(num);
-#endif
 #ifdef TARGET_NR_getpagesize
     case TARGET_NR_getpagesize:
         return TARGET_PAGE_SIZE;
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 20/33] linux-user: Split out getpid, getxpid, lseek
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (18 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 19/33] linux-user: Remove all unimplemented entries Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 21/33] linux-user: Split out mount, umount Richard Henderson
                   ` (14 subsequent siblings)
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 45 +++++++++++++++++++++++++++++---------------
 1 file changed, 30 insertions(+), 15 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 6a701ea8f6..b568144369 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8106,6 +8106,21 @@ IMPL(fork)
 }
 #endif
 
+#ifdef TARGET_NR_getpid
+IMPL(getpid)
+{
+    return get_errno(getpid());
+}
+#endif
+
+#if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA)
+IMPL(getxpid)
+{
+    ((CPUAlphaState *)cpu_env)->ir[IR_A4] = getppid();
+    return get_errno(getpid());
+}
+#endif
+
 #ifdef TARGET_NR_link
 IMPL(link)
 {
@@ -8143,6 +8158,14 @@ IMPL(linkat)
 }
 #endif
 
+IMPL(lseek)
+{
+    if (is_hostfd(arg1)) {
+        return -TARGET_EBADF;
+    }
+    return get_errno(lseek(arg1, arg2, arg3));
+}
+
 #ifdef TARGET_NR_mknod
 IMPL(mknod)
 {
@@ -8460,21 +8483,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-    case TARGET_NR_lseek:
-        if (is_hostfd(arg1)) {
-            return -TARGET_EBADF;
-        }
-        return get_errno(lseek(arg1, arg2, arg3));
-#if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA)
-    /* Alpha specific */
-    case TARGET_NR_getxpid:
-        ((CPUAlphaState *)cpu_env)->ir[IR_A4] = getppid();
-        return get_errno(getpid());
-#endif
-#ifdef TARGET_NR_getpid
-    case TARGET_NR_getpid:
-        return get_errno(getpid());
-#endif
     case TARGET_NR_mount:
         {
             /* need to look at the data field */
@@ -12869,12 +12877,19 @@ static impl_fn * const syscall_table[] = {
 #ifdef TARGET_NR_fork
     [TARGET_NR_fork] = impl_fork,
 #endif
+#ifdef TARGET_NR_getpid
+    [TARGET_NR_getpid] = impl_getpid,
+#endif
+#if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA)
+    [TARGET_NR_getxpid] = impl_getxpid,
+#endif
 #ifdef TARGET_NR_link
     [TARGET_NR_link] = impl_link,
 #endif
 #if defined(TARGET_NR_linkat)
     [TARGET_NR_linkat] = impl_linkat,
 #endif
+    [TARGET_NR_lseek] = impl_lseek,
 #ifdef TARGET_NR_mknod
     [TARGET_NR_mknod] = impl_mknod,
 #endif
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 21/33] linux-user: Split out mount, umount
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (19 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 20/33] linux-user: Split out getpid, getxpid, lseek Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 22/33] linux-user: Split out alarm, pause, stime, utime, utimes Richard Henderson
                   ` (13 subsequent siblings)
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 123 +++++++++++++++++++++----------------------
 1 file changed, 60 insertions(+), 63 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index b568144369..53eac58ec0 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8200,6 +8200,47 @@ IMPL(mknodat)
 }
 #endif
 
+IMPL(mount)
+{
+    char *p1 = NULL, *p2, *p3 = NULL;
+    abi_long ret = -TARGET_EFAULT;
+
+    if (arg1) {
+        p1 = lock_user_string(arg1);
+        if (!p1) {
+            goto exit1;
+        }
+    }
+    p2 = lock_user_string(arg2);
+    if (!p2) {
+        goto exit2;
+    }
+    if (arg3) {
+        p3 = lock_user_string(arg3);
+        if (!p3) {
+            goto exit3;
+        }
+    }
+
+    /* FIXME - arg5 should be locked, but it isn't clear how to do that
+     * since it's not guaranteed to be a NULL-terminated string.
+     */
+    ret = mount(p1, p2, p3, (unsigned long)arg4, arg5 ? g2h(arg5) : NULL);
+    ret = get_errno(ret);
+
+    if (arg3) {
+        unlock_user(p3, arg3, 0);
+    }
+ exit3:
+    unlock_user(p2, arg2, 0);
+ exit2:
+    if (arg1) {
+        unlock_user(p1, arg1, 0);
+    }
+ exit1:
+    return ret;
+}
+
 #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
 IMPL(name_to_handle_at)
 {
@@ -8373,6 +8414,21 @@ IMPL(time)
 }
 #endif
 
+#ifdef TARGET_NR_umount
+IMPL(umount)
+{
+    char *p = lock_user_string(arg1);
+    abi_long ret;
+
+    if (!p) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(umount(p));
+    unlock_user(p, arg1, 0);
+    return ret;
+}
+#endif
+
 #ifdef TARGET_NR_unlink
 IMPL(unlink)
 {
@@ -8483,69 +8539,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-    case TARGET_NR_mount:
-        {
-            /* need to look at the data field */
-            void *p2, *p3;
-
-            if (arg1) {
-                p = lock_user_string(arg1);
-                if (!p) {
-                    return -TARGET_EFAULT;
-                }
-            } else {
-                p = NULL;
-            }
-
-            p2 = lock_user_string(arg2);
-            if (!p2) {
-                if (arg1) {
-                    unlock_user(p, arg1, 0);
-                }
-                return -TARGET_EFAULT;
-            }
-
-            if (arg3) {
-                p3 = lock_user_string(arg3);
-                if (!p3) {
-                    if (arg1) {
-                        unlock_user(p, arg1, 0);
-                    }
-                    unlock_user(p2, arg2, 0);
-                    return -TARGET_EFAULT;
-                }
-            } else {
-                p3 = NULL;
-            }
-
-            /* FIXME - arg5 should be locked, but it isn't clear how to
-             * do that since it's not guaranteed to be a NULL-terminated
-             * string.
-             */
-            if (!arg5) {
-                ret = mount(p, p2, p3, (unsigned long)arg4, NULL);
-            } else {
-                ret = mount(p, p2, p3, (unsigned long)arg4, g2h(arg5));
-            }
-            ret = get_errno(ret);
-
-            if (arg1) {
-                unlock_user(p, arg1, 0);
-            }
-            unlock_user(p2, arg2, 0);
-            if (arg3) {
-                unlock_user(p3, arg3, 0);
-            }
-        }
-        return ret;
-#ifdef TARGET_NR_umount
-    case TARGET_NR_umount:
-        if (!(p = lock_user_string(arg1)))
-            return -TARGET_EFAULT;
-        ret = get_errno(umount(p));
-        unlock_user(p, arg1, 0);
-        return ret;
-#endif
 #ifdef TARGET_NR_stime /* not on alpha */
     case TARGET_NR_stime:
         {
@@ -12896,6 +12889,7 @@ static impl_fn * const syscall_table[] = {
 #ifdef TARGET_NR_mknodat
     [TARGET_NR_mknodat] = impl_mknodat,
 #endif
+    [TARGET_NR_mount] = impl_mount,
 #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
     [TARGET_NR_name_to_handle_at] = impl_name_to_handle_at,
 #endif
@@ -12910,6 +12904,9 @@ static impl_fn * const syscall_table[] = {
 #ifdef TARGET_NR_time
     [TARGET_NR_time] = impl_time,
 #endif
+#ifdef TARGET_NR_umount
+    [TARGET_NR_umount] = impl_umount,
+#endif
 #ifdef TARGET_NR_unlink
     [TARGET_NR_unlink] = impl_unlink,
 #endif
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 22/33] linux-user: Split out alarm, pause, stime, utime, utimes
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (20 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 21/33] linux-user: Split out mount, umount Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 23/33] linux-user: Split out access, faccessat, futimesat, kill, nice, sync, syncfs Richard Henderson
                   ` (12 subsequent siblings)
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 156 ++++++++++++++++++++++++++-----------------
 1 file changed, 94 insertions(+), 62 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 53eac58ec0..b3838c5161 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7894,6 +7894,13 @@ IMPL(enosys)
     return do_unimplemented(num);
 }
 
+#ifdef TARGET_NR_alarm
+IMPL(alarm)
+{
+    return alarm(arg1);
+}
+#endif
+
 IMPL(brk)
 {
     return do_brk(arg1);
@@ -8379,6 +8386,18 @@ IMPL(open_by_handle_at)
 }
 #endif
 
+#ifdef TARGET_NR_pause
+IMPL(pause)
+{
+    CPUState *cpu = ENV_GET_CPU(cpu_env);
+
+    if (!block_signals()) {
+        sigsuspend(&((TaskState *)cpu->opaque)->signal_mask);
+    }
+    return -TARGET_EINTR;
+}
+#endif
+
 IMPL(read)
 {
     abi_long ret;
@@ -8402,6 +8421,17 @@ IMPL(read)
     return ret;
 }
 
+#ifdef TARGET_NR_stime
+IMPL(stime)
+{
+    time_t host_time;
+    if (get_user_sal(host_time, arg1)) {
+        return -TARGET_EFAULT;
+    }
+    return get_errno(stime(&host_time));
+}
+#endif
+
 #ifdef TARGET_NR_time
 IMPL(time)
 {
@@ -8463,6 +8493,55 @@ IMPL(unlinkat)
 }
 #endif
 
+#ifdef TARGET_NR_utime
+IMPL(utime)
+{
+    struct utimbuf tbuf;
+    char *p;
+    abi_long ret;
+
+    if (arg2) {
+        struct target_utimbuf *target_tbuf;
+        if (!lock_user_struct(VERIFY_READ, target_tbuf, arg2, 1)) {
+            return -TARGET_EFAULT;
+        }
+        tbuf.actime = tswapal(target_tbuf->actime);
+        tbuf.modtime = tswapal(target_tbuf->modtime);
+        unlock_user_struct(target_tbuf, arg2, 0);
+    }
+    p = lock_user_string(arg1);
+    if (!p) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(utime(p, arg2 ? &tbuf : NULL));
+    unlock_user(p, arg1, 0);
+    return ret;
+}
+#endif
+
+#ifdef TARGET_NR_utimes
+IMPL(utimes)
+{
+    struct timeval tv[2];
+    char *p;
+    abi_long ret;
+
+    if (arg2 &&
+        (copy_from_user_timeval(&tv[0], arg2) ||
+         copy_from_user_timeval(&tv[1],
+                                arg2 + sizeof(struct target_timeval)))) {
+        return -TARGET_EFAULT;
+    }
+    p = lock_user_string(arg1);
+    if (!p) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(utimes(p, arg2 ? tv : NULL));
+    unlock_user(p, arg1, 0);
+    return ret;
+}
+#endif
+
 #ifdef TARGET_NR_waitid
 IMPL(waitid)
 {
@@ -8539,68 +8618,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-#ifdef TARGET_NR_stime /* not on alpha */
-    case TARGET_NR_stime:
-        {
-            time_t host_time;
-            if (get_user_sal(host_time, arg1))
-                return -TARGET_EFAULT;
-            return get_errno(stime(&host_time));
-        }
-#endif
-#ifdef TARGET_NR_alarm /* not on alpha */
-    case TARGET_NR_alarm:
-        return alarm(arg1);
-#endif
-#ifdef TARGET_NR_pause /* not on alpha */
-    case TARGET_NR_pause:
-        if (!block_signals()) {
-            sigsuspend(&((TaskState *)cpu->opaque)->signal_mask);
-        }
-        return -TARGET_EINTR;
-#endif
-#ifdef TARGET_NR_utime
-    case TARGET_NR_utime:
-        {
-            struct utimbuf tbuf, *host_tbuf;
-            struct target_utimbuf *target_tbuf;
-            if (arg2) {
-                if (!lock_user_struct(VERIFY_READ, target_tbuf, arg2, 1))
-                    return -TARGET_EFAULT;
-                tbuf.actime = tswapal(target_tbuf->actime);
-                tbuf.modtime = tswapal(target_tbuf->modtime);
-                unlock_user_struct(target_tbuf, arg2, 0);
-                host_tbuf = &tbuf;
-            } else {
-                host_tbuf = NULL;
-            }
-            if (!(p = lock_user_string(arg1)))
-                return -TARGET_EFAULT;
-            ret = get_errno(utime(p, host_tbuf));
-            unlock_user(p, arg1, 0);
-        }
-        return ret;
-#endif
-#ifdef TARGET_NR_utimes
-    case TARGET_NR_utimes:
-        {
-            struct timeval *tvp, tv[2];
-            if (arg2) {
-                if (copy_from_user_timeval(&tv[0], arg2)
-                    || copy_from_user_timeval(&tv[1],
-                                              arg2 + sizeof(struct target_timeval)))
-                    return -TARGET_EFAULT;
-                tvp = tv;
-            } else {
-                tvp = NULL;
-            }
-            if (!(p = lock_user_string(arg1)))
-                return -TARGET_EFAULT;
-            ret = get_errno(utimes(p, tvp));
-            unlock_user(p, arg1, 0);
-        }
-        return ret;
-#endif
 #if defined(TARGET_NR_futimesat)
     case TARGET_NR_futimesat:
         if (is_hostfd(arg1)) {
@@ -12856,6 +12873,9 @@ IMPL(everything_else)
 }
 
 static impl_fn * const syscall_table[] = {
+#ifdef TARGET_NR_alarm
+    [TARGET_NR_alarm] = impl_alarm,
+#endif
     [TARGET_NR_brk] = impl_brk,
     [TARGET_NR_close] = impl_close,
     [TARGET_NR_chdir] = impl_chdir,
@@ -12899,8 +12919,14 @@ static impl_fn * const syscall_table[] = {
     [TARGET_NR_openat] = impl_openat,
 #if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
     [TARGET_NR_open_by_handle_at] = impl_open_by_handle_at,
+#endif
+#ifdef TARGET_NR_pause
+    [TARGET_NR_pause] = impl_pause,
 #endif
     [TARGET_NR_read] = impl_read,
+#ifdef TARGET_NR_stime
+    [TARGET_NR_stime] = impl_stime,
+#endif
 #ifdef TARGET_NR_time
     [TARGET_NR_time] = impl_time,
 #endif
@@ -12913,6 +12939,12 @@ static impl_fn * const syscall_table[] = {
 #if TARGET_NR_unlinkat
     [TARGET_NR_unlinkat] = impl_unlinkat,
 #endif
+#ifdef TARGET_NR_utime
+    [TARGET_NR_utime] = impl_utime,
+#endif
+#ifdef TARGET_NR_utimes
+    [TARGET_NR_utimes] = impl_utimes,
+#endif
 #ifdef TARGET_NR_waitid
     [TARGET_NR_waitid] = impl_waitid,
 #endif
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 23/33] linux-user: Split out access, faccessat, futimesat, kill, nice, sync, syncfs
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (21 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 22/33] linux-user: Split out alarm, pause, stime, utime, utimes Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 24/33] linux-user: Split out rename, renameat, renameat2 Richard Henderson
                   ` (11 subsequent siblings)
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 179 +++++++++++++++++++++++++++----------------
 1 file changed, 113 insertions(+), 66 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index b3838c5161..2a172e24eb 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7894,6 +7894,24 @@ IMPL(enosys)
     return do_unimplemented(num);
 }
 
+#ifdef TARGET_NR_access
+IMPL(access)
+{
+    char *fn = lock_user_string(arg1);
+    abi_long ret;
+
+    if (!fn) {
+        return -TARGET_EFAULT;
+    }
+    TRY_INTERP_FD(ret, fn,
+                  faccessat(interp_dirfd, fn + 1, arg2, 0),
+                  access(fn, arg2));
+    ret = get_errno(ret);
+    unlock_user(fn, arg1, 0);
+    return ret;
+}
+#endif
+
 #ifdef TARGET_NR_alarm
 IMPL(alarm)
 {
@@ -8106,6 +8124,28 @@ IMPL(exit)
     g_assert_not_reached();
 }
 
+#ifdef TARGET_NR_faccessat
+IMPL(faccessat)
+{
+    char *fn;
+    abi_long ret;
+
+    if (is_hostfd(arg1)) {
+        return -TARGET_EBADF;
+    }
+    fn = lock_user_string(arg2);
+    if (!fn) {
+        return -TARGET_EFAULT;
+    }
+    TRY_INTERP_FD(ret, fn,
+                  faccessat(interp_dirfd, fn + 1, arg3, 0),
+                  faccessat(arg1, fn, arg3, 0));
+    ret = get_errno(ret);
+    unlock_user(fn, arg2, 0);
+    return ret;
+}
+#endif
+
 #ifdef TARGET_NR_fork
 IMPL(fork)
 {
@@ -8113,6 +8153,37 @@ IMPL(fork)
 }
 #endif
 
+#ifdef TARGET_NR_futimesat
+IMPL(futimesat)
+{
+    struct timeval tv[2], *tvp = NULL;
+    char *fn;
+    abi_long ret;
+
+    if (is_hostfd(arg1)) {
+        return -TARGET_EBADF;
+    }
+    if (arg3) {
+        if (copy_from_user_timeval(&tv[0], arg3) ||
+            copy_from_user_timeval(&tv[1],
+                                   arg3 + sizeof(struct target_timeval))) {
+            return -TARGET_EFAULT;
+        }
+        tvp = tv;
+    }
+    fn = lock_user_string(arg2);
+    if (!fn) {
+        return -TARGET_EFAULT;
+    }
+    TRY_INTERP_FD(ret, fn,
+                  futimesat(interp_dirfd, fn + 1, tvp),
+                  futimesat(arg1, fn, tvp));
+    ret = get_errno(ret);
+    unlock_user(fn, arg2, 0);
+    return ret;
+}
+#endif
+
 #ifdef TARGET_NR_getpid
 IMPL(getpid)
 {
@@ -8128,6 +8199,11 @@ IMPL(getxpid)
 }
 #endif
 
+IMPL(kill)
+{
+    return get_errno(safe_kill(arg1, target_to_host_signal(arg2)));
+}
+
 #ifdef TARGET_NR_link
 IMPL(link)
 {
@@ -8309,6 +8385,13 @@ IMPL(name_to_handle_at)
 }
 #endif
 
+#ifdef TARGET_NR_nice
+IMPL(nice)
+{
+    return get_errno(nice(arg1));
+}
+#endif
+
 #ifdef TARGET_NR_open
 IMPL(open)
 {
@@ -8432,6 +8515,19 @@ IMPL(stime)
 }
 #endif
 
+IMPL(sync)
+{
+    sync();
+    return 0;
+}
+
+#if defined(TARGET_NR_syncfs) && defined(CONFIG_SYNCFS)
+IMPL(syncfs)
+{
+    return get_errno(syncfs(arg1));
+}
+#endif
+
 #ifdef TARGET_NR_time
 IMPL(time)
 {
@@ -8618,72 +8714,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-#if defined(TARGET_NR_futimesat)
-    case TARGET_NR_futimesat:
-        if (is_hostfd(arg1)) {
-            return -TARGET_EBADF;
-        } else {
-            struct timeval *tvp, tv[2];
-            if (arg3) {
-                if (copy_from_user_timeval(&tv[0], arg3)
-                    || copy_from_user_timeval(&tv[1],
-                                              arg3 + sizeof(struct target_timeval)))
-                    return -TARGET_EFAULT;
-                tvp = tv;
-            } else {
-                tvp = NULL;
-            }
-            if (!(fn = lock_user_string(arg2))) {
-                return -TARGET_EFAULT;
-            }
-            TRY_INTERP_FD(ret, fn,
-                          futimesat(interp_dirfd, fn + 1, tvp),
-                          futimesat(arg1, fn, tvp));
-            ret = get_errno(ret);
-            unlock_user(fn, arg2, 0);
-        }
-        return ret;
-#endif
-#ifdef TARGET_NR_access
-    case TARGET_NR_access:
-        if (!(fn = lock_user_string(arg1))) {
-            return -TARGET_EFAULT;
-        }
-        TRY_INTERP_FD(ret, fn,
-                      faccessat(interp_dirfd, fn + 1, arg2, 0),
-                      access(fn, arg2));
-        ret = get_errno(ret);
-        unlock_user(fn, arg1, 0);
-        return ret;
-#endif
-#if defined(TARGET_NR_faccessat) && defined(__NR_faccessat)
-    case TARGET_NR_faccessat:
-        if (is_hostfd(arg1)) {
-            return -TARGET_EBADF;
-        }
-        if (!(fn = lock_user_string(arg2))) {
-            return -TARGET_EFAULT;
-        }
-        TRY_INTERP_FD(ret, fn,
-                      faccessat(interp_dirfd, fn + 1, arg3, 0),
-                      faccessat(arg1, fn, arg3, 0));
-        ret = get_errno(ret);
-        unlock_user(fn, arg2, 0);
-        return ret;
-#endif
-#ifdef TARGET_NR_nice /* not on alpha */
-    case TARGET_NR_nice:
-        return get_errno(nice(arg1));
-#endif
-    case TARGET_NR_sync:
-        sync();
-        return 0;
-#if defined(TARGET_NR_syncfs) && defined(CONFIG_SYNCFS)
-    case TARGET_NR_syncfs:
-        return get_errno(syncfs(arg1));
-#endif
-    case TARGET_NR_kill:
-        return get_errno(safe_kill(arg1, target_to_host_signal(arg2)));
 #ifdef TARGET_NR_rename
     case TARGET_NR_rename:
         {
@@ -12873,6 +12903,9 @@ IMPL(everything_else)
 }
 
 static impl_fn * const syscall_table[] = {
+#ifdef TARGET_NR_access
+    [TARGET_NR_access] = impl_access,
+#endif
 #ifdef TARGET_NR_alarm
     [TARGET_NR_alarm] = impl_alarm,
 #endif
@@ -12887,15 +12920,22 @@ static impl_fn * const syscall_table[] = {
 #endif
     [TARGET_NR_execve] = impl_execve,
     [TARGET_NR_exit] = impl_exit,
+#ifdef TARGET_NR_faccessat
+    [TARGET_NR_faccessat] = impl_faccessat,
+#endif
 #ifdef TARGET_NR_fork
     [TARGET_NR_fork] = impl_fork,
 #endif
+#ifdef TARGET_NR_futimesat
+    [TARGET_NR_futimesat] = impl_futimesat,
+#endif
 #ifdef TARGET_NR_getpid
     [TARGET_NR_getpid] = impl_getpid,
 #endif
 #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA)
     [TARGET_NR_getxpid] = impl_getxpid,
 #endif
+    [TARGET_NR_kill] = impl_kill,
 #ifdef TARGET_NR_link
     [TARGET_NR_link] = impl_link,
 #endif
@@ -12913,6 +12953,9 @@ static impl_fn * const syscall_table[] = {
 #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
     [TARGET_NR_name_to_handle_at] = impl_name_to_handle_at,
 #endif
+#ifdef TARGET_NR_nice
+    [TARGET_NR_nice] = impl_nice,
+#endif
 #ifdef TARGET_NR_open
     [TARGET_NR_open] = impl_open,
 #endif
@@ -12926,6 +12969,10 @@ static impl_fn * const syscall_table[] = {
     [TARGET_NR_read] = impl_read,
 #ifdef TARGET_NR_stime
     [TARGET_NR_stime] = impl_stime,
+#endif
+    [TARGET_NR_sync] = impl_sync,
+#if defined(TARGET_NR_syncfs) && defined(CONFIG_SYNCFS)
+    [TARGET_NR_syncfs] = impl_syncfs,
 #endif
 #ifdef TARGET_NR_time
     [TARGET_NR_time] = impl_time,
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 24/33] linux-user: Split out rename, renameat, renameat2
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (22 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 23/33] linux-user: Split out access, faccessat, futimesat, kill, nice, sync, syncfs Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 25/33] linux-user: Split out dup, mkdir, mkdirat, rmdir Richard Henderson
                   ` (10 subsequent siblings)
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 113 ++++++++++++++++++++++++-------------------
 1 file changed, 63 insertions(+), 50 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 2a172e24eb..24514329b0 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8504,6 +8504,60 @@ IMPL(read)
     return ret;
 }
 
+#ifdef TARGET_NR_rename
+IMPL(rename)
+{
+    char *p1 = lock_user_string(arg1);
+    char *p2 = lock_user_string(arg2);
+    abi_long ret = -TARGET_EFAULT;
+
+    if (p1 && p2) {
+        ret = get_errno(rename(p1, p2));
+    }
+    unlock_user(p2, arg2, 0);
+    unlock_user(p1, arg1, 0);
+    return ret;
+}
+#endif
+
+#if defined(TARGET_NR_renameat)
+IMPL(renameat)
+{
+    if (is_hostfd(arg1)) {
+        return -TARGET_EBADF;
+    }
+
+    char *p1 = lock_user_string(arg2);
+    char *p2 = lock_user_string(arg4);
+    abi_long ret = -TARGET_EFAULT;
+    if (p1 && p2) {
+        ret = get_errno(renameat(arg1, p1, arg3, p2));
+    }
+    unlock_user(p2, arg4, 0);
+    unlock_user(p1, arg2, 0);
+    return ret;
+}
+#endif
+
+#ifdef TARGET_NR_renameat2
+IMPL(renameat2)
+{
+    if (is_hostfd(arg1)) {
+        return -TARGET_EBADF;
+    }
+
+    char *p1 = lock_user_string(arg2);
+    char *p2 = lock_user_string(arg4);
+    abi_long ret = -TARGET_EFAULT;
+    if (p1 && p2) {
+        ret = get_errno(sys_renameat2(arg1, p1, arg3, p2, arg5));
+    }
+    unlock_user(p2, arg4, 0);
+    unlock_user(p1, arg2, 0);
+    return ret;
+}
+#endif
+
 #ifdef TARGET_NR_stime
 IMPL(stime)
 {
@@ -8714,56 +8768,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-#ifdef TARGET_NR_rename
-    case TARGET_NR_rename:
-        {
-            void *p2;
-            p = lock_user_string(arg1);
-            p2 = lock_user_string(arg2);
-            if (!p || !p2)
-                ret = -TARGET_EFAULT;
-            else
-                ret = get_errno(rename(p, p2));
-            unlock_user(p2, arg2, 0);
-            unlock_user(p, arg1, 0);
-        }
-        return ret;
-#endif
-#if defined(TARGET_NR_renameat)
-    case TARGET_NR_renameat:
-        if (is_hostfd(arg1)) {
-            return -TARGET_EBADF;
-        } else {
-            void *p2;
-            p  = lock_user_string(arg2);
-            p2 = lock_user_string(arg4);
-            if (!p || !p2)
-                ret = -TARGET_EFAULT;
-            else
-                ret = get_errno(renameat(arg1, p, arg3, p2));
-            unlock_user(p2, arg4, 0);
-            unlock_user(p, arg2, 0);
-        }
-        return ret;
-#endif
-#if defined(TARGET_NR_renameat2)
-    case TARGET_NR_renameat2:
-        if (is_hostfd(arg1)) {
-            return -TARGET_EBADF;
-        } else {
-            void *p2;
-            p  = lock_user_string(arg2);
-            p2 = lock_user_string(arg4);
-            if (!p || !p2) {
-                ret = -TARGET_EFAULT;
-            } else {
-                ret = get_errno(sys_renameat2(arg1, p, arg3, p2, arg5));
-            }
-            unlock_user(p2, arg4, 0);
-            unlock_user(p, arg2, 0);
-        }
-        return ret;
-#endif
 #ifdef TARGET_NR_mkdir
     case TARGET_NR_mkdir:
         if (!(p = lock_user_string(arg1)))
@@ -12967,6 +12971,15 @@ static impl_fn * const syscall_table[] = {
     [TARGET_NR_pause] = impl_pause,
 #endif
     [TARGET_NR_read] = impl_read,
+#ifdef TARGET_NR_rename
+    [TARGET_NR_rename] = impl_rename,
+#endif
+#ifdef TARGET_NR_renameat
+    [TARGET_NR_renameat] = impl_renameat,
+#endif
+#ifdef TARGET_NR_renameat2
+    [TARGET_NR_renameat2] = impl_renameat2,
+#endif
 #ifdef TARGET_NR_stime
     [TARGET_NR_stime] = impl_stime,
 #endif
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 25/33] linux-user: Split out dup, mkdir, mkdirat, rmdir
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (23 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 24/33] linux-user: Split out rename, renameat, renameat2 Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 26/33] linux-user: Split out acct, pipe, pipe2, times, umount2 Richard Henderson
                   ` (9 subsequent siblings)
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 109 +++++++++++++++++++++++++++++--------------
 1 file changed, 73 insertions(+), 36 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 24514329b0..36092d753d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7977,6 +7977,20 @@ IMPL(creat)
 }
 #endif
 
+IMPL(dup)
+{
+    abi_long ret;
+
+    if (is_hostfd(arg1)) {
+        return -TARGET_EBADF;
+    }
+    ret = get_errno(dup(arg1));
+    if (ret >= 0) {
+        fd_trans_dup(arg1, ret);
+    }
+    return ret;
+}
+
 IMPL(execve)
 {
     abi_ulong *guest_ptrs;
@@ -8249,6 +8263,40 @@ IMPL(lseek)
     return get_errno(lseek(arg1, arg2, arg3));
 }
 
+#ifdef TARGET_NR_mkdir
+IMPL(mkdir)
+{
+    char *p = lock_user_string(arg1);
+    abi_long ret;
+
+    if (!p) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(mkdir(p, arg2));
+    unlock_user(p, arg1, 0);
+    return ret;
+}
+#endif
+
+#ifdef TARGET_NR_mkdirat
+IMPL(mkdirat)
+{
+    char *p;
+    abi_long ret;
+
+    if (is_hostfd(arg1)) {
+        return -TARGET_EBADF;
+    }
+    p = lock_user_string(arg2);
+    if (!p) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(mkdirat(arg1, p, arg3));
+    unlock_user(p, arg2, 0);
+    return ret;
+}
+#endif
+
 #ifdef TARGET_NR_mknod
 IMPL(mknod)
 {
@@ -8558,6 +8606,21 @@ IMPL(renameat2)
 }
 #endif
 
+#ifdef TARGET_NR_rmdir
+IMPL(rmdir)
+{
+    char *p = lock_user_string(arg1);
+    abi_long ret;
+
+    if (!p) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(rmdir(p));
+    unlock_user(p, arg1, 0);
+    return ret;
+}
+#endif
+
 #ifdef TARGET_NR_stime
 IMPL(stime)
 {
@@ -8768,42 +8831,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-#ifdef TARGET_NR_mkdir
-    case TARGET_NR_mkdir:
-        if (!(p = lock_user_string(arg1)))
-            return -TARGET_EFAULT;
-        ret = get_errno(mkdir(p, arg2));
-        unlock_user(p, arg1, 0);
-        return ret;
-#endif
-#if defined(TARGET_NR_mkdirat)
-    case TARGET_NR_mkdirat:
-        if (is_hostfd(arg1)) {
-            return -TARGET_EBADF;
-        }
-        if (!(p = lock_user_string(arg2)))
-            return -TARGET_EFAULT;
-        ret = get_errno(mkdirat(arg1, p, arg3));
-        unlock_user(p, arg2, 0);
-        return ret;
-#endif
-#ifdef TARGET_NR_rmdir
-    case TARGET_NR_rmdir:
-        if (!(p = lock_user_string(arg1)))
-            return -TARGET_EFAULT;
-        ret = get_errno(rmdir(p));
-        unlock_user(p, arg1, 0);
-        return ret;
-#endif
-    case TARGET_NR_dup:
-        if (is_hostfd(arg1)) {
-            return -TARGET_EBADF;
-        }
-        ret = get_errno(dup(arg1));
-        if (ret >= 0) {
-            fd_trans_dup(arg1, ret);
-        }
-        return ret;
 #ifdef TARGET_NR_pipe
     case TARGET_NR_pipe:
         return do_pipe(cpu_env, arg1, 0, 0);
@@ -12922,6 +12949,7 @@ static impl_fn * const syscall_table[] = {
 #ifdef TARGET_NR_creat
     [TARGET_NR_creat] = impl_creat,
 #endif
+    [TARGET_NR_dup] = impl_dup,
     [TARGET_NR_execve] = impl_execve,
     [TARGET_NR_exit] = impl_exit,
 #ifdef TARGET_NR_faccessat
@@ -12947,6 +12975,12 @@ static impl_fn * const syscall_table[] = {
     [TARGET_NR_linkat] = impl_linkat,
 #endif
     [TARGET_NR_lseek] = impl_lseek,
+#ifdef TARGET_NR_mkdir
+    [TARGET_NR_mkdir] = impl_mkdir,
+#endif
+#ifdef TARGET_NR_mkdirat
+    [TARGET_NR_mkdirat] = impl_mkdirat,
+#endif
 #ifdef TARGET_NR_mknod
     [TARGET_NR_mknod] = impl_mknod,
 #endif
@@ -12980,6 +13014,9 @@ static impl_fn * const syscall_table[] = {
 #ifdef TARGET_NR_renameat2
     [TARGET_NR_renameat2] = impl_renameat2,
 #endif
+#ifdef TARGET_NR_rmdir
+    [TARGET_NR_rmdir] = impl_rmdir,
+#endif
 #ifdef TARGET_NR_stime
     [TARGET_NR_stime] = impl_stime,
 #endif
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 26/33] linux-user: Split out acct, pipe, pipe2, times, umount2
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (24 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 25/33] linux-user: Split out dup, mkdir, mkdirat, rmdir Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 27/33] linux-user: Split out ioctl Richard Henderson
                   ` (8 subsequent siblings)
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 127 +++++++++++++++++++++++++++----------------
 1 file changed, 80 insertions(+), 47 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 36092d753d..bde1f9872f 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7912,6 +7912,24 @@ IMPL(access)
 }
 #endif
 
+IMPL(acct)
+{
+    if (arg1 == 0) {
+        return get_errno(acct(NULL));
+    } else {
+        char *fn = lock_user_string(arg1);
+        abi_long ret;
+
+        if (!fn) {
+            return -TARGET_EFAULT;
+        }
+        TRY_INTERP_PATH(ret, fn, acct(fn));
+        ret = get_errno(ret);
+        unlock_user(fn, arg1, 0);
+        return ret;
+    }
+}
+
 #ifdef TARGET_NR_alarm
 IMPL(alarm)
 {
@@ -8529,6 +8547,21 @@ IMPL(pause)
 }
 #endif
 
+#ifdef TARGET_NR_pipe
+IMPL(pipe)
+{
+    return do_pipe(cpu_env, arg1, 0, 0);
+}
+#endif
+
+#ifdef TARGET_NR_pipe2
+IMPL(pipe2)
+{
+    return do_pipe(cpu_env, arg1,
+                   target_to_host_bitmask(arg2, fcntl_flags_tbl), 1);
+}
+#endif
+
 IMPL(read)
 {
     abi_long ret;
@@ -8657,6 +8690,27 @@ IMPL(time)
 }
 #endif
 
+IMPL(times)
+{
+    struct tms tms;
+    abi_long ret = get_errno(times(&tms));
+    if (arg1) {
+        struct target_tms *tmsp
+            = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_tms), 0);
+        if (!tmsp) {
+            return -TARGET_EFAULT;
+        }
+        tmsp->tms_utime = tswapal(host_to_target_clock_t(tms.tms_utime));
+        tmsp->tms_stime = tswapal(host_to_target_clock_t(tms.tms_stime));
+        tmsp->tms_cutime = tswapal(host_to_target_clock_t(tms.tms_cutime));
+        tmsp->tms_cstime = tswapal(host_to_target_clock_t(tms.tms_cstime));
+    }
+    if (!is_error(ret)) {
+        ret = host_to_target_clock_t(ret);
+    }
+    return ret;
+}
+
 #ifdef TARGET_NR_umount
 IMPL(umount)
 {
@@ -8672,6 +8726,21 @@ IMPL(umount)
 }
 #endif
 
+#ifdef TARGET_NR_umount2
+IMPL(umount2)
+{
+    char *p = lock_user_string(arg1);
+    abi_long ret;
+
+    if (!p) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(umount2(p, arg2));
+    unlock_user(p, arg1, 0);
+    return ret;
+}
+#endif
+
 #ifdef TARGET_NR_unlink
 IMPL(unlink)
 {
@@ -8831,53 +8900,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-#ifdef TARGET_NR_pipe
-    case TARGET_NR_pipe:
-        return do_pipe(cpu_env, arg1, 0, 0);
-#endif
-#ifdef TARGET_NR_pipe2
-    case TARGET_NR_pipe2:
-        return do_pipe(cpu_env, arg1,
-                       target_to_host_bitmask(arg2, fcntl_flags_tbl), 1);
-#endif
-    case TARGET_NR_times:
-        {
-            struct target_tms *tmsp;
-            struct tms tms;
-            ret = get_errno(times(&tms));
-            if (arg1) {
-                tmsp = lock_user(VERIFY_WRITE, arg1, sizeof(struct target_tms), 0);
-                if (!tmsp)
-                    return -TARGET_EFAULT;
-                tmsp->tms_utime = tswapal(host_to_target_clock_t(tms.tms_utime));
-                tmsp->tms_stime = tswapal(host_to_target_clock_t(tms.tms_stime));
-                tmsp->tms_cutime = tswapal(host_to_target_clock_t(tms.tms_cutime));
-                tmsp->tms_cstime = tswapal(host_to_target_clock_t(tms.tms_cstime));
-            }
-            if (!is_error(ret))
-                ret = host_to_target_clock_t(ret);
-        }
-        return ret;
-    case TARGET_NR_acct:
-        if (arg1 == 0) {
-            ret = get_errno(acct(NULL));
-        } else {
-            if (!(fn = lock_user_string(arg1))) {
-                return -TARGET_EFAULT;
-            }
-            TRY_INTERP_PATH(ret, fn, acct(fn));
-            ret = get_errno(ret);
-            unlock_user(fn, arg1, 0);
-        }
-        return ret;
-#ifdef TARGET_NR_umount2
-    case TARGET_NR_umount2:
-        if (!(p = lock_user_string(arg1)))
-            return -TARGET_EFAULT;
-        ret = get_errno(umount2(p, arg2));
-        unlock_user(p, arg1, 0);
-        return ret;
-#endif
     case TARGET_NR_ioctl:
         return do_ioctl(arg1, arg2, arg3);
 #ifdef TARGET_NR_fcntl
@@ -12937,6 +12959,7 @@ static impl_fn * const syscall_table[] = {
 #ifdef TARGET_NR_access
     [TARGET_NR_access] = impl_access,
 #endif
+    [TARGET_NR_acct] = impl_acct,
 #ifdef TARGET_NR_alarm
     [TARGET_NR_alarm] = impl_alarm,
 #endif
@@ -13003,6 +13026,12 @@ static impl_fn * const syscall_table[] = {
 #endif
 #ifdef TARGET_NR_pause
     [TARGET_NR_pause] = impl_pause,
+#endif
+#ifdef TARGET_NR_pipe
+    [TARGET_NR_pipe] = impl_pipe,
+#endif
+#ifdef TARGET_NR_pipe2
+    [TARGET_NR_pipe2] = impl_pipe2,
 #endif
     [TARGET_NR_read] = impl_read,
 #ifdef TARGET_NR_rename
@@ -13027,9 +13056,13 @@ static impl_fn * const syscall_table[] = {
 #ifdef TARGET_NR_time
     [TARGET_NR_time] = impl_time,
 #endif
+    [TARGET_NR_times] = impl_times,
 #ifdef TARGET_NR_umount
     [TARGET_NR_umount] = impl_umount,
 #endif
+#ifdef TARGET_NR_umount2
+    [TARGET_NR_umount2] = impl_umount2,
+#endif
 #ifdef TARGET_NR_unlink
     [TARGET_NR_unlink] = impl_unlink,
 #endif
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 27/33] linux-user: Split out ioctl
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (25 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 26/33] linux-user: Split out acct, pipe, pipe2, times, umount2 Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 28/33] linux-user: Split out chroot, dup2, dup3, fcntl, setpgid, umask Richard Henderson
                   ` (7 subsequent siblings)
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

At the same time, merge do_ioctl into the new function.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 190 ++++++++++++++++++++++---------------------
 1 file changed, 97 insertions(+), 93 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index bde1f9872f..4be71367fc 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5759,97 +5759,6 @@ static IOCTLEntry ioctl_entries[] = {
     { 0, 0, },
 };
 
-/* ??? Implement proper locking for ioctls.  */
-/* do_ioctl() Must return target values and target errnos. */
-static abi_long do_ioctl(int fd, int cmd, abi_long arg)
-{
-    const IOCTLEntry *ie;
-    const argtype *arg_type;
-    abi_long ret;
-    uint8_t buf_temp[MAX_STRUCT_SIZE];
-    int target_size;
-    void *argptr;
-
-    ie = ioctl_entries;
-    for(;;) {
-        if (ie->target_cmd == 0) {
-            gemu_log("Unsupported ioctl: cmd=0x%04lx\n", (long)cmd);
-            return -TARGET_ENOSYS;
-        }
-        if (ie->target_cmd == cmd)
-            break;
-        ie++;
-    }
-    arg_type = ie->arg_type;
-#if defined(DEBUG)
-    gemu_log("ioctl: cmd=0x%04lx (%s)\n", (long)cmd, ie->name);
-#endif
-    if (ie->do_ioctl) {
-        return ie->do_ioctl(ie, buf_temp, fd, cmd, arg);
-    } else if (!ie->host_cmd) {
-        /* Some architectures define BSD ioctls in their headers
-           that are not implemented in Linux.  */
-        return -TARGET_ENOSYS;
-    }
-
-    switch(arg_type[0]) {
-    case TYPE_NULL:
-        /* no argument */
-        ret = get_errno(safe_ioctl(fd, ie->host_cmd));
-        break;
-    case TYPE_PTRVOID:
-    case TYPE_INT:
-        ret = get_errno(safe_ioctl(fd, ie->host_cmd, arg));
-        break;
-    case TYPE_PTR:
-        arg_type++;
-        target_size = thunk_type_size(arg_type, 0);
-        switch(ie->access) {
-        case IOC_R:
-            ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp));
-            if (!is_error(ret)) {
-                argptr = lock_user(VERIFY_WRITE, arg, target_size, 0);
-                if (!argptr)
-                    return -TARGET_EFAULT;
-                thunk_convert(argptr, buf_temp, arg_type, THUNK_TARGET);
-                unlock_user(argptr, arg, target_size);
-            }
-            break;
-        case IOC_W:
-            argptr = lock_user(VERIFY_READ, arg, target_size, 1);
-            if (!argptr)
-                return -TARGET_EFAULT;
-            thunk_convert(buf_temp, argptr, arg_type, THUNK_HOST);
-            unlock_user(argptr, arg, 0);
-            ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp));
-            break;
-        default:
-        case IOC_RW:
-            argptr = lock_user(VERIFY_READ, arg, target_size, 1);
-            if (!argptr)
-                return -TARGET_EFAULT;
-            thunk_convert(buf_temp, argptr, arg_type, THUNK_HOST);
-            unlock_user(argptr, arg, 0);
-            ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp));
-            if (!is_error(ret)) {
-                argptr = lock_user(VERIFY_WRITE, arg, target_size, 0);
-                if (!argptr)
-                    return -TARGET_EFAULT;
-                thunk_convert(argptr, buf_temp, arg_type, THUNK_TARGET);
-                unlock_user(argptr, arg, target_size);
-            }
-            break;
-        }
-        break;
-    default:
-        gemu_log("Unsupported ioctl type: cmd=0x%04lx type=%d\n",
-                 (long)cmd, arg_type[0]);
-        ret = -TARGET_ENOSYS;
-        break;
-    }
-    return ret;
-}
-
 static const bitmask_transtbl iflag_tbl[] = {
         { TARGET_IGNBRK, TARGET_IGNBRK, IGNBRK, IGNBRK },
         { TARGET_BRKINT, TARGET_BRKINT, BRKINT, BRKINT },
@@ -8231,6 +8140,102 @@ IMPL(getxpid)
 }
 #endif
 
+/* ??? Implement proper locking for ioctls.  */
+IMPL(ioctl)
+{
+    abi_long fd = arg1;
+    abi_long cmd = arg2;
+    abi_long arg = arg3;
+    const IOCTLEntry *ie;
+    const argtype *arg_type;
+    abi_long ret;
+    uint8_t buf_temp[MAX_STRUCT_SIZE];
+    int target_size;
+    void *argptr;
+
+    for (ie = ioctl_entries; ; ie++) {
+        if (ie->target_cmd == 0) {
+            gemu_log("Unsupported ioctl: cmd=0x%04lx\n", (long)cmd);
+            return -TARGET_ENOSYS;
+        }
+        if (ie->target_cmd == cmd) {
+            break;
+        }
+    }
+    arg_type = ie->arg_type;
+#if defined(DEBUG)
+    gemu_log("ioctl: cmd=0x%04lx (%s)\n", (long)cmd, ie->name);
+#endif
+    if (ie->do_ioctl) {
+        return ie->do_ioctl(ie, buf_temp, fd, cmd, arg);
+    } else if (!ie->host_cmd) {
+        /* Some architectures define BSD ioctls in their headers
+           that are not implemented in Linux.  */
+        return -TARGET_ENOSYS;
+    }
+
+    switch (arg_type[0]) {
+    case TYPE_NULL:
+        /* no argument */
+        ret = get_errno(safe_ioctl(fd, ie->host_cmd));
+        break;
+    case TYPE_PTRVOID:
+    case TYPE_INT:
+        ret = get_errno(safe_ioctl(fd, ie->host_cmd, arg));
+        break;
+    case TYPE_PTR:
+        arg_type++;
+        target_size = thunk_type_size(arg_type, 0);
+        switch (ie->access) {
+        case IOC_R:
+            ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp));
+            if (!is_error(ret)) {
+                argptr = lock_user(VERIFY_WRITE, arg, target_size, 0);
+                if (!argptr) {
+                    return -TARGET_EFAULT;
+                }
+                thunk_convert(argptr, buf_temp, arg_type, THUNK_TARGET);
+                unlock_user(argptr, arg, target_size);
+            }
+            break;
+        case IOC_W:
+            argptr = lock_user(VERIFY_READ, arg, target_size, 1);
+            if (!argptr) {
+                return -TARGET_EFAULT;
+            }
+            thunk_convert(buf_temp, argptr, arg_type, THUNK_HOST);
+            unlock_user(argptr, arg, 0);
+            ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp));
+            break;
+        default:
+        case IOC_RW:
+            argptr = lock_user(VERIFY_READ, arg, target_size, 1);
+            if (!argptr) {
+                return -TARGET_EFAULT;
+            }
+            thunk_convert(buf_temp, argptr, arg_type, THUNK_HOST);
+            unlock_user(argptr, arg, 0);
+            ret = get_errno(safe_ioctl(fd, ie->host_cmd, buf_temp));
+            if (!is_error(ret)) {
+                argptr = lock_user(VERIFY_WRITE, arg, target_size, 0);
+                if (!argptr) {
+                    return -TARGET_EFAULT;
+                }
+                thunk_convert(argptr, buf_temp, arg_type, THUNK_TARGET);
+                unlock_user(argptr, arg, target_size);
+            }
+            break;
+        }
+        break;
+    default:
+        gemu_log("Unsupported ioctl type: cmd=0x%04lx type=%d\n",
+                 (long)cmd, arg_type[0]);
+        ret = -TARGET_ENOSYS;
+        break;
+    }
+    return ret;
+}
+
 IMPL(kill)
 {
     return get_errno(safe_kill(arg1, target_to_host_signal(arg2)));
@@ -8900,8 +8905,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-    case TARGET_NR_ioctl:
-        return do_ioctl(arg1, arg2, arg3);
 #ifdef TARGET_NR_fcntl
     case TARGET_NR_fcntl:
         return do_fcntl(arg1, arg2, arg3);
@@ -12990,6 +12993,7 @@ static impl_fn * const syscall_table[] = {
 #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA)
     [TARGET_NR_getxpid] = impl_getxpid,
 #endif
+    [TARGET_NR_ioctl] = impl_ioctl,
     [TARGET_NR_kill] = impl_kill,
 #ifdef TARGET_NR_link
     [TARGET_NR_link] = impl_link,
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 28/33] linux-user: Split out chroot, dup2, dup3, fcntl, setpgid, umask
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (26 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 27/33] linux-user: Split out ioctl Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 29/33] linux-user: Split out getpgrp, getppid, setsid Richard Henderson
                   ` (6 subsequent siblings)
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 123 +++++++++++++++++++++++++++----------------
 1 file changed, 79 insertions(+), 44 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 4be71367fc..4d9b9cad6e 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7879,6 +7879,19 @@ IMPL(chmod)
 }
 #endif
 
+IMPL(chroot)
+{
+    char *p = lock_user_string(arg1);
+    abi_long ret;
+
+    if (!p) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(chroot(p));
+    unlock_user(p, arg1, 0);
+    return ret;
+}
+
 IMPL(close)
 {
     if (is_hostfd(arg1)) {
@@ -7918,6 +7931,43 @@ IMPL(dup)
     return ret;
 }
 
+#ifdef TARGET_NR_dup2
+IMPL(dup2)
+{
+    abi_long ret;
+
+    if (is_hostfd(arg1) || is_hostfd(arg2)) {
+        return -TARGET_EBADF;
+    }
+    ret = get_errno(dup2(arg1, arg2));
+    if (ret >= 0) {
+        fd_trans_dup(arg1, arg2);
+    }
+    return ret;
+}
+#endif
+
+#if defined(TARGET_NR_dup3) && defined(CONFIG_DUP3)
+IMPL(dup3)
+{
+    int host_flags;
+    abi_long ret;
+
+    if (is_hostfd(arg1) || is_hostfd(arg2)) {
+        return -TARGET_EBADF;
+    }
+    if ((arg3 & ~TARGET_O_CLOEXEC) != 0) {
+        return -EINVAL;
+    }
+    host_flags = target_to_host_bitmask(arg3, fcntl_flags_tbl);
+    ret = get_errno(dup3(arg1, arg2, host_flags));
+    if (ret >= 0) {
+        fd_trans_dup(arg1, arg2);
+    }
+    return ret;
+}
+#endif
+
 IMPL(execve)
 {
     abi_ulong *guest_ptrs;
@@ -8087,6 +8137,13 @@ IMPL(faccessat)
 }
 #endif
 
+#ifdef TARGET_NR_fcntl
+IMPL(fcntl)
+{
+    return do_fcntl(arg1, arg2, arg3);
+}
+#endif
+
 #ifdef TARGET_NR_fork
 IMPL(fork)
 {
@@ -8659,6 +8716,11 @@ IMPL(rmdir)
 }
 #endif
 
+IMPL(setpgid)
+{
+    return get_errno(setpgid(arg1, arg2));
+}
+
 #ifdef TARGET_NR_stime
 IMPL(stime)
 {
@@ -8716,6 +8778,11 @@ IMPL(times)
     return ret;
 }
 
+IMPL(umask)
+{
+    return get_errno(umask(arg1));
+}
+
 #ifdef TARGET_NR_umount
 IMPL(umount)
 {
@@ -8905,50 +8972,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-#ifdef TARGET_NR_fcntl
-    case TARGET_NR_fcntl:
-        return do_fcntl(arg1, arg2, arg3);
-#endif
-    case TARGET_NR_setpgid:
-        return get_errno(setpgid(arg1, arg2));
-    case TARGET_NR_umask:
-        return get_errno(umask(arg1));
-    case TARGET_NR_chroot:
-        if (!(p = lock_user_string(arg1)))
-            return -TARGET_EFAULT;
-        ret = get_errno(chroot(p));
-        unlock_user(p, arg1, 0);
-        return ret;
-#ifdef TARGET_NR_dup2
-    case TARGET_NR_dup2:
-        if (is_hostfd(arg1) || is_hostfd(arg2)) {
-            return -TARGET_EBADF;
-        }
-        ret = get_errno(dup2(arg1, arg2));
-        if (ret >= 0) {
-            fd_trans_dup(arg1, arg2);
-        }
-        return ret;
-#endif
-#if defined(CONFIG_DUP3) && defined(TARGET_NR_dup3)
-    case TARGET_NR_dup3:
-    {
-        int host_flags;
-
-        if (is_hostfd(arg1) || is_hostfd(arg2)) {
-            return -TARGET_EBADF;
-        }
-        if ((arg3 & ~TARGET_O_CLOEXEC) != 0) {
-            return -EINVAL;
-        }
-        host_flags = target_to_host_bitmask(arg3, fcntl_flags_tbl);
-        ret = get_errno(dup3(arg1, arg2, host_flags));
-        if (ret >= 0) {
-            fd_trans_dup(arg1, arg2);
-        }
-        return ret;
-    }
-#endif
 #ifdef TARGET_NR_getppid /* not on alpha */
     case TARGET_NR_getppid:
         return get_errno(getppid());
@@ -12969,6 +12992,7 @@ static impl_fn * const syscall_table[] = {
     [TARGET_NR_brk] = impl_brk,
     [TARGET_NR_close] = impl_close,
     [TARGET_NR_chdir] = impl_chdir,
+    [TARGET_NR_chroot] = impl_chroot,
 #ifdef TARGET_NR_chmod
     [TARGET_NR_chmod] = impl_chmod,
 #endif
@@ -12976,11 +13000,20 @@ static impl_fn * const syscall_table[] = {
     [TARGET_NR_creat] = impl_creat,
 #endif
     [TARGET_NR_dup] = impl_dup,
+#ifdef TARGET_NR_dup2
+    [TARGET_NR_dup2] = impl_dup2,
+#endif
+#if defined(TARGET_NR_dup3) && defined(CONFIG_DUP3)
+    [TARGET_NR_dup3] = impl_dup3,
+#endif
     [TARGET_NR_execve] = impl_execve,
     [TARGET_NR_exit] = impl_exit,
 #ifdef TARGET_NR_faccessat
     [TARGET_NR_faccessat] = impl_faccessat,
 #endif
+#ifdef TARGET_NR_fcntl
+    [TARGET_NR_fcntl] = impl_fcntl,
+#endif
 #ifdef TARGET_NR_fork
     [TARGET_NR_fork] = impl_fork,
 #endif
@@ -13050,6 +13083,7 @@ static impl_fn * const syscall_table[] = {
 #ifdef TARGET_NR_rmdir
     [TARGET_NR_rmdir] = impl_rmdir,
 #endif
+    [TARGET_NR_setpgid] = impl_setpgid,
 #ifdef TARGET_NR_stime
     [TARGET_NR_stime] = impl_stime,
 #endif
@@ -13061,6 +13095,7 @@ static impl_fn * const syscall_table[] = {
     [TARGET_NR_time] = impl_time,
 #endif
     [TARGET_NR_times] = impl_times,
+    [TARGET_NR_umask] = impl_umask,
 #ifdef TARGET_NR_umount
     [TARGET_NR_umount] = impl_umount,
 #endif
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 29/33] linux-user: Split out getpgrp, getppid, setsid
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (27 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 28/33] linux-user: Split out chroot, dup2, dup3, fcntl, setpgid, umask Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 30/33] linux-user: Split out rt_sigaction, sigaction Richard Henderson
                   ` (5 subsequent siblings)
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 4d9b9cad6e..3dfb77ac11 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8182,6 +8182,13 @@ IMPL(futimesat)
 }
 #endif
 
+#ifdef TARGET_NR_getpgrp
+IMPL(getpgrp)
+{
+    return get_errno(getpgrp());
+}
+#endif
+
 #ifdef TARGET_NR_getpid
 IMPL(getpid)
 {
@@ -8189,6 +8196,13 @@ IMPL(getpid)
 }
 #endif
 
+#ifdef TARGET_NR_getppid
+IMPL(getppid)
+{
+    return get_errno(getppid());
+}
+#endif
+
 #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA)
 IMPL(getxpid)
 {
@@ -8721,6 +8735,11 @@ IMPL(setpgid)
     return get_errno(setpgid(arg1, arg2));
 }
 
+IMPL(setsid)
+{
+    return get_errno(setsid());
+}
+
 #ifdef TARGET_NR_stime
 IMPL(stime)
 {
@@ -8972,16 +8991,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-#ifdef TARGET_NR_getppid /* not on alpha */
-    case TARGET_NR_getppid:
-        return get_errno(getppid());
-#endif
-#ifdef TARGET_NR_getpgrp
-    case TARGET_NR_getpgrp:
-        return get_errno(getpgrp());
-#endif
-    case TARGET_NR_setsid:
-        return get_errno(setsid());
 #ifdef TARGET_NR_sigaction
     case TARGET_NR_sigaction:
         {
@@ -13020,9 +13029,15 @@ static impl_fn * const syscall_table[] = {
 #ifdef TARGET_NR_futimesat
     [TARGET_NR_futimesat] = impl_futimesat,
 #endif
+#ifdef TARGET_NR_getpgrp
+    [TARGET_NR_getpgrp] = impl_getpgrp,
+#endif
 #ifdef TARGET_NR_getpid
     [TARGET_NR_getpid] = impl_getpid,
 #endif
+#ifdef TARGET_NR_getppid
+    [TARGET_NR_getppid] = impl_getppid,
+#endif
 #if defined(TARGET_NR_getxpid) && defined(TARGET_ALPHA)
     [TARGET_NR_getxpid] = impl_getxpid,
 #endif
@@ -13084,6 +13099,7 @@ static impl_fn * const syscall_table[] = {
     [TARGET_NR_rmdir] = impl_rmdir,
 #endif
     [TARGET_NR_setpgid] = impl_setpgid,
+    [TARGET_NR_setsid] = impl_setsid,
 #ifdef TARGET_NR_stime
     [TARGET_NR_stime] = impl_stime,
 #endif
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 30/33] linux-user: Split out rt_sigaction, sigaction
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (28 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 29/33] linux-user: Split out getpgrp, getppid, setsid Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 31/33] linux-user: Split out rt_sigprocmask, sgetmask, sigprocmask, ssetmask Richard Henderson
                   ` (4 subsequent siblings)
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 325 ++++++++++++++++++++++---------------------
 1 file changed, 165 insertions(+), 160 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 3dfb77ac11..36e2bb838e 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8730,6 +8730,81 @@ IMPL(rmdir)
 }
 #endif
 
+IMPL(rt_sigaction)
+{
+    abi_long ret;
+#ifdef TARGET_ALPHA
+    /* For Alpha and SPARC this is a 5 argument syscall, with
+     * a 'restorer' parameter which must be copied into the
+     * sa_restorer field of the sigaction struct.
+     * For Alpha that 'restorer' is arg5; for SPARC it is arg4,
+     * and arg5 is the sigsetsize.
+     * Alpha also has a separate rt_sigaction struct that it uses
+     * here; SPARC uses the usual sigaction struct.
+     */
+    struct target_rt_sigaction *rt_act;
+    struct target_sigaction act, oact, *pact = 0;
+
+    if (arg4 != sizeof(target_sigset_t)) {
+        return -TARGET_EINVAL;
+    }
+    if (arg2) {
+        if (!lock_user_struct(VERIFY_READ, rt_act, arg2, 1)) {
+            return -TARGET_EFAULT;
+        }
+        act._sa_handler = rt_act->_sa_handler;
+        act.sa_mask = rt_act->sa_mask;
+        act.sa_flags = rt_act->sa_flags;
+        act.sa_restorer = arg5;
+        unlock_user_struct(rt_act, arg2, 0);
+        pact = &act;
+    }
+    ret = get_errno(do_sigaction(arg1, pact, &oact));
+    if (!is_error(ret) && arg3) {
+        if (!lock_user_struct(VERIFY_WRITE, rt_act, arg3, 0)) {
+            return -TARGET_EFAULT;
+        }
+        rt_act->_sa_handler = oact._sa_handler;
+        rt_act->sa_mask = oact.sa_mask;
+        rt_act->sa_flags = oact.sa_flags;
+        unlock_user_struct(rt_act, arg3, 1);
+    }
+#else
+# ifdef TARGET_SPARC
+    target_ulong restorer = arg4;
+    target_ulong sigsetsize = arg5;
+# else
+    target_ulong sigsetsize = arg4;
+# endif
+    struct target_sigaction *act = NULL;
+    struct target_sigaction *oact = NULL;
+
+    if (sigsetsize != sizeof(target_sigset_t)) {
+        return -TARGET_EINVAL;
+    }
+    if (arg2) {
+        if (!lock_user_struct(VERIFY_READ, act, arg2, 1)) {
+            return -TARGET_EFAULT;
+        }
+# ifdef TARGET_ARCH_HAS_KA_RESTORER
+        act->ka_restorer = restorer;
+# endif
+    }
+    if (arg3 && !lock_user_struct(VERIFY_WRITE, oact, arg3, 0)) {
+        ret = -TARGET_EFAULT;
+    } else {
+        ret = get_errno(do_sigaction(arg1, act, oact));
+    }
+    if (act) {
+        unlock_user_struct(act, arg2, 0);
+    }
+    if (oact) {
+        unlock_user_struct(oact, arg3, 1);
+    }
+#endif
+    return ret;
+}
+
 IMPL(setpgid)
 {
     return get_errno(setpgid(arg1, arg2));
@@ -8740,6 +8815,92 @@ IMPL(setsid)
     return get_errno(setsid());
 }
 
+#ifdef TARGET_NR_sigaction
+IMPL(sigaction)
+{
+    abi_long ret;
+# if defined(TARGET_ALPHA)
+    struct target_sigaction act, oact, *pact = NULL;
+    struct target_old_sigaction *old_act;
+    if (arg2) {
+        if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) {
+            return -TARGET_EFAULT;
+        }
+        act._sa_handler = old_act->_sa_handler;
+        target_siginitset(&act.sa_mask, old_act->sa_mask);
+        act.sa_flags = old_act->sa_flags;
+        act.sa_restorer = 0;
+        unlock_user_struct(old_act, arg2, 0);
+        pact = &act;
+    }
+    ret = get_errno(do_sigaction(arg1, pact, &oact));
+    if (!is_error(ret) && arg3) {
+        if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) {
+            return -TARGET_EFAULT;
+        }
+        old_act->_sa_handler = oact._sa_handler;
+        old_act->sa_mask = oact.sa_mask.sig[0];
+        old_act->sa_flags = oact.sa_flags;
+        unlock_user_struct(old_act, arg3, 1);
+    }
+# elif defined(TARGET_MIPS)
+    struct target_sigaction act, oact, *pact = NULL, *old_act;
+    if (arg2) {
+        if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) {
+            return -TARGET_EFAULT;
+        }
+	act._sa_handler = old_act->_sa_handler;
+	target_siginitset(&act.sa_mask, old_act->sa_mask.sig[0]);
+	act.sa_flags = old_act->sa_flags;
+	unlock_user_struct(old_act, arg2, 0);
+	pact = &act;
+    }
+    ret = get_errno(do_sigaction(arg1, pact, &oact));
+    if (!is_error(ret) && arg3) {
+        if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) {
+            return -TARGET_EFAULT;
+        }
+	old_act->_sa_handler = oact._sa_handler;
+	old_act->sa_flags = oact.sa_flags;
+	old_act->sa_mask.sig[0] = oact.sa_mask.sig[0];
+	old_act->sa_mask.sig[1] = 0;
+	old_act->sa_mask.sig[2] = 0;
+	old_act->sa_mask.sig[3] = 0;
+	unlock_user_struct(old_act, arg3, 1);
+    }
+# else
+    struct target_sigaction act, oact, *pact = NULL;
+    struct target_old_sigaction *old_act;
+    if (arg2) {
+        if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1)) {
+            return -TARGET_EFAULT;
+        }
+        act._sa_handler = old_act->_sa_handler;
+        target_siginitset(&act.sa_mask, old_act->sa_mask);
+        act.sa_flags = old_act->sa_flags;
+        act.sa_restorer = old_act->sa_restorer;
+#  ifdef TARGET_ARCH_HAS_KA_RESTORER
+        act.ka_restorer = 0;
+#  endif
+        unlock_user_struct(old_act, arg2, 0);
+        pact = &act;
+    }
+    ret = get_errno(do_sigaction(arg1, pact, &oact));
+    if (!is_error(ret) && arg3) {
+        if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0)) {
+            return -TARGET_EFAULT;
+        }
+        old_act->_sa_handler = oact._sa_handler;
+        old_act->sa_mask = oact.sa_mask.sig[0];
+        old_act->sa_flags = oact.sa_flags;
+        old_act->sa_restorer = oact.sa_restorer;
+        unlock_user_struct(old_act, arg3, 1);
+    }
+# endif
+    return ret;
+}
+#endif
+
 #ifdef TARGET_NR_stime
 IMPL(stime)
 {
@@ -8991,166 +9152,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-#ifdef TARGET_NR_sigaction
-    case TARGET_NR_sigaction:
-        {
-#if defined(TARGET_ALPHA)
-            struct target_sigaction act, oact, *pact = 0;
-            struct target_old_sigaction *old_act;
-            if (arg2) {
-                if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1))
-                    return -TARGET_EFAULT;
-                act._sa_handler = old_act->_sa_handler;
-                target_siginitset(&act.sa_mask, old_act->sa_mask);
-                act.sa_flags = old_act->sa_flags;
-                act.sa_restorer = 0;
-                unlock_user_struct(old_act, arg2, 0);
-                pact = &act;
-            }
-            ret = get_errno(do_sigaction(arg1, pact, &oact));
-            if (!is_error(ret) && arg3) {
-                if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))
-                    return -TARGET_EFAULT;
-                old_act->_sa_handler = oact._sa_handler;
-                old_act->sa_mask = oact.sa_mask.sig[0];
-                old_act->sa_flags = oact.sa_flags;
-                unlock_user_struct(old_act, arg3, 1);
-            }
-#elif defined(TARGET_MIPS)
-	    struct target_sigaction act, oact, *pact, *old_act;
-
-	    if (arg2) {
-                if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1))
-                    return -TARGET_EFAULT;
-		act._sa_handler = old_act->_sa_handler;
-		target_siginitset(&act.sa_mask, old_act->sa_mask.sig[0]);
-		act.sa_flags = old_act->sa_flags;
-		unlock_user_struct(old_act, arg2, 0);
-		pact = &act;
-	    } else {
-		pact = NULL;
-	    }
-
-	    ret = get_errno(do_sigaction(arg1, pact, &oact));
-
-	    if (!is_error(ret) && arg3) {
-                if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))
-                    return -TARGET_EFAULT;
-		old_act->_sa_handler = oact._sa_handler;
-		old_act->sa_flags = oact.sa_flags;
-		old_act->sa_mask.sig[0] = oact.sa_mask.sig[0];
-		old_act->sa_mask.sig[1] = 0;
-		old_act->sa_mask.sig[2] = 0;
-		old_act->sa_mask.sig[3] = 0;
-		unlock_user_struct(old_act, arg3, 1);
-	    }
-#else
-            struct target_old_sigaction *old_act;
-            struct target_sigaction act, oact, *pact;
-            if (arg2) {
-                if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1))
-                    return -TARGET_EFAULT;
-                act._sa_handler = old_act->_sa_handler;
-                target_siginitset(&act.sa_mask, old_act->sa_mask);
-                act.sa_flags = old_act->sa_flags;
-                act.sa_restorer = old_act->sa_restorer;
-#ifdef TARGET_ARCH_HAS_KA_RESTORER
-                act.ka_restorer = 0;
-#endif
-                unlock_user_struct(old_act, arg2, 0);
-                pact = &act;
-            } else {
-                pact = NULL;
-            }
-            ret = get_errno(do_sigaction(arg1, pact, &oact));
-            if (!is_error(ret) && arg3) {
-                if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))
-                    return -TARGET_EFAULT;
-                old_act->_sa_handler = oact._sa_handler;
-                old_act->sa_mask = oact.sa_mask.sig[0];
-                old_act->sa_flags = oact.sa_flags;
-                old_act->sa_restorer = oact.sa_restorer;
-                unlock_user_struct(old_act, arg3, 1);
-            }
-#endif
-        }
-        return ret;
-#endif
-    case TARGET_NR_rt_sigaction:
-        {
-#if defined(TARGET_ALPHA)
-            /* For Alpha and SPARC this is a 5 argument syscall, with
-             * a 'restorer' parameter which must be copied into the
-             * sa_restorer field of the sigaction struct.
-             * For Alpha that 'restorer' is arg5; for SPARC it is arg4,
-             * and arg5 is the sigsetsize.
-             * Alpha also has a separate rt_sigaction struct that it uses
-             * here; SPARC uses the usual sigaction struct.
-             */
-            struct target_rt_sigaction *rt_act;
-            struct target_sigaction act, oact, *pact = 0;
-
-            if (arg4 != sizeof(target_sigset_t)) {
-                return -TARGET_EINVAL;
-            }
-            if (arg2) {
-                if (!lock_user_struct(VERIFY_READ, rt_act, arg2, 1))
-                    return -TARGET_EFAULT;
-                act._sa_handler = rt_act->_sa_handler;
-                act.sa_mask = rt_act->sa_mask;
-                act.sa_flags = rt_act->sa_flags;
-                act.sa_restorer = arg5;
-                unlock_user_struct(rt_act, arg2, 0);
-                pact = &act;
-            }
-            ret = get_errno(do_sigaction(arg1, pact, &oact));
-            if (!is_error(ret) && arg3) {
-                if (!lock_user_struct(VERIFY_WRITE, rt_act, arg3, 0))
-                    return -TARGET_EFAULT;
-                rt_act->_sa_handler = oact._sa_handler;
-                rt_act->sa_mask = oact.sa_mask;
-                rt_act->sa_flags = oact.sa_flags;
-                unlock_user_struct(rt_act, arg3, 1);
-            }
-#else
-#ifdef TARGET_SPARC
-            target_ulong restorer = arg4;
-            target_ulong sigsetsize = arg5;
-#else
-            target_ulong sigsetsize = arg4;
-#endif
-            struct target_sigaction *act;
-            struct target_sigaction *oact;
-
-            if (sigsetsize != sizeof(target_sigset_t)) {
-                return -TARGET_EINVAL;
-            }
-            if (arg2) {
-                if (!lock_user_struct(VERIFY_READ, act, arg2, 1)) {
-                    return -TARGET_EFAULT;
-                }
-#ifdef TARGET_ARCH_HAS_KA_RESTORER
-                act->ka_restorer = restorer;
-#endif
-            } else {
-                act = NULL;
-            }
-            if (arg3) {
-                if (!lock_user_struct(VERIFY_WRITE, oact, arg3, 0)) {
-                    ret = -TARGET_EFAULT;
-                    goto rt_sigaction_fail;
-                }
-            } else
-                oact = NULL;
-            ret = get_errno(do_sigaction(arg1, act, oact));
-	rt_sigaction_fail:
-            if (act)
-                unlock_user_struct(act, arg2, 0);
-            if (oact)
-                unlock_user_struct(oact, arg3, 1);
-#endif
-        }
-        return ret;
 #ifdef TARGET_NR_sgetmask /* not on alpha */
     case TARGET_NR_sgetmask:
         {
@@ -13098,8 +13099,12 @@ static impl_fn * const syscall_table[] = {
 #ifdef TARGET_NR_rmdir
     [TARGET_NR_rmdir] = impl_rmdir,
 #endif
+    [TARGET_NR_rt_sigaction] = impl_rt_sigaction,
     [TARGET_NR_setpgid] = impl_setpgid,
     [TARGET_NR_setsid] = impl_setsid,
+#ifdef TARGET_NR_sigaction
+    [TARGET_NR_sigaction] = impl_sigaction,
+#endif
 #ifdef TARGET_NR_stime
     [TARGET_NR_stime] = impl_stime,
 #endif
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 31/33] linux-user: Split out rt_sigprocmask, sgetmask, sigprocmask, ssetmask
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (29 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 30/33] linux-user: Split out rt_sigaction, sigaction Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 32/33] linux-user: Split out rt_sigpending, rt_sigsuspend, sigpending, sigsuspend Richard Henderson
                   ` (3 subsequent siblings)
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 294 +++++++++++++++++++++++--------------------
 1 file changed, 158 insertions(+), 136 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 36e2bb838e..e37a3ab643 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8805,6 +8805,65 @@ IMPL(rt_sigaction)
     return ret;
 }
 
+IMPL(rt_sigprocmask)
+{
+    int how = 0;
+    sigset_t set, oldset, *set_ptr = NULL;
+    abi_long ret;
+    target_sigset_t *p;
+
+    if (arg4 != sizeof(target_sigset_t)) {
+        return -TARGET_EINVAL;
+    }
+
+    if (arg2) {
+        switch (arg1) {
+        case TARGET_SIG_BLOCK:
+            how = SIG_BLOCK;
+            break;
+        case TARGET_SIG_UNBLOCK:
+            how = SIG_UNBLOCK;
+            break;
+        case TARGET_SIG_SETMASK:
+            how = SIG_SETMASK;
+            break;
+        default:
+            return -TARGET_EINVAL;
+        }
+        p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1);
+        if (!p) {
+            return -TARGET_EFAULT;
+        }
+        target_to_host_sigset(&set, p);
+        unlock_user(p, arg2, 0);
+        set_ptr = &set;
+    }
+    ret = do_sigprocmask(how, set_ptr, &oldset);
+    if (!is_error(ret) && arg3) {
+        p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0);
+        if (!p) {
+            return -TARGET_EFAULT;
+        }
+        host_to_target_sigset(p, &oldset);
+        unlock_user(p, arg3, sizeof(target_sigset_t));
+    }
+    return ret;
+}
+
+#ifdef TARGET_NR_sgetmask
+IMPL(sgetmask)
+{
+    sigset_t cur_set;
+    abi_ulong target_set;
+    abi_long ret = do_sigprocmask(0, NULL, &cur_set);
+    if (!ret) {
+        host_to_target_old_sigset(&target_set, &cur_set);
+        ret = target_set;
+    }
+    return ret;
+}
+#endif
+
 IMPL(setpgid)
 {
     return get_errno(setpgid(arg1, arg2));
@@ -8901,6 +8960,95 @@ IMPL(sigaction)
 }
 #endif
 
+#ifdef TARGET_NR_sigprocmask
+IMPL(sigprocmask)
+{
+    abi_long ret;
+# ifdef TARGET_ALPHA
+    sigset_t set, oldset;
+    abi_ulong mask;
+    int how;
+
+    switch (arg1) {
+    case TARGET_SIG_BLOCK:
+        how = SIG_BLOCK;
+        break;
+    case TARGET_SIG_UNBLOCK:
+        how = SIG_UNBLOCK;
+        break;
+    case TARGET_SIG_SETMASK:
+        how = SIG_SETMASK;
+        break;
+    default:
+        return -TARGET_EINVAL;
+    }
+    mask = arg2;
+    target_to_host_old_sigset(&set, &mask);
+
+    ret = do_sigprocmask(how, &set, &oldset);
+    if (!is_error(ret)) {
+        host_to_target_old_sigset(&mask, &oldset);
+        ret = mask;
+        ((CPUAlphaState *)cpu_env)->ir[IR_V0] = 0; /* force no error */
+    }
+# else
+    sigset_t set, oldset, *set_ptr = NULL;
+    int how = 0;
+    abi_ulong *p;
+
+    if (arg2) {
+        switch (arg1) {
+        case TARGET_SIG_BLOCK:
+            how = SIG_BLOCK;
+            break;
+        case TARGET_SIG_UNBLOCK:
+            how = SIG_UNBLOCK;
+            break;
+        case TARGET_SIG_SETMASK:
+            how = SIG_SETMASK;
+            break;
+        default:
+            return -TARGET_EINVAL;
+        }
+        p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1);
+        if (!p) {
+            return -TARGET_EFAULT;
+        }
+        target_to_host_old_sigset(&set, p);
+        unlock_user(p, arg2, 0);
+        set_ptr = &set;
+    }
+    ret = do_sigprocmask(how, set_ptr, &oldset);
+    if (!is_error(ret) && arg3) {
+        p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0);
+        if (!p) {
+            return -TARGET_EFAULT;
+        }
+        host_to_target_old_sigset(p, &oldset);
+        unlock_user(p, arg3, sizeof(target_sigset_t));
+    }
+# endif
+    return ret;
+}
+#endif
+
+#ifdef TARGET_NR_ssetmask
+IMPL(ssetmask)
+{
+    sigset_t set, oset;
+    abi_ulong target_set = arg1;
+    abi_long ret;
+
+    target_to_host_old_sigset(&set, &target_set);
+    ret = do_sigprocmask(SIG_SETMASK, &set, &oset);
+    if (!ret) {
+        host_to_target_old_sigset(&target_set, &oset);
+        ret = target_set;
+    }
+    return ret;
+}
+#endif
+
 #ifdef TARGET_NR_stime
 IMPL(stime)
 {
@@ -9152,142 +9300,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-#ifdef TARGET_NR_sgetmask /* not on alpha */
-    case TARGET_NR_sgetmask:
-        {
-            sigset_t cur_set;
-            abi_ulong target_set;
-            ret = do_sigprocmask(0, NULL, &cur_set);
-            if (!ret) {
-                host_to_target_old_sigset(&target_set, &cur_set);
-                ret = target_set;
-            }
-        }
-        return ret;
-#endif
-#ifdef TARGET_NR_ssetmask /* not on alpha */
-    case TARGET_NR_ssetmask:
-        {
-            sigset_t set, oset;
-            abi_ulong target_set = arg1;
-            target_to_host_old_sigset(&set, &target_set);
-            ret = do_sigprocmask(SIG_SETMASK, &set, &oset);
-            if (!ret) {
-                host_to_target_old_sigset(&target_set, &oset);
-                ret = target_set;
-            }
-        }
-        return ret;
-#endif
-#ifdef TARGET_NR_sigprocmask
-    case TARGET_NR_sigprocmask:
-        {
-#if defined(TARGET_ALPHA)
-            sigset_t set, oldset;
-            abi_ulong mask;
-            int how;
-
-            switch (arg1) {
-            case TARGET_SIG_BLOCK:
-                how = SIG_BLOCK;
-                break;
-            case TARGET_SIG_UNBLOCK:
-                how = SIG_UNBLOCK;
-                break;
-            case TARGET_SIG_SETMASK:
-                how = SIG_SETMASK;
-                break;
-            default:
-                return -TARGET_EINVAL;
-            }
-            mask = arg2;
-            target_to_host_old_sigset(&set, &mask);
-
-            ret = do_sigprocmask(how, &set, &oldset);
-            if (!is_error(ret)) {
-                host_to_target_old_sigset(&mask, &oldset);
-                ret = mask;
-                ((CPUAlphaState *)cpu_env)->ir[IR_V0] = 0; /* force no error */
-            }
-#else
-            sigset_t set, oldset, *set_ptr;
-            int how;
-
-            if (arg2) {
-                switch (arg1) {
-                case TARGET_SIG_BLOCK:
-                    how = SIG_BLOCK;
-                    break;
-                case TARGET_SIG_UNBLOCK:
-                    how = SIG_UNBLOCK;
-                    break;
-                case TARGET_SIG_SETMASK:
-                    how = SIG_SETMASK;
-                    break;
-                default:
-                    return -TARGET_EINVAL;
-                }
-                if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))
-                    return -TARGET_EFAULT;
-                target_to_host_old_sigset(&set, p);
-                unlock_user(p, arg2, 0);
-                set_ptr = &set;
-            } else {
-                how = 0;
-                set_ptr = NULL;
-            }
-            ret = do_sigprocmask(how, set_ptr, &oldset);
-            if (!is_error(ret) && arg3) {
-                if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0)))
-                    return -TARGET_EFAULT;
-                host_to_target_old_sigset(p, &oldset);
-                unlock_user(p, arg3, sizeof(target_sigset_t));
-            }
-#endif
-        }
-        return ret;
-#endif
-    case TARGET_NR_rt_sigprocmask:
-        {
-            int how = arg1;
-            sigset_t set, oldset, *set_ptr;
-
-            if (arg4 != sizeof(target_sigset_t)) {
-                return -TARGET_EINVAL;
-            }
-
-            if (arg2) {
-                switch(how) {
-                case TARGET_SIG_BLOCK:
-                    how = SIG_BLOCK;
-                    break;
-                case TARGET_SIG_UNBLOCK:
-                    how = SIG_UNBLOCK;
-                    break;
-                case TARGET_SIG_SETMASK:
-                    how = SIG_SETMASK;
-                    break;
-                default:
-                    return -TARGET_EINVAL;
-                }
-                if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))
-                    return -TARGET_EFAULT;
-                target_to_host_sigset(&set, p);
-                unlock_user(p, arg2, 0);
-                set_ptr = &set;
-            } else {
-                how = 0;
-                set_ptr = NULL;
-            }
-            ret = do_sigprocmask(how, set_ptr, &oldset);
-            if (!is_error(ret) && arg3) {
-                if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0)))
-                    return -TARGET_EFAULT;
-                host_to_target_sigset(p, &oldset);
-                unlock_user(p, arg3, sizeof(target_sigset_t));
-            }
-        }
-        return ret;
 #ifdef TARGET_NR_sigpending
     case TARGET_NR_sigpending:
         {
@@ -13100,11 +13112,21 @@ static impl_fn * const syscall_table[] = {
     [TARGET_NR_rmdir] = impl_rmdir,
 #endif
     [TARGET_NR_rt_sigaction] = impl_rt_sigaction,
+    [TARGET_NR_rt_sigprocmask] = impl_rt_sigprocmask,
+#ifdef TARGET_NR_sgetmask
+    [TARGET_NR_sgetmask] = impl_sgetmask,
+#endif
     [TARGET_NR_setpgid] = impl_setpgid,
     [TARGET_NR_setsid] = impl_setsid,
 #ifdef TARGET_NR_sigaction
     [TARGET_NR_sigaction] = impl_sigaction,
 #endif
+#ifdef TARGET_NR_sigprocmask
+    [TARGET_NR_sigprocmask] = impl_sigprocmask,
+#endif
+#ifdef TARGET_NR_ssetmask
+    [TARGET_NR_ssetmask] = impl_ssetmask,
+#endif
 #ifdef TARGET_NR_stime
     [TARGET_NR_stime] = impl_stime,
 #endif
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 32/33] linux-user: Split out rt_sigpending, rt_sigsuspend, sigpending, sigsuspend
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (30 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 31/33] linux-user: Split out rt_sigprocmask, sgetmask, sigprocmask, ssetmask Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 33/33] linux-user: Split out rt_sigqueueinfo, rt_sigtimedwait, rt_tgsigqueueinfo Richard Henderson
                   ` (2 subsequent siblings)
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 176 +++++++++++++++++++++++++------------------
 1 file changed, 101 insertions(+), 75 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index e37a3ab643..c3bd625965 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8805,6 +8805,32 @@ IMPL(rt_sigaction)
     return ret;
 }
 
+IMPL(rt_sigpending)
+{
+    sigset_t set;
+    abi_long ret;
+
+    /* Yes, this check is >, not != like most. We follow the kernel's
+     * logic and it does it like this because it implements
+     * NR_sigpending through the same code path, and in that case
+     * the old_sigset_t is smaller in size.
+     */
+    if (arg2 > sizeof(target_sigset_t)) {
+        return -TARGET_EINVAL;
+    }
+    ret = get_errno(sigpending(&set));
+    if (!is_error(ret)) {
+        target_sigset_t *p;
+        p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0);
+        if (!p) {
+            return -TARGET_EFAULT;
+        }
+        host_to_target_sigset(p, &set);
+        unlock_user(p, arg1, sizeof(target_sigset_t));
+    }
+    return ret;
+}
+
 IMPL(rt_sigprocmask)
 {
     int how = 0;
@@ -8850,6 +8876,29 @@ IMPL(rt_sigprocmask)
     return ret;
 }
 
+IMPL(rt_sigsuspend)
+{
+    CPUState *cpu = ENV_GET_CPU(cpu_env);
+    TaskState *ts = cpu->opaque;
+    target_sigset_t *p;
+    abi_long ret;
+
+    if (arg2 != sizeof(target_sigset_t)) {
+        return -TARGET_EINVAL;
+    }
+    p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1);
+    if (!p) {
+        return -TARGET_EFAULT;
+    }
+    target_to_host_sigset(&ts->sigsuspend_mask, p);
+    unlock_user(p, arg1, 0);
+    ret = get_errno(safe_rt_sigsuspend(&ts->sigsuspend_mask, SIGSET_T_SIZE));
+    if (ret != -TARGET_ERESTARTSYS) {
+        ts->in_sigsuspend = 1;
+    }
+    return ret;
+}
+
 #ifdef TARGET_NR_sgetmask
 IMPL(sgetmask)
 {
@@ -8960,6 +9009,24 @@ IMPL(sigaction)
 }
 #endif
 
+#ifdef TARGET_NR_sigpending
+IMPL(sigpending)
+{
+    sigset_t set;
+    abi_long ret = get_errno(sigpending(&set));
+    if (!is_error(ret)) {
+        abi_ulong *p;
+        p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0);
+        if (!p) {
+            return -TARGET_EFAULT;
+        }
+        host_to_target_old_sigset(p, &set);
+        unlock_user(p, arg1, sizeof(target_sigset_t));
+    }
+    return ret;
+}
+#endif
+
 #ifdef TARGET_NR_sigprocmask
 IMPL(sigprocmask)
 {
@@ -9032,6 +9099,32 @@ IMPL(sigprocmask)
 }
 #endif
 
+#ifdef TARGET_NR_sigsuspend
+IMPL(sigsuspend)
+{
+    CPUState *cpu = ENV_GET_CPU(cpu_env);
+    TaskState *ts = cpu->opaque;
+    abi_long ret;
+
+# ifdef TARGET_ALPHA
+    abi_ulong mask = arg1;
+    target_to_host_old_sigset(&ts->sigsuspend_mask, &mask);
+# else
+    abi_ulong *p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1);
+    if (!p) {
+        return -TARGET_EFAULT;
+    }
+    target_to_host_old_sigset(&ts->sigsuspend_mask, p);
+    unlock_user(p, arg1, 0);
+# endif
+    ret = get_errno(safe_rt_sigsuspend(&ts->sigsuspend_mask, SIGSET_T_SIZE));
+    if (ret != -TARGET_ERESTARTSYS) {
+        ts->in_sigsuspend = 1;
+    }
+    return ret;
+}
+#endif
+
 #ifdef TARGET_NR_ssetmask
 IMPL(ssetmask)
 {
@@ -9300,81 +9393,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-#ifdef TARGET_NR_sigpending
-    case TARGET_NR_sigpending:
-        {
-            sigset_t set;
-            ret = get_errno(sigpending(&set));
-            if (!is_error(ret)) {
-                if (!(p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0)))
-                    return -TARGET_EFAULT;
-                host_to_target_old_sigset(p, &set);
-                unlock_user(p, arg1, sizeof(target_sigset_t));
-            }
-        }
-        return ret;
-#endif
-    case TARGET_NR_rt_sigpending:
-        {
-            sigset_t set;
-
-            /* Yes, this check is >, not != like most. We follow the kernel's
-             * logic and it does it like this because it implements
-             * NR_sigpending through the same code path, and in that case
-             * the old_sigset_t is smaller in size.
-             */
-            if (arg2 > sizeof(target_sigset_t)) {
-                return -TARGET_EINVAL;
-            }
-
-            ret = get_errno(sigpending(&set));
-            if (!is_error(ret)) {
-                if (!(p = lock_user(VERIFY_WRITE, arg1, sizeof(target_sigset_t), 0)))
-                    return -TARGET_EFAULT;
-                host_to_target_sigset(p, &set);
-                unlock_user(p, arg1, sizeof(target_sigset_t));
-            }
-        }
-        return ret;
-#ifdef TARGET_NR_sigsuspend
-    case TARGET_NR_sigsuspend:
-        {
-            TaskState *ts = cpu->opaque;
-#if defined(TARGET_ALPHA)
-            abi_ulong mask = arg1;
-            target_to_host_old_sigset(&ts->sigsuspend_mask, &mask);
-#else
-            if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))
-                return -TARGET_EFAULT;
-            target_to_host_old_sigset(&ts->sigsuspend_mask, p);
-            unlock_user(p, arg1, 0);
-#endif
-            ret = get_errno(safe_rt_sigsuspend(&ts->sigsuspend_mask,
-                                               SIGSET_T_SIZE));
-            if (ret != -TARGET_ERESTARTSYS) {
-                ts->in_sigsuspend = 1;
-            }
-        }
-        return ret;
-#endif
-    case TARGET_NR_rt_sigsuspend:
-        {
-            TaskState *ts = cpu->opaque;
-
-            if (arg2 != sizeof(target_sigset_t)) {
-                return -TARGET_EINVAL;
-            }
-            if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))
-                return -TARGET_EFAULT;
-            target_to_host_sigset(&ts->sigsuspend_mask, p);
-            unlock_user(p, arg1, 0);
-            ret = get_errno(safe_rt_sigsuspend(&ts->sigsuspend_mask,
-                                               SIGSET_T_SIZE));
-            if (ret != -TARGET_ERESTARTSYS) {
-                ts->in_sigsuspend = 1;
-            }
-        }
-        return ret;
     case TARGET_NR_rt_sigtimedwait:
         {
             sigset_t set;
@@ -13112,7 +13130,9 @@ static impl_fn * const syscall_table[] = {
     [TARGET_NR_rmdir] = impl_rmdir,
 #endif
     [TARGET_NR_rt_sigaction] = impl_rt_sigaction,
+    [TARGET_NR_rt_sigpending] = impl_rt_sigpending,
     [TARGET_NR_rt_sigprocmask] = impl_rt_sigprocmask,
+    [TARGET_NR_rt_sigsuspend] = impl_rt_sigsuspend,
 #ifdef TARGET_NR_sgetmask
     [TARGET_NR_sgetmask] = impl_sgetmask,
 #endif
@@ -13121,9 +13141,15 @@ static impl_fn * const syscall_table[] = {
 #ifdef TARGET_NR_sigaction
     [TARGET_NR_sigaction] = impl_sigaction,
 #endif
+#ifdef TARGET_NR_sigpending
+    [TARGET_NR_sigpending] = impl_sigpending,
+#endif
 #ifdef TARGET_NR_sigprocmask
     [TARGET_NR_sigprocmask] = impl_sigprocmask,
 #endif
+#ifdef TARGET_NR_sigsuspend
+    [TARGET_NR_sigsuspend] = impl_sigsuspend,
+#endif
 #ifdef TARGET_NR_ssetmask
     [TARGET_NR_ssetmask] = impl_ssetmask,
 #endif
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [Qemu-devel] [PATCH 33/33] linux-user: Split out rt_sigqueueinfo, rt_sigtimedwait, rt_tgsigqueueinfo
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (31 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 32/33] linux-user: Split out rt_sigpending, rt_sigsuspend, sigpending, sigsuspend Richard Henderson
@ 2018-06-01  7:30 ` Richard Henderson
  2018-06-01  7:33 ` [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
  2018-06-01  8:05 ` no-reply
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/syscall.c | 129 ++++++++++++++++++++++---------------------
 1 file changed, 67 insertions(+), 62 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index c3bd625965..b9e07c2d3f 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8876,6 +8876,20 @@ IMPL(rt_sigprocmask)
     return ret;
 }
 
+IMPL(rt_sigqueueinfo)
+{
+    siginfo_t uinfo;
+    target_siginfo_t *p;
+
+    p = lock_user(VERIFY_READ, arg3, sizeof(target_siginfo_t), 1);
+    if (!p) {
+        return -TARGET_EFAULT;
+    }
+    target_to_host_siginfo(&uinfo, p);
+    unlock_user(p, arg3, 0);
+    return get_errno(sys_rt_sigqueueinfo(arg1, arg2, &uinfo));
+}
+
 IMPL(rt_sigsuspend)
 {
     CPUState *cpu = ENV_GET_CPU(cpu_env);
@@ -8899,6 +8913,56 @@ IMPL(rt_sigsuspend)
     return ret;
 }
 
+IMPL(rt_sigtimedwait)
+{
+    sigset_t set;
+    struct timespec uts, *puts = NULL;
+    void *p;
+    siginfo_t uinfo;
+    abi_long ret;
+
+    if (arg4 != sizeof(target_sigset_t)) {
+        return -TARGET_EINVAL;
+    }
+    p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1);
+    if (!p) {
+        return -TARGET_EFAULT;
+    }
+    target_to_host_sigset(&set, p);
+    unlock_user(p, arg1, 0);
+    if (arg3) {
+        puts = &uts;
+        target_to_host_timespec(puts, arg3);
+    }
+    ret = get_errno(safe_rt_sigtimedwait(&set, &uinfo, puts, SIGSET_T_SIZE));
+    if (!is_error(ret)) {
+        if (arg2) {
+            p = lock_user(VERIFY_WRITE, arg2, sizeof(target_siginfo_t), 0);
+            if (!p) {
+                return -TARGET_EFAULT;
+            }
+            host_to_target_siginfo(p, &uinfo);
+            unlock_user(p, arg2, sizeof(target_siginfo_t));
+        }
+        ret = host_to_target_signal(ret);
+    }
+    return ret;
+}
+
+IMPL(rt_tgsigqueueinfo)
+{
+    siginfo_t uinfo;
+    target_siginfo_t *p;
+
+    p = lock_user(VERIFY_READ, arg4, sizeof(target_siginfo_t), 1);
+    if (!p) {
+        return -TARGET_EFAULT;
+    }
+    target_to_host_siginfo(&uinfo, p);
+    unlock_user(p, arg4, 0);
+    return get_errno(sys_rt_tgsigqueueinfo(arg1, arg2, arg3, &uinfo));
+}
+
 #ifdef TARGET_NR_sgetmask
 IMPL(sgetmask)
 {
@@ -9393,68 +9457,6 @@ IMPL(everything_else)
     char *fn;
 
     switch(num) {
-    case TARGET_NR_rt_sigtimedwait:
-        {
-            sigset_t set;
-            struct timespec uts, *puts;
-            siginfo_t uinfo;
-
-            if (arg4 != sizeof(target_sigset_t)) {
-                return -TARGET_EINVAL;
-            }
-
-            if (!(p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1)))
-                return -TARGET_EFAULT;
-            target_to_host_sigset(&set, p);
-            unlock_user(p, arg1, 0);
-            if (arg3) {
-                puts = &uts;
-                target_to_host_timespec(puts, arg3);
-            } else {
-                puts = NULL;
-            }
-            ret = get_errno(safe_rt_sigtimedwait(&set, &uinfo, puts,
-                                                 SIGSET_T_SIZE));
-            if (!is_error(ret)) {
-                if (arg2) {
-                    p = lock_user(VERIFY_WRITE, arg2, sizeof(target_siginfo_t),
-                                  0);
-                    if (!p) {
-                        return -TARGET_EFAULT;
-                    }
-                    host_to_target_siginfo(p, &uinfo);
-                    unlock_user(p, arg2, sizeof(target_siginfo_t));
-                }
-                ret = host_to_target_signal(ret);
-            }
-        }
-        return ret;
-    case TARGET_NR_rt_sigqueueinfo:
-        {
-            siginfo_t uinfo;
-
-            p = lock_user(VERIFY_READ, arg3, sizeof(target_siginfo_t), 1);
-            if (!p) {
-                return -TARGET_EFAULT;
-            }
-            target_to_host_siginfo(&uinfo, p);
-            unlock_user(p, arg3, 0);
-            ret = get_errno(sys_rt_sigqueueinfo(arg1, arg2, &uinfo));
-        }
-        return ret;
-    case TARGET_NR_rt_tgsigqueueinfo:
-        {
-            siginfo_t uinfo;
-
-            p = lock_user(VERIFY_READ, arg4, sizeof(target_siginfo_t), 1);
-            if (!p) {
-                return -TARGET_EFAULT;
-            }
-            target_to_host_siginfo(&uinfo, p);
-            unlock_user(p, arg4, 0);
-            ret = get_errno(sys_rt_tgsigqueueinfo(arg1, arg2, arg3, &uinfo));
-        }
-        return ret;
 #ifdef TARGET_NR_sigreturn
     case TARGET_NR_sigreturn:
         if (block_signals()) {
@@ -13132,7 +13134,10 @@ static impl_fn * const syscall_table[] = {
     [TARGET_NR_rt_sigaction] = impl_rt_sigaction,
     [TARGET_NR_rt_sigpending] = impl_rt_sigpending,
     [TARGET_NR_rt_sigprocmask] = impl_rt_sigprocmask,
+    [TARGET_NR_rt_sigqueueinfo] = impl_rt_sigqueueinfo,
     [TARGET_NR_rt_sigsuspend] = impl_rt_sigsuspend,
+    [TARGET_NR_rt_sigtimedwait] = impl_rt_sigtimedwait,
+    [TARGET_NR_rt_tgsigqueueinfo] = impl_rt_tgsigqueueinfo,
 #ifdef TARGET_NR_sgetmask
     [TARGET_NR_sgetmask] = impl_sgetmask,
 #endif
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* Re: [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (32 preceding siblings ...)
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 33/33] linux-user: Split out rt_sigqueueinfo, rt_sigtimedwait, rt_tgsigqueueinfo Richard Henderson
@ 2018-06-01  7:33 ` Richard Henderson
  2018-06-01  8:05 ` no-reply
  34 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01  7:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

On 06/01/2018 12:30 AM, Richard Henderson wrote:
> This function is, as I think everyone will agree, way too large.
> This is about a third of the complete change, but I thought I'd
> get some feedback on the method and form before I go any farther.

Bah.  I also meant to say

Based-on: 20180531224911.23725-1-richard.henderson@linaro.org

that is, the interp_prefix patch set from earlier today.


r~

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [Qemu-devel] [PATCH 01/33] linux-user: Split out do_syscall1
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 01/33] linux-user: Split out do_syscall1 Richard Henderson
@ 2018-06-01  7:36   ` Laurent Vivier
  2018-06-01 14:00   ` Eric Blake
  1 sibling, 0 replies; 49+ messages in thread
From: Laurent Vivier @ 2018-06-01  7:36 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel

Le 01/06/2018 à 09:30, Richard Henderson a écrit :
> There was supposed to be a single point of return for do_syscall
> so that tracing works properly.  However, there are a few bugs
> in that area.  It is significantly simpler to simply split out
> an inner function to enforce this.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  linux-user/syscall.c | 89 +++++++++++++++++++++++++++-----------------
>  1 file changed, 54 insertions(+), 35 deletions(-)

Reviewed-by: Laurent Vivier <laurent@vivier.eu>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall
  2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
                   ` (33 preceding siblings ...)
  2018-06-01  7:33 ` [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
@ 2018-06-01  8:05 ` no-reply
  34 siblings, 0 replies; 49+ messages in thread
From: no-reply @ 2018-06-01  8:05 UTC (permalink / raw)
  To: richard.henderson; +Cc: famz, qemu-devel, laurent

Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20180601073050.8054-1-richard.henderson@linaro.org
Subject: [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]               patchew/20180601073050.8054-1-richard.henderson@linaro.org -> patchew/20180601073050.8054-1-richard.henderson@linaro.org
Switched to a new branch 'test'
747f98cda4 linux-user: Split out rt_sigqueueinfo, rt_sigtimedwait, rt_tgsigqueueinfo
8c59503fd9 linux-user: Split out rt_sigpending, rt_sigsuspend, sigpending, sigsuspend
3a57cc334f linux-user: Split out rt_sigprocmask, sgetmask, sigprocmask, ssetmask
81bd8e94dd linux-user: Split out rt_sigaction, sigaction
0fc1031ca6 linux-user: Split out getpgrp, getppid, setsid
76b6ab61e4 linux-user: Split out chroot, dup2, dup3, fcntl, setpgid, umask
818843d921 linux-user: Split out ioctl
d3a9fa76f4 linux-user: Split out acct, pipe, pipe2, times, umount2
73775770a5 linux-user: Split out dup, mkdir, mkdirat, rmdir
8d6ff832d7 linux-user: Split out rename, renameat, renameat2
ded97414bf linux-user: Split out access, faccessat, futimesat, kill, nice, sync, syncfs
f2ac2715a0 linux-user: Split out alarm, pause, stime, utime, utimes
fd239f018f linux-user: Split out mount, umount
7f8d08b0df linux-user: Split out getpid, getxpid, lseek
0033fce107 linux-user: Remove all unimplemented entries
1d093d6966 linux-user: Split out chdir, mknod, mknodat, time, chmod
d0bc8c69af linux-user: Split out unlink, unlinkat
ee1804088c linux-user: Split out link, linkat
7da1a7d2ec linux-user: Split out creat, fork, waitid, waitpid
6c9db8aee2 linux-user: Split out open_to_handle_at
8e8c59cd27 linux-user: Split out name_to_handle_at
4ed7c56516 linux-user: Split out open, openat
dbf85fddf7 linux-user: Split out execve
d4654a6ef7 linux-user: Split out brk, close, exit, read, write
404318016d linux-user: Set up infrastructure for table-izing syscalls
a7b3ac0407 linux-user: Make syscall number unsigned
6086f3339b linux-user: Propagate goto fail to return
1969ae08d3 linux-user: Split out goto unimplemented to do_unimplemented
f3213e38ff linux-user: Propagate goto unimplemented_nowarn to return
4e20509f56 linux-user: Propagate goto efault to return
dda83e01f8 linux-user: Propagate goto ebadf to return
fddfe2eb57 linux-user: Relax single exit from "break"
bac309b293 linux-user: Split out do_syscall1

=== OUTPUT BEGIN ===
Checking PATCH 1/33: linux-user: Split out do_syscall1...
Checking PATCH 2/33: linux-user: Relax single exit from "break"...
ERROR: code indent should never use tabs
#1929: FILE: linux-user/syscall.c:11150:
+^Ireturn ret;$

ERROR: code indent should never use tabs
#1938: FILE: linux-user/syscall.c:11159:
+^Ireturn ret;$

ERROR: code indent should never use tabs
#1947: FILE: linux-user/syscall.c:11166:
+^Ireturn target_ftruncate64(cpu_env, arg1, arg2, arg3, arg4);$

ERROR: code indent should never use tabs
#2411: FILE: linux-user/syscall.c:11862:
+^Ireturn ret;$

ERROR: code indent should never use tabs
#2683: FILE: linux-user/syscall.c:12216:
+^Ireturn ret;$

total: 5 errors, 0 warnings, 2853 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

Checking PATCH 3/33: linux-user: Propagate goto ebadf to return...
Checking PATCH 4/33: linux-user: Propagate goto efault to return...
ERROR: suspect code indent for conditional statements (11, 14)
#642: FILE: linux-user/syscall.c:9553:
            if (!p) {
+              return -TARGET_EFAULT;

total: 1 errors, 0 warnings, 1211 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

Checking PATCH 5/33: linux-user: Propagate goto unimplemented_nowarn to return...
Checking PATCH 6/33: linux-user: Split out goto unimplemented to do_unimplemented...
Checking PATCH 7/33: linux-user: Propagate goto fail to return...
Checking PATCH 8/33: linux-user: Make syscall number unsigned...
Checking PATCH 9/33: linux-user: Set up infrastructure for table-izing syscalls...
Checking PATCH 10/33: linux-user: Split out brk, close, exit, read, write...
Checking PATCH 11/33: linux-user: Split out execve...
Checking PATCH 12/33: linux-user: Split out open, openat...
Checking PATCH 13/33: linux-user: Split out name_to_handle_at...
Checking PATCH 14/33: linux-user: Split out open_to_handle_at...
Checking PATCH 15/33: linux-user: Split out creat, fork, waitid, waitpid...
Checking PATCH 16/33: linux-user: Split out link, linkat...
Checking PATCH 17/33: linux-user: Split out unlink, unlinkat...
Checking PATCH 18/33: linux-user: Split out chdir, mknod, mknodat, time, chmod...
Checking PATCH 19/33: linux-user: Remove all unimplemented entries...
Checking PATCH 20/33: linux-user: Split out getpid, getxpid, lseek...
Checking PATCH 21/33: linux-user: Split out mount, umount...
Checking PATCH 22/33: linux-user: Split out alarm, pause, stime, utime, utimes...
Checking PATCH 23/33: linux-user: Split out access, faccessat, futimesat, kill, nice, sync, syncfs...
Checking PATCH 24/33: linux-user: Split out rename, renameat, renameat2...
Checking PATCH 25/33: linux-user: Split out dup, mkdir, mkdirat, rmdir...
Checking PATCH 26/33: linux-user: Split out acct, pipe, pipe2, times, umount2...
Checking PATCH 27/33: linux-user: Split out ioctl...
Checking PATCH 28/33: linux-user: Split out chroot, dup2, dup3, fcntl, setpgid, umask...
Checking PATCH 29/33: linux-user: Split out getpgrp, getppid, setsid...
Checking PATCH 30/33: linux-user: Split out rt_sigaction, sigaction...
ERROR: code indent should never use tabs
#134: FILE: linux-user/syscall.c:8852:
+^Iact._sa_handler = old_act->_sa_handler;$

ERROR: code indent should never use tabs
#135: FILE: linux-user/syscall.c:8853:
+^Itarget_siginitset(&act.sa_mask, old_act->sa_mask.sig[0]);$

ERROR: code indent should never use tabs
#136: FILE: linux-user/syscall.c:8854:
+^Iact.sa_flags = old_act->sa_flags;$

ERROR: code indent should never use tabs
#137: FILE: linux-user/syscall.c:8855:
+^Iunlock_user_struct(old_act, arg2, 0);$

ERROR: code indent should never use tabs
#138: FILE: linux-user/syscall.c:8856:
+^Ipact = &act;$

ERROR: code indent should never use tabs
#145: FILE: linux-user/syscall.c:8863:
+^Iold_act->_sa_handler = oact._sa_handler;$

ERROR: code indent should never use tabs
#146: FILE: linux-user/syscall.c:8864:
+^Iold_act->sa_flags = oact.sa_flags;$

ERROR: code indent should never use tabs
#147: FILE: linux-user/syscall.c:8865:
+^Iold_act->sa_mask.sig[0] = oact.sa_mask.sig[0];$

ERROR: code indent should never use tabs
#148: FILE: linux-user/syscall.c:8866:
+^Iold_act->sa_mask.sig[1] = 0;$

ERROR: code indent should never use tabs
#149: FILE: linux-user/syscall.c:8867:
+^Iold_act->sa_mask.sig[2] = 0;$

ERROR: code indent should never use tabs
#150: FILE: linux-user/syscall.c:8868:
+^Iold_act->sa_mask.sig[3] = 0;$

ERROR: code indent should never use tabs
#151: FILE: linux-user/syscall.c:8869:
+^Iunlock_user_struct(old_act, arg3, 1);$

total: 12 errors, 0 warnings, 351 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

Checking PATCH 31/33: linux-user: Split out rt_sigprocmask, sgetmask, sigprocmask, ssetmask...
Checking PATCH 32/33: linux-user: Split out rt_sigpending, rt_sigsuspend, sigpending, sigsuspend...
Checking PATCH 33/33: linux-user: Split out rt_sigqueueinfo, rt_sigtimedwait, rt_tgsigqueueinfo...
=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [Qemu-devel] [PATCH 01/33] linux-user: Split out do_syscall1
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 01/33] linux-user: Split out do_syscall1 Richard Henderson
  2018-06-01  7:36   ` Laurent Vivier
@ 2018-06-01 14:00   ` Eric Blake
  2018-06-01 14:52     ` Richard Henderson
  1 sibling, 1 reply; 49+ messages in thread
From: Eric Blake @ 2018-06-01 14:00 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel; +Cc: laurent

On 06/01/2018 02:30 AM, Richard Henderson wrote:
> There was supposed to be a single point of return for do_syscall
> so that tracing works properly.  However, there are a few bugs
> in that area.  It is significantly simpler to simply split out
> an inner function to enforce this.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   linux-user/syscall.c | 89 +++++++++++++++++++++++++++-----------------
>   1 file changed, 54 insertions(+), 35 deletions(-)
> 

> @@ -7977,28 +7979,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
>       void *p;
>       char *fn;
>   
> -#if defined(DEBUG_ERESTARTSYS)

> +abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
> +                    abi_long arg2, abi_long arg3, abi_long arg4,
> +                    abi_long arg5, abi_long arg6, abi_long arg7,
> +                    abi_long arg8)
> +{
> +    CPUState *cpu = ENV_GET_CPU(cpu_env);
> +    abi_long ret;
> +
> +#if defined(DEBUG_ERESTARTSYS)

Code motion, but...

> +    /* Debug-only code for exercising the syscall-restart code paths
> +     * in the per-architecture cpu main loops: restart every syscall
> +     * the guest makes once before letting it through.
> +     */
> +    {
> +        static bool flag;
> +        flag = !flag;
> +        if (flag) {
> +            return -TARGET_ERESTARTSYS;
> +        }
> +    }
> +#endif
> +#ifdef DEBUG

...it looks inconsistent to mix '#if defined()' with '#ifdef' in the 
same function.  Worth cleaning up while you do this refactoring?

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [Qemu-devel] [PATCH 01/33] linux-user: Split out do_syscall1
  2018-06-01 14:00   ` Eric Blake
@ 2018-06-01 14:52     ` Richard Henderson
  0 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-01 14:52 UTC (permalink / raw)
  To: Eric Blake, qemu-devel; +Cc: laurent

On 06/01/2018 07:00 AM, Eric Blake wrote:
> On 06/01/2018 02:30 AM, Richard Henderson wrote:
>> There was supposed to be a single point of return for do_syscall
>> so that tracing works properly.  However, there are a few bugs
>> in that area.  It is significantly simpler to simply split out
>> an inner function to enforce this.
>>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>   linux-user/syscall.c | 89 +++++++++++++++++++++++++++-----------------
>>   1 file changed, 54 insertions(+), 35 deletions(-)
>>
> 
>> @@ -7977,28 +7979,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long
>> arg1,
>>       void *p;
>>       char *fn;
>>   -#if defined(DEBUG_ERESTARTSYS)
> 
>> +abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
>> +                    abi_long arg2, abi_long arg3, abi_long arg4,
>> +                    abi_long arg5, abi_long arg6, abi_long arg7,
>> +                    abi_long arg8)
>> +{
>> +    CPUState *cpu = ENV_GET_CPU(cpu_env);
>> +    abi_long ret;
>> +
>> +#if defined(DEBUG_ERESTARTSYS)
> 
> Code motion, but...
> 
>> +    /* Debug-only code for exercising the syscall-restart code paths
>> +     * in the per-architecture cpu main loops: restart every syscall
>> +     * the guest makes once before letting it through.
>> +     */
>> +    {
>> +        static bool flag;
>> +        flag = !flag;
>> +        if (flag) {
>> +            return -TARGET_ERESTARTSYS;
>> +        }
>> +    }
>> +#endif
>> +#ifdef DEBUG
> 
> ...it looks inconsistent to mix '#if defined()' with '#ifdef' in the same
> function.  Worth cleaning up while you do this refactoring?

Yes, I've been trying to remember to fix this as I go, but obviously missed some.


r~
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [Qemu-devel] [PATCH 02/33] linux-user: Relax single exit from "break"
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 02/33] linux-user: Relax single exit from "break" Richard Henderson
@ 2018-06-04 19:29   ` Laurent Vivier
  0 siblings, 0 replies; 49+ messages in thread
From: Laurent Vivier @ 2018-06-04 19:29 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel

Le 01/06/2018 à 09:30, Richard Henderson a écrit :
> Transform outermost "break" to "return ret".  If the immediately
> preceeding statement was an assignment to ret, return the value
> directly.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  linux-user/syscall.c | 969 +++++++++++++++++--------------------------
>  1 file changed, 390 insertions(+), 579 deletions(-)

Reviewed-by: Laurent Vivier <laurent@vivier.eu>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [Qemu-devel] [PATCH 03/33] linux-user: Propagate goto ebadf to return
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 03/33] linux-user: Propagate goto ebadf to return Richard Henderson
@ 2018-06-04 19:33   ` Laurent Vivier
  0 siblings, 0 replies; 49+ messages in thread
From: Laurent Vivier @ 2018-06-04 19:33 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel

Le 01/06/2018 à 09:30, Richard Henderson a écrit :
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  linux-user/syscall.c | 187 +++++++++++++++++++++----------------------
>  1 file changed, 92 insertions(+), 95 deletions(-)
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [Qemu-devel] [PATCH 04/33] linux-user: Propagate goto efault to return
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 04/33] linux-user: Propagate goto efault " Richard Henderson
@ 2018-06-04 19:35   ` Laurent Vivier
  0 siblings, 0 replies; 49+ messages in thread
From: Laurent Vivier @ 2018-06-04 19:35 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel

Le 01/06/2018 à 09:30, Richard Henderson a écrit :
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  linux-user/syscall.c | 311 +++++++++++++++++++++----------------------
>  1 file changed, 154 insertions(+), 157 deletions(-)
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [Qemu-devel] [PATCH 05/33] linux-user: Propagate goto unimplemented_nowarn to return
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 05/33] linux-user: Propagate goto unimplemented_nowarn " Richard Henderson
@ 2018-06-04 19:36   ` Laurent Vivier
  0 siblings, 0 replies; 49+ messages in thread
From: Laurent Vivier @ 2018-06-04 19:36 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel

Le 01/06/2018 à 09:30, Richard Henderson a écrit :
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  linux-user/syscall.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [Qemu-devel] [PATCH 06/33] linux-user: Split out goto unimplemented to do_unimplemented
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 06/33] linux-user: Split out goto unimplemented to do_unimplemented Richard Henderson
@ 2018-06-04 19:38   ` Laurent Vivier
  0 siblings, 0 replies; 49+ messages in thread
From: Laurent Vivier @ 2018-06-04 19:38 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel

Le 01/06/2018 à 09:30, Richard Henderson a écrit :
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  linux-user/syscall.c | 82 +++++++++++++++++++++++---------------------
>  1 file changed, 43 insertions(+), 39 deletions(-)
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [Qemu-devel] [PATCH 07/33] linux-user: Propagate goto fail to return
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 07/33] linux-user: Propagate goto fail to return Richard Henderson
@ 2018-06-04 19:48   ` Laurent Vivier
  0 siblings, 0 replies; 49+ messages in thread
From: Laurent Vivier @ 2018-06-04 19:48 UTC (permalink / raw)
  To: Richard Henderson, QEMU Developers

Le 01/06/2018 à 09:30, Richard Henderson a écrit :
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  linux-user/syscall.c | 62 ++++++++++++++++----------------------------
>  1 file changed, 23 insertions(+), 39 deletions(-)
> 

> @@ -9951,18 +9947,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
>              case TARGET_SYSLOG_ACTION_READ_CLEAR:    /* Read/clear msgs */
>              case TARGET_SYSLOG_ACTION_READ_ALL:      /* Read last messages */
>                  {
> -                    ret = -TARGET_EINVAL;
>                      if (len < 0) {
> -                        goto fail;
> +                        return -TARGET_EINVAL;
>                      }
> -                    ret = 0;
>                      if (len == 0) {
> -                        return ret;
> +                        return 0;

I think you should do this change in '[PATCH 02/33] linux-user: Relax
single exit from "break"'

Reviewed-by: Laurent Vivier <laurent@vivier.eu>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [Qemu-devel] [PATCH 08/33] linux-user: Make syscall number unsigned
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 08/33] linux-user: Make syscall number unsigned Richard Henderson
@ 2018-06-04 19:50   ` Laurent Vivier
  0 siblings, 0 replies; 49+ messages in thread
From: Laurent Vivier @ 2018-06-04 19:50 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel

Le 01/06/2018 à 09:30, Richard Henderson a écrit :
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  linux-user/qemu.h    |  2 +-
>  linux-user/syscall.c | 20 ++++++++++----------
>  2 files changed, 11 insertions(+), 11 deletions(-)
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [Qemu-devel] [PATCH 09/33] linux-user: Set up infrastructure for table-izing syscalls
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 09/33] linux-user: Set up infrastructure for table-izing syscalls Richard Henderson
@ 2018-06-04 19:55   ` Laurent Vivier
  0 siblings, 0 replies; 49+ messages in thread
From: Laurent Vivier @ 2018-06-04 19:55 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel

Le 01/06/2018 à 09:30, Richard Henderson a écrit :
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  linux-user/syscall.c | 42 ++++++++++++++++++++++++++++++++++--------
>  1 file changed, 34 insertions(+), 8 deletions(-)
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [Qemu-devel] [PATCH 10/33] linux-user: Split out brk, close, exit, read, write
  2018-06-01  7:30 ` [Qemu-devel] [PATCH 10/33] linux-user: Split out brk, close, exit, read, write Richard Henderson
@ 2018-06-04 20:17   ` Laurent Vivier
  2018-06-04 21:01     ` Richard Henderson
  0 siblings, 1 reply; 49+ messages in thread
From: Laurent Vivier @ 2018-06-04 20:17 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel

Le 01/06/2018 à 09:30, Richard Henderson a écrit :
> These are relatively simple unconditionally defined syscalls.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  linux-user/syscall.c | 198 ++++++++++++++++++++++++-------------------
>  1 file changed, 111 insertions(+), 87 deletions(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index fc3dc3f40d..b0d268dab7 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -7984,6 +7984,112 @@ IMPL(enosys)
>      return do_unimplemented(num);
>  }
>  
> +IMPL(brk)
> +{
> +    return do_brk(arg1);
> +}
> +
> +IMPL(close)
> +{
> +    if (is_hostfd(arg1)) {
> +        return -TARGET_EBADF;
> +    }
> +    fd_trans_unregister(arg1);
> +    return get_errno(close(arg1));
> +}
> +
> +IMPL(exit)
> +{
> +    CPUState *cpu = ENV_GET_CPU(cpu_env);
> +
> +    /* In old applications this may be used to implement _exit(2).
> +       However in threaded applictions it is used for thread termination,
> +       and _exit_group is used for application termination.
> +       Do thread termination if we have more then one thread.  */
> +    if (block_signals()) {
> +        return -TARGET_ERESTARTSYS;
> +    }
> +
> +    cpu_list_lock();
> +
> +    if (CPU_NEXT(first_cpu)) {
> +        /* Remove the CPU from the list.  */
> +        QTAILQ_REMOVE(&cpus, cpu, node);
> +        cpu_list_unlock();
> +
> +        TaskState *ts = cpu->opaque;
> +        if (ts->child_tidptr) {
> +            put_user_u32(0, ts->child_tidptr);
> +            sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX,
> +                      NULL, NULL, 0);
> +        }
> +        thread_cpu = NULL;
> +        object_unref(OBJECT(cpu));
> +        g_free(ts);
> +        rcu_unregister_thread();
> +        pthread_exit(NULL);
> +    } else {
> +        cpu_list_unlock();
> +
> +#ifdef TARGET_GPROF
> +        _mcleanup();
> +#endif
> +        gdb_exit(cpu_env, arg1);
> +        _exit(arg1);
> +    }
> +    g_assert_not_reached();
> +}
> +
> +IMPL(read)
> +{
> +    abi_long ret;
> +    char *fn;
> +
> +    if (arg3 == 0) {
> +        return 0;
> +    }
> +    if (is_hostfd(arg1)) {
> +        return -TARGET_EBADF;
> +    }
> +    fn = lock_user(VERIFY_WRITE, arg2, arg3, 0);
> +    if (!fn) {
> +        return -TARGET_EFAULT;
> +    }
> +    ret = get_errno(safe_read(arg1, fn, arg3));
> +    if (ret >= 0 && fd_trans_host_to_target_data(arg1)) {
> +        ret = fd_trans_host_to_target_data(arg1)(fn, ret);
> +    }
> +    unlock_user(fn, arg2, ret);
> +    return ret;
> +}
> +
> +IMPL(write)
> +{
> +    abi_long ret;
> +    char *fn;
> +
> +    if (is_hostfd(arg1)) {
> +        return -TARGET_EBADF;
> +    }
> +    fn = lock_user(VERIFY_READ, arg2, arg3, 1);
> +    if (!fn) {
> +        return -TARGET_EFAULT;
> +    }
> +    if (fd_trans_target_to_host_data(arg1)) {
> +        void *copy = g_malloc(arg3);
> +        memcpy(copy, fn, arg3);
> +        ret = fd_trans_target_to_host_data(arg1)(copy, arg3);
> +        if (ret >= 0) {
> +            ret = get_errno(safe_write(arg1, copy, ret));
> +        }
> +        g_free(copy);
> +    } else {
> +        ret = get_errno(safe_write(arg1, fn, arg3));
> +    }
> +    unlock_user(fn, arg2, ret);
> +    return ret;
> +}
> +
>  /* This is an internal helper for do_syscall so that it is easier
>   * to have a single return point, so that actions, such as logging
>   * of syscall results, can be performed.
> @@ -7999,83 +8105,6 @@ IMPL(everything_else)
>      char *fn;
>  
>      switch(num) {
> -    case TARGET_NR_exit:
> -        /* In old applications this may be used to implement _exit(2).
> -           However in threaded applictions it is used for thread termination,
> -           and _exit_group is used for application termination.
> -           Do thread termination if we have more then one thread.  */
> -
> -        if (block_signals()) {
> -            return -TARGET_ERESTARTSYS;
> -        }
> -
> -        cpu_list_lock();
> -
> -        if (CPU_NEXT(first_cpu)) {
> -            TaskState *ts;
> -
> -            /* Remove the CPU from the list.  */
> -            QTAILQ_REMOVE(&cpus, cpu, node);
> -
> -            cpu_list_unlock();
> -
> -            ts = cpu->opaque;
> -            if (ts->child_tidptr) {
> -                put_user_u32(0, ts->child_tidptr);
> -                sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX,
> -                          NULL, NULL, 0);
> -            }
> -            thread_cpu = NULL;
> -            object_unref(OBJECT(cpu));
> -            g_free(ts);
> -            rcu_unregister_thread();
> -            pthread_exit(NULL);
> -        }
> -
> -        cpu_list_unlock();
> -#ifdef TARGET_GPROF
> -        _mcleanup();
> -#endif
> -        gdb_exit(cpu_env, arg1);
> -        _exit(arg1);
> -        return 0; /* avoid warning */
> -    case TARGET_NR_read:
> -        if (arg3 == 0) {
> -            return 0;
> -        } else {
> -            if (is_hostfd(arg1)) {
> -                return -TARGET_EBADF;
> -            }
> -            if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
> -                return -TARGET_EFAULT;
> -            ret = get_errno(safe_read(arg1, p, arg3));
> -            if (ret >= 0 &&
> -                fd_trans_host_to_target_data(arg1)) {
> -                ret = fd_trans_host_to_target_data(arg1)(p, ret);
> -            }
> -            unlock_user(p, arg2, ret);
> -        }
> -        return ret;
> -    case TARGET_NR_write:
> -        if (is_hostfd(arg1)) {
> -            return -TARGET_EBADF;
> -        }
> -        if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
> -            return -TARGET_EFAULT;
> -        if (fd_trans_target_to_host_data(arg1)) {
> -            void *copy = g_malloc(arg3);
> -            memcpy(copy, p, arg3);
> -            ret = fd_trans_target_to_host_data(arg1)(copy, arg3);
> -            if (ret >= 0) {
> -                ret = get_errno(safe_write(arg1, copy, ret));
> -            }
> -            g_free(copy);
> -        } else {
> -            ret = get_errno(safe_write(arg1, p, arg3));
> -        }
> -        unlock_user(p, arg2, 0);
> -        return ret;
> -
>  #ifdef TARGET_NR_open
>      case TARGET_NR_open:
>          if (!(p = lock_user_string(arg1)))
> @@ -8116,15 +8145,6 @@ IMPL(everything_else)
>          fd_trans_unregister(ret);
>          return ret;
>  #endif
> -    case TARGET_NR_close:
> -        if (is_hostfd(arg1)) {
> -            return -TARGET_EBADF;
> -        }
> -        fd_trans_unregister(arg1);
> -        return get_errno(close(arg1));
> -
> -    case TARGET_NR_brk:
> -        return do_brk(arg1);
>  #ifdef TARGET_NR_fork
>      case TARGET_NR_fork:
>          return get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0));
> @@ -12894,7 +12914,11 @@ IMPL(everything_else)
>  }
>  
>  static impl_fn * const syscall_table[] = {
> -    impl_everything_else,
> +    [TARGET_NR_brk] = impl_brk,
> +    [TARGET_NR_close] = impl_close,
> +    [TARGET_NR_exit] = impl_exit,
> +    [TARGET_NR_read] = impl_read,
> +    [TARGET_NR_write] = impl_write,
>  };
>  
>  abi_long do_syscall(void *cpu_env, unsigned num, abi_long arg1,
> 

Starting with this patch, this is broken...

For instance with ppc64le target:

qemu: Unsupported syscall: 33
qemu: Unsupported syscall: 33
qemu: Unsupported syscall: 5
qemu: Unsupported syscall: 5
qemu: Unsupported syscall: 5
qemu: Unsupported syscall: 5
qemu: Unsupported syscall: 5
qemu: Unsupported syscall: 5
qemu: Unsupported syscall: 5
qemu: Unsupported syscall: 5
qemu: Unsupported syscall: 5
/bin/uname: error while loading shared libraries: libc.so.6: cannot open
shared object file: Error 38

for instance, for num = TARGET_NR_OPEN:

+    impl_fn *fn = impl_everything_else;

-> fn = impl_everything_else

+    if (num < ARRAY_SIZE(syscall_table)) {
+        fn = syscall_table[num];

-> fn = NULL

+    }
+    if (fn == NULL) {
+        fn = impl_enosys;

-> fn = impl_enosys;

+    }

So all undefined syscall numbers < max(defined syscall numbers) will
call impl_enosys.

You should do

    fn = NULL;
    if (num < ARRAY_SIZE(syscall_table)) {
        fn = syscall_table[num];
    }
    if (fn == NULL) {
        fn = impl_eveything_else;
    }

and the impl_enosys is managed by impl_eveything_else.

You can come back to your initial code when all syscalls are split out
(when you remove the enosys case from everything_else)... otherwise we
will not be able to bisect this part in the future.

Thanks,
Laurent

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [Qemu-devel] [PATCH 10/33] linux-user: Split out brk, close, exit, read, write
  2018-06-04 20:17   ` Laurent Vivier
@ 2018-06-04 21:01     ` Richard Henderson
  0 siblings, 0 replies; 49+ messages in thread
From: Richard Henderson @ 2018-06-04 21:01 UTC (permalink / raw)
  To: Laurent Vivier, qemu-devel

On 06/04/2018 01:17 PM, Laurent Vivier wrote:
> Le 01/06/2018 à 09:30, Richard Henderson a écrit :
>> These are relatively simple unconditionally defined syscalls.
>>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>  linux-user/syscall.c | 198 ++++++++++++++++++++++++-------------------
>>  1 file changed, 111 insertions(+), 87 deletions(-)
>>
>> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
>> index fc3dc3f40d..b0d268dab7 100644
>> --- a/linux-user/syscall.c
>> +++ b/linux-user/syscall.c
>> @@ -7984,6 +7984,112 @@ IMPL(enosys)
>>      return do_unimplemented(num);
>>  }
>>  
>> +IMPL(brk)
>> +{
>> +    return do_brk(arg1);
>> +}
>> +
>> +IMPL(close)
>> +{
>> +    if (is_hostfd(arg1)) {
>> +        return -TARGET_EBADF;
>> +    }
>> +    fd_trans_unregister(arg1);
>> +    return get_errno(close(arg1));
>> +}
>> +
>> +IMPL(exit)
>> +{
>> +    CPUState *cpu = ENV_GET_CPU(cpu_env);
>> +
>> +    /* In old applications this may be used to implement _exit(2).
>> +       However in threaded applictions it is used for thread termination,
>> +       and _exit_group is used for application termination.
>> +       Do thread termination if we have more then one thread.  */
>> +    if (block_signals()) {
>> +        return -TARGET_ERESTARTSYS;
>> +    }
>> +
>> +    cpu_list_lock();
>> +
>> +    if (CPU_NEXT(first_cpu)) {
>> +        /* Remove the CPU from the list.  */
>> +        QTAILQ_REMOVE(&cpus, cpu, node);
>> +        cpu_list_unlock();
>> +
>> +        TaskState *ts = cpu->opaque;
>> +        if (ts->child_tidptr) {
>> +            put_user_u32(0, ts->child_tidptr);
>> +            sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX,
>> +                      NULL, NULL, 0);
>> +        }
>> +        thread_cpu = NULL;
>> +        object_unref(OBJECT(cpu));
>> +        g_free(ts);
>> +        rcu_unregister_thread();
>> +        pthread_exit(NULL);
>> +    } else {
>> +        cpu_list_unlock();
>> +
>> +#ifdef TARGET_GPROF
>> +        _mcleanup();
>> +#endif
>> +        gdb_exit(cpu_env, arg1);
>> +        _exit(arg1);
>> +    }
>> +    g_assert_not_reached();
>> +}
>> +
>> +IMPL(read)
>> +{
>> +    abi_long ret;
>> +    char *fn;
>> +
>> +    if (arg3 == 0) {
>> +        return 0;
>> +    }
>> +    if (is_hostfd(arg1)) {
>> +        return -TARGET_EBADF;
>> +    }
>> +    fn = lock_user(VERIFY_WRITE, arg2, arg3, 0);
>> +    if (!fn) {
>> +        return -TARGET_EFAULT;
>> +    }
>> +    ret = get_errno(safe_read(arg1, fn, arg3));
>> +    if (ret >= 0 && fd_trans_host_to_target_data(arg1)) {
>> +        ret = fd_trans_host_to_target_data(arg1)(fn, ret);
>> +    }
>> +    unlock_user(fn, arg2, ret);
>> +    return ret;
>> +}
>> +
>> +IMPL(write)
>> +{
>> +    abi_long ret;
>> +    char *fn;
>> +
>> +    if (is_hostfd(arg1)) {
>> +        return -TARGET_EBADF;
>> +    }
>> +    fn = lock_user(VERIFY_READ, arg2, arg3, 1);
>> +    if (!fn) {
>> +        return -TARGET_EFAULT;
>> +    }
>> +    if (fd_trans_target_to_host_data(arg1)) {
>> +        void *copy = g_malloc(arg3);
>> +        memcpy(copy, fn, arg3);
>> +        ret = fd_trans_target_to_host_data(arg1)(copy, arg3);
>> +        if (ret >= 0) {
>> +            ret = get_errno(safe_write(arg1, copy, ret));
>> +        }
>> +        g_free(copy);
>> +    } else {
>> +        ret = get_errno(safe_write(arg1, fn, arg3));
>> +    }
>> +    unlock_user(fn, arg2, ret);
>> +    return ret;
>> +}
>> +
>>  /* This is an internal helper for do_syscall so that it is easier
>>   * to have a single return point, so that actions, such as logging
>>   * of syscall results, can be performed.
>> @@ -7999,83 +8105,6 @@ IMPL(everything_else)
>>      char *fn;
>>  
>>      switch(num) {
>> -    case TARGET_NR_exit:
>> -        /* In old applications this may be used to implement _exit(2).
>> -           However in threaded applictions it is used for thread termination,
>> -           and _exit_group is used for application termination.
>> -           Do thread termination if we have more then one thread.  */
>> -
>> -        if (block_signals()) {
>> -            return -TARGET_ERESTARTSYS;
>> -        }
>> -
>> -        cpu_list_lock();
>> -
>> -        if (CPU_NEXT(first_cpu)) {
>> -            TaskState *ts;
>> -
>> -            /* Remove the CPU from the list.  */
>> -            QTAILQ_REMOVE(&cpus, cpu, node);
>> -
>> -            cpu_list_unlock();
>> -
>> -            ts = cpu->opaque;
>> -            if (ts->child_tidptr) {
>> -                put_user_u32(0, ts->child_tidptr);
>> -                sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX,
>> -                          NULL, NULL, 0);
>> -            }
>> -            thread_cpu = NULL;
>> -            object_unref(OBJECT(cpu));
>> -            g_free(ts);
>> -            rcu_unregister_thread();
>> -            pthread_exit(NULL);
>> -        }
>> -
>> -        cpu_list_unlock();
>> -#ifdef TARGET_GPROF
>> -        _mcleanup();
>> -#endif
>> -        gdb_exit(cpu_env, arg1);
>> -        _exit(arg1);
>> -        return 0; /* avoid warning */
>> -    case TARGET_NR_read:
>> -        if (arg3 == 0) {
>> -            return 0;
>> -        } else {
>> -            if (is_hostfd(arg1)) {
>> -                return -TARGET_EBADF;
>> -            }
>> -            if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
>> -                return -TARGET_EFAULT;
>> -            ret = get_errno(safe_read(arg1, p, arg3));
>> -            if (ret >= 0 &&
>> -                fd_trans_host_to_target_data(arg1)) {
>> -                ret = fd_trans_host_to_target_data(arg1)(p, ret);
>> -            }
>> -            unlock_user(p, arg2, ret);
>> -        }
>> -        return ret;
>> -    case TARGET_NR_write:
>> -        if (is_hostfd(arg1)) {
>> -            return -TARGET_EBADF;
>> -        }
>> -        if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
>> -            return -TARGET_EFAULT;
>> -        if (fd_trans_target_to_host_data(arg1)) {
>> -            void *copy = g_malloc(arg3);
>> -            memcpy(copy, p, arg3);
>> -            ret = fd_trans_target_to_host_data(arg1)(copy, arg3);
>> -            if (ret >= 0) {
>> -                ret = get_errno(safe_write(arg1, copy, ret));
>> -            }
>> -            g_free(copy);
>> -        } else {
>> -            ret = get_errno(safe_write(arg1, p, arg3));
>> -        }
>> -        unlock_user(p, arg2, 0);
>> -        return ret;
>> -
>>  #ifdef TARGET_NR_open
>>      case TARGET_NR_open:
>>          if (!(p = lock_user_string(arg1)))
>> @@ -8116,15 +8145,6 @@ IMPL(everything_else)
>>          fd_trans_unregister(ret);
>>          return ret;
>>  #endif
>> -    case TARGET_NR_close:
>> -        if (is_hostfd(arg1)) {
>> -            return -TARGET_EBADF;
>> -        }
>> -        fd_trans_unregister(arg1);
>> -        return get_errno(close(arg1));
>> -
>> -    case TARGET_NR_brk:
>> -        return do_brk(arg1);
>>  #ifdef TARGET_NR_fork
>>      case TARGET_NR_fork:
>>          return get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0));
>> @@ -12894,7 +12914,11 @@ IMPL(everything_else)
>>  }
>>  
>>  static impl_fn * const syscall_table[] = {
>> -    impl_everything_else,
>> +    [TARGET_NR_brk] = impl_brk,
>> +    [TARGET_NR_close] = impl_close,
>> +    [TARGET_NR_exit] = impl_exit,
>> +    [TARGET_NR_read] = impl_read,
>> +    [TARGET_NR_write] = impl_write,
>>  };
>>  
>>  abi_long do_syscall(void *cpu_env, unsigned num, abi_long arg1,
>>
> 
> Starting with this patch, this is broken...
> 
> For instance with ppc64le target:
> 
> qemu: Unsupported syscall: 33
> qemu: Unsupported syscall: 33
> qemu: Unsupported syscall: 5
> qemu: Unsupported syscall: 5
> qemu: Unsupported syscall: 5
> qemu: Unsupported syscall: 5
> qemu: Unsupported syscall: 5
> qemu: Unsupported syscall: 5
> qemu: Unsupported syscall: 5
> qemu: Unsupported syscall: 5
> qemu: Unsupported syscall: 5
> /bin/uname: error while loading shared libraries: libc.so.6: cannot open
> shared object file: Error 38
> 
> for instance, for num = TARGET_NR_OPEN:
> 
> +    impl_fn *fn = impl_everything_else;
> 
> -> fn = impl_everything_else
> 
> +    if (num < ARRAY_SIZE(syscall_table)) {
> +        fn = syscall_table[num];
> 
> -> fn = NULL
> 
> +    }
> +    if (fn == NULL) {
> +        fn = impl_enosys;
> 
> -> fn = impl_enosys;
> 
> +    }
> 
> So all undefined syscall numbers < max(defined syscall numbers) will
> call impl_enosys.
> 
> You should do
> 
>     fn = NULL;
>     if (num < ARRAY_SIZE(syscall_table)) {
>         fn = syscall_table[num];
>     }
>     if (fn == NULL) {
>         fn = impl_eveything_else;
>     }
> 
> and the impl_enosys is managed by impl_eveything_else.
> 
> You can come back to your initial code when all syscalls are split out
> (when you remove the enosys case from everything_else)... otherwise we
> will not be able to bisect this part in the future.

Ack.  How did my testing not catch this.  Will fix.


r~

^ permalink raw reply	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2018-06-04 21:01 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-01  7:30 [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 01/33] linux-user: Split out do_syscall1 Richard Henderson
2018-06-01  7:36   ` Laurent Vivier
2018-06-01 14:00   ` Eric Blake
2018-06-01 14:52     ` Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 02/33] linux-user: Relax single exit from "break" Richard Henderson
2018-06-04 19:29   ` Laurent Vivier
2018-06-01  7:30 ` [Qemu-devel] [PATCH 03/33] linux-user: Propagate goto ebadf to return Richard Henderson
2018-06-04 19:33   ` Laurent Vivier
2018-06-01  7:30 ` [Qemu-devel] [PATCH 04/33] linux-user: Propagate goto efault " Richard Henderson
2018-06-04 19:35   ` Laurent Vivier
2018-06-01  7:30 ` [Qemu-devel] [PATCH 05/33] linux-user: Propagate goto unimplemented_nowarn " Richard Henderson
2018-06-04 19:36   ` Laurent Vivier
2018-06-01  7:30 ` [Qemu-devel] [PATCH 06/33] linux-user: Split out goto unimplemented to do_unimplemented Richard Henderson
2018-06-04 19:38   ` Laurent Vivier
2018-06-01  7:30 ` [Qemu-devel] [PATCH 07/33] linux-user: Propagate goto fail to return Richard Henderson
2018-06-04 19:48   ` Laurent Vivier
2018-06-01  7:30 ` [Qemu-devel] [PATCH 08/33] linux-user: Make syscall number unsigned Richard Henderson
2018-06-04 19:50   ` Laurent Vivier
2018-06-01  7:30 ` [Qemu-devel] [PATCH 09/33] linux-user: Set up infrastructure for table-izing syscalls Richard Henderson
2018-06-04 19:55   ` Laurent Vivier
2018-06-01  7:30 ` [Qemu-devel] [PATCH 10/33] linux-user: Split out brk, close, exit, read, write Richard Henderson
2018-06-04 20:17   ` Laurent Vivier
2018-06-04 21:01     ` Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 11/33] linux-user: Split out execve Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 12/33] linux-user: Split out open, openat Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 13/33] linux-user: Split out name_to_handle_at Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 14/33] linux-user: Split out open_to_handle_at Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 15/33] linux-user: Split out creat, fork, waitid, waitpid Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 16/33] linux-user: Split out link, linkat Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 17/33] linux-user: Split out unlink, unlinkat Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 18/33] linux-user: Split out chdir, mknod, mknodat, time, chmod Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 19/33] linux-user: Remove all unimplemented entries Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 20/33] linux-user: Split out getpid, getxpid, lseek Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 21/33] linux-user: Split out mount, umount Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 22/33] linux-user: Split out alarm, pause, stime, utime, utimes Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 23/33] linux-user: Split out access, faccessat, futimesat, kill, nice, sync, syncfs Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 24/33] linux-user: Split out rename, renameat, renameat2 Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 25/33] linux-user: Split out dup, mkdir, mkdirat, rmdir Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 26/33] linux-user: Split out acct, pipe, pipe2, times, umount2 Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 27/33] linux-user: Split out ioctl Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 28/33] linux-user: Split out chroot, dup2, dup3, fcntl, setpgid, umask Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 29/33] linux-user: Split out getpgrp, getppid, setsid Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 30/33] linux-user: Split out rt_sigaction, sigaction Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 31/33] linux-user: Split out rt_sigprocmask, sgetmask, sigprocmask, ssetmask Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 32/33] linux-user: Split out rt_sigpending, rt_sigsuspend, sigpending, sigsuspend Richard Henderson
2018-06-01  7:30 ` [Qemu-devel] [PATCH 33/33] linux-user: Split out rt_sigqueueinfo, rt_sigtimedwait, rt_tgsigqueueinfo Richard Henderson
2018-06-01  7:33 ` [Qemu-devel] [PATCH 00/33] linux-user: Begin splitting do_syscall Richard Henderson
2018-06-01  8:05 ` no-reply

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.