Re: [PATCH 7/9] x86/unwind/orc: Fall back to using frame pointers for generated code

From: Josh Poimboeuf
Date: Fri Jun 14 2019 - 09:39:40 EST


On Thu, Jun 13, 2019 at 11:00:09PM -0700, Alexei Starovoitov wrote:
> > + if (src_reg == BPF_REG_FP) {
> > + /*
> > + * If the value was copied from RBP (real frame pointer),
> > + * adjust it to the BPF program's frame pointer value.
> > + *
> > + * add dst, -40
> > + */
> > + EMIT4(add_1mod(0x48, dst_reg), 0x83, add_1reg(0xC0, dst_reg),
> > + 0xD8);
> > + }
> > +
>
> That won't work. Any register can point to a stack.

Right, but if the stack pointer comes from BPF_REG_FP then won't the
above correct it? Then if the pointer gets passed around to other
registers it will have the correct value. Or did I miss your point?

> The register can point to a stack of a different JITed function as well.

Do you mean tail calls? Or something else? For tail calls the stack is
shared and the stack layout is the same.

--
Josh