aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAKASHI Takahiro <takahiro.akashi@linaro.org>2014-04-30 05:54:36 -0400
committerWill Deacon <will.deacon@arm.com>2014-05-29 04:08:33 -0400
commit055b1212d141f1f398fca548f8147787c0b6253f (patch)
treea2baa3bd73b450008056bf69edf708e7902736b5
parent3711784ece66d39352a0dbb6da40e097a77da057 (diff)
arm64: ftrace: Add system call tracepoint
This patch allows system call entry or exit to be traced as ftrace events, ie. sys_enter_*/sys_exit_*, if CONFIG_FTRACE_SYSCALLS is enabled. Those events appear and can be controlled under ${sysfs}/tracing/events/syscalls/ Please note that we can't trace compat system calls here because AArch32 mode does not share the same syscall table with AArch64. Just define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS in order to avoid unexpected results (bogus syscalls reported or even hang-up). Acked-by: Will Deacon <will.deacon@arm.com> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r--arch/arm64/Kconfig1
-rw-r--r--arch/arm64/include/asm/ftrace.h18
-rw-r--r--arch/arm64/include/asm/syscall.h1
-rw-r--r--arch/arm64/include/asm/unistd.h2
-rw-r--r--arch/arm64/kernel/ptrace.c9
5 files changed, 31 insertions, 0 deletions
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 4e689ad5f27c..bceeaf10c9d6 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -48,6 +48,7 @@ config ARM64
48 select HAVE_PERF_EVENTS 48 select HAVE_PERF_EVENTS
49 select HAVE_PERF_REGS 49 select HAVE_PERF_REGS
50 select HAVE_PERF_USER_STACK_DUMP 50 select HAVE_PERF_USER_STACK_DUMP
51 select HAVE_SYSCALL_TRACEPOINTS
51 select IRQ_DOMAIN 52 select IRQ_DOMAIN
52 select MODULES_USE_ELF_RELA 53 select MODULES_USE_ELF_RELA
53 select NO_BOOTMEM 54 select NO_BOOTMEM
diff --git a/arch/arm64/include/asm/ftrace.h b/arch/arm64/include/asm/ftrace.h
index 41e8670db20f..c5534facf941 100644
--- a/arch/arm64/include/asm/ftrace.h
+++ b/arch/arm64/include/asm/ftrace.h
@@ -17,6 +17,8 @@
17#define MCOUNT_INSN_SIZE AARCH64_INSN_SIZE 17#define MCOUNT_INSN_SIZE AARCH64_INSN_SIZE
18 18
19#ifndef __ASSEMBLY__ 19#ifndef __ASSEMBLY__
20#include <linux/compat.h>
21
20extern void _mcount(unsigned long); 22extern void _mcount(unsigned long);
21extern void *return_address(unsigned int); 23extern void *return_address(unsigned int);
22 24
@@ -36,6 +38,22 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr)
36} 38}
37 39
38#define ftrace_return_address(n) return_address(n) 40#define ftrace_return_address(n) return_address(n)
41
42/*
43 * Because AArch32 mode does not share the same syscall table with AArch64,
44 * tracing compat syscalls may result in reporting bogus syscalls or even
45 * hang-up, so just do not trace them.
46 * See kernel/trace/trace_syscalls.c
47 *
48 * x86 code says:
49 * If the user realy wants these, then they should use the
50 * raw syscall tracepoints with filtering.
51 */
52#define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS
53static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
54{
55 return is_compat_task();
56}
39#endif /* ifndef __ASSEMBLY__ */ 57#endif /* ifndef __ASSEMBLY__ */
40 58
41#endif /* __ASM_FTRACE_H */ 59#endif /* __ASM_FTRACE_H */
diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/syscall.h
index 70ba9d4ee978..383771eb0b87 100644
--- a/arch/arm64/include/asm/syscall.h
+++ b/arch/arm64/include/asm/syscall.h
@@ -18,6 +18,7 @@
18 18
19#include <linux/err.h> 19#include <linux/err.h>
20 20
21extern const void *sys_call_table[];
21 22
22static inline int syscall_get_nr(struct task_struct *task, 23static inline int syscall_get_nr(struct task_struct *task,
23 struct pt_regs *regs) 24 struct pt_regs *regs)
diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h
index a4654c656a1e..e5f47df00c24 100644
--- a/arch/arm64/include/asm/unistd.h
+++ b/arch/arm64/include/asm/unistd.h
@@ -29,3 +29,5 @@
29#endif 29#endif
30#define __ARCH_WANT_SYS_CLONE 30#define __ARCH_WANT_SYS_CLONE
31#include <uapi/asm/unistd.h> 31#include <uapi/asm/unistd.h>
32
33#define NR_syscalls (__NR_syscalls)
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index 32d52d3b079c..3e926b9c0641 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -42,6 +42,9 @@
42#include <asm/traps.h> 42#include <asm/traps.h>
43#include <asm/system_misc.h> 43#include <asm/system_misc.h>
44 44
45#define CREATE_TRACE_POINTS
46#include <trace/events/syscalls.h>
47
45/* 48/*
46 * TODO: does not yet catch signals sent when the child dies. 49 * TODO: does not yet catch signals sent when the child dies.
47 * in exit.c or in signal.c. 50 * in exit.c or in signal.c.
@@ -1093,11 +1096,17 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
1093 if (test_thread_flag(TIF_SYSCALL_TRACE)) 1096 if (test_thread_flag(TIF_SYSCALL_TRACE))
1094 tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER); 1097 tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER);
1095 1098
1099 if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
1100 trace_sys_enter(regs, regs->syscallno);
1101
1096 return regs->syscallno; 1102 return regs->syscallno;
1097} 1103}
1098 1104
1099asmlinkage void syscall_trace_exit(struct pt_regs *regs) 1105asmlinkage void syscall_trace_exit(struct pt_regs *regs)
1100{ 1106{
1107 if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
1108 trace_sys_exit(regs, regs_return_value(regs));
1109
1101 if (test_thread_flag(TIF_SYSCALL_TRACE)) 1110 if (test_thread_flag(TIF_SYSCALL_TRACE))
1102 tracehook_report_syscall(regs, PTRACE_SYSCALL_EXIT); 1111 tracehook_report_syscall(regs, PTRACE_SYSCALL_EXIT);
1103} 1112}