Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 107598
b: refs/heads/master
c: ab99c73
h: refs/heads/master
v: v3
  • Loading branch information
Paul Mundt committed Aug 1, 2008
1 parent fcea30e commit 9ad6ca0
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 159 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c459dbf294b4a3d70490a468a7ca3907fb2c2f57
refs/heads/master: ab99c733ae73cce31f2a2434f7099564e5a73d95
11 changes: 7 additions & 4 deletions trunk/arch/sh/include/asm/thread_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,11 @@ static inline struct thread_info *current_thread_info(void)
#define TIF_SINGLESTEP 4 /* singlestepping active */
#define TIF_SYSCALL_AUDIT 5 /* syscall auditing active */
#define TIF_SECCOMP 6 /* secure computing */
#define TIF_NOTIFY_RESUME 7 /* callback before returning to user */
#define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
#define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */
#define TIF_MEMDIE 18
#define TIF_FREEZE 19
#define TIF_FREEZE 19 /* Freezing for suspend */

#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
Expand All @@ -131,6 +132,7 @@ static inline struct thread_info *current_thread_info(void)
#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
#define _TIF_SECCOMP (1 << TIF_SECCOMP)
#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
#define _TIF_USEDFPU (1 << TIF_USEDFPU)
#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
#define _TIF_FREEZE (1 << TIF_FREEZE)
Expand All @@ -146,9 +148,10 @@ static inline struct thread_info *current_thread_info(void)
_TIF_SYSCALL_AUDIT | _TIF_SECCOMP)

/* work to do on any return to u-space */
#define _TIF_ALLWORK_MASK (_TIF_SYSCALL_TRACE | _TIF_SIGPENDING | \
_TIF_NEED_RESCHED | _TIF_SYSCALL_AUDIT | \
_TIF_SINGLESTEP | _TIF_RESTORE_SIGMASK)
#define _TIF_ALLWORK_MASK (_TIF_SYSCALL_TRACE | _TIF_SIGPENDING | \
_TIF_NEED_RESCHED | _TIF_SYSCALL_AUDIT | \
_TIF_SINGLESTEP | _TIF_RESTORE_SIGMASK | \
_TIF_NOTIFY_RESUME)

/* work to do on interrupt/exception return */
#define _TIF_WORK_MASK (_TIF_ALLWORK_MASK & ~(_TIF_SYSCALL_TRACE | \
Expand Down
17 changes: 9 additions & 8 deletions trunk/arch/sh/kernel/cpu/sh5/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -987,11 +987,11 @@ work_resched:
work_notifysig:
gettr tr1, LINK

movi do_signal, r6
movi do_notify_resume, r6
ptabs r6, tr0
or SP, ZERO, r2
or ZERO, ZERO, r3
blink tr0, LINK /* Call do_signal(regs, 0), return here */
or r7, ZERO, r3
blink tr0, LINK /* Call do_notify_resume(regs, current_thread_info->flags), return here */

restore_all:
/* Do prefetches */
Expand Down Expand Up @@ -1305,13 +1305,15 @@ syscall_allowed:
beq/l r6, ZERO, tr0

/* Trace it by calling syscall_trace before and after */
movi syscall_trace, r4
movi do_syscall_trace_enter, r4
or SP, ZERO, r2
or ZERO, ZERO, r3
ptabs r4, tr0
blink tr0, LINK

/* Reload syscall number as r5 is trashed by syscall_trace */
/* Save the retval */
st.q SP, FRAME_R(2), r2

/* Reload syscall number as r5 is trashed by do_syscall_trace_enter */
ld.q SP, FRAME_S(FSYSCALL_ID), r5
andi r5, 0x1ff, r5

Expand Down Expand Up @@ -1343,9 +1345,8 @@ syscall_ret_trace:
/* We get back here only if under trace */
st.q SP, FRAME_R(9), r2 /* Save return value */

movi syscall_trace, LINK
movi do_syscall_trace_leave, LINK
or SP, ZERO, r2
movi 1, r3
ptabs LINK, tr0
blink tr0, LINK

