Re: [RFC][PATCH] objtool,x86_64,paravirt: Add pv_ops[] support

From: peterz
Date: Mon Aug 03 2020 - 11:59:38 EST


On Mon, Aug 03, 2020 at 08:15:02AM -0700, Andy Lutomirski wrote:
> On Mon, Aug 3, 2020 at 7:33 AM <peterz@xxxxxxxxxxxxx> wrote:
> >
> >
> > Thomas wanted paramuck vs noinstr, here goes. Very rough, very nasty,
> > mostly works.
> >
> > It requires call sites are the normal indirect call, and not mangled
> > retpoison (slow_down_io() had those), it also requires pv_ops[]
> > assignments are single instructions and not laundered through some
> > pointless intermediate helper (hyperv).
> >
> > It doesn't warn when you get any of that wrong.
> >
> > But if you have it all lined up right, it will warn about noinstr
> > violations due to paramuck:
>
> I certainly agree that pv_ops is mucky, but could you expound on
> precisely what this patch actually does? On a very quick
> read-through, I'm guessing you're complaining about any call to pv_ops
> in a noinstr section? But maybe this is only calls to pv_ops that
> aren't themselves noinstr?

Yeah, it makes sure that any pv_op called from noinstr are to a noinstr
function.

The example here:

../../defconfig-build/vmlinux.o: warning: objtool: exc_double_fault()+0x15: call pv_ops[48] from noinstr
../../defconfig-build/vmlinux.o: warning: objtool: pv_op[48]: xen_read_cr2
../../defconfig-build/vmlinux.o: warning: objtool: exc_double_fault()+0x15: call to {dynamic}() leaves .noinstr.text section

complains about exc_double_fault(), a noinstr function, calling to
xen_read_cr2(), a regular function.

Basically, for every pv_ops[] entry, it compiles a list of assigned
functions, and when there's a noinstr call, it makes sure all functions
assigned to that pv_op are noinstr.