Re: [RFC PATCH 06/10] x86/entry: add CFI hint undwarf annotations

From: Josh Poimboeuf
Date: Thu Jun 01 2017 - 11:01:48 EST


On Thu, Jun 01, 2017 at 07:39:38AM -0700, Andy Lutomirski wrote:
> On Thu, Jun 1, 2017 at 7:28 AM, Josh Poimboeuf <jpoimboe@xxxxxxxxxx> wrote:
> > On Thu, Jun 01, 2017 at 09:23:58AM -0500, Josh Poimboeuf wrote:
> >> On Thu, Jun 01, 2017 at 07:03:18AM -0700, Andy Lutomirski wrote:
> >> > On Wed, May 31, 2017 at 10:44 PM, Josh Poimboeuf <jpoimboe@xxxxxxxxxx> wrote:
> >> > Just to make sure I understand this, if we unwind from...
> >> >
> >> > > @@ -112,6 +114,7 @@ For 32-bit we have the following conventions - kernel is built with
> >> > > movq %rdx, 12*8+\offset(%rsp)
> >> > > movq %rsi, 13*8+\offset(%rsp)
> >> >
> >> > ...here..., will objtool think that rdx and rsi (etc) still live in
> >> > their respective regs, or will it find them in the on-stack data given
> >> > by CFI_REGS? If the former, how does undwarf deal with the
> >> > corresponding pops?
> >>
> >> It will find them in their respective registers, which is fine because
> >> they haven't been clobbered yet.
> >
> > Sorry, I hit send too soon. Which pops are you referring to?
> >
>
> If we do push, push, push, CFI_REGS, and then, later, we pop all those
> saved regs, how does undwarf figure out that those pops are moving a
> saved reg from the stack back to a register? Is objtool just that
> smart, or did I fail to notice an annotation somewhere, or does it not
> matter?

RESTORE_EXTRA_REGS has an annotation that attempts to do that, though
CFI_REGS ignores the 'extra' arg so there's a bug there. It should
resolve to a CFI_IRET_REGS annotation with an offset because the
unwinder doesn't care about C regs.

I'll fix that and make the save/restore annotations more symmetrical.

--
Josh