]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
tracing: Unify arch_syscall_addr() implementations
authorMike Frysinger <vapier@gentoo.org>
Tue, 26 Jan 2010 09:40:03 +0000 (04:40 -0500)
committerFrederic Weisbecker <fweisbec@gmail.com>
Wed, 17 Feb 2010 12:07:21 +0000 (13:07 +0100)
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>
Documentation/trace/ftrace-design.txt
arch/s390/include/asm/syscall.h
arch/s390/kernel/ftrace.c
arch/sh/include/asm/syscall.h
arch/sh/kernel/ftrace.c
arch/sparc/include/asm/syscall.h
arch/sparc/kernel/ftrace.c
arch/x86/include/asm/syscall.h
arch/x86/kernel/ftrace.c
include/linux/ftrace.h
kernel/trace/trace_syscalls.c

index 239f14b2b55a28213e1a7170db4b870ab82ff1b9..99df1101d2a56ab29bbc7dbe03aad48f26fdf85d 100644 (file)
@@ -218,11 +218,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.
index e0a73d3eb8371be3bb599413aa09cd65a7f7da56..8429686951f94f7ffeff1fafdb9ea2f5bba6a7d6 100644 (file)
 #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)
 {
index 5a82bc68193ed472b1c143e88d4f498b6fb02a99..9e69449e77adaf835d1589e466bbbdf91227e053 100644 (file)
@@ -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
index 6a381429ee9d4cbddcb9639779dba8cac52edd3c..aa7777bdc37036fdc3d2938c6c6f8115784f16bf 100644 (file)
@@ -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
index a48cdedc73b5f934444b7169a6cae0f583a5f562..30e13196d35bf0b96c1367788635b5778464f2ba 100644 (file)
@@ -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 */
index 7486c605e23cb36832ec74019c4adad2a68ec0a9..025a02ad2e31c9a87c15350241234b8943e04ae6 100644 (file)
@@ -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)
index 29973daa993013f404c711b29fcf1fcc3c6ea457..9103a56b39e839aed5af1f1f7b8fa78b9f7beee3 100644 (file)
@@ -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
index 8d33bc5462d1bd30af43bcb4156fec351149eaa6..c4a348f7bd43de3932f88d0f8ddb5b66a7526863 100644 (file)
@@ -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
index 30968924543129853b05bcb1aaa34dbcf1439ed2..0d93a941934cba87a2dc1715b41db26e317cebc8 100644 (file)
@@ -484,13 +484,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
index 0b4f97d24d7f510b243bdd8cd461daa2786eaa19..1cbb36f2759c5848637ffe97fe9d04d2d85299cb 100644 (file)
@@ -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 */
index 49cea70fbf6dc2b85983390056c063cc179ae729..ecf00782b46c598b1935e894a7835e7f29e1a19f 100644 (file)
@@ -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;