aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/kernel/mcount.S
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/kernel/mcount.S')
-rw-r--r--arch/mips/kernel/mcount.S55
1 files changed, 34 insertions, 21 deletions
diff --git a/arch/mips/kernel/mcount.S b/arch/mips/kernel/mcount.S
index 6851fc97a511..6bfcb7a00ec6 100644
--- a/arch/mips/kernel/mcount.S
+++ b/arch/mips/kernel/mcount.S
@@ -6,6 +6,7 @@
6 * more details. 6 * more details.
7 * 7 *
8 * Copyright (C) 2009 Lemote Inc. & DSLab, Lanzhou University, China 8 * Copyright (C) 2009 Lemote Inc. & DSLab, Lanzhou University, China
9 * Copyright (C) 2010 DSLab, Lanzhou University, China
9 * Author: Wu Zhangjin <wuzhangjin@gmail.com> 10 * Author: Wu Zhangjin <wuzhangjin@gmail.com>
10 */ 11 */
11 12
@@ -45,8 +46,6 @@
45 PTR_L a5, PT_R9(sp) 46 PTR_L a5, PT_R9(sp)
46 PTR_L a6, PT_R10(sp) 47 PTR_L a6, PT_R10(sp)
47 PTR_L a7, PT_R11(sp) 48 PTR_L a7, PT_R11(sp)
48#endif
49#ifdef CONFIG_64BIT
50 PTR_ADDIU sp, PT_SIZE 49 PTR_ADDIU sp, PT_SIZE
51#else 50#else
52 PTR_ADDIU sp, (PT_SIZE + 8) 51 PTR_ADDIU sp, (PT_SIZE + 8)
@@ -58,6 +57,12 @@
58 move ra, AT 57 move ra, AT
59 .endm 58 .endm
60 59
60/*
61 * The -mmcount-ra-address option of gcc 4.5 uses register $12 to pass
62 * the location of the parent's return address.
63 */
64#define MCOUNT_RA_ADDRESS_REG $12
65
61#ifdef CONFIG_DYNAMIC_FTRACE 66#ifdef CONFIG_DYNAMIC_FTRACE
62 67
63NESTED(ftrace_caller, PT_SIZE, ra) 68NESTED(ftrace_caller, PT_SIZE, ra)
@@ -71,14 +76,14 @@ _mcount:
71 76
72 MCOUNT_SAVE_REGS 77 MCOUNT_SAVE_REGS
73#ifdef KBUILD_MCOUNT_RA_ADDRESS 78#ifdef KBUILD_MCOUNT_RA_ADDRESS
74 PTR_S t0, PT_R12(sp) /* t0 saved the location of the return address(at) by -mmcount-ra-address */ 79 PTR_S MCOUNT_RA_ADDRESS_REG, PT_R12(sp)
75#endif 80#endif
76 81
77 move a0, ra /* arg1: next ip, selfaddr */ 82 move a0, ra /* arg1: self return address */
78 .globl ftrace_call 83 .globl ftrace_call
79ftrace_call: 84ftrace_call:
80 nop /* a placeholder for the call to a real tracing function */ 85 nop /* a placeholder for the call to a real tracing function */
81 move a1, AT /* arg2: the caller's next ip, parent */ 86 move a1, AT /* arg2: parent's return address */
82 87
83#ifdef CONFIG_FUNCTION_GRAPH_TRACER 88#ifdef CONFIG_FUNCTION_GRAPH_TRACER
84 .globl ftrace_graph_call 89 .globl ftrace_graph_call
@@ -119,9 +124,9 @@ NESTED(_mcount, PT_SIZE, ra)
119static_trace: 124static_trace:
120 MCOUNT_SAVE_REGS 125 MCOUNT_SAVE_REGS
121 126
122 move a0, ra /* arg1: next ip, selfaddr */ 127 move a0, ra /* arg1: self return address */
123 jalr t2 /* (1) call *ftrace_trace_function */ 128 jalr t2 /* (1) call *ftrace_trace_function */
124 move a1, AT /* arg2: the caller's next ip, parent */ 129 move a1, AT /* arg2: parent's return address */
125 130
126 MCOUNT_RESTORE_REGS 131 MCOUNT_RESTORE_REGS
127 .globl ftrace_stub 132 .globl ftrace_stub
@@ -134,28 +139,34 @@ ftrace_stub:
134#ifdef CONFIG_FUNCTION_GRAPH_TRACER 139#ifdef CONFIG_FUNCTION_GRAPH_TRACER
135 140
136NESTED(ftrace_graph_caller, PT_SIZE, ra) 141NESTED(ftrace_graph_caller, PT_SIZE, ra)
137#ifdef CONFIG_DYNAMIC_FTRACE 142#ifndef CONFIG_DYNAMIC_FTRACE
138 PTR_L a1, PT_R31(sp) /* load the original ra from the stack */
139#ifdef KBUILD_MCOUNT_RA_ADDRESS
140 PTR_L t0, PT_R12(sp) /* load the original t0 from the stack */
141#endif
142#else
143 MCOUNT_SAVE_REGS 143 MCOUNT_SAVE_REGS
144 move a1, ra /* arg2: next ip, selfaddr */
145#endif 144#endif
146 145
146 /* arg1: Get the location of the parent's return address */
147#ifdef KBUILD_MCOUNT_RA_ADDRESS 147#ifdef KBUILD_MCOUNT_RA_ADDRESS
148 bnez t0, 1f /* non-leaf func: t0 saved the location of the return address */ 148#ifdef CONFIG_DYNAMIC_FTRACE
149 PTR_L a0, PT_R12(sp)
150#else
151 move a0, MCOUNT_RA_ADDRESS_REG
152#endif
153 bnez a0, 1f /* non-leaf func: stored in MCOUNT_RA_ADDRESS_REG */
149 nop 154 nop
150 PTR_LA t0, PT_R1(sp) /* leaf func: get the location of at(old ra) from our own stack */ 155#endif
1511: move a0, t0 /* arg1: the location of the return address */ 156 PTR_LA a0, PT_R1(sp) /* leaf func: the location in current stack */
1571:
158
159 /* arg2: Get self return address */
160#ifdef CONFIG_DYNAMIC_FTRACE
161 PTR_L a1, PT_R31(sp)
152#else 162#else
153 PTR_LA a0, PT_R1(sp) /* arg1: &AT -> a0 */ 163 move a1, ra
154#endif 164#endif
155 jal prepare_ftrace_return 165
166 /* arg3: Get frame pointer of current stack */
156#ifdef CONFIG_FRAME_POINTER 167#ifdef CONFIG_FRAME_POINTER
157 move a2, fp /* arg3: frame pointer */ 168 move a2, fp
158#else 169#else /* ! CONFIG_FRAME_POINTER */
159#ifdef CONFIG_64BIT 170#ifdef CONFIG_64BIT
160 PTR_LA a2, PT_SIZE(sp) 171 PTR_LA a2, PT_SIZE(sp)
161#else 172#else
@@ -163,6 +174,8 @@ NESTED(ftrace_graph_caller, PT_SIZE, ra)
163#endif 174#endif
164#endif 175#endif
165 176
177 jal prepare_ftrace_return
178 nop
166 MCOUNT_RESTORE_REGS 179 MCOUNT_RESTORE_REGS
167 RETURN_BACK 180 RETURN_BACK
168 END(ftrace_graph_caller) 181 END(ftrace_graph_caller)