Re: linux-next: Tree for Aug 27 (objtool)

From: Masami Hiramatsu
Date: Wed Aug 28 2019 - 21:54:07 EST


This is a multi-part message in MIME format.
Hi Josh,

On Wed, 28 Aug 2019 11:34:33 -0500
Josh Poimboeuf <jpoimboe@xxxxxxxxxx> wrote:

> On Wed, Aug 28, 2019 at 11:13:31AM -0500, Josh Poimboeuf wrote:
> > Turns out this patch does break something:
> >
> > arch/x86/xen/enlighten_pv.o: warning: objtool: xen_cpuid()+0x25: can't find jump dest instruction at .text+0x9c
> >
> > I'll need to figure out a better way to whitelist that
> > XEN_EMULATE_PREFIX fake instruction thing. I'll probably just teach
> > the objtool decoder about it.
>
> Hi Masami,
>
> Is it possible for the kernel x86 decoder to recognize the
> XEN_EMULATE_PREFIX prefix?
>
> asm(XEN_EMULATE_PREFIX "cpuid"
> : "=a" (*ax),
> "=b" (*bx),
> "=c" (*cx),
> "=d" (*dx)
> : "0" (*ax), "2" (*cx));
>
> is disassembled to:
>
> 33: 0f 0b ud2
> 35: 78 65 js 9c <xen_store_tr+0xc>
> 37: 6e outsb %ds:(%rsi),(%dx)
> 38: 0f a2 cpuid
>
> which confuses objtool. Presumably that would confuse other users of
> the decoder as well.

Good catch! It should be problematic, since x86 decoder sanity test is
based on objtool. But I don't want to change the test code itself,
because this problem is highly depending on Xen.

> That's a highly unlikely sequence of instructions, maybe the kernel
> decoder should recognize it as a single instruction.

OK, it is better to be done in decoder (only for CONFIG_XEN_PVHVM)

BTW, could you also share what test case would you using?

And what about attached patch? (just compile checked with/without CONFIG_XEN_PVHVM)

Thank you,


--
Masami Hiramatsu <mhiramat@xxxxxxxxxx>