Unwrapping early produces a much nicer log output. Disallow recursive syscall, as per ARM and MIPS.
Signed-off-by: Richard Henderson <richard.hender...@linaro.org> --- linux-user/syscall.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 4f6c01092b..87374014b1 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -10230,11 +10230,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, switch(num) { case TARGET_NR_vhangup: return get_errno(vhangup()); -#ifdef TARGET_NR_syscall - case TARGET_NR_syscall: - return do_syscall(cpu_env, arg1 & 0xffff, arg2, arg3, arg4, arg5, - arg6, arg7, arg8, 0); -#endif case TARGET_NR_wait4: { int status; @@ -13171,6 +13166,32 @@ abi_long do_syscall(void *cpu_env, unsigned num, abi_long arg1, } } #endif +#ifdef TARGET_NR_syscall + /* For the benefit of strace, unwrap NR_syscall now. */ + if (num == TARGET_NR_syscall) { + num = arg1 & 0xffff; + if (num == TARGET_NR_syscall) { + /* Do not allow recursion. */ + ret = -TARGET_ENOSYS; + 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); + print_syscall_ret(num, ret); + } + trace_guest_user_syscall_ret(cpu, num, ret); + return ret; + } + arg1 = arg2; + arg2 = arg3; + arg3 = arg4; + arg4 = arg5; + arg5 = arg6; + arg6 = arg7; + arg7 = arg8; + arg8 = 0; + } +#endif trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); -- 2.17.1