ARM support for syscall tracing
I believe I have incorporated all of the suggestions given on the previous patches. Unfortunately, NR_syscalls is still a hard-coded number. I implemented making it a variable that was exported from entry-common.o, but there are places that assume that NR_syscalls is a constant known at compile time:
kernel/trace/trace_syscalls.c:15:
static DECLARE_BITMAP(enabled_enter_syscalls, NR_syscalls);
However, entry-common.S will check to ensure that a call doesn't get added to the table without bumping NR_syscalls when needed. I'm not sure this can be improved upon without tearing up core kernel code.
Suggestions welcome!
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 3/3 ARM: support syscall tracing
Hi Steven,
Just a minor comment:
arch/arm/kernel/entry-common.S no_work_pending: · line 86
Quoted 13 lines · Steven Walter
arch/arm/kernel/entry-common.S +5
-0@@ -79,6 +79,11 @@ no_work_pending: ENDPROC(ret_to_user_from_irq) ENDPROC(ret_to_user) +.macro test_syscall_tracing reg + tst \reg, #_TIF_SYSCALL_TRACE + tsteq \reg, #_TIF_SYSCALL_TRACEPOINT +.endm +
You could put this macro in entry-header.S instead.
Will
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 1/3 ARM: add support for the generic syscall.h interface
Review
Quoted 6 lines · Steven Walter
(quoted diff) +6
-0+static inline void syscall_get_arguments(struct task_struct *task, + struct pt_regs *regs, + unsigned int i, unsigned int n, + unsigned long *args) +{ + BUG_ON(i + n > 6);
So I guess 6 is the maximum number of registers that are used for syscall passing. That sounds about right to me, but I wondered how you worked it out (and whether or not it should be defined somewhere?).
In fact, how are these things supposed to deal with 64-bit arguments that straddle two registers? I think we always pack arguments such that we don't get holes in the register layout, but it might be worth checking (EABI requires 64-bit arguments to be passed in even registers).
Review
Quoted 8 lines
(quoted diff) +8
-0+ if (i == 0) { + args[0] = regs->ARM_ORIG_r0; + args++; + i++; + n--; + } + + memcpy(args, ®s->ARM_r1 + (i - 1), n * sizeof(args[0]));
This might look nicer as ®s->ARM_r0 + i. args[0] could also be out of range here, but I guess sizeof is ok with that.
Quoted 6 lines
(quoted diff) +6
-0+ +static inline void syscall_set_arguments(struct task_struct *task, + struct pt_regs *regs, + unsigned int i, unsigned int n, + const unsigned long *args) +{
Review
Quoted 10 lines
(quoted diff) +10
-0+ BUG_ON(i + n > 6); + if (i == 0) { + regs->ARM_ORIG_r0 = args[0]; + args++; + i++; + n--; + } + + memcpy(®s->ARM_r1 + (i - 1), args, n * sizeof(args[0])); +}
Same comments here.
Will
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v2 2/3 ARM: add TRACEHOOK support
Minor nit (pedantry):
Review
Quoted 6 lines · Steven Walter
(quoted diff) +6
-0+ if (why) { + tracehook_report_syscall_exit(regs, 0); + } else { + if (tracehook_report_syscall_entry(regs)) + current_thread_info()->syscall = -1; + }
You could bang the second if next to the else and lose the braces.
Will