[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 2/7] linux-user: Split out do_syscall1
From: |
Laurent Vivier |
Subject: |
[Qemu-devel] [PULL 2/7] linux-user: Split out do_syscall1 |
Date: |
Wed, 22 Aug 2018 03:14:12 +0200 |
From: Richard Henderson <address@hidden>
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.
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Laurent Vivier <address@hidden>
Signed-off-by: Richard Henderson <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Laurent Vivier <address@hidden>
---
linux-user/syscall.c | 77 +++++++++++++++++++++++++++-----------------
1 file changed, 48 insertions(+), 29 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 2e45f854f7..f651024357 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8092,13 +8092,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;
@@ -8113,25 +8115,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long
arg1,
#endif
void *p;
-#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
-
- 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).
@@ -12942,11 +12925,47 @@ abi_long do_syscall(void *cpu_env, int num, abi_long
arg1,
break;
}
fail:
- if(do_strace)
- print_syscall_ret(num, ret);
- trace_guest_user_syscall_ret(cpu, num, ret);
return ret;
efault:
ret = -TARGET_EFAULT;
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;
+
+#ifdef 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
+
+ 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);
+ }
+
+ trace_guest_user_syscall_ret(cpu, num, ret);
+ return ret;
+}
--
2.17.1
- [Qemu-devel] [PULL 7/7] linux-user: add QEMU_IFLA_INFO_KIND nested type for tun, (continued)
- [Qemu-devel] [PULL 7/7] linux-user: add QEMU_IFLA_INFO_KIND nested type for tun, Laurent Vivier, 2018/08/20
- [Qemu-devel] [PULL 2/7] linux-user: fix 32bit g2h()/h2g(), Laurent Vivier, 2018/08/20
- [Qemu-devel] [PULL 1/7] qemu-binfmt-conf.sh: add x86_64 target, Laurent Vivier, 2018/08/20
- [Qemu-devel] [PULL 5/7] linux-user: introduce QEMU_RTA_* to use with rtattr_type_t, Laurent Vivier, 2018/08/20
- [Qemu-devel] [PULL 6/7] linux-user: update netlink route types, Laurent Vivier, 2018/08/20
- [Qemu-devel] [PULL 3/7] sh4: fix use_icount with linux-user, Laurent Vivier, 2018/08/20
- [Qemu-devel] [PULL 4/7] linux-user: fix recvmsg()/recvfrom() with netlink and MSG_TRUNC, Laurent Vivier, 2018/08/20
- Re: [Qemu-devel] [PULL 0/7] Linux user for 3.1 patches, no-reply, 2018/08/20
- Re: [Qemu-devel] [PULL 0/7] Linux user for 3.1 patches, Peter Maydell, 2018/08/21
- [Qemu-devel] [PULL 0/7] Linux user for 3.1 patches, Laurent Vivier, 2018/08/21
- [Qemu-devel] [PULL 2/7] linux-user: Split out do_syscall1,
Laurent Vivier <=
- [Qemu-devel] [PULL 5/7] linux-user: Propagate goto unimplemented_nowarn to return, Laurent Vivier, 2018/08/21
- [Qemu-devel] [PULL 6/7] linux-user: Propagate goto unimplemented to default, Laurent Vivier, 2018/08/21
- [Qemu-devel] [PULL 7/7] linux-user: Propagate goto fail to return, Laurent Vivier, 2018/08/21
- [Qemu-devel] [PULL 1/7] linux-user: Remove DEBUG, Laurent Vivier, 2018/08/21
- [Qemu-devel] [PULL 4/7] linux-user: Propagate goto efault to return, Laurent Vivier, 2018/08/21
- [Qemu-devel] [PULL 3/7] linux-user: Relax single exit from "break", Laurent Vivier, 2018/08/21
- Re: [Qemu-devel] [PULL 0/7] Linux user for 3.1 patches, Peter Maydell, 2018/08/23