Re: [RFC][PATCH 5/5] ftrace/x86-32: Add -mfentry support to x86_32 with DYNAMIC_FTRACE set

From: Steven Rostedt
Date: Wed Mar 15 2017 - 19:15:31 EST


On Wed, 15 Mar 2017 16:55:45 -0500
Josh Poimboeuf <jpoimboe@xxxxxxxxxx> wrote:

> On Wed, Mar 15, 2017 at 03:55:32PM -0400, Steven Rostedt wrote:
> > +#ifdef USING_FRAME_POINTER
> > +# ifdef CC_USING_FENTRY
> > + /*
> > + * Frame pointers are of ip followed by bp.
> > + * Since fentry is an immediate jump, we are left with
> > + * parent-ip, function-ip. We need to add a frame with
> > + * parent-ip followed by ebp.
> > + */
> > + pushl 4(%esp) /* parent ip */
> > pushl %ebp
> > movl %esp, %ebp
> > -
> > + pushl 2*4(%esp) /* function ip */
> > +# endif
> > + /* For mcount, the function ip is directly above */
> > + pushl %ebp
> > + movl %esp, %ebp
> > +#endif
>
> More vertical operand alignment issues.
>
> > @@ -85,6 +140,10 @@ ENTRY(ftrace_regs_caller)
> > pushl %edx
> > pushl %ecx
> > pushl %ebx
> > +#ifndef USING_FRAME_POINTER
> > + /* Load 4 off of the parent ip addr into ebp */
> > + lea 14*4(%esp), %ebp
> > +#endif
>
> Instead of:
>
> #ifndef USING_FRAME_POINTER
>
> Shouldn't it be:
>
> #ifdef CC_USING_FENTRY
>
> ?
>
> Otherwise, if I'm reading it right, with fentry and
> CONFIG_FRAME_POINTER=y, ebp will lead to the grandparent's ip instead of
> the parent's ip.

Yep I think you're right. I original added frame pointer setup for the
parent on CC_USING_FENTRY and FRAME_POINTER but that got ugly, this may
be leftover from that.

Thanks, will update.

-- Steve