Re: [RFC][PATCH 2/3] x86_64: Allow breakpoints to emulate call functions

From: Steven Rostedt
Date: Tue May 07 2019 - 15:02:53 EST


On Tue, 7 May 2019 12:53:42 -0500
Josh Poimboeuf <jpoimboe@xxxxxxxxxx> wrote:

> > To handle this, copy the exception frame on entry of the breakpoint handler
> > and have leave a gap that can be used to add a return address to the stack
> > frame and return from the breakpoint to the emulated called function,
> > allowing for that called function to return back to the location after the
> > breakpoint was placed.
>
> This part is done by patch 1.
>
> >
> > The helper functions were also added:
>
> No longer "also" :-)


> > +#ifdef CONFIG_X86_64
> > +static inline void int3_emulate_push(struct pt_regs *regs, unsigned long val)
> > +{
> > + regs->sp -= sizeof(unsigned long);
> > + *(unsigned long *)regs->sp = val;
> > +}
>
> How this works isn't really obvious. A comment is probably warranted to
> explain the fact that the int3 entry code reserved some space on the
> stack.
>


How's this?

-- Steve