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

arch/tile: Call tracehook_report_syscall_{entry,exit} in syscall trace

Call tracehook functions for syscall tracing.

The check for TIF_SYSCALL_TRACE was removed, because the same check is
done right before in the assembly file.

Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com> [with ptrace.h fixup]

authored by

Simon Marchi and committed by
Chris Metcalf
ef182724 a937536b

+29 -26
+2 -1
arch/tile/include/asm/ptrace.h
··· 44 44 struct pt_regs *get_pt_regs(struct pt_regs *); 45 45 46 46 /* Trace the current syscall. */ 47 - extern void do_syscall_trace(void); 47 + extern int do_syscall_trace_enter(struct pt_regs *regs); 48 + extern void do_syscall_trace_exit(struct pt_regs *regs); 48 49 49 50 #define arch_has_single_step() (1) 50 51
+8 -2
arch/tile/kernel/intvec_32.S
··· 1201 1201 lw r30, r31 1202 1202 andi r30, r30, _TIF_SYSCALL_TRACE 1203 1203 bzt r30, .Lrestore_syscall_regs 1204 - jal do_syscall_trace 1204 + { 1205 + PTREGS_PTR(r0, PTREGS_OFFSET_BASE) 1206 + jal do_syscall_trace_enter 1207 + } 1205 1208 FEEDBACK_REENTER(handle_syscall) 1206 1209 1207 1210 /* ··· 1255 1252 lw r30, r31 1256 1253 andi r30, r30, _TIF_SYSCALL_TRACE 1257 1254 bzt r30, 1f 1258 - jal do_syscall_trace 1255 + { 1256 + PTREGS_PTR(r0, PTREGS_OFFSET_BASE) 1257 + jal do_syscall_trace_exit 1258 + } 1259 1259 FEEDBACK_REENTER(handle_syscall) 1260 1260 1: { 1261 1261 movei r30, 0 /* not an NMI */
+8 -2
arch/tile/kernel/intvec_64.S
··· 1006 1006 addi r30, r31, THREAD_INFO_STATUS_OFFSET - THREAD_INFO_FLAGS_OFFSET 1007 1007 beqzt r30, .Lrestore_syscall_regs 1008 1008 } 1009 - jal do_syscall_trace 1009 + { 1010 + PTREGS_PTR(r0, PTREGS_OFFSET_BASE) 1011 + jal do_syscall_trace_enter 1012 + } 1010 1013 FEEDBACK_REENTER(handle_syscall) 1011 1014 1012 1015 /* ··· 1080 1077 andi r0, r30, _TIF_SINGLESTEP 1081 1078 beqzt r0, 1f 1082 1079 } 1083 - jal do_syscall_trace 1080 + { 1081 + PTREGS_PTR(r0, PTREGS_OFFSET_BASE) 1082 + jal do_syscall_trace_exit 1083 + } 1084 1084 FEEDBACK_REENTER(handle_syscall) 1085 1085 andi r0, r30, _TIF_SINGLESTEP 1086 1086
+11 -21
arch/tile/kernel/ptrace.c
··· 21 21 #include <linux/uaccess.h> 22 22 #include <linux/regset.h> 23 23 #include <linux/elf.h> 24 + #include <linux/tracehook.h> 24 25 #include <asm/traps.h> 25 26 #include <arch/chip.h> 26 27 ··· 247 246 } 248 247 #endif 249 248 250 - void do_syscall_trace(void) 249 + int do_syscall_trace_enter(struct pt_regs *regs) 251 250 { 252 - if (!test_thread_flag(TIF_SYSCALL_TRACE)) 253 - return; 254 - 255 - if (!(current->ptrace & PT_PTRACED)) 256 - return; 257 - 258 - /* 259 - * The 0x80 provides a way for the tracing parent to distinguish 260 - * between a syscall stop and SIGTRAP delivery 261 - */ 262 - ptrace_notify(SIGTRAP|((current->ptrace & PT_TRACESYSGOOD) ? 0x80 : 0)); 263 - 264 - /* 265 - * this isn't the same as continuing with a signal, but it will do 266 - * for normal use. strace only continues with a signal if the 267 - * stopping signal is not SIGTRAP. -brl 268 - */ 269 - if (current->exit_code) { 270 - send_sig(current->exit_code, current, 1); 271 - current->exit_code = 0; 251 + if (tracehook_report_syscall_entry(regs)) { 252 + regs->regs[TREG_SYSCALL_NR] = -1; 272 253 } 254 + 255 + return regs->regs[TREG_SYSCALL_NR]; 256 + } 257 + 258 + void do_syscall_trace_exit(struct pt_regs *regs) 259 + { 260 + tracehook_report_syscall_exit(regs, 0); 273 261 } 274 262 275 263 void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code)