aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Filippov <jcmvbkbc@gmail.com>2015-03-16 07:40:14 -0400
committerMax Filippov <jcmvbkbc@gmail.com>2017-05-01 10:00:10 -0400
commitf984409a00e7d9aa40af64d7c9619e5de3d980bf (patch)
tree5ea7712929934f428eba2d59abf3eda6e6532d2b
parent0700ed072feffd65212e6a03840d19c4988d6820 (diff)
xtensa: use generic tracehooks
Use tracehook_report_syscall_{entry,exit} instead of a local copy of it in do_syscall_trace. Allow tracehook to cancel syscall by returning invalid syscall number to the system_call function. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
-rw-r--r--arch/xtensa/kernel/entry.S3
-rw-r--r--arch/xtensa/kernel/ptrace.c38
2 files changed, 14 insertions, 27 deletions
diff --git a/arch/xtensa/kernel/entry.S b/arch/xtensa/kernel/entry.S
index f5ef3cc0497c..37a239556889 100644
--- a/arch/xtensa/kernel/entry.S
+++ b/arch/xtensa/kernel/entry.S
@@ -1899,10 +1899,11 @@ ENTRY(system_call)
1899 movi a4, do_syscall_trace_enter 1899 movi a4, do_syscall_trace_enter
1900 s32i a3, a2, PT_SYSCALL 1900 s32i a3, a2, PT_SYSCALL
1901 callx4 a4 1901 callx4 a4
1902 mov a3, a6
1902 1903
1903 /* syscall = sys_call_table[syscall_nr] */ 1904 /* syscall = sys_call_table[syscall_nr] */
1904 1905
1905 movi a4, sys_call_table; 1906 movi a4, sys_call_table
1906 movi a5, __NR_syscall_count 1907 movi a5, __NR_syscall_count
1907 movi a6, -ENOSYS 1908 movi a6, -ENOSYS
1908 bgeu a3, a5, 1f 1909 bgeu a3, a5, 1f
diff --git a/arch/xtensa/kernel/ptrace.c b/arch/xtensa/kernel/ptrace.c
index ae7985ec7b8e..e2461968efb2 100644
--- a/arch/xtensa/kernel/ptrace.c
+++ b/arch/xtensa/kernel/ptrace.c
@@ -23,6 +23,7 @@
23#include <linux/security.h> 23#include <linux/security.h>
24#include <linux/signal.h> 24#include <linux/signal.h>
25#include <linux/smp.h> 25#include <linux/smp.h>
26#include <linux/tracehook.h>
26#include <linux/uaccess.h> 27#include <linux/uaccess.h>
27 28
28#include <asm/coprocessor.h> 29#include <asm/coprocessor.h>
@@ -468,36 +469,21 @@ long arch_ptrace(struct task_struct *child, long request,
468 return ret; 469 return ret;
469} 470}
470 471
471void do_syscall_trace(void) 472unsigned long do_syscall_trace_enter(struct pt_regs *regs)
472{
473 /*
474 * The 0x80 provides a way for the tracing parent to distinguish
475 * between a syscall stop and SIGTRAP delivery
476 */
477 ptrace_notify(SIGTRAP |
478 ((current->ptrace & PT_TRACESYSGOOD) ? 0x80 : 0));
479
480 /*
481 * this isn't the same as continuing with a signal, but it will do
482 * for normal use. strace only continues with a signal if the
483 * stopping signal is not SIGTRAP. -brl
484 */
485 if (current->exit_code) {
486 send_sig(current->exit_code, current, 1);
487 current->exit_code = 0;
488 }
489}
490
491void do_syscall_trace_enter(struct pt_regs *regs)
492{ 473{
493 if (test_thread_flag(TIF_SYSCALL_TRACE) && 474 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
494 (current->ptrace & PT_PTRACED)) 475 tracehook_report_syscall_entry(regs))
495 do_syscall_trace(); 476 return -1;
477
478 return regs->areg[2];
496} 479}
497 480
498void do_syscall_trace_leave(struct pt_regs *regs) 481void do_syscall_trace_leave(struct pt_regs *regs)
499{ 482{
500 if (test_thread_flag(TIF_SYSCALL_TRACE) && 483 int step;
501 (current->ptrace & PT_PTRACED)) 484
502 do_syscall_trace(); 485 step = test_thread_flag(TIF_SINGLESTEP);
486
487 if (step || test_thread_flag(TIF_SYSCALL_TRACE))
488 tracehook_report_syscall_exit(regs, step);
503} 489}