]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
powerpc32, ftrace: save and restore mcount regs with macro
authorSteven Rostedt <rostedt@goodmis.org>
Wed, 11 Feb 2009 20:01:18 +0000 (15:01 -0500)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Sun, 22 Feb 2009 23:48:54 +0000 (10:48 +1100)
Impact: clean up

Use a macro to save and restore the registers for PowerPC32,
since that code is duplicated.

This is similar to the work done by Cyrill Gorcunov for the
mcount code in x86_64.

Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/include/asm/ftrace.h
arch/powerpc/kernel/entry_32.S

index e5f2ae8362f7ea8e15fcaca975fefa6e3662010b..dde1296b8b41a903dd2707f0d9465162efd36fbc 100644 (file)
@@ -5,7 +5,44 @@
 #define MCOUNT_ADDR            ((long)(_mcount))
 #define MCOUNT_INSN_SIZE       4 /* sizeof mcount call */
 
-#ifndef __ASSEMBLY__
+#ifdef __ASSEMBLY__
+
+/* Based off of objdump optput from glibc */
+
+#define MCOUNT_SAVE_FRAME                      \
+       stwu    r1,-48(r1);                     \
+       stw     r3, 12(r1);                     \
+       stw     r4, 16(r1);                     \
+       stw     r5, 20(r1);                     \
+       stw     r6, 24(r1);                     \
+       mflr    r3;                             \
+       lwz     r4, 52(r1);                     \
+       mfcr    r5;                             \
+       stw     r7, 28(r1);                     \
+       stw     r8, 32(r1);                     \
+       stw     r9, 36(r1);                     \
+       stw     r10,40(r1);                     \
+       stw     r3, 44(r1);                     \
+       stw     r5, 8(r1)
+
+#define MCOUNT_RESTORE_FRAME                   \
+       lwz     r6, 8(r1);                      \
+       lwz     r0, 44(r1);                     \
+       lwz     r3, 12(r1);                     \
+       mtctr   r0;                             \
+       lwz     r4, 16(r1);                     \
+       mtcr    r6;                             \
+       lwz     r5, 20(r1);                     \
+       lwz     r6, 24(r1);                     \
+       lwz     r0, 52(r1);                     \
+       lwz     r7, 28(r1);                     \
+       lwz     r8, 32(r1);                     \
+       mtlr    r0;                             \
+       lwz     r9, 36(r1);                     \
+       lwz     r10,40(r1);                     \
+       addi    r1, r1, 48
+
+#else /* !__ASSEMBLY__ */
 extern void _mcount(void);
 
 #ifdef CONFIG_DYNAMIC_FTRACE
index 301c646d1a7d75840fb11ba732a27bb8fdcc3f2c..fd54cb59728ef646b8384476c8d40ff6c62fb93e 100644 (file)
@@ -1176,59 +1176,22 @@ _GLOBAL(_mcount)
        bctr
 
 _GLOBAL(ftrace_caller)
-       /* Based off of objdump optput from glibc */
-       stwu    r1,-48(r1)
-       stw     r3, 12(r1)
-       stw     r4, 16(r1)
-       stw     r5, 20(r1)
-       stw     r6, 24(r1)
-       mflr    r3
-       lwz     r4, 52(r1)
-       mfcr    r5
-       stw     r7, 28(r1)
-       stw     r8, 32(r1)
-       stw     r9, 36(r1)
-       stw     r10,40(r1)
-       stw     r3, 44(r1)
-       stw     r5, 8(r1)
+       MCOUNT_SAVE_FRAME
+       /* r3 ends up with link register */
        subi    r3, r3, MCOUNT_INSN_SIZE
 .globl ftrace_call
 ftrace_call:
        bl      ftrace_stub
        nop
-       lwz     r6, 8(r1)
-       lwz     r0, 44(r1)
-       lwz     r3, 12(r1)
-       mtctr   r0
-       lwz     r4, 16(r1)
-       mtcr    r6
-       lwz     r5, 20(r1)
-       lwz     r6, 24(r1)
-       lwz     r0, 52(r1)
-       lwz     r7, 28(r1)
-       lwz     r8, 32(r1)
-       mtlr    r0
-       lwz     r9, 36(r1)
-       lwz     r10,40(r1)
-       addi    r1, r1, 48
+
+       MCOUNT_RESTORE_FRAME
+       /* old link register ends up in ctr reg */
        bctr
 #else
 _GLOBAL(mcount)
 _GLOBAL(_mcount)
-       stwu    r1,-48(r1)
-       stw     r3, 12(r1)
-       stw     r4, 16(r1)
-       stw     r5, 20(r1)
-       stw     r6, 24(r1)
-       mflr    r3
-       lwz     r4, 52(r1)
-       mfcr    r5
-       stw     r7, 28(r1)
-       stw     r8, 32(r1)
-       stw     r9, 36(r1)
-       stw     r10,40(r1)
-       stw     r3, 44(r1)
-       stw     r5, 8(r1)
+
+       MCOUNT_SAVE_FRAME
 
        subi    r3, r3, MCOUNT_INSN_SIZE
        LOAD_REG_ADDR(r5, ftrace_trace_function)
@@ -1239,21 +1202,8 @@ _GLOBAL(_mcount)
 
        nop
 
-       lwz     r6, 8(r1)
-       lwz     r0, 44(r1)
-       lwz     r3, 12(r1)
-       mtctr   r0
-       lwz     r4, 16(r1)
-       mtcr    r6
-       lwz     r5, 20(r1)
-       lwz     r6, 24(r1)
-       lwz     r0, 52(r1)
-       lwz     r7, 28(r1)
-       lwz     r8, 32(r1)
-       mtlr    r0
-       lwz     r9, 36(r1)
-       lwz     r10,40(r1)
-       addi    r1, r1, 48
+       MCOUNT_RESTORE_FRAME
+       
        bctr
 #endif