aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sparc')
-rw-r--r--arch/sparc/Kconfig2
-rw-r--r--arch/sparc/include/asm/ftrace.h11
-rw-r--r--arch/sparc/kernel/ftrace.c47
3 files changed, 45 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