Skip to content

Commit 6fb8302

Browse files
author
Ingo Molnar
committed
Merge branch 'tracing/core' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing into tracing/core
2 parents 281b371 + e01292b commit 6fb8302

17 files changed

Lines changed: 112 additions & 45 deletions

File tree

‎Documentation/trace/ftrace-design.txt‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,10 @@ HAVE_SYSCALL_TRACEPOINTS
238238

239239
You need very few things to get the syscalls tracing in an arch.
240240

241+
- Support HAVE_ARCH_TRACEHOOK (see arch/Kconfig).
241242
- Have a NR_syscalls variable in <asm/unistd.h> that provides the number
242243
of syscalls supported by the arch.
243-
- Implement arch_syscall_addr() that resolves a syscall address from a
244-
syscall number.
245-
- Support the TIF_SYSCALL_TRACEPOINT thread flags
244+
- Support the TIF_SYSCALL_TRACEPOINT thread flags.
246245
- Put the trace_sys_enter() and trace_sys_exit() tracepoints calls from ptrace
247246
in the ptrace syscalls tracing path.
248247
- Tag this arch as HAVE_SYSCALL_TRACEPOINTS.

‎arch/Kconfig‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ config HAVE_DMA_ATTRS
121121
config USE_GENERIC_SMP_HELPERS
122122
bool
123123

124+
config HAVE_REGS_AND_STACK_ACCESS_API
125+
bool
126+
help
127+
This symbol should be selected by an architecure if it supports
128+
the API needed to access registers and stack entries from pt_regs,
129+
declared in asm/ptrace.h
130+
For example the kprobes-based event tracer needs this API.
131+
124132
config HAVE_CLK
125133
bool
126134
help

‎arch/s390/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ config S390
8787
select HAVE_SYSCALL_TRACEPOINTS
8888
select HAVE_DYNAMIC_FTRACE
8989
select HAVE_FUNCTION_GRAPH_TRACER
90+
select HAVE_REGS_AND_STACK_ACCESS_API
9091
select HAVE_DEFAULT_NO_SPIN_MUTEXES
9192
select HAVE_OPROFILE
9293
select HAVE_KPROBES

‎arch/s390/include/asm/ptrace.h‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,13 +492,24 @@ struct user_regs_struct
492492
struct task_struct;
493493
extern void user_enable_single_step(struct task_struct *);
494494
extern void user_disable_single_step(struct task_struct *);
495+
extern void show_regs(struct pt_regs * regs);
495496

496497
#define user_mode(regs) (((regs)->psw.mask & PSW_MASK_PSTATE) != 0)
497498
#define instruction_pointer(regs) ((regs)->psw.addr & PSW_ADDR_INSN)
498499
#define user_stack_pointer(regs)((regs)->gprs[15])
499500
#define regs_return_value(regs)((regs)->gprs[2])
500501
#define profile_pc(regs) instruction_pointer(regs)
501-
extern void show_regs(struct pt_regs * regs);
502+
503+
int regs_query_register_offset(const char *name);
504+
const char *regs_query_register_name(unsigned int offset);
505+
unsigned long regs_get_register(struct pt_regs *regs, unsigned int offset);
506+
unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, unsigned int n);
507+
508+
static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
509+
{
510+
return regs->gprs[15] & PSW_ADDR_INSN;
511+
}
512+
502513
#endif /* __KERNEL__ */
503514
#endif /* __ASSEMBLY__ */
504515

‎arch/s390/include/asm/syscall.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
#include <linux/sched.h>
1616
#include <asm/ptrace.h>
1717

18+
/*
19+
* The syscall table always contains 32 bit pointers since we know that the
20+
* address of the function to be called is (way) below 4GB. So the "int"
21+
* type here is what we want [need] for both 32 bit and 64 bit systems.
22+
*/
23+
extern const unsigned int sys_call_table[];
24+
1825
static inline long syscall_get_nr(struct task_struct *task,
1926
struct pt_regs *regs)
2027
{

‎arch/s390/kernel/ftrace.c‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,3 @@ unsigned long prepare_ftrace_return(unsigned long ip, unsigned long parent)
200200
return parent;
201201
}
202202
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
203-
204-
#ifdef CONFIG_FTRACE_SYSCALLS
205-
206-
extern unsigned int sys_call_table[];
207-
208-
unsigned long __init arch_syscall_addr(int nr)
209-
{
210-
return (unsigned long)sys_call_table[nr];
211-
}
212-
#endif

