From patchwork Mon Jul 4 23:09:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 943092 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p64N9ilX028759 for ; Mon, 4 Jul 2011 23:09:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752784Ab1GDXJg (ORCPT ); Mon, 4 Jul 2011 19:09:36 -0400 Received: from mail-ww0-f44.google.com ([74.125.82.44]:63967 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752586Ab1GDXJf (ORCPT ); Mon, 4 Jul 2011 19:09:35 -0400 Received: by wwe5 with SMTP id 5so5406424wwe.1 for ; Mon, 04 Jul 2011 16:09:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=PpVpvuvOW4hqzFlgbeho0gK3tsLLOaEHA4vqZ4d3VBY=; b=Tl5hZ29uFiDrW5AGtJswWAbov5Sa44kw88u4avDDatmF/LHE76bSD4A3SxbR+bQ1Du hL7R+oqcr3pQlQ1+LSaiDg4qcs7hRUQidXa82ovx/OTaFgQD43v0qcBOvpL4oEWva+zj 1kGAwVvJFL8CxAxg1KsLaR9P3Q7UY93Zgohkk= Received: by 10.216.68.203 with SMTP id l53mr5501289wed.84.1309820974281; Mon, 04 Jul 2011 16:09:34 -0700 (PDT) Received: from localhost.localdomain ([31.210.184.221]) by mx.google.com with ESMTPS id w62sm3331696wec.42.2011.07.04.16.09.28 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 04 Jul 2011 16:09:33 -0700 (PDT) From: Sasha Levin To: kvm@vger.kernel.org Cc: Sasha Levin , Avi Kivity , Marcelo Tosatti Subject: [PATCH 1/2] vmx, svm: Add module parameter to ignore the 'in use' check Date: Tue, 5 Jul 2011 02:09:13 +0300 Message-Id: <1309820954-8629-1-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.6 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 04 Jul 2011 23:09:44 +0000 (UTC) Add a module parameter 'check_inuse' to allow disabling the check of whether virtualization has already been enabled on the given cpu. This is needed to deal with broken BIOS which set the SVM/VMX bit by default. Cc: Avi Kivity Cc: Marcelo Tosatti Suggested-by: Alexander Graf Signed-off-by: Sasha Levin --- arch/x86/kvm/svm.c | 5 ++++- arch/x86/kvm/vmx.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 475d1c9..5ca76e3 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -183,6 +183,9 @@ module_param(npt, int, S_IRUGO); static int nested = 1; module_param(nested, int, S_IRUGO); +static bool check_inuse = 1; +module_param(check_inuse, bool, S_IRUGO); + static void svm_flush_tlb(struct kvm_vcpu *vcpu); static void svm_complete_interrupts(struct vcpu_svm *svm); @@ -587,7 +590,7 @@ static int svm_hardware_enable(void *garbage) int me = raw_smp_processor_id(); rdmsrl(MSR_EFER, efer); - if (efer & EFER_SVME) + if (check_inuse && (efer & EFER_SVME)) return -EBUSY; if (!has_svm()) { diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index f5b49c7..3046b07 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -74,6 +74,9 @@ module_param(vmm_exclusive, bool, S_IRUGO); static int __read_mostly yield_on_hlt = 1; module_param(yield_on_hlt, bool, S_IRUGO); +static bool check_inuse = 1; +module_param(check_inuse, bool, S_IRUGO); + /* * If nested=1, nested virtualization is supported, i.e., guests may use * VMX and be a hypervisor for its own guests. If nested=0, guests may not @@ -2230,7 +2233,7 @@ static int hardware_enable(void *garbage) u64 phys_addr = __pa(per_cpu(vmxarea, cpu)); u64 old, test_bits; - if (read_cr4() & X86_CR4_VMXE) + if (check_inuse && (read_cr4() & X86_CR4_VMXE)) return -EBUSY; INIT_LIST_HEAD(&per_cpu(loaded_vmcss_on_cpu, cpu));