hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/riscv/kernel/ftrace.c
....@@ -15,11 +15,21 @@
1515 int ftrace_arch_code_modify_prepare(void) __acquires(&text_mutex)
1616 {
1717 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
+
1827 return 0;
1928 }
2029
2130 int ftrace_arch_code_modify_post_process(void) __releases(&text_mutex)
2231 {
32
+ riscv_patch_in_stop_machine = false;
2333 mutex_unlock(&text_mutex);
2434 return 0;
2535 }
....@@ -109,9 +119,9 @@
109119 {
110120 int out;
111121
112
- ftrace_arch_code_modify_prepare();
122
+ mutex_lock(&text_mutex);
113123 out = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
114
- ftrace_arch_code_modify_post_process();
124
+ mutex_unlock(&text_mutex);
115125
116126 return out;
117127 }