Commit ba9c1d65 authored by Max Filippov's avatar Max Filippov

xtensa: rearrange syscall tracing

system_call saves and restores syscall number across system call to make
clone and execv entry and exit tracing match. This complicates things
when syscall code may be changed by ptrace.
Preserve syscall code in copy_thread and start_thread directly instead of
doing tricks in system_call.
Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
parent c2d9aa3b
...@@ -195,6 +195,7 @@ struct thread_struct { ...@@ -195,6 +195,7 @@ struct thread_struct {
/* Clearing a0 terminates the backtrace. */ /* Clearing a0 terminates the backtrace. */
#define start_thread(regs, new_pc, new_sp) \ #define start_thread(regs, new_pc, new_sp) \
do { \ do { \
unsigned long syscall = (regs)->syscall; \
memset((regs), 0, sizeof(*(regs))); \ memset((regs), 0, sizeof(*(regs))); \
(regs)->pc = (new_pc); \ (regs)->pc = (new_pc); \
(regs)->ps = USER_PS_VALUE; \ (regs)->ps = USER_PS_VALUE; \
...@@ -204,7 +205,7 @@ struct thread_struct { ...@@ -204,7 +205,7 @@ struct thread_struct {
(regs)->depc = 0; \ (regs)->depc = 0; \
(regs)->windowbase = 0; \ (regs)->windowbase = 0; \
(regs)->windowstart = 1; \ (regs)->windowstart = 1; \
(regs)->syscall = NO_SYSCALL; \ (regs)->syscall = syscall; \
} while (0) } while (0)
/* Forward declaration */ /* Forward declaration */
......
...@@ -1895,8 +1895,6 @@ ENTRY(system_call) ...@@ -1895,8 +1895,6 @@ ENTRY(system_call)
l32i a7, a2, PT_SYSCALL l32i a7, a2, PT_SYSCALL
1: 1:
s32i a7, a1, 4
/* syscall = sys_call_table[syscall_nr] */ /* syscall = sys_call_table[syscall_nr] */
movi a4, sys_call_table movi a4, sys_call_table
...@@ -1930,12 +1928,8 @@ ENTRY(system_call) ...@@ -1930,12 +1928,8 @@ ENTRY(system_call)
abi_ret(4) abi_ret(4)
1: 1:
l32i a4, a1, 4
l32i a3, a2, PT_SYSCALL
s32i a4, a2, PT_SYSCALL
mov a6, a2 mov a6, a2
call4 do_syscall_trace_leave call4 do_syscall_trace_leave
s32i a3, a2, PT_SYSCALL
abi_ret(4) abi_ret(4)
ENDPROC(system_call) ENDPROC(system_call)
......
...@@ -264,6 +264,8 @@ int copy_thread(unsigned long clone_flags, unsigned long usp_thread_fn, ...@@ -264,6 +264,8 @@ int copy_thread(unsigned long clone_flags, unsigned long usp_thread_fn,
&regs->areg[XCHAL_NUM_AREGS - len/4], len); &regs->areg[XCHAL_NUM_AREGS - len/4], len);
} }
childregs->syscall = regs->syscall;
/* The thread pointer is passed in the '4th argument' (= a5) */ /* The thread pointer is passed in the '4th argument' (= a5) */
if (clone_flags & CLONE_SETTLS) if (clone_flags & CLONE_SETTLS)
childregs->threadptr = childregs->areg[5]; childregs->threadptr = childregs->areg[5];
......
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