diff mbox

[2/2] vmx,svm: Print errors if SVM or VMX were already set

Message ID 1309820954-8629-2-git-send-email-levinsasha928@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sasha Levin July 4, 2011, 11:09 p.m. 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 <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 arch/x86/kvm/svm.c |    5 ++++-
 arch/x86/kvm/vmx.c |    4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)

Comments

Alexander Graf July 5, 2011, 12:42 a.m. UTC | #1
On 05.07.2011, at 01:09, Sasha Levin wrote:

> 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 <avi@redhat.com>
> Cc: Marcelo Tosatti <mtosatti@redhat.com>
> Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
> ---
> 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",

CPU%d

Also I'd rephrase it as "already in use on". Otherwise looks good :)


Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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);