Expand Down
12 changes: 5 additions & 7 deletions trunk/arch/sh/kernel/entry-common.S
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,8 @@ syscall_exit_work:
nop
#endif
sti
! XXX setup arguments...
mov r15, r4
mov #1, r5
mov.l 4f, r0 ! do_syscall_trace
mov.l 8f, r0 ! do_syscall_trace_leave
jsr @r0
nop
bra resume_userspace
Expand All @@ -223,12 +221,11 @@ syscall_exit_work:
.align 2
syscall_trace_entry:
! Yes it is traced.
! XXX setup arguments...
mov r15, r4
mov #0, r5
mov.l 4f, r11 ! Call do_syscall_trace which notifies
mov.l 7f, r11 ! Call do_syscall_trace_enter which notifies
jsr @r11 ! superior (will chomp R[0-7])
nop
mov.l r0, @(OFF_R0,r15) ! Save return value
! Reload R0-R4 from kernel stack, where the
! parent may have modified them using
! ptrace(POKEUSR). (Note that R0-R2 are
Expand Down Expand Up @@ -389,8 +386,9 @@ syscall_exit:
#endif
2: .long NR_syscalls
3: .long sys_call_table
4: .long do_syscall_trace
#ifdef CONFIG_TRACE_IRQFLAGS
5: .long trace_hardirqs_on
6: .long trace_hardirqs_off
#endif
7: .long do_syscall_trace_enter
8: .long do_syscall_trace_leave
54 changes: 26 additions & 28 deletions trunk/arch/sh/kernel/ptrace_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <linux/io.h>
#include <linux/audit.h>
#include <linux/seccomp.h>
#include <linux/tracehook.h>
#include <asm/uaccess.h>
#include <asm/pgtable.h>
#include <asm/system.h>
Expand Down Expand Up @@ -216,41 +217,38 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
return ret;
}

asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit)
asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
{
struct task_struct *tsk = current;
long ret = 0;

secure_computing(regs->regs[0]);

if (unlikely(current->audit_context) && entryexit)
audit_syscall_exit(AUDITSC_RESULT(regs->regs[0]),
regs->regs[0]);

if (!test_thread_flag(TIF_SYSCALL_TRACE) &&
!test_thread_flag(TIF_SINGLESTEP))
goto out;
if (!(tsk->ptrace & PT_PTRACED))
goto out;

/* the 0x80 provides a way for the tracing parent to distinguish
between a syscall stop and SIGTRAP delivery */
ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) &&
!test_thread_flag(TIF_SINGLESTEP) ? 0x80 : 0));

/*
* 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 (tsk->exit_code) {
send_sig(tsk->exit_code, tsk, 1);
tsk->exit_code = 0;
}
if (test_thread_flag(TIF_SYSCALL_TRACE) &&
tracehook_report_syscall_entry(regs))
/*
* Tracing decided this syscall should not happen.
* We'll return a bogus call number to get an ENOSYS
* error, but leave the original number in regs->regs[0].
*/
ret = -1L;

out:
if (unlikely(current->audit_context) && !entryexit)
if (unlikely(current->audit_context))
audit_syscall_entry(AUDIT_ARCH_SH, regs->regs[3],
regs->regs[4], regs->regs[5],
regs->regs[6], regs->regs[7]);

return ret ?: regs->regs[0];
}

asmlinkage void do_syscall_trace_leave(struct pt_regs *regs)
{
int step;

if (unlikely(current->audit_context))
audit_syscall_exit(AUDITSC_RESULT(regs->regs[0]),
regs->regs[0]);

step = test_thread_flag(TIF_SINGLESTEP);
if (step || test_thread_flag(TIF_SYSCALL_TRACE))
tracehook_report_syscall_exit(regs, step);
}
50 changes: 24 additions & 26 deletions trunk/arch/sh/kernel/ptrace_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <linux/syscalls.h>
#include <linux/audit.h>
#include <linux/seccomp.h>
#include <linux/tracehook.h>
#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/pgtable.h>
Expand Down Expand Up @@ -221,40 +222,37 @@ asmlinkage int sh64_ptrace(long request, long pid, long addr, long data)
return sys_ptrace(request, pid, addr, data);
}

