Commit c658ad1b4e1520511da8323aa5e60d444cc303ed

Authored by David S. Miller
1 parent 4d14a45985

sparc64: Add syscall tracepoint support.

Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 7 changed files with 33 additions and 9 deletions Side-by-side Diff

... ... @@ -43,6 +43,7 @@
43 43 select HAVE_SYSCALL_WRAPPERS
44 44 select HAVE_DYNAMIC_FTRACE
45 45 select HAVE_FTRACE_MCOUNT_RECORD
  46 + select HAVE_SYSCALL_TRACEPOINTS
46 47 select USE_GENERIC_SMP_HELPERS if SMP
47 48 select RTC_DRV_CMOS
48 49 select RTC_DRV_BQ4802
arch/sparc/include/asm/thread_info_64.h
... ... @@ -227,6 +227,7 @@
227 227 /* flag bit 8 is available */
228 228 #define TIF_SECCOMP 9 /* secure computing */
229 229 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
  230 +#define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
230 231 /* flag bit 11 is available */
231 232 /* NOTE: Thread flags >= 12 should be ones we have no interest
232 233 * in using in assembly, else we can't use the mask as
... ... @@ -246,6 +247,7 @@
246 247 #define _TIF_32BIT (1<<TIF_32BIT)
247 248 #define _TIF_SECCOMP (1<<TIF_SECCOMP)
248 249 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
  250 +#define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
249 251 #define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING)
250 252 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
251 253 #define _TIF_FREEZE (1<<TIF_FREEZE)
arch/sparc/include/asm/unistd.h
... ... @@ -398,7 +398,7 @@
398 398 #define __NR_perf_event_open 327
399 399 #define __NR_recvmmsg 328
400 400  
401   -#define NR_SYSCALLS 329
  401 +#define NR_syscalls 329
402 402  
403 403 #ifdef __32bit_syscall_numbers__
404 404 /* Sparc 32-bit only has the "setresuid32", "getresuid32" variants,
arch/sparc/kernel/entry.S
... ... @@ -1294,7 +1294,7 @@
1294 1294 sethi %hi(PSR_SYSCALL), %l4
1295 1295 or %l0, %l4, %l0
1296 1296 /* Direct access to user regs, must faster. */
1297   - cmp %g1, NR_SYSCALLS
  1297 + cmp %g1, NR_syscalls
1298 1298 bgeu linux_sparc_ni_syscall
1299 1299 sll %g1, 2, %l4
1300 1300 ld [%l7 + %l4], %l7
arch/sparc/kernel/ftrace.c
... ... @@ -4,6 +4,7 @@
4 4 #include <linux/percpu.h>
5 5 #include <linux/init.h>
6 6 #include <linux/list.h>
  7 +#include <trace/syscall.h>
7 8  
8 9 #include <asm/ftrace.h>
9 10  
... ... @@ -89,5 +90,16 @@
89 90  
90 91 return 0;
91 92 }
  93 +#endif
  94 +
  95 +#ifdef CONFIG_FTRACE_SYSCALLS
  96 +
  97 +extern unsigned int sys_call_table[];
  98 +
  99 +unsigned long __init arch_syscall_addr(int nr)
  100 +{
  101 + return (unsigned long)sys_call_table[nr];
  102 +}
  103 +
92 104 #endif
arch/sparc/kernel/ptrace_64.c
... ... @@ -23,6 +23,7 @@
23 23 #include <linux/signal.h>
24 24 #include <linux/regset.h>
25 25 #include <linux/tracehook.h>
  26 +#include <trace/syscall.h>
26 27 #include <linux/compat.h>
27 28 #include <linux/elf.h>
28 29  
... ... @@ -37,6 +38,9 @@
37 38 #include <asm/cpudata.h>
38 39 #include <asm/cacheflush.h>
39 40  
  41 +#define CREATE_TRACE_POINTS
  42 +#include <trace/events/syscalls.h>
  43 +
40 44 #include "entry.h"
41 45  
42 46 /* #define ALLOW_INIT_TRACING */
... ... @@ -1059,6 +1063,9 @@
1059 1063 if (test_thread_flag(TIF_SYSCALL_TRACE))
1060 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 1069 if (unlikely(current->audit_context) && !ret)
1063 1070 audit_syscall_entry((test_thread_flag(TIF_32BIT) ?
1064 1071 AUDIT_ARCH_SPARC :
... ... @@ -1083,6 +1090,9 @@
1083 1090  
1084 1091 audit_syscall_exit(result, regs->u_regs[UREG_I0]);
1085 1092 }
  1093 +
  1094 + if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
  1095 + trace_sys_exit(regs, regs->u_regs[UREG_G1]);
1086 1096  
1087 1097 if (test_thread_flag(TIF_SYSCALL_TRACE))
1088 1098 tracehook_report_syscall_exit(regs, 0);
arch/sparc/kernel/syscalls.S
... ... @@ -62,7 +62,7 @@
62 62 #endif
63 63 .align 32
64 64 1: 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 66 be,pt %icc, rtrap
67 67 nop
68 68 call syscall_trace_leave
... ... @@ -187,7 +187,7 @@
187 187 .globl linux_sparc_syscall32
188 188 linux_sparc_syscall32:
189 189 /* Direct access to user regs, much faster. */
190   - cmp %g1, NR_SYSCALLS ! IEU1 Group
  190 + cmp %g1, NR_syscalls ! IEU1 Group
191 191 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
192 192 srl %i0, 0, %o0 ! IEU0
193 193 sll %g1, 2, %l4 ! IEU0 Group
... ... @@ -198,7 +198,7 @@
198 198  
199 199 srl %i5, 0, %o5 ! IEU1
200 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 202 bne,pn %icc, linux_syscall_trace32 ! CTI
203 203 mov %i0, %l5 ! IEU1
204 204 call %l7 ! CTI Group brk forced
... ... @@ -210,7 +210,7 @@
210 210 .globl linux_sparc_syscall
211 211 linux_sparc_syscall:
212 212 /* Direct access to user regs, much faster. */
213   - cmp %g1, NR_SYSCALLS ! IEU1 Group
  213 + cmp %g1, NR_syscalls ! IEU1 Group
214 214 bgeu,pn %xcc, linux_sparc_ni_syscall ! CTI
215 215 mov %i0, %o0 ! IEU0
216 216 sll %g1, 2, %l4 ! IEU0 Group
... ... @@ -221,7 +221,7 @@
221 221  
222 222 mov %i3, %o3 ! IEU1
223 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 225 bne,pn %icc, linux_syscall_trace ! CTI Group
226 226 mov %i0, %l5 ! IEU0
227 227 2: call %l7 ! CTI Group brk forced
... ... @@ -245,7 +245,7 @@
245 245  
246 246 cmp %o0, -ERESTART_RESTARTBLOCK
247 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
249 249 80:
250 250 /* System call success, clear Carry condition code. */
251 251 andn %g3, %g2, %g3
... ... @@ -260,7 +260,7 @@
260 260 /* System call failure, set Carry condition code.
261 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 264 sub %g0, %o0, %o0
265 265 or %g3, %g2, %g3
266 266 stx %o0, [%sp + PTREGS_OFF + PT_V9_I0]