Skip to content

Commit 2798af1

Browse files
jkkmKyle McMartin
authored andcommitted
parisc: split syscall_trace into two halves
Instead of fiddling with gr[20], restructure code to return whether or not to -ENOSYS. (Also do a bit of fiddling to let them take pt_regs directly instead of re-computing it.) Signed-off-by: Kyle McMartin <[email protected]>
1 parent 5837d42 commit 2798af1

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

arch/parisc/kernel/ptrace.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -264,20 +264,19 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
264264
}
265265
#endif
266266

267+
long do_syscall_trace_enter(struct pt_regs *regs)
268+
{
269+
if (test_thread_flag(TIF_SYSCALL_TRACE) &&
270+
tracehook_report_syscall_entry(regs))
271+
return -1L;
272+
273+
return regs->gr[20];
274+
}
267275

268-
void syscall_trace(int why)
276+
void do_syscall_trace_exit(struct pt_regs *regs)
269277
{
270-
struct pt_regs *regs = &current->thread.regs;
278+
int stepping = !!(current->ptrace & (PT_SINGLESTEP|PT_BLOCKSTEP));
271279

272-
if (!test_thread_flag(TIF_SYSCALL_TRACE))
273-
return;
274-
/*
275-
* Report the system call for tracing. Entry tracing can
276-
* decide to abort the call. We handle that by setting an
277-
* invalid syscall number (-1) to force an ENOSYS error.
278-
*/
279-
if (why)
280-
tracehook_report_syscall_exit(regs, 0);
281-
else if (tracehook_report_syscall_entry(regs))
282-
regs->gr[20] = -1; /* force ENOSYS */
280+
if (stepping || test_thread_flag(TIF_SYSCALL_TRACE))
281+
tracehook_report_syscall_exit(regs, stepping);
283282
}

arch/parisc/kernel/syscall.S

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -288,19 +288,23 @@ tracesys:
288288
STREG %r18,PT_GR18(%r2)
289289
/* Finished saving things for the debugger */
290290

291-
ldi 0,%r26 /* syscall entry */
292-
ldil L%syscall_trace,%r1
291+
copy %r2,%r26
292+
ldil L%do_syscall_trace_enter,%r1
293293
ldil L%tracesys_next,%r2
294-
be R%syscall_trace(%sr7,%r1)
294+
be R%do_syscall_trace_enter(%sr7,%r1)
295295
ldo R%tracesys_next(%r2),%r2
296296

297-
tracesys_next:
297+
tracesys_next:
298+
/* do_syscall_trace_enter either returned the syscallno, or -1L,
299+
* so we skip restoring the PT_GR20 below, since we pulled it from
300+
* task->thread.regs.gr[20] above.
301+
*/
302+
copy %ret0,%r20
298303
ldil L%sys_call_table,%r1
299304
ldo R%sys_call_table(%r1), %r19
300305

301306
ldo -THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1 /* get task ptr */
302307
LDREG TI_TASK(%r1), %r1
303-
LDREG TASK_PT_GR20(%r1), %r20
304308
LDREG TASK_PT_GR26(%r1), %r26 /* Restore the users args */
305309
LDREG TASK_PT_GR25(%r1), %r25
306310
LDREG TASK_PT_GR24(%r1), %r24
@@ -337,8 +341,8 @@ tracesys_exit:
337341
#ifdef CONFIG_64BIT
338342
ldo -16(%r30),%r29 /* Reference param save area */
339343
#endif
340-
ldi 1,%r26 /* syscall exit */
341-
bl syscall_trace, %r2
344+
ldo TASK_REGS(%r1),%r26
345+
bl do_syscall_trace_exit,%r2
342346
STREG %r28,TASK_PT_GR28(%r1) /* save return value now */
343347
ldo -THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1 /* get task ptr */
344348
LDREG TI_TASK(%r1), %r1
@@ -359,8 +363,8 @@ tracesys_sigexit:
359363
#ifdef CONFIG_64BIT
360364
ldo -16(%r30),%r29 /* Reference param save area */
361365
#endif
362-
bl syscall_trace, %r2
363-
ldi 1,%r26 /* syscall exit */
366+
bl do_syscall_trace_exit,%r2
367+
ldo TASK_REGS(%r1),%r26
364368

365369
ldil L%syscall_exit_rfi,%r1
366370
be,n R%syscall_exit_rfi(%sr7,%r1)

0 commit comments

Comments
 (0)