[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 09/33] linux-user: Set up infrastructure for table-i
From: |
Richard Henderson |
Subject: |
[Qemu-devel] [PATCH 09/33] linux-user: Set up infrastructure for table-izing syscalls |
Date: |
Fri, 1 Jun 2018 00:30:26 -0700 |
Signed-off-by: Richard Henderson <address@hidden>
---
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
- Re: [Qemu-devel] [PATCH 05/33] linux-user: Propagate goto unimplemented_nowarn to return, (continued)
- [Qemu-devel] [PATCH 08/33] linux-user: Make syscall number unsigned, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 06/33] linux-user: Split out goto unimplemented to do_unimplemented, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 07/33] linux-user: Propagate goto fail to return, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 04/33] linux-user: Propagate goto efault to return, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 12/33] linux-user: Split out open, openat, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 09/33] linux-user: Set up infrastructure for table-izing syscalls,
Richard Henderson <=
- [Qemu-devel] [PATCH 10/33] linux-user: Split out brk, close, exit, read, write, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 02/33] linux-user: Relax single exit from "break", Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 11/33] linux-user: Split out execve, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 14/33] linux-user: Split out open_to_handle_at, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 15/33] linux-user: Split out creat, fork, waitid, waitpid, Richard Henderson, 2018/06/01
- [Qemu-devel] [PATCH 13/33] linux-user: Split out name_to_handle_at, Richard Henderson, 2018/06/01