Re: [PATCH v2] kvm: x86: emulate monitor and mwait instructions as nop

Gabriel L. Somlo
2014-06-04T14:39:45Z

Paolo,

I noticed the monitor=mwait=nop patch is making its way upstream, so
thanks !

I'm still interested in following up with something that would enable
this behavior only conditionally (e.g. following an ioctl call from
userspace to enable it only for the (set of) vcpu(s) belonging to one
guest VM at a time), which should then also include advertising the
feature in CPUID.

I grep-ed through the kvm sources for KVM_CAP for some inspiration,
and it looks more like KVM_CAP_* is a way to tell userspace what the
kernel supports, but nothing I saw showed me an example of a "tunable"
feature that userspace may ask to be turned on or off (e.g per-vcpu).

Is there something like that I could use as an example ?

Obviously, if you really like the current behavior better you can
always reject whatever patch I'll come up with, but I'd like to at
least try and see what it would look like :)

Thanks,
--Gabriel

On Tue, Jun 03, 2014 at 11:17:48AM +0200, Paolo Bonzini wrote:
> Il 02/06/2014 21:25, Gabriel L. Somlo ha scritto:
> >Would it make sense to make this a module parameter,
> >(e.g., "int emulate_mwait") ?
> >
> >Default would be 0 (no emulation). 1 would mean "emulate as nop", and
> >if anyone ever figures out how to do proper page-locking based
> >emulation we could use 2 to enable that, etc. ?
> >
> >Not sure we'd want qemu to enable/disable it automatically, though...
> >
> >What do you all think ?
>
> I think it's fine as it is now. :)
>
> Paolo