From patchwork Mon Jul 4 23:09:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 943102 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 p64N9ilY028759 for ; Mon, 4 Jul 2011 23:09:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752818Ab1GDXJi (ORCPT ); Mon, 4 Jul 2011 19:09:38 -0400 Received: from mail-ww0-f44.google.com ([74.125.82.44]:56183 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752586Ab1GDXJh (ORCPT ); Mon, 4 Jul 2011 19:09:37 -0400 Received: by wwe5 with SMTP id 5so5406433wwe.1 for ; Mon, 04 Jul 2011 16:09:36 -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:in-reply-to:references; bh=CxlhSEDmY+XXHNu2NdqAMbYk5UAjZuxwMNMPpXBrG40=; b=moPfPaXautLXJtZyft9b46cNGNsJx9b63rrG5NSnKXV9KTn2LK9usz526WEyFbPqTi 5HA0XlCzJqarORPSwPQkpH2Y3tZ0Z/4TiTmwjFqWWbFzDCJ5wiaoF78EbZgtEZnI9edX u51fKFYKz6bSQ0r48cnobXil8UfHZ7QsZHFyM= Received: by 10.216.88.132 with SMTP id a4mr1633381wef.31.1309820976045; Mon, 04 Jul 2011 16:09:36 -0700 (PDT) Received: from localhost.localdomain ([31.210.184.221]) by mx.google.com with ESMTPS id w62sm3331696wec.42.2011.07.04.16.09.34 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 04 Jul 2011 16:09:35 -0700 (PDT) From: Sasha Levin To: kvm@vger.kernel.org Cc: Sasha Levin , Avi Kivity , Marcelo Tosatti Subject: [PATCH 2/2] vmx,svm: Print errors if SVM or VMX were already set Date: Tue, 5 Jul 2011 02:09:14 +0300 Message-Id: <1309820954-8629-2-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1309820954-8629-1-git-send-email-levinsasha928@gmail.com> References: <1309820954-8629-1-git-send-email-levinsasha928@gmail.com> 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) Instead of exiting quietly, print an error if the VMX or the SVM bits were already set when loading the module. Having VMX/SVM bits set means that either there is someone else doing hardware virtualization, or that the BIOS is buggy and sets it on by default. Cc: Avi Kivity Cc: Marcelo Tosatti Signed-off-by: Sasha Levin --- arch/x86/kvm/svm.c | 5 ++++- arch/x86/kvm/vmx.c | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 5ca76e3..2a1df2e 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -590,8 +590,11 @@ static int svm_hardware_enable(void *garbage) int me = raw_smp_processor_id(); rdmsrl(MSR_EFER, efer); - if (check_inuse && (efer & EFER_SVME)) + if (check_inuse && (efer & EFER_SVME)) { + printk(KERN_ERR "svm_hardware_enable: SVM already set on %d\n", + me); return -EBUSY; + } if (!has_svm()) { printk(KERN_ERR "svm_hardware_enable: err EOPNOTSUPP on %d\n", diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 3046b07..df69b1d 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -2233,8 +2233,10 @@ static int hardware_enable(void *garbage) u64 phys_addr = __pa(per_cpu(vmxarea, cpu)); u64 old, test_bits; - if (check_inuse && (read_cr4() & X86_CR4_VMXE)) + if (check_inuse && (read_cr4() & X86_CR4_VMXE)) { + printk(KERN_ERR "hardware_enable: VMX already set\n"); return -EBUSY; + } INIT_LIST_HEAD(&per_cpu(loaded_vmcss_on_cpu, cpu)); rdmsrl(MSR_IA32_FEATURE_CONTROL, old);