aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2009-12-11 03:44:47 -0500
committerDavid S. Miller <davem@davemloft.net>2009-12-11 03:44:47 -0500
commitc658ad1b4e1520511da8323aa5e60d444cc303ed (patch)
tree7e2ce4179ecfdb0e10caa7c69fa86857c0398bf4
parent4d14a459857bd151ecbd14bcd37b4628da00792b (diff)
sparc64: Add syscall tracepoint support.
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--arch/sparc/Kconfig1
-rw-r--r--arch/sparc/include/asm/thread_info_64.h2
-rw-r--r--arch/sparc/include/asm/unistd.h2
-rw-r--r--arch/sparc/kernel/entry.S2
-rw-r--r--arch/sparc/kernel/ftrace.c11
-rw-r--r--arch/sparc/kernel/ptrace_64.c10
-rw-r--r--arch/sparc/kernel/syscalls.S14
7 files changed, 33 insertions, 9 deletions
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 33ac1a9ac881..108197ac0d56 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -43,6 +43,7 @@ config SPARC64
43 select HAVE_SYSCALL_WRAPPERS 43 select HAVE_SYSCALL_WRAPPERS
44 select HAVE_DYNAMIC_FTRACE 44 select HAVE_DYNAMIC_FTRACE
45 select HAVE_FTRACE_MCOUNT_RECORD 45 select HAVE_FTRACE_MCOUNT_RECORD
46 select HAVE_SYSCALL_TRACEPOINTS
46 select USE_GENERIC_SMP_HELPERS if SMP 47 select USE_GENERIC_SMP_HELPERS if SMP
47 select RTC_DRV_CMOS 48 select RTC_DRV_CMOS
48 select RTC_DRV_BQ4802 49 select RTC_DRV_BQ4802
diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
index 1b45a7bbe407..7257ebb8f394 100644
--- a/arch/sparc/include/asm/thread_info_64.h
+++ b/arch/sparc/include/asm/thread_info_64.h
@@ -227,6 +227,7 @@ register struct thread_info *current_thread_info_reg asm("g6");
227/* flag bit 8 is available */ 227/* flag bit 8 is available */
228#define TIF_SECCOMP 9 /* secure computing */ 228#define TIF_SECCOMP 9 /* secure computing */
229#define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */ 229#define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
230#define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
230/* flag bit 11 is available */ 231/* flag bit 11 is available */
231/* NOTE: Thread flags >= 12 should be ones we have no interest 232/* NOTE: Thread flags >= 12 should be ones we have no interest
232 * in using in assembly, else we can't use the mask as 233 * in using in assembly, else we can't use the mask as
@@ -246,6 +247,7 @@ register struct thread_info *current_thread_info_reg asm("g6");
246#define _TIF_32BIT (1<<TIF_32BIT) 247#define _TIF_32BIT (1<<TIF_32BIT)
247#define _TIF_SECCOMP (1<<TIF_SECCOMP) 248#define _TIF_SECCOMP (1<<TIF_SECCOMP)
248#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) 249#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
250#define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
249#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) 251#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING)
250#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 252#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
251#define _TIF_FREEZE (1<<TIF_FREEZE) 253#define _TIF_FREEZE (1<<TIF_FREEZE)
diff --git a/arch/sparc/include/asm/unistd.h b/arch/sparc/include/asm/unistd.h
index d8d25bd97121..cb4b9bfd0d87 100644
--- a/arch/sparc/include/asm/unistd.h
+++ b/arch/sparc/include/asm/unistd.h
@@ -398,7 +398,7 @@
398#define __NR_perf_event_open 327 398#define __NR_perf_event_open 327
399#define __NR_recvmmsg 328 399#define __NR_recvmmsg 328
400 400
401#define NR_SYSCALLS 329 401#define NR_syscalls 329
402 402
403#ifdef __32bit_syscall_numbers__ 403#ifdef __32bit_syscall_numbers__
404/* Sparc 32-bit only has the "setresuid32", "getresuid32" variants, 404/* Sparc 32-bit only has the "setresuid32", "getresuid32" variants,
diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index ec9c7bc67d21..1504df8ddf70 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -1294,7 +1294,7 @@ linux_sparc_syscall:
1294 sethi %hi(PSR_SYSCALL), %l4 1294 sethi %hi(PSR_SYSCALL), %l4
1295 or %l0, %l4, %l0 1295 or %l0, %l4, %l0
1296 /* Direct access to user regs, must faster. */ 1296 /* Direct access to user regs, must faster. */
1297 cmp %g1, NR_SYSCALLS 1297 cmp %g1, NR_syscalls
1298 bgeu linux_sparc_ni_syscall 1298 bgeu linux_sparc_ni_syscall
1299 sll %g1, 2, %l4 1299 sll %g1, 2, %l4
1300 ld [%l7 + %l4], %l7 1300 ld [%l7 + %l4], %l7
diff --git a/arch/sparc/kernel/ftrace.c b/arch/sparc/kernel/ftrace.c
index d3b1a3076569..29973daa9930 100644
--- a/arch/sparc/kernel/ftrace.c
+++ b/arch/sparc/kernel/ftrace.c
@@ -4,6 +4,7 @@
4#include <linux/percpu.h> 4#include <linux/percpu.h>
5#include <linux/init.h> 5#include <linux/init.h>
6#include <linux/list.h> 6#include <linux/list.h>
7#include <trace/syscall.h>
7 8
8#include <asm/ftrace.h> 9#include <asm/ftrace.h>
9 10
@@ -91,3 +92,13 @@ int __init ftrace_dyn_arch_init(void *data)
91} 92}
92#endif 93#endif
93 94
95#ifdef CONFIG_FTRACE_SYSCALLS
96
97extern unsigned int sys_call_table[];
98
99unsigned long __init arch_syscall_addr(int nr)
100{
101 return (unsigned long)sys_call_table[nr];
102}
103
104#endif
diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
index 4ae91dc2feb9..2f6524d1a817 100644
--- a/arch/sparc/kernel/ptrace_64.c
+++ b/arch/sparc/kernel/ptrace_64.c
@@ -23,6 +23,7 @@
23#include <linux/signal.h> 23#include <linux/signal.h>
24#include <linux/regset.h> 24#include <linux/regset.h>
25#include <linux/tracehook.h> 25#include <linux/tracehook.h>
26#include <trace/syscall.h>
26#include <linux/compat.h> 27#include <linux/compat.h>
27#include <linux/elf.h> 28#include <linux/elf.h>
28 29
@@ -37,6 +38,9 @@
37#include <asm/cpudata.h> 38#include <asm/cpudata.h>
38#include <asm/cacheflush.h> 39#include <asm/cacheflush.h>
39 40
41#define CREATE_TRACE_POINTS
42#include <trace/events/syscalls.h>
43
40#include "entry.h" 44#include "entry.h"
41 45
42/* #define ALLOW_INIT_TRACING */ 46/* #define ALLOW_INIT_TRACING */
@@ -1059,6 +1063,9 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
1059 if (test_thread_flag(TIF_SYSCALL_TRACE)) 1063 if (test_thread_flag(TIF_SYSCALL_TRACE))
1060 ret = tracehook_report_syscall_entry(regs); 1064 ret = tracehook_report_syscall_entry(regs);
1061 1065
1066 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
1067 trace_sys_enter(regs, regs->u_regs[UREG_G1]);
1068
1062 if (unlikely(current->audit_context) && !ret) 1069 if (unlikely(current->audit_context) && !ret)
1063 audit_syscall_entry((test_thread_flag(TIF_32BIT) ? 1070 audit_syscall_entry((test_thread_flag(TIF_32BIT) ?
1064 AUDIT_ARCH_SPARC : 1071 AUDIT_ARCH_SPARC :
@@ -1084,6 +1091,9 @@ asmlinkage void syscall_trace_leave(struct pt_regs *regs)
1084 audit_syscall_exit(result, regs->u_regs[UREG_I0]); 1091 audit_syscall_exit(result, regs->u_regs[UREG_I0]);
1085 } 1092 }
1086 1093
1094 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
1095 trace_sys_exit(regs, regs->u_regs[UREG_G1]);
1096
1087 if (test_thread_flag(TIF_SYSCALL_TRACE)) 1097 if (test_thread_flag(TIF_SYSCALL_TRACE))
1088 tracehook_report_syscall_exit(regs, 0); 1098 tracehook_report_syscall_exit(regs, 0);
1089} 1099}
diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
index d150c2aa98d2..dc4a458f74dc 100644
--- a/arch/sparc/kernel/syscalls.S
+++ b/arch/sparc/kernel/syscalls.S
@@ -62,7 +62,7 @@ sys32_rt_sigreturn:
62#endif 62#endif
63 .align 32 63 .align 32
641: ldx [%g6 + TI_FLAGS], %l5 641: ldx [%g6 + TI_FLAGS], %l5
65 andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0 65 andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
66 be,pt %icc, rtrap 66 be,pt %icc, rtrap
67 nop 67 nop
68 call syscall_trace_leave 68 call syscall_trace_leave
@@ -187,7 +187,7 @@ linux_syscall_trace:
187 .globl linux_sparc_syscall32 187 .globl linux_sparc_syscall32
188linux_sparc_syscall32: 188linux_sparc_syscall32:
189 /* Direct access to user regs, much faster. */ 189 /* Direct access to user regs, much faster. */
190 cmp %g1, NR_SYSCALLS ! IEU1 Group 190 cmp %g1, NR_syscalls ! IEU1 Group
191 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI 191 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
192 srl %i0, 0, %o0 ! IEU0 192 srl %i0, 0, %o0 ! IEU0
193 sll %g1, 2, %l4 ! IEU0 Group 193 sll %g1, 2, %l4 ! IEU0 Group
@@ -198,7 +198,7 @@ linux_sparc_syscall32:
198 198
199 srl %i5, 0, %o5 ! IEU1 199 srl %i5, 0, %o5 ! IEU1
200 srl %i2, 0, %o2 ! IEU0 Group 200 srl %i2, 0, %o2 ! IEU0 Group
201 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0 201 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
202 bne,pn %icc, linux_syscall_trace32 ! CTI 202 bne,pn %icc, linux_syscall_trace32 ! CTI
203 mov %i0, %l5 ! IEU1 203 mov %i0, %l5 ! IEU1
204 call %l7 ! CTI Group brk forced 204 call %l7 ! CTI Group brk forced
@@ -210,7 +210,7 @@ linux_sparc_syscall32:
210 .globl linux_sparc_syscall 210 .globl linux_sparc_syscall
211linux_sparc_syscall: 211linux_sparc_syscall:
212 /* Direct access to user regs, much faster. */ 212 /* Direct access to user regs, much faster. */
213 cmp %g1, NR_SYSCALLS ! IEU1 Group 213 cmp %g1, NR_syscalls ! IEU1 Group
214 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI 214 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
215 mov %i0, %o0 ! IEU0 215 mov %i0, %o0 ! IEU0
216 sll %g1, 2, %l4 ! IEU0 Group 216 sll %g1, 2, %l4 ! IEU0 Group
@@ -221,7 +221,7 @@ linux_sparc_syscall:
221 221
222 mov %i3, %o3 ! IEU1 222 mov %i3, %o3 ! IEU1
223 mov %i4, %o4 ! IEU0 Group 223 mov %i4, %o4 ! IEU0 Group
224 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0 224 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
225 bne,pn %icc, linux_syscall_trace ! CTI Group 225 bne,pn %icc, linux_syscall_trace ! CTI Group
226 mov %i0, %l5 ! IEU0 226 mov %i0, %l5 ! IEU0
2272: call %l7 ! CTI Group brk forced 2272: call %l7 ! CTI Group brk forced
@@ -245,7 +245,7 @@ ret_sys_call:
245 245
246 cmp %o0, -ERESTART_RESTARTBLOCK 246 cmp %o0, -ERESTART_RESTARTBLOCK
247 bgeu,pn %xcc, 1f 247 bgeu,pn %xcc, 1f
248 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6 248 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %l6
24980: 24980:
250 /* System call success, clear Carry condition code. */ 250 /* System call success, clear Carry condition code. */
251 andn %g3, %g2, %g3 251 andn %g3, %g2, %g3
@@ -260,7 +260,7 @@ ret_sys_call:
260 /* System call failure, set Carry condition code. 260 /* System call failure, set Carry condition code.
261 * Also, get abs(errno) to return to the process. 261 * Also, get abs(errno) to return to the process.
262 */ 262 */
263 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %l6 263 andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %l6
264 sub %g0, %o0, %o0 264 sub %g0, %o0, %o0
265 or %g3, %g2, %g3 265 or %g3, %g2, %g3
266 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0] 266 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]