^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef _TRACE_SYSCALL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define _TRACE_SYSCALL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/tracepoint.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/unistd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/trace_events.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/thread_info.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <asm/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * A syscall entry in the ftrace syscalls array.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * @name: name of the syscall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * @syscall_nr: number of the syscall
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * @nb_args: number of parameters it takes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * @types: list of types as strings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * @args: list of args as strings (args[i] matches types[i])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * @enter_fields: list of fields for syscall_enter trace event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * @enter_event: associated syscall_enter trace event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * @exit_event: associated syscall_exit trace event
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct syscall_metadata {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) int syscall_nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) int nb_args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) const char **types;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) const char **args;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) struct list_head enter_fields;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct trace_event_call *enter_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct trace_event_call *exit_event;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static inline void syscall_tracepoint_update(struct task_struct *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) set_tsk_thread_flag(p, TIF_SYSCALL_TRACEPOINT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) clear_tsk_thread_flag(p, TIF_SYSCALL_TRACEPOINT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) static inline void syscall_tracepoint_update(struct task_struct *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #endif /* _TRACE_SYSCALL_H */