aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2009-06-13 04:03:24 -0400
committerDavid S. Miller <davem@davemloft.net>2009-06-16 07:56:53 -0400
commit9be12f9b1c4fd5f18cc82c170a32bfe1713ba76d (patch)
treed59b601e655160be8caaeb3ba755b0ad50199cc0
parent949e82744b31b555dd6dba40758e05338f305233 (diff)
sparc64: Add proper dynamic ftrace support.
Signed-off-by: David S. Miller <davem@davemloft.net> Acked-by: Steven Rostedt <rostedt@goodmis.org> Acked-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/sparc/Kconfig2
-rw-r--r--arch/sparc/include/asm/ftrace.h11
-rw-r--r--arch/sparc/kernel/ftrace.c47
-rwxr-xr-xscripts/recordmcount.pl20
4 files changed, 65 insertions, 15 deletions
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 2185cf946d68..3f8b6a92eabd 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -37,6 +37,8 @@ config SPARC64
37 select HAVE_KPROBES 37 select HAVE_KPROBES
38 select HAVE_LMB 38 select HAVE_LMB
39 select HAVE_SYSCALL_WRAPPERS 39 select HAVE_SYSCALL_WRAPPERS
40 select HAVE_DYNAMIC_FTRACE
41 select HAVE_FTRACE_MCOUNT_RECORD
40 select USE_GENERIC_SMP_HELPERS if SMP 42 select USE_GENERIC_SMP_HELPERS if SMP
41 select RTC_DRV_CMOS 43 select RTC_DRV_CMOS
42 select RTC_DRV_BQ4802 44 select RTC_DRV_BQ4802
diff --git a/arch/sparc/include/asm/ftrace.h b/arch/sparc/include/asm/ftrace.h
index d27716cd38c1..b0f18e9893db 100644
--- a/arch/sparc/include/asm/ftrace.h
+++ b/arch/sparc/include/asm/ftrace.h
@@ -11,4 +11,15 @@ extern void _mcount(void);
11 11
12#endif 12#endif
13 13
14#ifdef CONFIG_DYNAMIC_FTRACE
15/* reloction of mcount call site is the same as the address */
16static inline unsigned long ftrace_call_adjust(unsigned long addr)
17{
18 return addr;
19}
20
21struct dyn_arch_ftrace {
22};
23#endif /* CONFIG_DYNAMIC_FTRACE */
24
14#endif /* _ASM_SPARC64_FTRACE */ 25#endif /* _ASM_SPARC64_FTRACE */
diff --git a/arch/sparc/kernel/ftrace.c b/arch/sparc/kernel/ftrace.c
index d0218e73f982..d3b1a3076569 100644
--- a/arch/sparc/kernel/ftrace.c
+++ b/arch/sparc/kernel/ftrace.c
@@ -7,14 +7,10 @@
7 7
8#include <asm/ftrace.h> 8#include <asm/ftrace.h>
9 9
10#ifdef CONFIG_DYNAMIC_FTRACE
10static const u32 ftrace_nop = 0x01000000; 11static const u32 ftrace_nop = 0x01000000;
11 12
12unsigned char *ftrace_nop_replace(void) 13static u32 ftrace_call_replace(unsigned long ip, unsigned long addr)
13{
14 return (char *)&ftrace_nop;
15}
16
17unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr)
18{ 14{
19 static u32 call; 15 static u32 call;
20 s32 off; 16 s32 off;
@@ -22,15 +18,11 @@ unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr)
22 off = ((s32)addr - (s32)ip); 18 off = ((s32)addr - (s32)ip);
23 call = 0x40000000 | ((u32)off >> 2); 19 call = 0x40000000 | ((u32)off >> 2);
24 20
25 return (unsigned char *) &call; 21 return call;
26} 22}
27 23
28int 24static int ftrace_modify_code(unsigned long ip, u32 old, u32 new)
29ftrace_modify_code(unsigned long ip, unsigned char *old_code,
30 unsigned char *new_code)
31{ 25{
32 u32 old = *(u32 *)old_code;
33 u32 new = *(u32 *)new_code;
34 u32 replaced; 26 u32 replaced;
35 int faulted; 27 int faulted;
36 28
@@ -59,18 +51,43 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code,
59 return faulted; 51 return faulted;
60} 52}
61 53
54int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec, unsigned long addr)
55{
56 unsigned long ip = rec->ip;
57 u32 old, new;
58
59 old = ftrace_call_replace(ip, addr);
60 new = ftrace_nop;
61 return ftrace_modify_code(ip, old, new);
62}
63
64int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
65{
66 unsigned long ip = rec->ip;
67 u32 old, new;
68
69 old = ftrace_nop;
70 new = ftrace_call_replace(ip, addr);
71 return ftrace_modify_code(ip, old, new);
72}
73
62int ftrace_update_ftrace_func(ftrace_func_t func) 74int ftrace_update_ftrace_func(ftrace_func_t func)
63{ 75{
64 unsigned long ip = (unsigned long)(&ftrace_call); 76 unsigned long ip = (unsigned long)(&ftrace_call);
65 unsigned char old[MCOUNT_INSN_SIZE], *new; 77 u32 old, new;
66 78
67 memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE); 79 old = *(u32 *) &ftrace_call;
68 new = ftrace_call_replace(ip, (unsigned long)func); 80 new = ftrace_call_replace(ip, (unsigned long)func);
69 return ftrace_modify_code(ip, old, new); 81 return ftrace_modify_code(ip, old, new);
70} 82}
71 83
72int __init ftrace_dyn_arch_init(void *data) 84int __init ftrace_dyn_arch_init(void *data)
73{ 85{
74 ftrace_mcount_set(data); 86 unsigned long *p = data;
87
88 *p = 0;
89
75 return 0; 90 return 0;
76} 91}
92#endif
93
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index 91033e67321e..7109e2b5bc0a 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -226,6 +226,26 @@ if ($arch eq "x86_64") {
226 if ($is_module eq "0") { 226 if ($is_module eq "0") {
227 $cc .= " -mconstant-gp"; 227 $cc .= " -mconstant-gp";
228 } 228 }
229} elsif ($arch eq "sparc64") {
230 # In the objdump output there are giblets like:
231 # 0000000000000000 <igmp_net_exit-0x18>:
232 # As there's some data blobs that get emitted into the
233 # text section before the first instructions and the first
234 # real symbols. We don't want to match that, so to combat
235 # this we use '\w' so we'll match just plain symbol names,
236 # and not those that also include hex offsets inside of the
237 # '<>' brackets. Actually the generic function_regex setting
238 # could safely use this too.
239 $function_regex = "^([0-9a-fA-F]+)\\s+<(\\w*?)>:";
240
241 # Sparc64 calls '_mcount' instead of plain 'mcount'.
242 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$";
243
244 $alignment = 8;
245 $type = ".xword";
246 $ld .= " -m elf64_sparc";
247 $cc .= " -m64";
248 $objcopy .= " -O elf64-sparc";
229} else { 249} else {
230 die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD"; 250 die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD";
231} 251}