asmlinkage void syscall_trace(struct pt_regs *regs, int entryexit)
asmlinkage long long do_syscall_trace_enter(struct pt_regs *regs)
{
struct task_struct *tsk = current;
long long ret = 0;

secure_computing(regs->regs[9]);

if (unlikely(current->audit_context) && entryexit)
audit_syscall_exit(AUDITSC_RESULT(regs->regs[9]),
regs->regs[9]);

if (!test_thread_flag(TIF_SYSCALL_TRACE) &&
!test_thread_flag(TIF_SINGLESTEP))
goto out;
if (!(tsk->ptrace & PT_PTRACED))
goto out;

ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) &&
!test_thread_flag(TIF_SINGLESTEP) ? 0x80 : 0));

/*
* 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 (tsk->exit_code) {
send_sig(tsk->exit_code, tsk, 1);
tsk->exit_code = 0;
}
if (test_thread_flag(TIF_SYSCALL_TRACE) &&
tracehook_report_syscall_entry(regs))
/*
* Tracing decided this syscall should not happen.
* We'll return a bogus call number to get an ENOSYS
* error, but leave the original number in regs->regs[0].
*/
ret = -1LL;

out:
if (unlikely(current->audit_context) && !entryexit)
if (unlikely(current->audit_context))
audit_syscall_entry(AUDIT_ARCH_SH, regs->regs[1],
regs->regs[2], regs->regs[3],
regs->regs[4], regs->regs[5]);

return ret ?: regs->regs[9];
}

asmlinkage void do_syscall_trace_leave(struct pt_regs *regs)
{
if (unlikely(current->audit_context))
audit_syscall_exit(AUDITSC_RESULT(regs->regs[9]),
regs->regs[9]);

if (test_thread_flag(TIF_SYSCALL_TRACE))
tracehook_report_syscall_exit(regs, 0);
}

/* Called with interrupts disabled */
Expand Down
22 changes: 15 additions & 7 deletions trunk/arch/sh/kernel/signal_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <linux/binfmts.h>
#include <linux/freezer.h>
#include <linux/io.h>
#include <linux/tracehook.h>
#include <asm/system.h>
#include <asm/ucontext.h>
#include <asm/uaccess.h>
Expand Down Expand Up @@ -507,14 +508,13 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
switch (regs->regs[0]) {
case -ERESTART_RESTARTBLOCK:
case -ERESTARTNOHAND:
no_system_call_restart:
regs->regs[0] = -EINTR;
break;

case -ERESTARTSYS:
if (!(ka->sa.sa_flags & SA_RESTART)) {
regs->regs[0] = -EINTR;
break;
}
if (!(ka->sa.sa_flags & SA_RESTART))
goto no_system_call_restart;
/* fallthrough */
case -ERESTARTNOINTR:
regs->regs[0] = save_r0;
Expand Down Expand Up @@ -589,12 +589,15 @@ static void do_signal(struct pt_regs *regs, unsigned int save_r0)
* clear the TIF_RESTORE_SIGMASK flag */
if (test_thread_flag(TIF_RESTORE_SIGMASK))
clear_thread_flag(TIF_RESTORE_SIGMASK);

tracehook_signal_handler(signr, &info, &ka, regs,
test_thread_flag(TIF_SINGLESTEP));
}

return;
}

no_signal:
no_signal:
/* Did we come from a system call? */
if (regs->tra >= 0) {
/* Restart the system call - no handlers present */
Expand All @@ -618,9 +621,14 @@ static void do_signal(struct pt_regs *regs, unsigned int save_r0)
}

asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned int save_r0,
__u32 thread_info_flags)
unsigned long thread_info_flags)
{
/* deal with pending signal delivery */
if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK))
if (thread_info_flags & _TIF_SIGPENDING)
do_signal(regs, save_r0);

if (thread_info_flags & _TIF_NOTIFY_RESUME) {
clear_thread_flag(TIF_NOTIFY_RESUME);
tracehook_notify_resume(regs);
}
}
Loading

0 comments on commit 9ad6ca0

Please sign in to comment.