Skip to content

Commit 1f66e06

Browse files
Wade FarnsworthRussell King
Wade Farnsworth
authored and
Russell King
committed
ARM: 7524/1: support syscall tracing
As specified by ftrace-design.txt, TIF_SYSCALL_TRACEPOINT was added, as well as NR_syscalls in asm/unistd.h. Additionally, __sys_trace was modified to call trace_sys_enter and trace_sys_exit when appropriate. Tests #2 - #4 of "perf test" now complete successfully. Signed-off-by: Steven Walter <stevenrwalter@gmail.com> Signed-off-by: Wade Farnsworth <wade_farnsworth@mentor.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent 5698bd7 commit 1f66e06

File tree

6 files changed

+34
-3
lines changed

6 files changed

+34
-3
lines changed

arch/arm/Kconfig

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ config ARM
1616
select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL
1717
select HAVE_ARCH_KGDB
1818
select HAVE_ARCH_TRACEHOOK
19+
select HAVE_SYSCALL_TRACEPOINTS
1920
select HAVE_KPROBES if !XIP_KERNEL
2021
select HAVE_KRETPROBES if (HAVE_KPROBES)
2122
select HAVE_FUNCTION_TRACER if (!XIP_KERNEL)

arch/arm/include/asm/syscall.h

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
#include <linux/err.h>
1111

12+
#include <asm/unistd.h>
13+
14+
#define NR_syscalls (__NR_syscalls)
15+
1216
extern const unsigned long sys_call_table[];
1317

1418
static inline int syscall_get_nr(struct task_struct *task,

arch/arm/include/asm/thread_info.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
148148
#define TIF_NOTIFY_RESUME 2 /* callback before returning to user */
149149
#define TIF_SYSCALL_TRACE 8
150150
#define TIF_SYSCALL_AUDIT 9
151+
#define TIF_SYSCALL_TRACEPOINT 10
151152
#define TIF_POLLING_NRFLAG 16
152153
#define TIF_USING_IWMMXT 17
153154
#define TIF_MEMDIE 18 /* is terminating due to OOM killer */
@@ -160,12 +161,13 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
160161
#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
161162
#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
162163
#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
164+
#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
163165
#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
164166
#define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
165167
#define _TIF_SECCOMP (1 << TIF_SECCOMP)
166168

167169
/* Checks for any syscall work in entry-common.S */
168-
#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
170+
#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SYSCALL_TRACEPOINT)
169171

170172
/*
171173
* Change these and you break ASM code in entry-common.S

arch/arm/include/asm/unistd.h

+8
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,14 @@
405405
#define __NR_process_vm_readv (__NR_SYSCALL_BASE+376)
406406
#define __NR_process_vm_writev (__NR_SYSCALL_BASE+377)
407407

408+
/*
409+
* This may need to be greater than __NR_last_syscall+1 in order to
410+
* account for the padding in the syscall table
411+
*/
412+
#ifdef __KERNEL__
413+
#define __NR_syscalls (380)
414+
#endif /* __KERNEL__ */
415+
408416
/*
409417
* The following SWIs are ARM private.
410418
*/

arch/arm/kernel/entry-common.S

+9
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ ENDPROC(ret_from_fork)
9494
.equ NR_syscalls,0
9595
#define CALL(x) .equ NR_syscalls,NR_syscalls+1
9696
#include "calls.S"
97+
98+
/*
99+
* Ensure that the system call table is equal to __NR_syscalls,
100+
* which is the value the rest of the system sees
101+
*/
102+
.ifne NR_syscalls - __NR_syscalls
103+
.error "__NR_syscalls is not equal to the size of the syscall table"
104+
.endif
105+
97106
#undef CALL
98107
#define CALL(x) .long x
99108

arch/arm/kernel/ptrace.c

+9-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
#include <asm/pgtable.h>
3131
#include <asm/traps.h>
3232

33+
#define CREATE_TRACE_POINTS
34+
#include <trace/events/syscalls.h>
35+
3336
#define REG_PC 15
3437
#define REG_PSR 16
3538
/*
@@ -918,11 +921,11 @@ static int ptrace_syscall_trace(struct pt_regs *regs, int scno,
918921
{
919922
unsigned long ip;
920923

924+
current_thread_info()->syscall = scno;
925+
921926
if (!test_thread_flag(TIF_SYSCALL_TRACE))
922927
return scno;
923928

924-
current_thread_info()->syscall = scno;
925-
926929
/*
927930
* IP is used to denote syscall entry/exit:
928931
* IP = 0 -> entry, =1 -> exit
@@ -942,6 +945,8 @@ static int ptrace_syscall_trace(struct pt_regs *regs, int scno,
942945
asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
943946
{
944947
int ret = ptrace_syscall_trace(regs, scno, PTRACE_SYSCALL_ENTER);
948+
if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
949+
trace_sys_enter(regs, ret);
945950
audit_syscall_entry(AUDIT_ARCH_ARM, scno, regs->ARM_r0, regs->ARM_r1,
946951
regs->ARM_r2, regs->ARM_r3);
947952
return ret;
@@ -950,6 +955,8 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
950955
asmlinkage int syscall_trace_exit(struct pt_regs *regs, int scno)
951956
{
952957
int ret = ptrace_syscall_trace(regs, scno, PTRACE_SYSCALL_EXIT);
958+
if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
959+
trace_sys_exit(regs, ret);
953960
audit_syscall_exit(regs);
954961
return ret;
955962
}

0 commit comments

Comments
 (0)