]> git.baikalelectronics.ru Git - kernel.git/commitdiff
powerpc/ftrace: Prepare PPC32's ftrace_caller() for CONFIG_DYNAMIC_FTRACE_WITH_ARGS
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Mon, 20 Dec 2021 16:38:22 +0000 (16:38 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 7 Feb 2022 10:03:11 +0000 (21:03 +1100)
In order to implement CONFIG_DYNAMIC_FTRACE_WITH_ARGS, change
ftrace_caller() stack layout to match struct pt_regs.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/da9734eba504998fb914aca12131c9f6bf6120a8.1640017960.git.christophe.leroy@csgroup.eu
arch/powerpc/include/asm/ftrace.h
arch/powerpc/kernel/trace/ftrace_32.S

index debe8c4f7062608ed43320ec16ae41251031ea6a..b3f6184f77eaade525b07b1b415d1a981f573a9f 100644 (file)
 
 #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
 
-#ifdef __ASSEMBLY__
-
-/* Based off of objdump output 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__ */
+#ifndef __ASSEMBLY__
 extern void _mcount(void);
 
 static inline unsigned long ftrace_call_adjust(unsigned long addr)
index 95ffea2bdc29a1bd27085157bafa68ac4e622837..c4055b41af5fd06c8878b41865ea99129d0039b5 100644 (file)
@@ -27,17 +27,38 @@ _GLOBAL(_mcount)
 EXPORT_SYMBOL(_mcount)
 
 _GLOBAL(ftrace_caller)
-       MCOUNT_SAVE_FRAME
-       /* r3 ends up with link register */
+       stwu    r1, -INT_FRAME_SIZE(r1)
+
+       SAVE_GPRS(3, 10, r1)
+
+       addi    r8, r1, INT_FRAME_SIZE
+       stw     r8, GPR1(r1)
+
+       mflr    r3
+       stw     r3, _NIP(r1)
        subi    r3, r3, MCOUNT_INSN_SIZE
+
+       stw     r0, _LINK(r1)
+       mr      r4, r0
+
        lis     r5,function_trace_op@ha
        lwz     r5,function_trace_op@l(r5)
-       li      r6, 0
+
+       addi    r6, r1, STACK_FRAME_OVERHEAD
 .globl ftrace_call
 ftrace_call:
        bl      ftrace_stub
        nop
-       MCOUNT_RESTORE_FRAME
+
+       lwz     r3, _NIP(r1)
+       mtctr   r3
+
+       REST_GPRS(3, 10, r1)
+
+       lwz     r0, _LINK(r1)
+       mtlr    r0
+
+       addi    r1, r1, INT_FRAME_SIZE
 ftrace_caller_common:
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
 .globl ftrace_graph_call