.. | .. |
---|
15 | 15 | int ftrace_arch_code_modify_prepare(void) __acquires(&text_mutex) |
---|
16 | 16 | { |
---|
17 | 17 | mutex_lock(&text_mutex); |
---|
| 18 | + |
---|
| 19 | + /* |
---|
| 20 | + * The code sequences we use for ftrace can't be patched while the |
---|
| 21 | + * kernel is running, so we need to use stop_machine() to modify them |
---|
| 22 | + * for now. This doesn't play nice with text_mutex, we use this flag |
---|
| 23 | + * to elide the check. |
---|
| 24 | + */ |
---|
| 25 | + riscv_patch_in_stop_machine = true; |
---|
| 26 | + |
---|
18 | 27 | return 0; |
---|
19 | 28 | } |
---|
20 | 29 | |
---|
21 | 30 | int ftrace_arch_code_modify_post_process(void) __releases(&text_mutex) |
---|
22 | 31 | { |
---|
| 32 | + riscv_patch_in_stop_machine = false; |
---|
23 | 33 | mutex_unlock(&text_mutex); |
---|
24 | 34 | return 0; |
---|
25 | 35 | } |
---|
.. | .. |
---|
109 | 119 | { |
---|
110 | 120 | int out; |
---|
111 | 121 | |
---|
112 | | - ftrace_arch_code_modify_prepare(); |
---|
| 122 | + mutex_lock(&text_mutex); |
---|
113 | 123 | out = ftrace_make_nop(mod, rec, MCOUNT_ADDR); |
---|
114 | | - ftrace_arch_code_modify_post_process(); |
---|
| 124 | + mutex_unlock(&text_mutex); |
---|
115 | 125 | |
---|
116 | 126 | return out; |
---|
117 | 127 | } |
---|