From: "Michael S. Tsirkin" <mst@redhat.com>
To: Alexander Graf <agraf@suse.de>
Cc: "Gabriel L. Somlo" <gsomlo@gmail.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"pbonzini@redhat.com" <pbonzini@redhat.com>,
"afaerber@suse.de" <afaerber@suse.de>
Subject: Re: [PATCH v2] kvm: x86: emulate monitor and mwait instructions as nop
Date: Mon, 2 Jun 2014 23:41:28 +0300 [thread overview]
Message-ID: <20140602204128.GA5791@redhat.com> (raw)
In-Reply-To: <FBFE1254-8036-4E30-81D9-F42BCE083AC8@suse.de>
On Mon, Jun 02, 2014 at 10:35:56PM +0200, Alexander Graf wrote:
>
>
> > Am 02.06.2014 um 22:20 schrieb "Michael S. Tsirkin" <mst@redhat.com>:
> >
> >> On Mon, Jun 02, 2014 at 09:48:19PM +0200, Alexander Graf wrote:
> >>
> >>
> >>>> Am 02.06.2014 um 21:25 schrieb "Gabriel L. Somlo" <gsomlo@gmail.com>:
> >>>>
> >>>> On Wed, May 07, 2014 at 04:52:13PM -0400, Gabriel L. Somlo wrote:
> >>>> Treat monitor and mwait instructions as nop, which is architecturally
> >>>> correct (but inefficient) behavior. We do this to prevent misbehaving
> >>>> guests (e.g. OS X <= 10.7) from crashing after they fail to check for
> >>>> monitor/mwait availability via cpuid.
> >>>>
> >>>> Since mwait-based idle loops relying on these nop-emulated instructions
> >>>> would keep the host CPU pegged at 100%, do NOT advertise their presence
> >>>> via cpuid, to prevent compliant guests from using them inadvertently.
> >>>>
> >>>> Signed-off-by: Gabriel L. Somlo <somlo@cmu.edu>
> >>>> ---
> >>>>
> >>>> New in v2: remove invalid_op handler functions which were only used to
> >>>> handle exits caused by monitor and mwait
> >>>>
> >>>>>> On Wed, May 07, 2014 at 08:31:27PM +0200, Alexander Graf wrote:
> >>>>>> On 05/07/2014 08:15 PM, Michael S. Tsirkin wrote:
> >>>>>> If we really want to be paranoid and worry about guests
> >>>>>> that use this strange way to trigger invalid opcode,
> >>>>>> we can make it possible for userspace to enable/disable
> >>>>>> this hack, and teach qemu to set it.
> >>>>>>
> >>>>>> That would make it even safer than it was.
> >>>>>>
> >>>>>> Not sure it's worth it, just a thought.
> >>>>>
> >>>>> Since we don't trap on non-exposed other instructions (new SSE and
> >>>>> whatdoiknow) I don't think it's really bad to just expose
> >>>>> MONITOR/MWAIT as nops.
> >>>
> >>> 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 don't like module parameters - they're system global and there's a good chance you want to run non-osx in parallel ;).
> >>
> >> I'd either link this to the cpuid bits or enable it forcefully through ENABLE_CAP per vcpu.
> >>
> >> Alex
> >
> > Point is that.
> > Paolo here thinks it's safe to just make it a NOP unconditionally.
> > so module parameter would be there as a debugging tool:
> > as a means for users to test with old kvm behaviour if they see breakage.
> > Which we don't expect, so no need to waste cycles creating a pretty
> > interface for it.
>
> Both interfaces already exist, so where's the problem?
Hmm sorry which interfaces for enabling mwait nop emulation exist?
> I'm fine with making it always nop too though.
>
> Gabriel was asking how to make it switchable - and the only thing I'd nak is a module parameter because it's not useful.
>
>
> Alex
>
--
MST
next prev parent reply other threads:[~2014-06-02 20:41 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-07 20:52 [PATCH v2] kvm: x86: emulate monitor and mwait instructions as nop Gabriel L. Somlo
2014-06-02 19:25 ` Gabriel L. Somlo
2014-06-02 19:48 ` Alexander Graf
2014-06-02 20:20 ` Michael S. Tsirkin
2014-06-02 20:35 ` Alexander Graf
2014-06-02 20:41 ` Michael S. Tsirkin [this message]
2014-06-02 21:01 ` Alexander Graf
2014-06-03 1:55 ` Gabriel L. Somlo
2014-06-02 20:24 ` Michael S. Tsirkin
2014-06-03 9:17 ` Paolo Bonzini
2014-06-03 14:21 ` Gabriel L. Somlo
2014-06-03 15:37 ` Alexander Graf
2014-06-03 19:07 ` Gabriel L. Somlo
2014-06-10 10:16 ` Michael S. Tsirkin
2014-06-04 14:39 ` Gabriel L. Somlo
2014-06-04 14:44 ` Alexander Graf
2014-06-04 15:05 ` Gabriel L. Somlo
2014-06-04 15:09 ` Alexander Graf
2014-06-04 17:07 ` Gabriel L. Somlo
2014-06-04 19:06 ` Michael S. Tsirkin
2014-06-04 19:24 ` Gabriel L. Somlo
2014-06-04 19:37 ` Michael S. Tsirkin
2014-06-04 16:34 ` Paolo Bonzini
2014-06-04 19:08 ` Michael S. Tsirkin
2014-06-04 19:33 ` Gabriel L. Somlo
2014-06-04 19:40 ` Michael S. Tsirkin
2014-06-04 19:12 ` Nadav Amit
2014-06-04 19:43 ` Gabriel L. Somlo
2014-06-04 20:44 ` Borislav Petkov
2014-06-05 14:40 ` Eduardo Habkost
2014-06-05 20:59 ` Eric Northup
2014-06-05 21:19 ` Gabriel L. Somlo
[not found] <46EF8587-E226-44C5-930A-49E4F7FBBC82@gmail.com>
2014-06-04 20:01 ` Nadav Amit
2014-06-04 20:11 ` Gabriel L. Somlo
2014-06-04 20:55 ` Nadav Amit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140602204128.GA5791@redhat.com \
--to=mst@redhat.com \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=gsomlo@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.