summaryrefslogtreecommitdiff
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.S14
1 files changed, 14 insertions, 0 deletions
diff --git a/arch/mips/kernel/mcount.S b/arch/mips/kernel/mcount.S
index 522e91c688fc..0a9cfdb271dd 100644
--- a/arch/mips/kernel/mcount.S
+++ b/arch/mips/kernel/mcount.S
@@ -70,6 +70,9 @@ _mcount:
nop
MCOUNT_SAVE_REGS
+#ifdef KBUILD_MCOUNT_RA_ADDRESS
+ PTR_S t0, PT_R12(sp) /* t0 saved the location of the return address(at) by -mmcount-ra-address */
+#endif
move a0, ra /* arg1: next ip, selfaddr */
.globl ftrace_call
@@ -133,11 +136,22 @@ ftrace_stub:
NESTED(ftrace_graph_caller, PT_SIZE, ra)
#ifdef CONFIG_DYNAMIC_FTRACE
PTR_L a1, PT_R31(sp) /* load the original ra from the stack */
+#ifdef KBUILD_MCOUNT_RA_ADDRESS
+ PTR_L t0, PT_R12(sp) /* load the original t0 from the stack */
+#endif
#else
MCOUNT_SAVE_REGS
move a1, ra /* arg2: next ip, selfaddr */
#endif
+
+#ifdef KBUILD_MCOUNT_RA_ADDRESS
+ bnez t0, 1f /* non-leaf func: t0 saved the location of the return address */
+ nop
+ PTR_LA t0, PT_R1(sp) /* leaf func: get the location of at(old ra) from our own stack */
+1: move a0, t0 /* arg1: the location of the return address */
+#else
PTR_LA a0, PT_R1(sp) /* arg1: &AT -> a0 */
+#endif
jal prepare_ftrace_return
#ifdef CONFIG_FRAME_POINTER
move a2, fp /* arg3: frame pointer */