Re: [PATCH 2/4] x86/kprobes: Fix frame pointer annotations

From: Peter Zijlstra
Date: Fri May 10 2019 - 08:16:33 EST


On Fri, May 10, 2019 at 12:21:03PM +0900, Masami Hiramatsu wrote:
> On Thu, 9 May 2019 13:43:16 -0400
> Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> > On Thu, May 09, 2019 at 09:20:06AM -0700, Andy Lutomirski wrote:
> > > > +END(call_to_exception_trampoline)
> > > > --- a/arch/x86/kernel/kprobes/core.c
> > > > +++ b/arch/x86/kernel/kprobes/core.c
> > > > @@ -731,29 +731,8 @@ asm(
> > > > ".global kretprobe_trampoline\n"
> > > > ".type kretprobe_trampoline, @function\n"
> > > > "kretprobe_trampoline:\n"
> > > > - /* We don't bother saving the ss register */
> > > > -#ifdef CONFIG_X86_64
> > > > - " pushq %rsp\n"
> > > > - " pushfq\n"
> > > > - SAVE_REGS_STRING
> > > > - " movq %rsp, %rdi\n"
> > > > - " call trampoline_handler\n"
> > > > - /* Replace saved sp with true return address. */
> > > > - " movq %rax, 19*8(%rsp)\n"
> > > > - RESTORE_REGS_STRING
> > > > - " popfq\n"
> > > > -#else
> > > > - " pushl %esp\n"
> > > > - " pushfl\n"
> > > > - SAVE_REGS_STRING
> > > > - " movl %esp, %eax\n"
> > > > - " call trampoline_handler\n"
> > > > - /* Replace saved sp with true return address. */
> > > > - " movl %eax, 15*4(%esp)\n"
> > > > - RESTORE_REGS_STRING
> > > > - " popfl\n"
> > > > -#endif
> > > > - " ret\n"
> > > > + "push trampoline_handler\n"
> > > > + "jmp call_to_exception_trampoline\n"
> > > > ".size kretprobe_trampoline, .-kretprobe_trampoline\n"
> > > > );
> > >
> > >
> > > Potentially minor nit: youâre doing popfl, but youâre not doing TRACE_IRQ_whatever. This makes me think that you should either add the tracing (ugh!) or you should maybe just skip the popfl.
> >
> >
> > Note, kprobes (and ftrace for that matter) are not saving flags for
> > interrupts, but because it must not modify the sign, zero and carry flags.

Uh, C ABI considers those clobbered over function calls, surely. Relying
on those flags over a CALL would be _insane_.