Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Copyright (C) 2000 Anton Blanchard (anton@linuxcare.com) | |
3 | * | |
4 | * This file implements mcount(), which is used to collect profiling data. | |
5 | * This can also be tweaked for kernel stack overflow detection. | |
6 | */ | |
7 | ||
1da177e4 LT |
8 | #include <linux/linkage.h> |
9 | ||
1da177e4 LT |
10 | /* |
11 | * This is the main variant and is called by C code. GCC's -pg option | |
12 | * automatically instruments every C function with a call to this. | |
13 | */ | |
14 | ||
1da177e4 | 15 | .text |
d05f5f99 DM |
16 | .align 32 |
17 | .globl _mcount | |
18 | .type _mcount,#function | |
19 | .globl mcount | |
20 | .type mcount,#function | |
1da177e4 | 21 | _mcount: |
d05f5f99 | 22 | mcount: |
606576ce | 23 | #ifdef CONFIG_FUNCTION_TRACER |
d05f5f99 | 24 | #ifdef CONFIG_DYNAMIC_FTRACE |
63b75495 | 25 | /* Do nothing, the retl/nop below is all we need. */ |
d05f5f99 | 26 | #else |
2563b9d9 | 27 | sethi %hi(ftrace_trace_function), %g1 |
d05f5f99 DM |
28 | sethi %hi(ftrace_stub), %g2 |
29 | ldx [%g1 + %lo(ftrace_trace_function)], %g1 | |
30 | or %g2, %lo(ftrace_stub), %g2 | |
31 | cmp %g1, %g2 | |
32 | be,pn %icc, 1f | |
9960e9e8 | 33 | mov %i7, %g3 |
035df35d | 34 | save %sp, -176, %sp |
9960e9e8 | 35 | mov %g3, %o1 |
a71d1d6b DM |
36 | jmpl %g1, %o7 |
37 | mov %i7, %o0 | |
38 | ret | |
39 | restore | |
d05f5f99 DM |
40 | /* not reached */ |
41 | 1: | |
9960e9e8 DM |
42 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
43 | sethi %hi(ftrace_graph_return), %g1 | |
44 | ldx [%g1 + %lo(ftrace_graph_return)], %g3 | |
45 | cmp %g2, %g3 | |
46 | bne,pn %xcc, 5f | |
47 | sethi %hi(ftrace_graph_entry_stub), %g2 | |
48 | sethi %hi(ftrace_graph_entry), %g1 | |
49 | or %g2, %lo(ftrace_graph_entry_stub), %g2 | |
50 | ldx [%g1 + %lo(ftrace_graph_entry)], %g1 | |
51 | cmp %g1, %g2 | |
52 | be,pt %xcc, 2f | |
53 | nop | |
54 | 5: mov %i7, %g2 | |
55 | mov %fp, %g3 | |
035df35d | 56 | save %sp, -176, %sp |
9960e9e8 DM |
57 | mov %g2, %l0 |
58 | ba,pt %xcc, ftrace_graph_caller | |
59 | mov %g3, %l1 | |
60 | #endif | |
61 | 2: | |
1da177e4 | 62 | #endif |
d05f5f99 DM |
63 | #endif |
64 | retl | |
1da177e4 | 65 | nop |
d05f5f99 DM |
66 | .size _mcount,.-_mcount |
67 | .size mcount,.-mcount | |
68 | ||
606576ce | 69 | #ifdef CONFIG_FUNCTION_TRACER |
d05f5f99 DM |
70 | .globl ftrace_stub |
71 | .type ftrace_stub,#function | |
72 | ftrace_stub: | |
73 | retl | |
74 | nop | |
75 | .size ftrace_stub,.-ftrace_stub | |
76 | #ifdef CONFIG_DYNAMIC_FTRACE | |
77 | .globl ftrace_caller | |
78 | .type ftrace_caller,#function | |
79 | ftrace_caller: | |
a71d1d6b | 80 | mov %i7, %g2 |
2563b9d9 | 81 | mov %fp, %g3 |
035df35d | 82 | save %sp, -176, %sp |
a71d1d6b | 83 | mov %g2, %o1 |
9960e9e8 DM |
84 | mov %g2, %l0 |
85 | mov %g3, %l1 | |
d05f5f99 DM |
86 | .globl ftrace_call |
87 | ftrace_call: | |
88 | call ftrace_stub | |
a71d1d6b | 89 | mov %i7, %o0 |
9960e9e8 DM |
90 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
91 | .globl ftrace_graph_call | |
92 | ftrace_graph_call: | |
93 | call ftrace_stub | |
94 | nop | |
95 | #endif | |
a71d1d6b DM |
96 | ret |
97 | restore | |
9960e9e8 DM |
98 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
99 | .size ftrace_graph_call,.-ftrace_graph_call | |
100 | #endif | |
63b75495 | 101 | .size ftrace_call,.-ftrace_call |
d05f5f99 DM |
102 | .size ftrace_caller,.-ftrace_caller |
103 | #endif | |
104 | #endif | |
9960e9e8 DM |
105 | |
106 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | |
107 | ENTRY(ftrace_graph_caller) | |
108 | mov %l0, %o0 | |
109 | mov %i7, %o1 | |
110 | call prepare_ftrace_return | |
111 | mov %l1, %o2 | |
112 | ret | |
113 | restore %o0, -8, %i7 | |
114 | END(ftrace_graph_caller) | |
115 | ||
116 | ENTRY(return_to_handler) | |
035df35d | 117 | save %sp, -176, %sp |
9960e9e8 DM |
118 | call ftrace_return_to_handler |
119 | mov %fp, %o0 | |
120 | jmpl %o0 + 8, %g0 | |
121 | restore | |
122 | END(return_to_handler) | |
123 | #endif |