]> git.baikalelectronics.ru Git - kernel.git/commitdiff
powerpc/ftrace: Have arch_ftrace_get_regs() return NULL unless FL_SAVE_REGS is set
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Tue, 15 Feb 2022 18:31:24 +0000 (19:31 +0100)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 16 Feb 2022 12:09:47 +0000 (23:09 +1100)
When FL_SAVE_REGS is not set we get here via ftrace_caller()
which doesn't save all registers.

ftrace_caller() explicitely clears regs.msr, so we can rely
on it to know where we come from. We don't expect MSR register
to be 0 at all when involving ftrace.

Fixes: cf4e1809c66b ("powerpc/ftrace: Implement CONFIG_DYNAMIC_FTRACE_WITH_ARGS")
Reported-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/2f9a7e898c93cc7438ef5ccd47cb9c3a9c5b53ef.1644949750.git.christophe.leroy@csgroup.eu
arch/powerpc/include/asm/ftrace.h
arch/powerpc/kernel/trace/ftrace_mprofile.S

index 70b457097098a5f94b2379a2d1366416d4768f91..ff034ae4e472599afc49e7a7b8212c69417d979a 100644 (file)
@@ -30,7 +30,8 @@ struct ftrace_regs {
 
 static __always_inline struct pt_regs *arch_ftrace_get_regs(struct ftrace_regs *fregs)
 {
-       return &fregs->regs;
+       /* We clear regs.msr in ftrace_call */
+       return fregs->regs.msr ? &fregs->regs : NULL;
 }
 
 static __always_inline void ftrace_instruction_pointer_set(struct ftrace_regs *fregs,
index 8443902d5a05aa446aab60e017a584967df4b6d3..eb077270ec2fd26041be838a22a81cc069d2800c 100644 (file)
@@ -205,6 +205,10 @@ _GLOBAL(ftrace_caller)
        PPC_STL r0, _LINK(r1)
        mr      r4, r0
 
+       /* Clear MSR to flag as ftrace_caller versus frace_regs_caller */
+       li      r8, 0
+       PPC_STL r8, _MSR(r1)
+
        /* Load &pt_regs in r6 for call below */
        addi    r6, r1 ,STACK_FRAME_OVERHEAD