*-user: plugin syscalls
To avoid too much duplication add a wrapper that the existing trace and the new plugin calls can live in. We could move the -strace code here as well but that is left for a future series as the code is subtly different between the bsd and linux. Signed-off-by: Emilio G. Cota <cota@braap.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> [AJB: wrap in syscall-trace.h, expand commit msg] Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
This commit is contained in:
parent
8634d77bdb
commit
c36f7a642c
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include "qemu.h"
|
#include "qemu.h"
|
||||||
#include "qemu-common.h"
|
#include "qemu-common.h"
|
||||||
|
#include "user/syscall-trace.h"
|
||||||
|
|
||||||
//#define DEBUG
|
//#define DEBUG
|
||||||
|
|
||||||
@ -322,7 +323,8 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
gemu_log("freebsd syscall %d\n", num);
|
gemu_log("freebsd syscall %d\n", num);
|
||||||
#endif
|
#endif
|
||||||
trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
|
record_syscall_start(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, 0);
|
||||||
|
|
||||||
if(do_strace)
|
if(do_strace)
|
||||||
print_freebsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
|
print_freebsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
|
||||||
|
|
||||||
@ -403,7 +405,8 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, abi_long arg1,
|
|||||||
#endif
|
#endif
|
||||||
if (do_strace)
|
if (do_strace)
|
||||||
print_freebsd_syscall_ret(num, ret);
|
print_freebsd_syscall_ret(num, ret);
|
||||||
trace_guest_user_syscall_ret(cpu, num, ret);
|
|
||||||
|
record_syscall_return(cpu, num, ret);
|
||||||
return ret;
|
return ret;
|
||||||
efault:
|
efault:
|
||||||
ret = -TARGET_EFAULT;
|
ret = -TARGET_EFAULT;
|
||||||
@ -421,7 +424,9 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long arg1,
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
gemu_log("netbsd syscall %d\n", num);
|
gemu_log("netbsd syscall %d\n", num);
|
||||||
#endif
|
#endif
|
||||||
trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, 0);
|
|
||||||
|
record_syscall_start(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, 0);
|
||||||
|
|
||||||
if(do_strace)
|
if(do_strace)
|
||||||
print_netbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
|
print_netbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
|
||||||
|
|
||||||
@ -479,7 +484,8 @@ abi_long do_netbsd_syscall(void *cpu_env, int num, abi_long arg1,
|
|||||||
#endif
|
#endif
|
||||||
if (do_strace)
|
if (do_strace)
|
||||||
print_netbsd_syscall_ret(num, ret);
|
print_netbsd_syscall_ret(num, ret);
|
||||||
trace_guest_user_syscall_ret(cpu, num, ret);
|
|
||||||
|
record_syscall_return(cpu, num, ret);
|
||||||
return ret;
|
return ret;
|
||||||
efault:
|
efault:
|
||||||
ret = -TARGET_EFAULT;
|
ret = -TARGET_EFAULT;
|
||||||
@ -497,7 +503,9 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1,
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
gemu_log("openbsd syscall %d\n", num);
|
gemu_log("openbsd syscall %d\n", num);
|
||||||
#endif
|
#endif
|
||||||
trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, 0);
|
|
||||||
|
record_syscall_start(cpu, num, arg1, arg2, arg3, arg4, arg5, arg6, 0, 0);
|
||||||
|
|
||||||
if(do_strace)
|
if(do_strace)
|
||||||
print_openbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
|
print_openbsd_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
|
||||||
|
|
||||||
@ -555,7 +563,8 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1,
|
|||||||
#endif
|
#endif
|
||||||
if (do_strace)
|
if (do_strace)
|
||||||
print_openbsd_syscall_ret(num, ret);
|
print_openbsd_syscall_ret(num, ret);
|
||||||
trace_guest_user_syscall_ret(cpu, num, ret);
|
|
||||||
|
record_syscall_return(cpu, num, ret);
|
||||||
return ret;
|
return ret;
|
||||||
efault:
|
efault:
|
||||||
ret = -TARGET_EFAULT;
|
ret = -TARGET_EFAULT;
|
||||||
|
40
include/user/syscall-trace.h
Normal file
40
include/user/syscall-trace.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Common System Call Tracing Wrappers for *-user
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Linaro
|
||||||
|
* Written by Alex Bennée <alex.bennee@linaro.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SYSCALL_TRACE_H_
|
||||||
|
#define _SYSCALL_TRACE_H_
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These helpers just provide a common place for the various
|
||||||
|
* subsystems that want to track syscalls to put their hooks in. We
|
||||||
|
* could potentially unify the -strace code here as well.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static inline void record_syscall_start(void *cpu, 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)
|
||||||
|
{
|
||||||
|
trace_guest_user_syscall(cpu, num,
|
||||||
|
arg1, arg2, arg3, arg4,
|
||||||
|
arg5, arg6, arg7, arg8);
|
||||||
|
qemu_plugin_vcpu_syscall(cpu, num,
|
||||||
|
arg1, arg2, arg3, arg4,
|
||||||
|
arg5, arg6, arg7, arg8);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void record_syscall_return(void *cpu, int num, abi_long ret)
|
||||||
|
{
|
||||||
|
trace_guest_user_syscall_ret(cpu, num, ret);
|
||||||
|
qemu_plugin_vcpu_syscall_ret(cpu, num, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _SYSCALL_TRACE_H_ */
|
@ -112,6 +112,7 @@
|
|||||||
|
|
||||||
#include "qemu.h"
|
#include "qemu.h"
|
||||||
#include "qemu/guest-random.h"
|
#include "qemu/guest-random.h"
|
||||||
|
#include "user/syscall-trace.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "fd-trans.h"
|
#include "fd-trans.h"
|
||||||
|
|
||||||
@ -11984,8 +11985,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
trace_guest_user_syscall(cpu, num, arg1, arg2, arg3, arg4,
|
record_syscall_start(cpu, num, arg1,
|
||||||
arg5, arg6, arg7, arg8);
|
arg2, arg3, arg4, arg5, arg6, arg7, arg8);
|
||||||
|
|
||||||
if (unlikely(do_strace)) {
|
if (unlikely(do_strace)) {
|
||||||
print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
|
print_syscall(num, arg1, arg2, arg3, arg4, arg5, arg6);
|
||||||
@ -11997,6 +11998,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
|
|||||||
arg5, arg6, arg7, arg8);
|
arg5, arg6, arg7, arg8);
|
||||||
}
|
}
|
||||||
|
|
||||||
trace_guest_user_syscall_ret(cpu, num, ret);
|
record_syscall_return(cpu, num, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user