Commit fb0b5490 authored by Sergey Matyukevich's avatar Sergey Matyukevich Committed by Vineet Gupta

ARC: implement syscall tracepoints

Implement all the bits required to support HAVE_SYSCALL_TRACEPOINTS
according to Documentation/trace/ftrace-design.rst.
Signed-off-by: default avatarSergey Matyukevich <sergey.matyukevich@synopsys.com>
Signed-off-by: default avatarVineet Gupta <vgupta@kernel.org>
parent b3bbf6a7
...@@ -39,6 +39,7 @@ config ARC ...@@ -39,6 +39,7 @@ config ARC
select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_REGS_AND_STACK_ACCESS_API
select HAVE_MOD_ARCH_SPECIFIC select HAVE_MOD_ARCH_SPECIFIC
select HAVE_PERF_EVENTS select HAVE_PERF_EVENTS
select HAVE_SYSCALL_TRACEPOINTS
select IRQ_DOMAIN select IRQ_DOMAIN
select MODULES_USE_ELF_RELA select MODULES_USE_ELF_RELA
select OF select OF
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include <asm/unistd.h> #include <asm/unistd.h>
#include <asm/ptrace.h> /* in_syscall() */ #include <asm/ptrace.h> /* in_syscall() */
extern void *sys_call_table[];
static inline long static inline long
syscall_get_nr(struct task_struct *task, struct pt_regs *regs) syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
{ {
......
...@@ -78,9 +78,9 @@ static inline __attribute_const__ struct thread_info *current_thread_info(void) ...@@ -78,9 +78,9 @@ static inline __attribute_const__ struct thread_info *current_thread_info(void)
#define TIF_SYSCALL_AUDIT 4 /* syscall auditing active */ #define TIF_SYSCALL_AUDIT 4 /* syscall auditing active */
#define TIF_NOTIFY_SIGNAL 5 /* signal notifications exist */ #define TIF_NOTIFY_SIGNAL 5 /* signal notifications exist */
#define TIF_SYSCALL_TRACE 15 /* syscall trace active */ #define TIF_SYSCALL_TRACE 15 /* syscall trace active */
/* true if poll_idle() is polling TIF_NEED_RESCHED */ /* true if poll_idle() is polling TIF_NEED_RESCHED */
#define TIF_MEMDIE 16 #define TIF_MEMDIE 16
#define TIF_SYSCALL_TRACEPOINT 17 /* syscall tracepoint instrumentation */
#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
...@@ -89,11 +89,14 @@ static inline __attribute_const__ struct thread_info *current_thread_info(void) ...@@ -89,11 +89,14 @@ static inline __attribute_const__ struct thread_info *current_thread_info(void)
#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
#define _TIF_NOTIFY_SIGNAL (1<<TIF_NOTIFY_SIGNAL) #define _TIF_NOTIFY_SIGNAL (1<<TIF_NOTIFY_SIGNAL)
#define _TIF_MEMDIE (1<<TIF_MEMDIE) #define _TIF_MEMDIE (1<<TIF_MEMDIE)
#define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
/* work to do on interrupt/exception return */ /* work to do on interrupt/exception return */
#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \ #define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
_TIF_NOTIFY_RESUME | _TIF_NOTIFY_SIGNAL) _TIF_NOTIFY_RESUME | _TIF_NOTIFY_SIGNAL)
#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_TRACEPOINT)
/* /*
* _TIF_ALLWORK_MASK includes SYSCALL_TRACE, but we don't need it. * _TIF_ALLWORK_MASK includes SYSCALL_TRACE, but we don't need it.
* SYSCALL_TRACE is anyway separately/unconditionally tested right after a * SYSCALL_TRACE is anyway separately/unconditionally tested right after a
......
...@@ -29,8 +29,8 @@ ENTRY(sys_clone_wrapper) ...@@ -29,8 +29,8 @@ ENTRY(sys_clone_wrapper)
DISCARD_CALLEE_SAVED_USER DISCARD_CALLEE_SAVED_USER
GET_CURR_THR_INFO_FLAGS r10 GET_CURR_THR_INFO_FLAGS r10
btst r10, TIF_SYSCALL_TRACE and.f 0, r10, _TIF_SYSCALL_WORK
bnz tracesys_exit bnz tracesys_exit
b .Lret_from_system_call b .Lret_from_system_call
END(sys_clone_wrapper) END(sys_clone_wrapper)
...@@ -41,8 +41,8 @@ ENTRY(sys_clone3_wrapper) ...@@ -41,8 +41,8 @@ ENTRY(sys_clone3_wrapper)
DISCARD_CALLEE_SAVED_USER DISCARD_CALLEE_SAVED_USER
GET_CURR_THR_INFO_FLAGS r10 GET_CURR_THR_INFO_FLAGS r10
btst r10, TIF_SYSCALL_TRACE and.f 0, r10, _TIF_SYSCALL_WORK
bnz tracesys_exit bnz tracesys_exit
b .Lret_from_system_call b .Lret_from_system_call
END(sys_clone3_wrapper) END(sys_clone3_wrapper)
...@@ -247,8 +247,8 @@ ENTRY(EV_Trap) ...@@ -247,8 +247,8 @@ ENTRY(EV_Trap)
; If syscall tracing ongoing, invoke pre-post-hooks ; If syscall tracing ongoing, invoke pre-post-hooks
GET_CURR_THR_INFO_FLAGS r10 GET_CURR_THR_INFO_FLAGS r10
btst r10, TIF_SYSCALL_TRACE and.f 0, r10, _TIF_SYSCALL_WORK
bnz tracesys ; this never comes back bnz tracesys ; this never comes back
;============ Normal syscall case ;============ Normal syscall case
......
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
#include <linux/unistd.h> #include <linux/unistd.h>
#include <linux/elf.h> #include <linux/elf.h>
#define CREATE_TRACE_POINTS
#include <trace/events/syscalls.h>
struct pt_regs_offset { struct pt_regs_offset {
const char *name; const char *name;
int offset; int offset;
...@@ -340,15 +343,27 @@ long arch_ptrace(struct task_struct *child, long request, ...@@ -340,15 +343,27 @@ long arch_ptrace(struct task_struct *child, long request,
asmlinkage int syscall_trace_entry(struct pt_regs *regs) asmlinkage int syscall_trace_entry(struct pt_regs *regs)
{ {
if (ptrace_report_syscall_entry(regs)) if (test_thread_flag(TIF_SYSCALL_TRACE))
return ULONG_MAX; if (ptrace_report_syscall_entry(regs))
return ULONG_MAX;
#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
trace_sys_enter(regs, syscall_get_nr(current, regs));
#endif
return regs->r8; return regs->r8;
} }
asmlinkage void syscall_trace_exit(struct pt_regs *regs) asmlinkage void syscall_trace_exit(struct pt_regs *regs)
{ {
ptrace_report_syscall_exit(regs, 0); if (test_thread_flag(TIF_SYSCALL_TRACE))
ptrace_report_syscall_exit(regs, 0);
#ifdef CONFIG_HAVE_SYSCALL_TRACEPOINTS
if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
trace_sys_exit(regs, regs_return_value(regs));
#endif
} }
int regs_query_register_offset(const char *name) int regs_query_register_offset(const char *name)
......
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