Despite having the generic arch_syscall_addr being weak, as per commit:
commit c763ba06bd9b ("tracing/syscalls: Make arch_syscall_addr weak")
the level of flexibility provided towards supporting customization of the sys_call_table is still insufficient for certain architectures, making arch_syscall_addr being susceptible to compile-time errors, whenever sys_call_table entries end up being more than just regular function pointer (as in the case of Morello and PCuABI :
commit bb3fbc44e783 ("arm64/syscalls: Allow syscalls to return capabilities")
Instead, drop the generic implementation (and assumptions made there) for archs that explicitly request not to use it.
Signed-off-by: Beata Michalska beata.michalska@arm.com --- Documentation/trace/ftrace-design.rst | 5 +++-- arch/mips/include/asm/ftrace.h | 4 ++++ kernel/trace/trace_syscalls.c | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/Documentation/trace/ftrace-design.rst b/Documentation/trace/ftrace-design.rst index 6893399157f0..d7c17901cb5a 100644 --- a/Documentation/trace/ftrace-design.rst +++ b/Documentation/trace/ftrace-design.rst @@ -241,8 +241,9 @@ You need very few things to get the syscalls tracing in an arch. - Put the trace_sys_enter() and trace_sys_exit() tracepoints calls from ptrace in the ptrace syscalls tracing path. - If the system call table on this arch is more complicated than a simple array - of addresses of the system calls, implement an arch_syscall_addr to return - the address of a given system call. + of addresses of the system calls or requires custom handling, define + ARCH_HAS_SYSCALL_ADDR in asm/ftrace.h and implement arch_syscall_addr to + return the address of a given system call. - If the symbol names of the system calls do not match the function names on this arch, define ARCH_HAS_SYSCALL_MATCH_SYM_NAME in asm/ftrace.h and implement arch_syscall_match_sym_name with the appropriate logic to return diff --git a/arch/mips/include/asm/ftrace.h b/arch/mips/include/asm/ftrace.h index db497a8167da..a93b8e1c8d2c 100644 --- a/arch/mips/include/asm/ftrace.h +++ b/arch/mips/include/asm/ftrace.h @@ -10,6 +10,10 @@ #ifndef _ASM_MIPS_FTRACE_H #define _ASM_MIPS_FTRACE_H
+#ifdef CONFIG_FTRACE_SYSCALLS +#define ARCH_HAS_SYSCALL_ADDR +#endif + #ifdef CONFIG_FUNCTION_TRACER
#define MCOUNT_ADDR ((unsigned long)(_mcount)) diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c index f755bde42fd0..ad3bb8e8c651 100644 --- a/kernel/trace/trace_syscalls.c +++ b/kernel/trace/trace_syscalls.c @@ -516,10 +516,12 @@ struct trace_event_class __refdata event_class_syscall_exit = { .raw_init = init_syscall_trace, };
-unsigned long __init __weak arch_syscall_addr(int nr) +#ifndef ARCH_HAS_SYSCALL_ADDR +unsigned long __init arch_syscall_addr(int nr) { return (unsigned long)sys_call_table[nr]; } +#endif
void __init init_ftrace_syscalls(void) {