18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _TRACE_SYSCALL_H
38c2ecf20Sopenharmony_ci#define _TRACE_SYSCALL_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <linux/tracepoint.h>
68c2ecf20Sopenharmony_ci#include <linux/unistd.h>
78c2ecf20Sopenharmony_ci#include <linux/trace_events.h>
88c2ecf20Sopenharmony_ci#include <linux/thread_info.h>
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <asm/ptrace.h>
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/*
148c2ecf20Sopenharmony_ci * A syscall entry in the ftrace syscalls array.
158c2ecf20Sopenharmony_ci *
168c2ecf20Sopenharmony_ci * @name: name of the syscall
178c2ecf20Sopenharmony_ci * @syscall_nr: number of the syscall
188c2ecf20Sopenharmony_ci * @nb_args: number of parameters it takes
198c2ecf20Sopenharmony_ci * @types: list of types as strings
208c2ecf20Sopenharmony_ci * @args: list of args as strings (args[i] matches types[i])
218c2ecf20Sopenharmony_ci * @enter_fields: list of fields for syscall_enter trace event
228c2ecf20Sopenharmony_ci * @enter_event: associated syscall_enter trace event
238c2ecf20Sopenharmony_ci * @exit_event: associated syscall_exit trace event
248c2ecf20Sopenharmony_ci */
258c2ecf20Sopenharmony_cistruct syscall_metadata {
268c2ecf20Sopenharmony_ci	const char	*name;
278c2ecf20Sopenharmony_ci	int		syscall_nr;
288c2ecf20Sopenharmony_ci	int		nb_args;
298c2ecf20Sopenharmony_ci	const char	**types;
308c2ecf20Sopenharmony_ci	const char	**args;
318c2ecf20Sopenharmony_ci	struct list_head enter_fields;
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci	struct trace_event_call *enter_event;
348c2ecf20Sopenharmony_ci	struct trace_event_call *exit_event;
358c2ecf20Sopenharmony_ci};
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS)
388c2ecf20Sopenharmony_cistatic inline void syscall_tracepoint_update(struct task_struct *p)
398c2ecf20Sopenharmony_ci{
408c2ecf20Sopenharmony_ci	if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
418c2ecf20Sopenharmony_ci		set_tsk_thread_flag(p, TIF_SYSCALL_TRACEPOINT);
428c2ecf20Sopenharmony_ci	else
438c2ecf20Sopenharmony_ci		clear_tsk_thread_flag(p, TIF_SYSCALL_TRACEPOINT);
448c2ecf20Sopenharmony_ci}
458c2ecf20Sopenharmony_ci#else
468c2ecf20Sopenharmony_cistatic inline void syscall_tracepoint_update(struct task_struct *p)
478c2ecf20Sopenharmony_ci{
488c2ecf20Sopenharmony_ci}
498c2ecf20Sopenharmony_ci#endif
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci#endif /* _TRACE_SYSCALL_H */
52