Skip to content

Commit ba9c1d6

Browse files
committed
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: Max Filippov <[email protected]>
1 parent c2d9aa3 commit ba9c1d6

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

arch/xtensa/include/asm/processor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ struct thread_struct {
195195
/* Clearing a0 terminates the backtrace. */
196196
#define start_thread(regs, new_pc, new_sp) \
197197
do { \
198+
unsigned long syscall = (regs)->syscall; \
198199
memset((regs), 0, sizeof(*(regs))); \
199200
(regs)->pc = (new_pc); \
200201
(regs)->ps = USER_PS_VALUE; \
@@ -204,7 +205,7 @@ struct thread_struct {
204205
(regs)->depc = 0; \
205206
(regs)->windowbase = 0; \
206207
(regs)->windowstart = 1; \
207-
(regs)->syscall = NO_SYSCALL; \
208+
(regs)->syscall = syscall; \
208209
} while (0)
209210

210211
/* Forward declaration */

arch/xtensa/kernel/entry.S

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,8 +1895,6 @@ ENTRY(system_call)
18951895
l32i a7, a2, PT_SYSCALL
18961896

18971897
1:
1898-
s32i a7, a1, 4
1899-
19001898
/* syscall = sys_call_table[syscall_nr] */
19011899

19021900
movi a4, sys_call_table
@@ -1930,12 +1928,8 @@ ENTRY(system_call)
19301928
abi_ret(4)
19311929

19321930
1:
1933-
l32i a4, a1, 4
1934-
l32i a3, a2, PT_SYSCALL
1935-
s32i a4, a2, PT_SYSCALL
19361931
mov a6, a2
19371932
call4 do_syscall_trace_leave
1938-
s32i a3, a2, PT_SYSCALL
19391933
abi_ret(4)
19401934

19411935
ENDPROC(system_call)

arch/xtensa/kernel/process.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ int copy_thread(unsigned long clone_flags, unsigned long usp_thread_fn,
264264
&regs->areg[XCHAL_NUM_AREGS - len/4], len);
265265
}
266266

267+
childregs->syscall = regs->syscall;
268+
267269
/* The thread pointer is passed in the '4th argument' (= a5) */
268270
if (clone_flags & CLONE_SETTLS)
269271
childregs->threadptr = childregs->areg[5];

0 commit comments

Comments
 (0)