forked from Minki/linux
Merge branch 'tracing/core' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing into tracing/core
This commit is contained in:
commit
6fb83029db
@ -238,11 +238,10 @@ HAVE_SYSCALL_TRACEPOINTS
|
||||
|
||||
You need very few things to get the syscalls tracing in an arch.
|
||||
|
||||
- Support HAVE_ARCH_TRACEHOOK (see arch/Kconfig).
|
||||
- Have a NR_syscalls variable in <asm/unistd.h> that provides the number
|
||||
of syscalls supported by the arch.
|
||||
- Implement arch_syscall_addr() that resolves a syscall address from a
|
||||
syscall number.
|
||||
- Support the TIF_SYSCALL_TRACEPOINT thread flags
|
||||
- Support the TIF_SYSCALL_TRACEPOINT thread flags.
|
||||
- Put the trace_sys_enter() and trace_sys_exit() tracepoints calls from ptrace
|
||||
in the ptrace syscalls tracing path.
|
||||
- Tag this arch as HAVE_SYSCALL_TRACEPOINTS.
|
||||
|
@ -121,6 +121,14 @@ config HAVE_DMA_ATTRS
|
||||
config USE_GENERIC_SMP_HELPERS
|
||||
bool
|
||||
|
||||
config HAVE_REGS_AND_STACK_ACCESS_API
|
||||
bool
|
||||
help
|
||||
This symbol should be selected by an architecure if it supports
|
||||
the API needed to access registers and stack entries from pt_regs,
|
||||
declared in asm/ptrace.h
|
||||
For example the kprobes-based event tracer needs this API.
|
||||
|
||||
config HAVE_CLK
|
||||
bool
|
||||
help
|
||||
|
@ -87,6 +87,7 @@ config S390
|
||||
select HAVE_SYSCALL_TRACEPOINTS
|
||||
select HAVE_DYNAMIC_FTRACE
|
||||
select HAVE_FUNCTION_GRAPH_TRACER
|
||||
select HAVE_REGS_AND_STACK_ACCESS_API
|
||||
select HAVE_DEFAULT_NO_SPIN_MUTEXES
|
||||
select HAVE_OPROFILE
|
||||
select HAVE_KPROBES
|
||||
|
@ -492,13 +492,24 @@ struct user_regs_struct
|
||||
struct task_struct;
|
||||
extern void user_enable_single_step(struct task_struct *);
|
||||
extern void user_disable_single_step(struct task_struct *);
|
||||
extern void show_regs(struct pt_regs * regs);
|
||||
|
||||
#define user_mode(regs) (((regs)->psw.mask & PSW_MASK_PSTATE) != 0)
|
||||
#define instruction_pointer(regs) ((regs)->psw.addr & PSW_ADDR_INSN)
|
||||
#define user_stack_pointer(regs)((regs)->gprs[15])
|
||||
#define regs_return_value(regs)((regs)->gprs[2])
|
||||
#define profile_pc(regs) instruction_pointer(regs)
|
||||
extern void show_regs(struct pt_regs * regs);
|
||||
|
||||
int regs_query_register_offset(const char *name);
|
||||
const char *regs_query_register_name(unsigned int offset);
|
||||
unsigned long regs_get_register(struct pt_regs *regs, unsigned int offset);
|
||||
unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, unsigned int n);
|
||||
|
||||
static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
|
||||
{
|
||||
return regs->gprs[15] & PSW_ADDR_INSN;
|
||||
}
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
|
@ -15,6 +15,13 @@
|
||||
#include <linux/sched.h>
|
||||
#include <asm/ptrace.h>
|
||||
|
||||
/*
|
||||
* The syscall table always contains 32 bit pointers since we know that the
|
||||
* address of the function to be called is (way) below 4GB. So the "int"
|
||||
* type here is what we want [need] for both 32 bit and 64 bit systems.
|
||||
*/
|
||||
extern const unsigned int sys_call_table[];
|
||||
|
||||
static inline long syscall_get_nr(struct task_struct *task,
|
||||
struct pt_regs *regs)
|
||||
{
|
||||
|
@ -200,13 +200,3 @@ out:
|
||||
return parent;
|
||||
}
|
||||
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
|
||||
|
||||
#ifdef CONFIG_FTRACE_SYSCALLS
|
||||
|
||||
extern unsigned int sys_call_table[];
|
||||
|
||||
unsigned long __init arch_syscall_addr(int nr)
|
||||
{
|
||||
return (unsigned long)sys_call_table[nr];
|
||||
}
|
||||
#endif
|
||||
|
@ -992,3 +992,61 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)
|
||||
#endif
|
||||
return &user_s390_view;
|
||||
}
|
||||
|
||||
static const char *gpr_names[NUM_GPRS] = {
|
||||
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
|
||||
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
|
||||
};
|
||||
|
||||
unsigned long regs_get_register(struct pt_regs *regs, unsigned int offset)
|
||||
{
|
||||
if (offset >= NUM_GPRS)
|
||||
return 0;
|
||||
return regs->gprs[offset];
|
||||
}
|
||||
|
||||
int regs_query_register_offset(const char *name)
|
||||
{
|
||||
unsigned long offset;
|
||||
|
||||
if (!name || *name != 'r')
|
||||
return -EINVAL;
|
||||
if (strict_strtoul(name + 1, 10, &offset))
|
||||
return -EINVAL;
|
||||
if (offset >= NUM_GPRS)
|
||||
return -EINVAL;
|
||||
return offset;
|
||||
}
|
||||
|
||||
const char *regs_query_register_name(unsigned int offset)
|
||||
{
|
||||
if (offset >= NUM_GPRS)
|
||||
return NULL;
|
||||
return gpr_names[offset];
|
||||
}
|
||||
|
||||
static int regs_within_kernel_stack(struct pt_regs *regs, unsigned long addr)
|
||||
{
|
||||
unsigned long ksp = kernel_stack_pointer(regs);
|
||||
|
||||
return (addr & ~(THREAD_SIZE - 1)) == (ksp & ~(THREAD_SIZE - 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* regs_get_kernel_stack_nth() - get Nth entry of the stack
|
||||
* @regs:pt_regs which contains kernel stack pointer.
|
||||
* @n:stack entry number.
|
||||
*
|
||||
* regs_get_kernel_stack_nth() returns @n th entry of the kernel stack which
|
||||
* is specifined by @regs. If the @n th entry is NOT in the kernel stack,
|
||||
* this returns 0.
|
||||
*/
|
||||
unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, unsigned int n)
|
||||
{
|
||||
unsigned long addr;
|
||||
|
||||
addr = kernel_stack_pointer(regs) + n * sizeof(long);
|
||||
if (!regs_within_kernel_stack(regs, addr))
|
||||
return 0;
|
||||
return *(unsigned long *)addr;
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef __ASM_SH_SYSCALL_H
|
||||
#define __ASM_SH_SYSCALL_H
|
||||
|
||||
extern const unsigned long sys_call_table[];
|
||||
|
||||
#ifdef CONFIG_SUPERH32
|
||||
# include "syscall_32.h"
|
||||
#else
|
||||
|
@ -399,12 +399,3 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
|
||||
|
||||
#ifdef CONFIG_FTRACE_SYSCALLS
|
||||
extern unsigned long *sys_call_table;
|
||||
|
||||
unsigned long __init arch_syscall_addr(int nr)
|
||||
{
|
||||
return (unsigned long)sys_call_table[nr];
|
||||
}
|
||||
#endif /* CONFIG_FTRACE_SYSCALLS */
|
||||
|
@ -5,6 +5,13 @@
|
||||
#include <linux/sched.h>
|
||||
#include <asm/ptrace.h>
|
||||
|
||||
/*
|
||||
* The syscall table always contains 32 bit pointers since we know that the
|
||||
* address of the function to be called is (way) below 4GB. So the "int"
|
||||
* type here is what we want [need] for both 32 bit and 64 bit systems.
|
||||
*/
|
||||
extern const unsigned int sys_call_table[];
|
||||
|
||||
/* The system call number is given by the user in %g1 */
|
||||
static inline long syscall_get_nr(struct task_struct *task,
|
||||
struct pt_regs *regs)
|
||||
|
@ -91,14 +91,3 @@ int __init ftrace_dyn_arch_init(void *data)
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FTRACE_SYSCALLS
|
||||
|
||||
extern unsigned int sys_call_table[];
|
||||
|
||||
unsigned long __init arch_syscall_addr(int nr)
|
||||
{
|
||||
return (unsigned long)sys_call_table[nr];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -45,6 +45,7 @@ config X86
|
||||
select HAVE_GENERIC_DMA_COHERENT if X86_32
|
||||
select HAVE_EFFICIENT_UNALIGNED_ACCESS
|
||||
select USER_STACKTRACE_SUPPORT
|
||||
select HAVE_REGS_AND_STACK_ACCESS_API
|
||||
select HAVE_DMA_API_DEBUG
|
||||
select HAVE_KERNEL_GZIP
|
||||
select HAVE_KERNEL_BZIP2
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include <linux/sched.h>
|
||||
#include <linux/err.h>
|
||||
|
||||
extern const unsigned long sys_call_table[];
|
||||
|
||||
/*
|
||||
* Only the low 32 bits of orig_ax are meaningful, so we return int.
|
||||
* This importantly ignores the high bits on 64-bit, so comparisons
|
||||
|
@ -510,13 +510,3 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
|
||||
|
||||
#ifdef CONFIG_FTRACE_SYSCALLS
|
||||
|
||||
extern unsigned long *sys_call_table;
|
||||
|
||||
unsigned long __init arch_syscall_addr(int nr)
|
||||
{
|
||||
return (unsigned long)(&sys_call_table)[nr];
|
||||
}
|
||||
#endif
|
||||
|
@ -511,4 +511,10 @@ static inline void trace_hw_branch_oops(void) {}
|
||||
|
||||
#endif /* CONFIG_HW_BRANCH_TRACER */
|
||||
|
||||
#ifdef CONFIG_FTRACE_SYSCALLS
|
||||
|
||||
unsigned long arch_syscall_addr(int nr);
|
||||
|
||||
#endif /* CONFIG_FTRACE_SYSCALLS */
|
||||
|
||||
#endif /* _LINUX_FTRACE_H */
|
||||
|
@ -440,7 +440,7 @@ config BLK_DEV_IO_TRACE
|
||||
|
||||
config KPROBE_EVENT
|
||||
depends on KPROBES
|
||||
depends on X86
|
||||
depends on HAVE_REGS_AND_STACK_ACCESS_API
|
||||
bool "Enable kprobes-based dynamic events"
|
||||
select TRACING
|
||||
default y
|
||||
|
@ -394,6 +394,11 @@ int init_syscall_trace(struct ftrace_event_call *call)
|
||||
return id;
|
||||
}
|
||||
|
||||
unsigned long __init arch_syscall_addr(int nr)
|
||||
{
|
||||
return (unsigned long)sys_call_table[nr];
|
||||
}
|
||||
|
||||
int __init init_ftrace_syscalls(void)
|
||||
{
|
||||
struct syscall_metadata *meta;
|
||||
|
Loading…
Reference in New Issue
Block a user