diff options
Diffstat (limited to 'arch/microblaze/kernel/ftrace.c')
-rw-r--r-- | arch/microblaze/kernel/ftrace.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/arch/microblaze/kernel/ftrace.c b/arch/microblaze/kernel/ftrace.c index c1889b101cb8..0952a8b52c35 100644 --- a/arch/microblaze/kernel/ftrace.c +++ b/arch/microblaze/kernel/ftrace.c | |||
@@ -14,6 +14,64 @@ | |||
14 | #include <asm/cacheflush.h> | 14 | #include <asm/cacheflush.h> |
15 | #include <linux/ftrace.h> | 15 | #include <linux/ftrace.h> |
16 | 16 | ||
17 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | ||
18 | /* | ||
19 | * Hook the return address and push it in the stack of return addrs | ||
20 | * in current thread info. | ||
21 | */ | ||
22 | void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr) | ||
23 | { | ||
24 | unsigned long old; | ||
25 | int faulted, err; | ||
26 | struct ftrace_graph_ent trace; | ||
27 | unsigned long return_hooker = (unsigned long) | ||
28 | &return_to_handler; | ||
29 | |||
30 | if (unlikely(atomic_read(¤t->tracing_graph_pause))) | ||
31 | return; | ||
32 | |||
33 | /* | ||
34 | * Protect against fault, even if it shouldn't | ||
35 | * happen. This tool is too much intrusive to | ||
36 | * ignore such a protection. | ||
37 | */ | ||
38 | asm volatile(" 1: lwi %0, %2, 0; \ | ||
39 | 2: swi %3, %2, 0; \ | ||
40 | addik %1, r0, 0; \ | ||
41 | 3: \ | ||
42 | .section .fixup, \"ax\"; \ | ||
43 | 4: brid 3b; \ | ||
44 | addik %1, r0, 1; \ | ||
45 | .previous; \ | ||
46 | .section __ex_table,\"a\"; \ | ||
47 | .word 1b,4b; \ | ||
48 | .word 2b,4b; \ | ||
49 | .previous;" \ | ||
50 | : "=&r" (old), "=r" (faulted) | ||
51 | : "r" (parent), "r" (return_hooker) | ||
52 | ); | ||
53 | |||
54 | if (unlikely(faulted)) { | ||
55 | ftrace_graph_stop(); | ||
56 | WARN_ON(1); | ||
57 | return; | ||
58 | } | ||
59 | |||
60 | err = ftrace_push_return_trace(old, self_addr, &trace.depth, 0); | ||
61 | if (err == -EBUSY) { | ||
62 | *parent = old; | ||
63 | return; | ||
64 | } | ||
65 | |||
66 | trace.func = self_addr; | ||
67 | /* Only trace if the calling function expects to */ | ||
68 | if (!ftrace_graph_entry(&trace)) { | ||
69 | current->curr_ret_stack--; | ||
70 | *parent = old; | ||
71 | } | ||
72 | } | ||
73 | #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ | ||
74 | |||
17 | #ifdef CONFIG_DYNAMIC_FTRACE | 75 | #ifdef CONFIG_DYNAMIC_FTRACE |
18 | /* save value to addr - it is save to do it in asm */ | 76 | /* save value to addr - it is save to do it in asm */ |
19 | static int ftrace_modify_code(unsigned long addr, unsigned int value) | 77 | static int ftrace_modify_code(unsigned long addr, unsigned int value) |