Merge branches 'at91', 'cache', 'cup', 'ep93xx', 'ixp4xx', 'nuc', 'pending-dma-stream...
[sfrench/cifs-2.6.git] / arch / mips / kernel / mcount.S
index 98d4690325066d2828019c808f16731732d6db7c..0a9cfdb271dd2c2c92f0cb8f31930f84d73c6127 100644 (file)
@@ -65,11 +65,14 @@ NESTED(ftrace_caller, PT_SIZE, ra)
 _mcount:
        b       ftrace_stub
         nop
-       lw      t0, function_trace_stop
-       bnez    t0, ftrace_stub
+       lw      t1, function_trace_stop
+       bnez    t1, ftrace_stub
         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
@@ -93,21 +96,21 @@ ftrace_stub:
 #else  /* ! CONFIG_DYNAMIC_FTRACE */
 
 NESTED(_mcount, PT_SIZE, ra)
-       lw      t0, function_trace_stop
-       bnez    t0, ftrace_stub
+       lw      t1, function_trace_stop
+       bnez    t1, ftrace_stub
         nop
-       PTR_LA  t0, ftrace_stub
-       PTR_L   t1, ftrace_trace_function /* Prepare t1 for (1) */
-       bne     t0, t1, static_trace
+       PTR_LA  t1, ftrace_stub
+       PTR_L   t2, ftrace_trace_function /* Prepare t2 for (1) */
+       bne     t1, t2, static_trace
         nop
 
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
-       PTR_L   t2, ftrace_graph_return
-       bne     t0, t2, ftrace_graph_caller
+       PTR_L   t3, ftrace_graph_return
+       bne     t1, t3, ftrace_graph_caller
         nop
-       PTR_LA  t0, ftrace_graph_entry_stub
-       PTR_L   t2, ftrace_graph_entry
-       bne     t0, t2, ftrace_graph_caller
+       PTR_LA  t1, ftrace_graph_entry_stub
+       PTR_L   t3, ftrace_graph_entry
+       bne     t1, t3, ftrace_graph_caller
         nop
 #endif
        b       ftrace_stub
@@ -117,7 +120,7 @@ static_trace:
        MCOUNT_SAVE_REGS
 
        move    a0, ra          /* arg1: next ip, selfaddr */
-       jalr    t1      /* (1) call *ftrace_trace_function */
+       jalr    t2              /* (1) call *ftrace_trace_function */
         move   a1, AT          /* arg2: the caller's next ip, parent */
 
        MCOUNT_RESTORE_REGS
@@ -133,13 +136,32 @@ 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 */
+#else
+#ifdef CONFIG_64BIT
+        PTR_LA a2, PT_SIZE(sp)
+#else
+        PTR_LA a2, (PT_SIZE+8)(sp)
+#endif
+#endif
 
        MCOUNT_RESTORE_REGS
        RETURN_BACK