From: Alexander Graf Subject: Re: [PATCH 9/9] Allow setting the SVME bit v5 Date: Wed, 29 Oct 2008 15:03:15 +0100 Message-ID: <063522FE-5E35-44A0-AE99-B594CEC61363@suse.de> References: <1224522290-11740-1-git-send-email-agraf@suse.de> <1224522290-11740-2-git-send-email-agraf@suse.de> <1224522290-11740-3-git-send-email-agraf@suse.de> <1224522290-11740-4-git-send-email-agraf@suse.de> <1224522290-11740-5-git-send-email-agraf@suse.de> <1224522290-11740-6-git-send-email-agraf@suse.de> <1224522290-11740-7-git-send-email-agraf@suse.de> <1224522290-11740-8-git-send-email-agraf@suse.de> <1224522290-11740-9-git-send-email-agraf@suse.de> <1224522290-11740-10-git-send-email-agraf@suse.de> <20081029135832.GE11682@8bytes.org> Mime-Version: 1.0 (Apple Message framework v929.2) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, anthony@codemonkey.ws, avi@redhat.com To: Joerg Roedel Return-path: Received: from ns1.suse.de ([195.135.220.2]:33045 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754234AbYJ2ODW (ORCPT ); Wed, 29 Oct 2008 10:03:22 -0400 In-Reply-To: <20081029135832.GE11682@8bytes.org> Sender: kvm-owner@vger.kernel.org List-ID: On 29.10.2008, at 14:58, Joerg Roedel wrote: > On Mon, Oct 20, 2008 at 07:04:50PM +0200, Alexander Graf wrote: >> Normally setting the SVME bit in EFER is not allowed, as we did >> not support SVM. Not since we do, we should also allow enabling >> SVM mode. >> >> v2 comes as last patch, so we don't enable half-ready code >> v4 introduces a module option to enable SVM >> >> Signed-off-by: Alexander Graf >> --- >> arch/x86/kvm/svm.c | 6 ++++++ >> 1 files changed, 6 insertions(+), 0 deletions(-) >> >> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c >> index 4582699..1e63860 100644 >> --- a/arch/x86/kvm/svm.c >> +++ b/arch/x86/kvm/svm.c >> @@ -68,6 +68,9 @@ static int npt = 1; >> >> module_param(npt, int, S_IRUGO); >> >> +static int nested = 0; >> +module_param(nested, int, S_IRUGO); >> + >> static void kvm_reput_irq(struct vcpu_svm *svm); >> static void svm_flush_tlb(struct kvm_vcpu *vcpu); >> >> @@ -457,6 +460,9 @@ static __init int svm_hardware_setup(void) >> if (boot_cpu_has(X86_FEATURE_NX)) >> kvm_enable_efer_bits(EFER_NX); >> >> + if (nested) >> + kvm_enable_efer_bits(MSR_EFER_SVME_MASK); >> + >> for_each_online_cpu(cpu) { >> r = svm_cpu_init(cpu); >> if (r) > > > What I think is missing here is some kind of userspace interface. If > we > do it this way (with a kernel parameter) we should expose to userspace > if nested svm is enabled. This way userspace knows whether it has to > set > the SVM CPUID bit or not. To an Operating System, the SVM CPUID should not imply that SVM works. The firmware can easily disable it by locking the SVM capability MSR to "off". Maybe we could expose this behavior in the nested=0 case. I don't believe we need a userspace interface for now. The userspace part does not need to know what capabilities the virtual CPU has - that's what the CPUID masking in the kvm code is for IMHO.