On Wed, Oct 16, 2024 at 09:59:12AM +0900, Masami Hiramatsu (Google) wrote: > From: Masami Hiramatsu (Google) <[email protected]> > > Add ftrace_fill_perf_regs() which should be compatible with the > perf_fetch_caller_regs(). In other words, the pt_regs returned from the > ftrace_fill_perf_regs() must satisfy 'user_mode(regs) == false' and can be > used for stack tracing. > > Signed-off-by: Masami Hiramatsu (Google) <[email protected]> > Cc: Steven Rostedt <[email protected]> > Cc: Mark Rutland <[email protected]> > Cc: Catalin Marinas <[email protected]> > Cc: Will Deacon <[email protected]> > Cc: Michael Ellerman <[email protected]> > Cc: Nicholas Piggin <[email protected]> > Cc: Christophe Leroy <[email protected]> > Cc: Naveen N Rao <[email protected]> > Cc: Madhavan Srinivasan <[email protected]> > Cc: Heiko Carstens <[email protected]> > Cc: Vasily Gorbik <[email protected]> > Cc: Alexander Gordeev <[email protected]> > Cc: Christian Borntraeger <[email protected]> > Cc: Sven Schnelle <[email protected]> > Cc: Thomas Gleixner <[email protected]> > Cc: Ingo Molnar <[email protected]> > Cc: Borislav Petkov <[email protected]> > Cc: Dave Hansen <[email protected]> > Cc: [email protected] > Cc: "H. Peter Anvin" <[email protected]> > > --- > Changes in v16: > - Fix s390 to clear psw.mask according to Heiko's suggestion. > --- > arch/arm64/include/asm/ftrace.h | 7 +++++++ > arch/powerpc/include/asm/ftrace.h | 7 +++++++ > arch/s390/include/asm/ftrace.h | 6 ++++++ > arch/x86/include/asm/ftrace.h | 7 +++++++ > include/linux/ftrace.h | 31 +++++++++++++++++++++++++++++++ > 5 files changed, 58 insertions(+) > > diff --git a/arch/arm64/include/asm/ftrace.h b/arch/arm64/include/asm/ftrace.h > index d344c69eb01e..6493a575664f 100644 > --- a/arch/arm64/include/asm/ftrace.h > +++ b/arch/arm64/include/asm/ftrace.h > @@ -146,6 +146,13 @@ ftrace_partial_regs(const struct ftrace_regs *fregs, > struct pt_regs *regs) > return regs; > } > > +#define arch_ftrace_fill_perf_regs(fregs, _regs) do { \ > + (_regs)->pc = arch_ftrace_regs(fregs)->pc; > \ > + (_regs)->regs[29] = arch_ftrace_regs(fregs)->fp; > \ > + (_regs)->sp = arch_ftrace_regs(fregs)->sp; > \ > + (_regs)->pstate = PSR_MODE_EL1h; \ > + } while (0)
arm64 bit looks correct to me: Acked-by: Will Deacon <[email protected]> Will
