From: "Gabriel L. Somlo" Subject: Re: [PATCH v2] kvm: x86: emulate monitor and mwait instructions as nop Date: Tue, 3 Jun 2014 15:07:13 -0400 Message-ID: <20140603190712.GE1653@ERROL.INI.CMU.EDU> References: <20140507205210.GA30030@ERROL.INI.CMU.EDU> <20140602192530.GC1653@ERROL.INI.CMU.EDU> <538D92BC.4060203@redhat.com> <20140603142157.GD1653@ERROL.INI.CMU.EDU> <538DEBA4.5020600@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Paolo Bonzini , kvm@vger.kernel.org, mst@redhat.com, afaerber@suse.de To: Alexander Graf Return-path: Received: from mail-qg0-f49.google.com ([209.85.192.49]:40404 "EHLO mail-qg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752813AbaFCTHQ (ORCPT ); Tue, 3 Jun 2014 15:07:16 -0400 Received: by mail-qg0-f49.google.com with SMTP id a108so13602686qge.22 for ; Tue, 03 Jun 2014 12:07:15 -0700 (PDT) Content-Disposition: inline In-Reply-To: <538DEBA4.5020600@suse.de> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Jun 03, 2014 at 05:37:08PM +0200, Alexander Graf wrote: > On 06/03/2014 04:21 PM, Gabriel L. Somlo wrote: > >On Tue, Jun 03, 2014 at 11:17:48AM +0200, Paolo Bonzini wrote: > >>I think it's fine as it is now. :) > >On Mon, Jun 02, 2014 at 09:55:18PM -0400, Gabriel L. Somlo wrote: > >>W.r.t. monitor/mwait, a guest can do one of the following: > >> > >>1. Never check CPUID, and never use monitor/mwait > >> - This is great, we don't have to do anything about these > >> > >>2. Check CPUID for mwait, use it to idle in preference over hlt > >> - Linux, Windows, and Mavericks (10.9) do this > >> - we never want to have CPUID say "yes" to these, since > >> monitor/mwait support will be clunky in the best case, > >> and hlt is overwhelmingly preferable! [*] > >> > >>3. Never check CPUID, use monitor/mwait with abandon > >> - OS X 10.6 .. 10.8 does this > >> - emulating monitor/mwait here allows us to boot the guest > >> and use it, and perform sysadmin surgery to force a hlt > >> based idle > >> > >>4. Check CPUID, panic if unavailable > >> - OS X 10.5 did this, IIRC. > >> - whether I can do kext surgery and get it to stop checking > >> CPUID *in addition to* falling back to hlt-based idle is > >> TBD. > >> - emulating monitor/mwait allows us to boot this type of > >> guest, BUT WE ALSO HAVE TO ADVERTISE IT VIA CPUID !!! > >As it is right now, #4 is not being addressed (and we can't just > >advertise mwait via cpuid, or we'd be screwing up #2). > > I think we should be able to handle #4 by doing -cpu core2duo,+monitor on > the QEMU command line which should override the cpuid bits that the kernel > tells us. Using that (with kvm patched to do monitor = mwait = nop, but without advertising it in cpuid), I still get a "Monitor feature not present" panic with the 10.5.6 Leopard install DVD. Patching kvm to add F(MWAIT) to kvm_supported_word4_x86_features gets me past that panic. Did you mean "-cpu core2duo,+monitor" should work right now, or that we'd have to add a quick patch to QEMU to make it happen ? (it doesn't complain when I do that now, just doesn't work :) Thx, --Gabriel > > > Alex > > > > >I also feel a bit weird about the "undocumented feature" aspect > >of NOT generating an invalid opcode for something that *should* > >be an invalid opcode according to the feature set advertised via > >cpuid... > > > >So if there's a way to make it so we can tell QEMU/KVM to > >"--enable-mwait" on a per-guest basis, I think that'd be better > >than an always-on "undocumented" behavior... > > > >But then again, I'm most likely missing something about the big > >picture... :) > > > >Thanks much, > >--Gabriel >