Skip to content

Commit b2d5549

Browse files
Ian Munsierostedt
authored andcommitted
tracing/syscalls: Allow arch specific syscall symbol matching
Some architectures have unusual symbol names and the generic code to match the symbol name with the function name for the syscall metadata will fail. For example, symbols on PPC64 start with a period and the generic code will fail to match them. This patch moves the match logic out into a separate function which an arch can override by defining ARCH_HAS_SYSCALL_MATCH_SYM_NAME in asm/ftrace.h and implementing arch_syscall_match_sym_name. Signed-off-by: Ian Munsie <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Steven Rostedt <[email protected]>
1 parent c763ba0 commit b2d5549

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

Documentation/trace/ftrace-design.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ You need very few things to get the syscalls tracing in an arch.
250250
- If the system call table on this arch is more complicated than a simple array
251251
of addresses of the system calls, implement an arch_syscall_addr to return
252252
the address of a given system call.
253+
- If the symbol names of the system calls do not match the function names on
254+
this arch, define ARCH_HAS_SYSCALL_MATCH_SYM_NAME in asm/ftrace.h and
255+
implement arch_syscall_match_sym_name with the appropriate logic to return
256+
true if the function name corresponds with the symbol name.
253257
- Tag this arch as HAVE_SYSCALL_TRACEPOINTS.
254258

255259

kernel/trace/trace_syscalls.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,19 @@ extern struct syscall_metadata *__stop_syscalls_metadata[];
6060

6161
static struct syscall_metadata **syscalls_metadata;
6262

63+
#ifndef ARCH_HAS_SYSCALL_MATCH_SYM_NAME
64+
static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
65+
{
66+
/*
67+
* Only compare after the "sys" prefix. Archs that use
68+
* syscall wrappers may have syscalls symbols aliases prefixed
69+
* with "SyS" instead of "sys", leading to an unwanted
70+
* mismatch.
71+
*/
72+
return !strcmp(sym + 3, name + 3);
73+
}
74+
#endif
75+
6376
static __init struct syscall_metadata *
6477
find_syscall_meta(unsigned long syscall)
6578
{
@@ -73,13 +86,7 @@ find_syscall_meta(unsigned long syscall)
7386
kallsyms_lookup(syscall, NULL, NULL, NULL, str);
7487

7588
for ( ; start < stop; start++) {
76-
/*
77-
* Only compare after the "sys" prefix. Archs that use
78-
* syscall wrappers may have syscalls symbols aliases prefixed
79-
* with "SyS" instead of "sys", leading to an unwanted
80-
* mismatch.
81-
*/
82-
if ((*start)->name && !strcmp((*start)->name + 3, str + 3))
89+
if ((*start)->name && arch_syscall_match_sym_name(str, (*start)->name))
8390
return *start;
8491
}
8592
return NULL;

0 commit comments

Comments
 (0)