Commit fe06ccaa authored by David S. Miller's avatar David S. Miller

sparc64: Split syscall_trace() into two functions.

Christoph Hellwig noticed that having both entry and exit
logic in one function no longer makes sense, and having
seperate ones simplifies things a lot.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 15df0f33
...@@ -22,7 +22,8 @@ extern void do_notify_resume(struct pt_regs *regs, ...@@ -22,7 +22,8 @@ extern void do_notify_resume(struct pt_regs *regs,
unsigned long orig_i0, unsigned long orig_i0,
unsigned long thread_info_flags); unsigned long thread_info_flags);
extern asmlinkage int syscall_trace(struct pt_regs *regs, int syscall_exit_p); extern asmlinkage int syscall_trace_enter(struct pt_regs *regs);
extern asmlinkage void syscall_trace_leave(struct pt_regs *regs);
extern void bad_trap_tl1(struct pt_regs *regs, long lvl); extern void bad_trap_tl1(struct pt_regs *regs, long lvl);
......
...@@ -1050,31 +1050,17 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) ...@@ -1050,31 +1050,17 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
return ret; return ret;
} }
asmlinkage int syscall_trace(struct pt_regs *regs, int syscall_exit_p) asmlinkage int syscall_trace_enter(struct pt_regs *regs)
{ {
int ret = 0; int ret = 0;
/* do the secure computing check first */ /* do the secure computing check first */
secure_computing(regs->u_regs[UREG_G1]); secure_computing(regs->u_regs[UREG_G1]);
if (unlikely(current->audit_context) && syscall_exit_p) { if (test_thread_flag(TIF_SYSCALL_TRACE))
unsigned long tstate = regs->tstate; ret = tracehook_report_syscall_entry(regs);
int result = AUDITSC_SUCCESS;
if (unlikely(tstate & (TSTATE_XCARRY | TSTATE_ICARRY)))
result = AUDITSC_FAILURE;
audit_syscall_exit(result, regs->u_regs[UREG_I0]);
}
if (test_thread_flag(TIF_SYSCALL_TRACE)) {
if (syscall_exit_p)
tracehook_report_syscall_exit(regs, 0);
else
ret = tracehook_report_syscall_entry(regs);
}
if (unlikely(current->audit_context) && !syscall_exit_p && !ret) if (unlikely(current->audit_context) && !ret)
audit_syscall_entry((test_thread_flag(TIF_32BIT) ? audit_syscall_entry((test_thread_flag(TIF_32BIT) ?
AUDIT_ARCH_SPARC : AUDIT_ARCH_SPARC :
AUDIT_ARCH_SPARC64), AUDIT_ARCH_SPARC64),
...@@ -1086,3 +1072,19 @@ asmlinkage int syscall_trace(struct pt_regs *regs, int syscall_exit_p) ...@@ -1086,3 +1072,19 @@ asmlinkage int syscall_trace(struct pt_regs *regs, int syscall_exit_p)
return ret; return ret;
} }
asmlinkage void syscall_trace_leave(struct pt_regs *regs)
{
if (unlikely(current->audit_context)) {
unsigned long tstate = regs->tstate;
int result = AUDITSC_SUCCESS;
if (unlikely(tstate & (TSTATE_XCARRY | TSTATE_ICARRY)))
result = AUDITSC_FAILURE;
audit_syscall_exit(result, regs->u_regs[UREG_I0]);
}
if (test_thread_flag(TIF_SYSCALL_TRACE))
tracehook_report_syscall_exit(regs, 0);
}
...@@ -68,7 +68,6 @@ extern void *__memscan_zero(void *, size_t); ...@@ -68,7 +68,6 @@ extern void *__memscan_zero(void *, size_t);
extern void *__memscan_generic(void *, int, size_t); extern void *__memscan_generic(void *, int, size_t);
extern int __memcmp(const void *, const void *, __kernel_size_t); extern int __memcmp(const void *, const void *, __kernel_size_t);
extern __kernel_size_t strlen(const char *); extern __kernel_size_t strlen(const char *);
extern void syscall_trace(struct pt_regs *, int);
extern void sys_sigsuspend(void); extern void sys_sigsuspend(void);
extern int compat_sys_ioctl(unsigned int fd, unsigned int cmd, u32 arg); extern int compat_sys_ioctl(unsigned int fd, unsigned int cmd, u32 arg);
extern int (*handle_mathemu)(struct pt_regs *, struct fpustate *); extern int (*handle_mathemu)(struct pt_regs *, struct fpustate *);
......
...@@ -65,9 +65,8 @@ sys32_rt_sigreturn: ...@@ -65,9 +65,8 @@ sys32_rt_sigreturn:
andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0 andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT), %g0
be,pt %icc, rtrap be,pt %icc, rtrap
nop nop
add %sp, PTREGS_OFF, %o0 call syscall_trace_leave
call syscall_trace add %sp, PTREGS_OFF, %o0
mov 1, %o1
ba,pt %xcc, rtrap ba,pt %xcc, rtrap
nop nop
...@@ -159,9 +158,8 @@ linux_sparc_ni_syscall: ...@@ -159,9 +158,8 @@ linux_sparc_ni_syscall:
or %l7, %lo(sys_ni_syscall), %l7 or %l7, %lo(sys_ni_syscall), %l7
linux_syscall_trace32: linux_syscall_trace32:
add %sp, PTREGS_OFF, %o0 call syscall_trace_enter
call syscall_trace add %sp, PTREGS_OFF, %o0
clr %o1
brnz,pn %o0, 3f brnz,pn %o0, 3f
mov -ENOSYS, %o0 mov -ENOSYS, %o0
srl %i0, 0, %o0 srl %i0, 0, %o0
...@@ -172,9 +170,8 @@ linux_syscall_trace32: ...@@ -172,9 +170,8 @@ linux_syscall_trace32:
srl %i3, 0, %o3 srl %i3, 0, %o3
linux_syscall_trace: linux_syscall_trace:
add %sp, PTREGS_OFF, %o0 call syscall_trace_enter
call syscall_trace add %sp, PTREGS_OFF, %o0
clr %o1
brnz,pn %o0, 3f brnz,pn %o0, 3f
mov -ENOSYS, %o0 mov -ENOSYS, %o0
mov %i0, %o0 mov %i0, %o0
...@@ -275,9 +272,8 @@ ret_sys_call: ...@@ -275,9 +272,8 @@ ret_sys_call:
b,pt %xcc, rtrap b,pt %xcc, rtrap
stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC] stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
linux_syscall_trace2: linux_syscall_trace2:
add %sp, PTREGS_OFF, %o0 call syscall_trace_leave
call syscall_trace add %sp, PTREGS_OFF, %o0
mov 1, %o1
stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC] stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]
ba,pt %xcc, rtrap ba,pt %xcc, rtrap
stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC] stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment