xtensa: implement syscall tracepoints
Add TIF_SYSCALL_TRACEPOINT flag definition; add _TIF_SYSCALL_TRACEPOINT to _TIF_WORK_MASK. Call trace_sys_enter from do_syscall_trace_enter and trace_sys_exit from do_syscall_trace_leave when TIF_SYSCALL_TRACEPOINT flag is set. Add declaration of sys_call_table to arch/xtensa/include/asm/syscall.h Add definition of NR_syscalls to arch/xtensa/include/asm/unistd.h Select HAVE_SYSCALL_TRACEPOINTS. This change allows tracing each syscall entry and exit through the ftrace mechanism. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
This commit is contained in:
parent
9f24f3c106
commit
af5395c214
|
@ -29,6 +29,7 @@ config XTENSA
|
||||||
select HAVE_OPROFILE
|
select HAVE_OPROFILE
|
||||||
select HAVE_PERF_EVENTS
|
select HAVE_PERF_EVENTS
|
||||||
select HAVE_STACKPROTECTOR
|
select HAVE_STACKPROTECTOR
|
||||||
|
select HAVE_SYSCALL_TRACEPOINTS
|
||||||
select IRQ_DOMAIN
|
select IRQ_DOMAIN
|
||||||
select MODULES_USE_ELF_RELA
|
select MODULES_USE_ELF_RELA
|
||||||
select PERF_USE_VMALLOC
|
select PERF_USE_VMALLOC
|
||||||
|
|
|
@ -102,6 +102,11 @@ struct pt_regs {
|
||||||
|
|
||||||
#define user_stack_pointer(regs) ((regs)->areg[1])
|
#define user_stack_pointer(regs) ((regs)->areg[1])
|
||||||
|
|
||||||
|
static inline unsigned long regs_return_value(struct pt_regs *regs)
|
||||||
|
{
|
||||||
|
return regs->areg[2];
|
||||||
|
}
|
||||||
|
|
||||||
#else /* __ASSEMBLY__ */
|
#else /* __ASSEMBLY__ */
|
||||||
|
|
||||||
# include <asm/asm-offsets.h>
|
# include <asm/asm-offsets.h>
|
||||||
|
|
|
@ -19,6 +19,9 @@ static inline int syscall_get_arch(void)
|
||||||
return AUDIT_ARCH_XTENSA;
|
return AUDIT_ARCH_XTENSA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef void (*syscall_t)(void);
|
||||||
|
extern syscall_t sys_call_table[];
|
||||||
|
|
||||||
static inline long syscall_get_nr(struct task_struct *task,
|
static inline long syscall_get_nr(struct task_struct *task,
|
||||||
struct pt_regs *regs)
|
struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
|
|
|
@ -106,6 +106,7 @@ static inline struct thread_info *current_thread_info(void)
|
||||||
#define TIF_SIGPENDING 1 /* signal pending */
|
#define TIF_SIGPENDING 1 /* signal pending */
|
||||||
#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
|
#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
|
||||||
#define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */
|
#define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */
|
||||||
|
#define TIF_SYSCALL_TRACEPOINT 4 /* syscall tracepoint instrumentation */
|
||||||
#define TIF_MEMDIE 5 /* is terminating due to OOM killer */
|
#define TIF_MEMDIE 5 /* is terminating due to OOM killer */
|
||||||
#define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */
|
#define TIF_RESTORE_SIGMASK 6 /* restore signal mask in do_signal() */
|
||||||
#define TIF_NOTIFY_RESUME 7 /* callback before returning to user */
|
#define TIF_NOTIFY_RESUME 7 /* callback before returning to user */
|
||||||
|
@ -115,8 +116,10 @@ static inline struct thread_info *current_thread_info(void)
|
||||||
#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
|
#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
|
||||||
#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
|
#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
|
||||||
#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
|
#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
|
||||||
|
#define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
|
||||||
|
|
||||||
#define _TIF_WORK_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP)
|
#define _TIF_WORK_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \
|
||||||
|
_TIF_SYSCALL_TRACEPOINT)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Thread-synchronous status.
|
* Thread-synchronous status.
|
||||||
|
|
|
@ -22,4 +22,6 @@
|
||||||
#define __IGNORE_vfork /* use clone */
|
#define __IGNORE_vfork /* use clone */
|
||||||
#define __IGNORE_fadvise64 /* use fadvise64_64 */
|
#define __IGNORE_fadvise64 /* use fadvise64_64 */
|
||||||
|
|
||||||
|
#define NR_syscalls __NR_syscalls
|
||||||
|
|
||||||
#endif /* _XTENSA_UNISTD_H */
|
#endif /* _XTENSA_UNISTD_H */
|
||||||
|
|
|
@ -27,6 +27,9 @@
|
||||||
#include <linux/tracehook.h>
|
#include <linux/tracehook.h>
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
|
|
||||||
|
#define CREATE_TRACE_POINTS
|
||||||
|
#include <trace/events/syscalls.h>
|
||||||
|
|
||||||
#include <asm/coprocessor.h>
|
#include <asm/coprocessor.h>
|
||||||
#include <asm/elf.h>
|
#include <asm/elf.h>
|
||||||
#include <asm/page.h>
|
#include <asm/page.h>
|
||||||
|
@ -545,12 +548,17 @@ void do_syscall_trace_enter(struct pt_regs *regs)
|
||||||
tracehook_report_syscall_entry(regs))
|
tracehook_report_syscall_entry(regs))
|
||||||
regs->syscall = NO_SYSCALL;
|
regs->syscall = NO_SYSCALL;
|
||||||
|
|
||||||
|
if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
|
||||||
|
trace_sys_enter(regs, syscall_get_nr(current, regs));
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_syscall_trace_leave(struct pt_regs *regs)
|
void do_syscall_trace_leave(struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
int step;
|
int step;
|
||||||
|
|
||||||
|
if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
|
||||||
|
trace_sys_exit(regs, regs_return_value(regs));
|
||||||
|
|
||||||
step = test_thread_flag(TIF_SINGLESTEP);
|
step = test_thread_flag(TIF_SINGLESTEP);
|
||||||
|
|
||||||
if (step || test_thread_flag(TIF_SYSCALL_TRACE))
|
if (step || test_thread_flag(TIF_SYSCALL_TRACE))
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
#include <linux/sched/mm.h>
|
#include <linux/sched/mm.h>
|
||||||
#include <linux/shm.h>
|
#include <linux/shm.h>
|
||||||
|
|
||||||
typedef void (*syscall_t)(void);
|
|
||||||
|
|
||||||
syscall_t sys_call_table[__NR_syscalls] /* FIXME __cacheline_aligned */= {
|
syscall_t sys_call_table[__NR_syscalls] /* FIXME __cacheline_aligned */= {
|
||||||
[0 ... __NR_syscalls - 1] = (syscall_t)&sys_ni_syscall,
|
[0 ... __NR_syscalls - 1] = (syscall_t)&sys_ni_syscall,
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user