diff options
author | Mike Frysinger <vapier@gentoo.org> | 2010-01-26 04:40:03 -0500 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2010-02-17 07:07:21 -0500 |
commit | e7b8e675d9c71b868b66f62f725a948047514719 (patch) | |
tree | 77877e2470148dc47653408c4b624734a8f14239 | |
parent | ea2c68a08fedb5053ba312d661e47df9f4d72411 (diff) |
tracing: Unify arch_syscall_addr() implementations
Most implementations of arch_syscall_addr() are the same, so create a
default version in common code and move the one piece that differs (the
syscall table) to asm/syscall.h. New arch ports don't have to waste
time copying & pasting this simple function.
The s390/sparc versions need to be different, so document why.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Paul Mundt <lethal@linux-sh.org>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
LKML-Reference: <1264498803-17278-1-git-send-email-vapier@gentoo.org>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
-rw-r--r-- | Documentation/trace/ftrace-design.txt | 5 | ||||
-rw-r--r-- | arch/s390/include/asm/syscall.h | 7 | ||||
-rw-r--r-- | arch/s390/kernel/ftrace.c | 10 | ||||
-rw-r--r-- | arch/sh/include/asm/syscall.h | 2 | ||||
-rw-r--r-- | arch/sh/kernel/ftrace.c | 9 | ||||
-rw-r--r-- | arch/sparc/include/asm/syscall.h | 7 | ||||
-rw-r--r-- | arch/sparc/kernel/ftrace.c | 11 | ||||
-rw-r--r-- | arch/x86/include/asm/syscall.h | 2 | ||||
-rw-r--r-- | arch/x86/kernel/ftrace.c | 10 | ||||
-rw-r--r-- | include/linux/ftrace.h | 6 | ||||
-rw-r--r-- | kernel/trace/trace_syscalls.c | 5 |
11 files changed, 31 insertions, 43 deletions
diff --git a/Documentation/trace/ftrace-design.txt b/Documentation/trace/ftrace-design.txt index 239f14b2b55a..99df1101d2a5 100644 --- a/Documentation/trace/ftrace-design.txt +++ b/Documentation/trace/ftrace-design.txt | |||
@@ -218,11 +218,10 @@ HAVE_SYSCALL_TRACEPOINTS | |||
218 | 218 | ||
219 | You need very few things to get the syscalls tracing in an arch. | 219 | You need very few things to get the syscalls tracing in an arch. |
220 | 220 | ||
221 | - Support HAVE_ARCH_TRACEHOOK (see arch/Kconfig). | ||
221 | - Have a NR_syscalls variable in <asm/unistd.h> that provides the number | 222 | - Have a NR_syscalls variable in <asm/unistd.h> that provides the number |
222 | of syscalls supported by the arch. | 223 | of syscalls supported by the arch. |
223 | - Implement arch_syscall_addr() that resolves a syscall address from a | 224 | - Support the TIF_SYSCALL_TRACEPOINT thread flags. |
224 | syscall number. | ||
225 | - Support the TIF_SYSCALL_TRACEPOINT thread flags | ||
226 | - Put the trace_sys_enter() and trace_sys_exit() tracepoints calls from ptrace | 225 | - Put the trace_sys_enter() and trace_sys_exit() tracepoints calls from ptrace |
227 | in the ptrace syscalls tracing path. | 226 | in the ptrace syscalls tracing path. |
228 | - Tag this arch as HAVE_SYSCALL_TRACEPOINTS. | 227 | - Tag this arch as HAVE_SYSCALL_TRACEPOINTS. |
diff --git a/arch/s390/include/asm/syscall.h b/arch/s390/include/asm/syscall.h index e0a73d3eb837..8429686951f9 100644 --- a/arch/s390/include/asm/syscall.h +++ b/arch/s390/include/asm/syscall.h | |||
@@ -15,6 +15,13 @@ | |||
15 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
16 | #include <asm/ptrace.h> | 16 | #include <asm/ptrace.h> |
17 | 17 | ||
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 | |||
18 | static inline long syscall_get_nr(struct task_struct *task, | 25 | static inline long syscall_get_nr(struct task_struct *task, |
19 | struct pt_regs *regs) | 26 | struct pt_regs *regs) |
20 | { | 27 | { |
diff --git a/arch/s390/kernel/ftrace.c b/arch/s390/kernel/ftrace.c index 5a82bc68193e..9e69449e77ad 100644 --- a/arch/s390/kernel/ftrace.c +++ b/arch/s390/kernel/ftrace.c | |||
@@ -200,13 +200,3 @@ out: | |||
200 | return parent; | 200 | return parent; |
201 | } | 201 | } |
202 | #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ | 202 | #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 | ||
diff --git a/arch/sh/include/asm/syscall.h b/arch/sh/include/asm/syscall.h index 6a381429ee9d..aa7777bdc370 100644 --- a/arch/sh/include/asm/syscall.h +++ b/arch/sh/include/asm/syscall.h | |||
@@ -1,6 +1,8 @@ | |||
1 | #ifndef __ASM_SH_SYSCALL_H | 1 | #ifndef __ASM_SH_SYSCALL_H |
2 | #define __ASM_SH_SYSCALL_H | 2 | #define __ASM_SH_SYSCALL_H |
3 | 3 | ||
4 | extern const unsigned long sys_call_table[]; | ||
5 | |||
4 | #ifdef CONFIG_SUPERH32 | 6 | #ifdef CONFIG_SUPERH32 |
5 | # include "syscall_32.h" | 7 | # include "syscall_32.h" |
6 | #else | 8 | #else |
diff --git a/arch/sh/kernel/ftrace.c b/arch/sh/kernel/ftrace.c index a48cdedc73b5..30e13196d35b 100644 --- a/arch/sh/kernel/ftrace.c +++ b/arch/sh/kernel/ftrace.c | |||
@@ -399,12 +399,3 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr) | |||
399 | } | 399 | } |
400 | } | 400 | } |
401 | #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ | 401 | #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 */ | ||
diff --git a/arch/sparc/include/asm/syscall.h b/arch/sparc/include/asm/syscall.h index 7486c605e23c..025a02ad2e31 100644 --- a/arch/sparc/include/asm/syscall.h +++ b/arch/sparc/include/asm/syscall.h | |||
@@ -5,6 +5,13 @@ | |||
5 | #include <linux/sched.h> | 5 | #include <linux/sched.h> |
6 | #include <asm/ptrace.h> | 6 | #include <asm/ptrace.h> |
7 | 7 | ||
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 | |||
8 | /* The system call number is given by the user in %g1 */ | 15 | /* The system call number is given by the user in %g1 */ |
9 | static inline long syscall_get_nr(struct task_struct *task, | 16 | static inline long syscall_get_nr(struct task_struct *task, |
10 | struct pt_regs *regs) | 17 | struct pt_regs *regs) |
diff --git a/arch/sparc/kernel/ftrace.c b/arch/sparc/kernel/ftrace.c index 29973daa9930..9103a56b39e8 100644 --- a/arch/sparc/kernel/ftrace.c +++ b/arch/sparc/kernel/ftrace.c | |||
@@ -91,14 +91,3 @@ int __init ftrace_dyn_arch_init(void *data) | |||
91 | return 0; | 91 | return 0; |
92 | } | 92 | } |
93 | #endif | 93 | #endif |
94 | |||
95 | #ifdef CONFIG_FTRACE_SYSCALLS | ||
96 | |||
97 | extern unsigned int sys_call_table[]; | ||
98 | |||
99 | unsigned long __init arch_syscall_addr(int nr) | ||
100 | { | ||
101 | return (unsigned long)sys_call_table[nr]; | ||
102 | } | ||
103 | |||
104 | #endif | ||
diff --git a/arch/x86/include/asm/syscall.h b/arch/x86/include/asm/syscall.h index 8d33bc5462d1..c4a348f7bd43 100644 --- a/arch/x86/include/asm/syscall.h +++ b/arch/x86/include/asm/syscall.h | |||
@@ -16,6 +16,8 @@ | |||
16 | #include <linux/sched.h> | 16 | #include <linux/sched.h> |
17 | #include <linux/err.h> | 17 | #include <linux/err.h> |
18 | 18 | ||
19 | extern const unsigned long sys_call_table[]; | ||
20 | |||
19 | /* | 21 | /* |
20 | * Only the low 32 bits of orig_ax are meaningful, so we return int. | 22 | * Only the low 32 bits of orig_ax are meaningful, so we return int. |
21 | * This importantly ignores the high bits on 64-bit, so comparisons | 23 | * This importantly ignores the high bits on 64-bit, so comparisons |
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c index 309689245431..0d93a941934c 100644 --- a/arch/x86/kernel/ftrace.c +++ b/arch/x86/kernel/ftrace.c | |||
@@ -484,13 +484,3 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr, | |||
484 | } | 484 | } |
485 | } | 485 | } |
486 | #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ | 486 | #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ |
487 | |||
488 | #ifdef CONFIG_FTRACE_SYSCALLS | ||
489 | |||
490 | extern unsigned long *sys_call_table; | ||
491 | |||
492 | unsigned long __init arch_syscall_addr(int nr) | ||
493 | { | ||
494 | return (unsigned long)(&sys_call_table)[nr]; | ||
495 | } | ||
496 | #endif | ||
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index 0b4f97d24d7f..1cbb36f2759c 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h | |||
@@ -511,4 +511,10 @@ static inline void trace_hw_branch_oops(void) {} | |||
511 | 511 | ||
512 | #endif /* CONFIG_HW_BRANCH_TRACER */ | 512 | #endif /* CONFIG_HW_BRANCH_TRACER */ |
513 | 513 | ||
514 | #ifdef CONFIG_FTRACE_SYSCALLS | ||
515 | |||
516 | unsigned long arch_syscall_addr(int nr); | ||
517 | |||
518 | #endif /* CONFIG_FTRACE_SYSCALLS */ | ||
519 | |||
514 | #endif /* _LINUX_FTRACE_H */ | 520 | #endif /* _LINUX_FTRACE_H */ |
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c index 49cea70fbf6d..ecf00782b46c 100644 --- a/kernel/trace/trace_syscalls.c +++ b/kernel/trace/trace_syscalls.c | |||
@@ -394,6 +394,11 @@ int init_syscall_trace(struct ftrace_event_call *call) | |||
394 | return id; | 394 | return id; |
395 | } | 395 | } |
396 | 396 | ||
397 | unsigned long __init arch_syscall_addr(int nr) | ||
398 | { | ||
399 | return (unsigned long)sys_call_table[nr]; | ||
400 | } | ||
401 | |||
397 | int __init init_ftrace_syscalls(void) | 402 | int __init init_ftrace_syscalls(void) |
398 | { | 403 | { |
399 | struct syscall_metadata *meta; | 404 | struct syscall_metadata *meta; |