[PATCH 1b] utrace: tracehook for sparc64 This patch does the initial tracehook conversion for sparc64. Signed-off-by: Roland McGrath Signed-off-by: David S. Miller --- arch/sparc64/kernel/entry.S | 6 ------ arch/sparc64/kernel/ptrace.c | 29 +++++++++-------------------- arch/sparc64/kernel/signal.c | 2 ++ arch/sparc64/kernel/signal32.c | 2 ++ include/asm-sparc64/tracehook.h | 40 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 53 insertions(+), 26 deletions(-) create include/asm-sparc64/tracehook.h Index: b/arch/sparc64/kernel/ptrace.c =================================================================== --- a/arch/sparc64/kernel/ptrace.c +++ b/arch/sparc64/kernel/ptrace.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -33,6 +34,7 @@ #include #include +#if 0 /* XXX */ /* Returning from ptrace is a bit tricky because the syscall return * low level code assumes any value returned which is negative and * is a valid errno will mean setting the condition codes to indicate @@ -82,6 +84,7 @@ pt_os_succ_return (struct pt_regs *regs, else pt_succ_return_linux (regs, val, addr); } +#endif /* #define ALLOW_INIT_TRACING */ /* #define DEBUG_PTRACE */ @@ -167,6 +170,7 @@ void flush_ptrace_access(struct vm_area_ } } +#if 0 /* XXX */ asmlinkage void do_ptrace(struct pt_regs *regs) { int request = regs->u_regs[UREG_I0]; @@ -640,11 +644,13 @@ out_tsk: out: unlock_kernel(); } +#endif asmlinkage void syscall_trace(struct pt_regs *regs, int syscall_exit_p) { /* do the secure computing check first */ - secure_computing(regs->u_regs[UREG_G1]); + if (!syscall_exit_p) + secure_computing(regs->u_regs[UREG_G1]); if (unlikely(current->audit_context) && syscall_exit_p) { unsigned long tstate = regs->tstate; @@ -656,26 +662,9 @@ asmlinkage void syscall_trace(struct pt_ audit_syscall_exit(result, regs->u_regs[UREG_I0]); } - if (!(current->ptrace & PT_PTRACED)) - goto out; - - if (!test_thread_flag(TIF_SYSCALL_TRACE)) - goto out; - - ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) - ? 0x80 : 0)); + if (test_thread_flag(TIF_SYSCALL_TRACE)) + tracehook_report_syscall(regs, syscall_exit_p); - /* - * this isn't the same as continuing with a signal, but it will do - * for normal use. strace only continues with a signal if the - * stopping signal is not SIGTRAP. -brl - */ - if (current->exit_code) { - send_sig(current->exit_code, current, 1); - current->exit_code = 0; - } - -out: if (unlikely(current->audit_context) && !syscall_exit_p) audit_syscall_entry((test_thread_flag(TIF_32BIT) ? AUDIT_ARCH_SPARC : Index: b/arch/sparc64/kernel/signal.c =================================================================== --- a/arch/sparc64/kernel/signal.c +++ b/arch/sparc64/kernel/signal.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -491,6 +492,7 @@ static inline void handle_signal(unsigne sigaddset(¤t->blocked,signr); recalc_sigpending(); spin_unlock_irq(¤t->sighand->siglock); + tracehook_report_handle_signal(signr, ka, oldset, regs); } static inline void syscall_restart(unsigned long orig_i0, struct pt_regs *regs, Index: b/arch/sparc64/kernel/signal32.c =================================================================== --- a/arch/sparc64/kernel/signal32.c +++ b/arch/sparc64/kernel/signal32.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -1236,6 +1237,7 @@ static inline void handle_signal32(unsig sigaddset(¤t->blocked,signr); recalc_sigpending(); spin_unlock_irq(¤t->sighand->siglock); + tracehook_report_handle_signal(signr, ka, oldset, regs); } static inline void syscall_restart32(unsigned long orig_i0, struct pt_regs *regs, Index: b/arch/sparc64/kernel/entry.S =================================================================== --- a/arch/sparc64/kernel/entry.S +++ b/arch/sparc64/kernel/entry.S @@ -1410,7 +1410,6 @@ execve_merge: .globl sys_pipe, sys_sigpause, sys_nis_syscall .globl sys_rt_sigreturn - .globl sys_ptrace .globl sys_sigaltstack .align 32 sys_pipe: ba,pt %xcc, sparc_pipe @@ -1453,11 +1452,6 @@ sys32_rt_sigreturn: add %o7, 1f-.-4, %o7 nop #endif -sys_ptrace: add %sp, PTREGS_OFF, %o0 - call do_ptrace - add %o7, 1f-.-4, %o7 - nop - .align 32 1: ldx [%curptr + TI_FLAGS], %l5 andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0 be,pt %icc, rtrap Index: b/include/asm-sparc64/tracehook.h =================================================================== --- /dev/null +++ b/include/asm-sparc64/tracehook.h @@ -0,0 +1,40 @@ +/* + * Tracing hooks, SPARC64 CPU support + * + * Copyright (C) 2006, 2007 Red Hat, Inc. All rights reserved. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU General Public License v.2. + * + * Red Hat Author: Roland McGrath. + */ + +#ifndef _ASM_TRACEHOOK_H +#define _ASM_TRACEHOOK_H 1 + + +#include +#include + +/* + * See linux/tracehook.h for the descriptions of what these need to do. + */ + + +static inline void tracehook_enable_syscall_trace(struct task_struct *tsk) +{ + set_tsk_thread_flag(tsk, TIF_SYSCALL_TRACE); +} + +static inline void tracehook_disable_syscall_trace(struct task_struct *tsk) +{ + clear_tsk_thread_flag(tsk, TIF_SYSCALL_TRACE); +} + +static inline void tracehook_abort_syscall(struct pt_regs *regs) +{ + regs->u_regs[UREG_G1] = -1L; +} + +#endif