[PATCH v2 04/11] syscall/tracing: allow arch to override syscall_get_nr for ftrace

From: Marcin Nowakowski
Date: Fri Sep 16 2016 - 03:12:54 EST

Some architectures modify syscall numbers to indicate ABI used
and as a result syscall number as returned by syscall_get_nr
does not correspond to the syscall number used inside the kernel.
Allow an arch to provide a separate implementation for ftrace
that returns the 'real' syscall number from the regs provided.

This will be used by x86 in a follow-up change.

Signed-off-by: Marcin Nowakowski <marcin.nowakowski@xxxxxxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
kernel/trace/trace_syscalls.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 8dd0fbf..bb1e901 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -74,7 +74,11 @@ static inline bool trace_is_compat_syscall(struct pt_regs *regs)
static inline int
trace_get_syscall_nr(struct task_struct *task, struct pt_regs *regs)
+#ifdef arch_trace_syscall_get_nr
+ return arch_trace_syscall_get_nr(task, regs);
return syscall_get_nr(task, regs);