Skip to content

Commit a87e7d3

Browse files
Alexandre Ghitipalmer-dabbelt
authored andcommitted
riscv: Fix ftrace syscall handling which are now prefixed with __riscv_
ftrace creates entries for each syscall in the tracefs but has failed since commit 08d0ce3 ("riscv: Implement syscall wrappers") which prefixes all riscv syscalls with __riscv_. So fix this by implementing arch_syscall_match_sym_name() which allows us to ignore this prefix. And also ignore compat syscalls like x86/arm64 by implementing arch_trace_is_compat_syscall(). Fixes: 08d0ce3 ("riscv: Implement syscall wrappers") Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com> Reviewed-by: Sami Tolvanen <samitolvanen@google.com> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Tested-by: Björn Töpel <bjorn@rivosinc.com> Link: https://lore.kernel.org/r/20231003182407.32198-1-alexghiti@rivosinc.com Cc: stable@vger.kernel.org Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 07a2766 commit a87e7d3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

arch/riscv/include/asm/ftrace.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,27 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr)
3131
return addr;
3232
}
3333

34+
/*
35+
* Let's do like x86/arm64 and ignore the compat syscalls.
36+
*/
37+
#define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS
38+
static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
39+
{
40+
return is_compat_task();
41+
}
42+
43+
#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
44+
static inline bool arch_syscall_match_sym_name(const char *sym,
45+
const char *name)
46+
{
47+
/*
48+
* Since all syscall functions have __riscv_ prefix, we must skip it.
49+
* However, as we described above, we decided to ignore compat
50+
* syscalls, so we don't care about __riscv_compat_ prefix here.
51+
*/
52+
return !strcmp(sym + 8, name);
53+
}
54+
3455
struct dyn_arch_ftrace {
3556
};
3657
#endif

0 commit comments

Comments
 (0)