On Mon, 21 Oct 2024 18:01:21 +0100 Will Deacon <will@xxxxxxxxxx> wrote: > On Wed, Oct 16, 2024 at 09:59:12AM +0900, Masami Hiramatsu (Google) wrote: > > From: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx> > > > > 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) <mhiramat@xxxxxxxxxx> > > Cc: Steven Rostedt <rostedt@xxxxxxxxxxx> > > Cc: Mark Rutland <mark.rutland@xxxxxxx> > > Cc: Catalin Marinas <catalin.marinas@xxxxxxx> > > Cc: Will Deacon <will@xxxxxxxxxx> > > Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx> > > Cc: Nicholas Piggin <npiggin@xxxxxxxxx> > > Cc: Christophe Leroy <christophe.leroy@xxxxxxxxxx> > > Cc: Naveen N Rao <naveen@xxxxxxxxxx> > > Cc: Madhavan Srinivasan <maddy@xxxxxxxxxxxxx> > > Cc: Heiko Carstens <hca@xxxxxxxxxxxxx> > > Cc: Vasily Gorbik <gor@xxxxxxxxxxxxx> > > Cc: Alexander Gordeev <agordeev@xxxxxxxxxxxxx> > > Cc: Christian Borntraeger <borntraeger@xxxxxxxxxxxxx> > > Cc: Sven Schnelle <svens@xxxxxxxxxxxxx> > > Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> > > Cc: Ingo Molnar <mingo@xxxxxxxxxx> > > Cc: Borislav Petkov <bp@xxxxxxxxx> > > Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx> > > Cc: x86@xxxxxxxxxx > > Cc: "H. Peter Anvin" <hpa@xxxxxxxxx> > > > > --- > > 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 <will@xxxxxxxxxx> Thank you! > > Will -- Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>