Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: ftrace: Add support for syscall tracepoints.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

+43 -3
+1
arch/mips/Kconfig
··· 19 19 select HAVE_KPROBES 20 20 select HAVE_KRETPROBES 21 21 select HAVE_DEBUG_KMEMLEAK 22 + select HAVE_SYSCALL_TRACEPOINTS 22 23 select ARCH_BINFMT_ELF_RANDOMIZE_PIE 23 24 select HAVE_ARCH_TRANSPARENT_HUGEPAGE if CPU_SUPPORTS_HUGEPAGES && 64BIT 24 25 select RTC_LIB if !MACH_LOONGSON
+19
arch/mips/include/asm/syscall.h
··· 59 59 } 60 60 } 61 61 62 + static inline long syscall_get_return_value(struct task_struct *task, 63 + struct pt_regs *regs) 64 + { 65 + return regs->regs[2]; 66 + } 67 + 68 + static inline void syscall_set_return_value(struct task_struct *task, 69 + struct pt_regs *regs, 70 + int error, long val) 71 + { 72 + if (error) { 73 + regs->regs[2] = -error; 74 + regs->regs[7] = -1; 75 + } else { 76 + regs->regs[2] = val; 77 + regs->regs[7] = 0; 78 + } 79 + } 80 + 62 81 static inline void syscall_get_arguments(struct task_struct *task, 63 82 struct pt_regs *regs, 64 83 unsigned int i, unsigned int n,
+6 -3
arch/mips/include/asm/thread_info.h
··· 116 116 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */ 117 117 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */ 118 118 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */ 119 + #define TIF_SYSCALL_TRACEPOINT 26 /* syscall tracepoint instrumentation */ 119 120 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */ 120 121 121 122 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) ··· 133 132 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR) 134 133 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND) 135 134 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH) 135 + #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT) 136 136 137 137 #define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \ 138 - _TIF_SYSCALL_AUDIT) 138 + _TIF_SYSCALL_AUDIT | _TIF_SYSCALL_TRACEPOINT) 139 139 140 140 /* work to do in syscall_trace_leave() */ 141 141 #define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \ 142 - _TIF_SYSCALL_AUDIT) 142 + _TIF_SYSCALL_AUDIT | _TIF_SYSCALL_TRACEPOINT) 143 143 144 144 /* work to do on interrupt/exception return */ 145 145 #define _TIF_WORK_MASK \ 146 146 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME) 147 147 /* work to do on any return to u-space */ 148 148 #define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \ 149 - _TIF_WORK_SYSCALL_EXIT) 149 + _TIF_WORK_SYSCALL_EXIT | \ 150 + _TIF_SYSCALL_TRACEPOINT) 150 151 151 152 /* 152 153 * We stash processor id into a COP0 register to retrieve it fast
+7
arch/mips/include/asm/unistd.h
··· 14 14 15 15 #include <uapi/asm/unistd.h> 16 16 17 + #ifdef CONFIG_MIPS32_N32 18 + #define NR_syscalls (__NR_N32_Linux + __NR_N32_Linux_syscalls) 19 + #elif defined(CONFIG_64BIT) 20 + #define NR_syscalls (__NR_64_Linux + __NR_64_Linux_syscalls) 21 + #else 22 + #define NR_syscalls (__NR_O32_Linux + __NR_O32_Linux_syscalls) 23 + #endif 17 24 18 25 #ifndef __ASSEMBLY__ 19 26
+10
arch/mips/kernel/ptrace.c
··· 29 29 #include <linux/tracehook.h> 30 30 #include <linux/audit.h> 31 31 #include <linux/seccomp.h> 32 + #include <linux/ftrace.h> 32 33 33 34 #include <asm/byteorder.h> 34 35 #include <asm/cpu.h> ··· 43 42 #include <asm/uaccess.h> 44 43 #include <asm/bootinfo.h> 45 44 #include <asm/reg.h> 45 + 46 + #define CREATE_TRACE_POINTS 47 + #include <trace/events/syscalls.h> 46 48 47 49 /* 48 50 * Called by kernel/ptrace.c when detaching.. ··· 668 664 tracehook_report_syscall_entry(regs)) 669 665 ret = -1; 670 666 667 + if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) 668 + trace_sys_enter(regs, regs->regs[2]); 669 + 671 670 audit_syscall_entry(__syscall_get_arch(), 672 671 regs->regs[2], 673 672 regs->regs[4], regs->regs[5], ··· 691 684 user_exit(); 692 685 693 686 audit_syscall_exit(regs); 687 + 688 + if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) 689 + trace_sys_exit(regs, regs->regs[2]); 694 690 695 691 if (test_thread_flag(TIF_SYSCALL_TRACE)) 696 692 tracehook_report_syscall_exit(regs, 0);