aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/ftrace.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/trace/ftrace.c')
-rw-r--r--kernel/trace/ftrace.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index cf59f4c54745..5a3a06b21eee 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -557,8 +557,11 @@ static void ftrace_replace_code(int enable)
557 if ((system_state == SYSTEM_BOOTING) || 557 if ((system_state == SYSTEM_BOOTING) ||
558 !core_kernel_text(rec->ip)) { 558 !core_kernel_text(rec->ip)) {
559 ftrace_free_rec(rec); 559 ftrace_free_rec(rec);
560 } else 560 } else {
561 ftrace_bug(failed, rec->ip); 561 ftrace_bug(failed, rec->ip);
562 /* Stop processing */
563 return;
564 }
562 } 565 }
563 } while_for_each_ftrace_rec(); 566 } while_for_each_ftrace_rec();
564} 567}
@@ -580,6 +583,24 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
580 return 1; 583 return 1;
581} 584}
582 585
586/*
587 * archs can override this function if they must do something
588 * before the modifying code is performed.
589 */
590int __weak ftrace_arch_code_modify_prepare(void)
591{
592 return 0;
593}
594
595/*
596 * archs can override this function if they must do something
597 * after the modifying code is performed.
598 */
599int __weak ftrace_arch_code_modify_post_process(void)
600{
601 return 0;
602}
603
583static int __ftrace_modify_code(void *data) 604static int __ftrace_modify_code(void *data)
584{ 605{
585 int *command = data; 606 int *command = data;
@@ -602,7 +623,17 @@ static int __ftrace_modify_code(void *data)
602 623
603static void ftrace_run_update_code(int command) 624static void ftrace_run_update_code(int command)
604{ 625{
626 int ret;
627
628 ret = ftrace_arch_code_modify_prepare();
629 FTRACE_WARN_ON(ret);
630 if (ret)
631 return;
632
605 stop_machine(__ftrace_modify_code, &command, NULL); 633 stop_machine(__ftrace_modify_code, &command, NULL);
634
635 ret = ftrace_arch_code_modify_post_process();
636 FTRACE_WARN_ON(ret);
606} 637}
607 638
608static ftrace_func_t saved_ftrace_func; 639static ftrace_func_t saved_ftrace_func;