aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc/kernel/ftrace.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sparc/kernel/ftrace.c')
-rw-r--r--arch/sparc/kernel/ftrace.c47
1 files changed, 32 insertions, 15 deletions
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