Skip to content

Commit 12f79be

Browse files
author
Al Viro
committed
alpha: don't open-code trace_report_syscall_{enter,exit}
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 3cffdc8 commit 12f79be

2 files changed

Lines changed: 19 additions & 26 deletions

File tree

‎arch/alpha/kernel/entry.S‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,10 @@ $work_notifysig:
418418
strace:
419419
/* set up signal stack, call syscall_trace */
420420
bsr $1, do_switch_stack
421-
jsr $26, syscall_trace
421+
jsr $26, syscall_trace_enter /* returns the syscall number */
422422
bsr $1, undo_switch_stack
423423

424-
/* get the system call number and the arguments back.. */
425-
ldq $0, 0($sp)
424+
/* get the arguments back.. */
426425
ldq $16, SP_OFF+24($sp)
427426
ldq $17, SP_OFF+32($sp)
428427
ldq $18, SP_OFF+40($sp)
@@ -449,7 +448,7 @@ $strace_success:
449448
stq $0, 0($sp) /* save return value */
450449

451450
bsr $1, do_switch_stack
452-
jsr $26, syscall_trace
451+
jsr $26, syscall_trace_leave
453452
bsr $1, undo_switch_stack
454453
br $31, ret_from_sys_call
455454

@@ -467,7 +466,7 @@ $strace_error:
467466
bsr $1, do_switch_stack
468467
mov $19, $9 /* save old syscall number */
469468
mov $20, $10 /* save old a3 */
470-
jsr $26, syscall_trace
469+
jsr $26, syscall_trace_leave
471470
mov $9, $19
472471
mov $10, $20
473472
bsr $1, undo_switch_stack
@@ -698,7 +697,7 @@ sys_sigreturn:
698697
lda $sp, -SWITCH_STACK_SIZE($sp)
699698
jsr $26, do_sigreturn
700699
bne $9, 1f
701-
jsr $26, syscall_trace
700+
jsr $26, syscall_trace_leave
702701
1: br $1, undo_switch_stack
703702
br ret_from_sys_call
704703
.end sys_sigreturn
@@ -715,7 +714,7 @@ sys_rt_sigreturn:
715714
lda $sp, -SWITCH_STACK_SIZE($sp)
716715
jsr $26, do_rt_sigreturn
717716
bne $9, 1f
718-
jsr $26, syscall_trace
717+
jsr $26, syscall_trace_leave
719718
1: br $1, undo_switch_stack
720719
br ret_from_sys_call
721720
.end sys_rt_sigreturn

‎arch/alpha/kernel/ptrace.c‎

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/user.h>
1414
#include <linux/security.h>
1515
#include <linux/signal.h>
16+
#include <linux/tracehook.h>
1617

1718
#include <asm/uaccess.h>
1819
#include <asm/pgtable.h>
@@ -312,25 +313,18 @@ long arch_ptrace(struct task_struct *child, long request,
312313
return ret;
313314
}
314315

316+
asmlinkage unsigned long syscall_trace_enter(void)
317+
{
318+
unsigned long ret = 0;
319+
if (test_thread_flag(TIF_SYSCALL_TRACE) &&
320+
tracehook_report_syscall_entry(current_pt_regs()))
321+
ret = -1UL;
322+
return ret ?: current_pt_regs()->r0;
323+
}
324+
315325
asmlinkage void
316-
syscall_trace(void)
326+
syscall_trace_leave(void)
317327
{
318-
if (!test_thread_flag(TIF_SYSCALL_TRACE))
319-
return;
320-
if (!(current->ptrace & PT_PTRACED))
321-
return;
322-
/* The 0x80 provides a way for the tracing parent to distinguish
323-
between a syscall stop and SIGTRAP delivery */
324-
ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
325-
? 0x80 : 0));
326-
327-
/*
328-
* This isn't the same as continuing with a signal, but it will do
329-
* for normal use. strace only continues with a signal if the
330-
* stopping signal is not SIGTRAP. -brl
331-
*/
332-
if (current->exit_code) {
333-
send_sig(current->exit_code, current, 1);
334-
current->exit_code = 0;
335-
}
328+
if (test_thread_flag(TIF_SYSCALL_TRACE))
329+
tracehook_report_syscall_exit(current_pt_regs(), 0);
336330
}

0 commit comments

Comments
 (0)