sparc64: Add syscall tracepoint support.

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

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