]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
KVM: SVM: Reliably detect if SVM was disabled by BIOS
authorJoerg Roedel <joerg.roedel@amd.com>
Wed, 18 Jul 2007 16:51:36 +0000 (19:51 +0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 9 Aug 2007 21:27:30 +0000 (14:27 -0700)
This patch adds an implementation to the svm is_disabled function to
detect reliably if the BIOS disabled the SVM feature in the CPU. This
fixes the issues with kernel panics when loading the kvm-amd module on
machines where SVM is available but disabled.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/kvm/svm.c
drivers/kvm/svm.h

index fa17d6d4f0cb64f0052e41194ee15cbb775cd070..aee952fa029d88e3e4255b2337500c085925e102 100644 (file)
@@ -1727,6 +1727,12 @@ static void svm_inject_page_fault(struct kvm_vcpu *vcpu,
 
 static int is_disabled(void)
 {
+       u64 vm_cr;
+
+       rdmsrl(MSR_VM_CR, vm_cr);
+       if (vm_cr & (1 << SVM_VM_CR_SVM_DISABLE))
+               return 1;
+
        return 0;
 }
 
index 5e93814400ce3725db0fb6eb3a07289302f0a79f..3b1b0f35b6cba172ac5fbb58cdceec93cdc7221c 100644 (file)
@@ -175,8 +175,11 @@ struct __attribute__ ((__packed__)) vmcb {
 #define SVM_CPUID_FUNC 0x8000000a
 
 #define MSR_EFER_SVME_MASK (1ULL << 12)
+#define MSR_VM_CR       0xc0010114
 #define MSR_VM_HSAVE_PA 0xc0010117ULL
 
+#define SVM_VM_CR_SVM_DISABLE 4
+
 #define SVM_SELECTOR_S_SHIFT 4
 #define SVM_SELECTOR_DPL_SHIFT 5
 #define SVM_SELECTOR_P_SHIFT 7