Skip to content

Commit

Permalink
riscv: Fix ftrace syscall handling which are now prefixed with __riscv_
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Sami Tolvanen <[email protected]>
Acked-by: Masami Hiramatsu (Google) <[email protected]>
Tested-by: Björn Töpel <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Cc: [email protected]
Signed-off-by: Palmer Dabbelt <[email protected]>
  • Loading branch information
Alexandre Ghiti authored and palmer-dabbelt committed Oct 12, 2023
1 parent 07a2766 commit a87e7d3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions arch/riscv/include/asm/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,27 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr)
return addr;
}

/*
* Let's do like x86/arm64 and ignore the compat syscalls.
*/
#define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS
static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
{
return is_compat_task();
}

#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
static inline bool arch_syscall_match_sym_name(const char *sym,
const char *name)
{
/*
* Since all syscall functions have __riscv_ prefix, we must skip it.
* However, as we described above, we decided to ignore compat
* syscalls, so we don't care about __riscv_compat_ prefix here.
*/
return !strcmp(sym + 8, name);
}

struct dyn_arch_ftrace {
};
#endif
Expand Down

0 comments on commit a87e7d3

Please sign in to comment.