‎arch/s390/kernel/ptrace.c‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,3 +992,61 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)
992992
#endif
993993
return &user_s390_view;
994994
}
995+
996+
static const char *gpr_names[NUM_GPRS] = {
997+
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
998+
"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
999+
};
1000+
1001+
unsigned long regs_get_register(struct pt_regs *regs, unsigned int offset)
1002+
{
1003+
if (offset >= NUM_GPRS)
1004+
return 0;
1005+
return regs->gprs[offset];
1006+
}
1007+
1008+
int regs_query_register_offset(const char *name)
1009+
{
1010+
unsigned long offset;
1011+
1012+
if (!name || *name != 'r')
1013+
return -EINVAL;
1014+
if (strict_strtoul(name + 1, 10, &offset))
1015+
return -EINVAL;
1016+
if (offset >= NUM_GPRS)
1017+
return -EINVAL;
1018+
return offset;
1019+
}
1020+
1021+
const char *regs_query_register_name(unsigned int offset)
1022+
{
1023+
if (offset >= NUM_GPRS)
1024+
return NULL;
1025+
return gpr_names[offset];
1026+
}
1027+
1028+
static int regs_within_kernel_stack(struct pt_regs *regs, unsigned long addr)
1029+
{
1030+
unsigned long ksp = kernel_stack_pointer(regs);
1031+
1032+
return (addr & ~(THREAD_SIZE - 1)) == (ksp & ~(THREAD_SIZE - 1));
1033+
}
1034+
1035+
/**
1036+
* regs_get_kernel_stack_nth() - get Nth entry of the stack
1037+
* @regs:pt_regs which contains kernel stack pointer.
1038+
* @n:stack entry number.
1039+
*
1040+
* regs_get_kernel_stack_nth() returns @n th entry of the kernel stack which
1041+
* is specifined by @regs. If the @n th entry is NOT in the kernel stack,
1042+
* this returns 0.
1043+
*/
1044+
unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, unsigned int n)
1045+
{
1046+
unsigned long addr;
1047+
1048+
addr = kernel_stack_pointer(regs) + n * sizeof(long);
1049+
if (!regs_within_kernel_stack(regs, addr))
1050+
return 0;
1051+
return *(unsigned long *)addr;
1052+
}

‎arch/sh/include/asm/syscall.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef __ASM_SH_SYSCALL_H
22
#define __ASM_SH_SYSCALL_H
33

4+
extern const unsigned long sys_call_table[];
5+
46
#ifdef CONFIG_SUPERH32
57
# include "syscall_32.h"
68
#else

‎arch/sh/kernel/ftrace.c‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,3 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
399399
}
400400
}
401401
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
402-
403-
#ifdef CONFIG_FTRACE_SYSCALLS
404-
extern unsigned long *sys_call_table;
405-
406-
unsigned long __init arch_syscall_addr(int nr)
407-
{
408-
return (unsigned long)sys_call_table[nr];
409-
}
410-
#endif /* CONFIG_FTRACE_SYSCALLS */

‎arch/sparc/include/asm/syscall.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
#include <linux/sched.h>
66
#include <asm/ptrace.h>
77

8+
/*
9+
* The syscall table always contains 32 bit pointers since we know that the
10+
* address of the function to be called is (way) below 4GB. So the "int"
11+
* type here is what we want [need] for both 32 bit and 64 bit systems.
12+
*/
13+
extern const unsigned int sys_call_table[];
14+
815
/* The system call number is given by the user in %g1 */
916
static inline long syscall_get_nr(struct task_struct *task,
1017
struct pt_regs *regs)

0 commit comments

Comments
 (0)