From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: [PATCH v2] kvm: x86: emulate monitor and mwait instructions as nop Date: Wed, 4 Jun 2014 22:37:39 +0300 Message-ID: <20140604193738.GA744@redhat.com> References: <20140507205210.GA30030@ERROL.INI.CMU.EDU> <20140602192530.GC1653@ERROL.INI.CMU.EDU> <538D92BC.4060203@redhat.com> <20140604143941.GF1653@ERROL.INI.CMU.EDU> <538F30BD.5000501@suse.de> <20140604150519.GG1653@ERROL.INI.CMU.EDU> <538F36BD.9040404@suse.de> <20140604170720.GH1653@ERROL.INI.CMU.EDU> <20140604190618.GF11756@redhat.com> <20140604192405.GI1653@ERROL.INI.CMU.EDU> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Alexander Graf , Paolo Bonzini , kvm@vger.kernel.org To: "Gabriel L. Somlo" Return-path: Received: from mx1.redhat.com ([209.132.183.28]:1150 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751293AbaFDThN (ORCPT ); Wed, 4 Jun 2014 15:37:13 -0400 Content-Disposition: inline In-Reply-To: <20140604192405.GI1653@ERROL.INI.CMU.EDU> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Jun 04, 2014 at 03:24:06PM -0400, Gabriel L. Somlo wrote: > On Wed, Jun 04, 2014 at 10:06:18PM +0300, Michael S. Tsirkin wrote: > > On Wed, Jun 04, 2014 at 01:07:21PM -0400, Gabriel L. Somlo wrote: > > > Ah, so kvm_vcpu_ioctl_set_cpuid() and friends, morally similar to > > > kvm_vcpu_ioctl_enable_cap() on ppc, except it turns on cpuid flags > > > instead of entire kvm capabilities. > > > > > > So we either have > > > > > > 1 always-on but masked-by-default monitor/mwait as > > > nop, and enable just the cpuid flag on demand via the > > > existing ioctl_enable_cap() mechanism (and I have to > > > check out the qemu parser for cpuid command-line flags), > > > > > > or > > > > > > 2 off-by-default monitor/mwait/cpuid-flag, enabled via > > > ioctl_enable_cap(), which would have to first be ported > > > to x86, and would require somewhat more extensive qemu > > > hackery to take advantage of. > > > > > > I think I sense a "path of least resistance" here, even though IMHO > > > #2 is still "The Right Thing To Do (TM)" :) :) > > > > > > Thanks, > > > --Gabriel > > > > I think it's worng. > > We really can't emulate mwait at the moment. > > All we manage to do is a work-around for broken guests. > > > > So let's not pretend that we can, just enable nop > > unconditionally and be done with it. > > Paolo already said it's OK with him, and I'll ack too. > > > > Otherwise you are giving bad information to well-behaved guests, > > so e.g. linux will try to use mwait. You don't want this. > > That's why I suggested having it default to disabled, and only > allowing it to be turned on per VM, explicitly. Turn on the bit in CPUID? Why is it useful? I thought the point of the nop hack is work around for broken guests. > > The advantage is that if at some point CPUs can > > actually support mwait in VMs, at that point > > we will enable the CPUID bit, and userspace and guests > > will be able to detect that and rely on that bit > > to mean "mwait works and is efficient". > > OK, that makes sense. Thanks for helping me finally get over it ;) > > --Gabriel