|
7 | 7 |
|
8 | 8 | #include <asm/ftrace.h> |
9 | 9 |
|
| 10 | +#ifdef CONFIG_DYNAMIC_FTRACE |
10 | 11 | static const u32 ftrace_nop = 0x01000000; |
11 | 12 |
|
12 | | -unsigned char *ftrace_nop_replace(void) |
13 | | -{ |
14 | | - return (char *)&ftrace_nop; |
15 | | -} |
16 | | - |
17 | | -unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr) |
| 13 | +static u32 ftrace_call_replace(unsigned long ip, unsigned long addr) |
18 | 14 | { |
19 | 15 | static u32 call; |
20 | 16 | s32 off; |
21 | 17 |
|
22 | 18 | off = ((s32)addr - (s32)ip); |
23 | 19 | call = 0x40000000 | ((u32)off >> 2); |
24 | 20 |
|
25 | | - return (unsigned char *) &call; |
| 21 | + return call; |
26 | 22 | } |
27 | 23 |
|
28 | | -int |
29 | | -ftrace_modify_code(unsigned long ip, unsigned char *old_code, |
30 | | - unsigned char *new_code) |
| 24 | +static int ftrace_modify_code(unsigned long ip, u32 old, u32 new) |
31 | 25 | { |
32 | | - u32 old = *(u32 *)old_code; |
33 | | - u32 new = *(u32 *)new_code; |
34 | 26 | u32 replaced; |
35 | 27 | int faulted; |
36 | 28 |
|
@@ -59,18 +51,43 @@ ftrace_modify_code(unsigned long ip, unsigned char *old_code, |
59 | 51 | return faulted; |
60 | 52 | } |
61 | 53 |
|
| 54 | +int 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 | + |
| 64 | +int 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 | + |
62 | 74 | int ftrace_update_ftrace_func(ftrace_func_t func) |
63 | 75 | { |
64 | 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 | 80 | new = ftrace_call_replace(ip, (unsigned long)func); |
69 | 81 | return ftrace_modify_code(ip, old, new); |
70 | 82 | } |
71 | 83 |
|
72 | 84 | int __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 | 90 | return 0; |
76 | 91 | } |
| 92 | +#endif |
| 93 | + |
0 commit comments