]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
KVM: align valid EFER bits with the features of the host system
authorJoerg Roedel <joerg.roedel@amd.com>
Thu, 31 Jan 2008 13:57:38 +0000 (14:57 +0100)
committerAvi Kivity <avi@qumranet.com>
Sun, 27 Apr 2008 08:53:18 +0000 (11:53 +0300)
This patch aligns the bits the guest can set in the EFER register with the
features in the host processor. Currently it lets EFER.NX disabled if the
processor does not support it and enables EFER.LME and EFER.LMA only for KVM on
64 bit hosts.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
arch/x86/kvm/svm.c
arch/x86/kvm/vmx.c
arch/x86/kvm/x86.c

index 1a582f1090e895aaa19634aa21d02ccf6c1584f0..ff3bc74af728a2f8e6d525ba0e5962793e58a577 100644 (file)
@@ -403,6 +403,9 @@ static __init int svm_hardware_setup(void)
        set_msr_interception(msrpm_va, MSR_IA32_SYSENTER_ESP, 1, 1);
        set_msr_interception(msrpm_va, MSR_IA32_SYSENTER_EIP, 1, 1);
 
+       if (boot_cpu_has(X86_FEATURE_NX))
+               kvm_enable_efer_bits(EFER_NX);
+
        for_each_online_cpu(cpu) {
                r = svm_cpu_init(cpu);
                if (r)
index 1157e8a4059ba614af58896e14d6915620e27e0f..a509910f6b532fb2060ecc781b4516958ac666bf 100644 (file)
@@ -1117,6 +1117,10 @@ static __init int hardware_setup(void)
 {
        if (setup_vmcs_config(&vmcs_config) < 0)
                return -EIO;
+
+       if (boot_cpu_has(X86_FEATURE_NX))
+               kvm_enable_efer_bits(EFER_NX);
+
        return alloc_kvm_area();
 }
 
index ec9265b354b057d3a686b7c7ab96d9f9014aeabd..db16f2353e4bbdad5d1da5a13db5717ffb12b190 100644 (file)
                          | X86_CR4_OSXMMEXCPT | X86_CR4_VMXE))
 
 #define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR)
-static u64 __read_mostly efer_reserved_bits = 0xfffffffffffff2fe;
+/* EFER defaults:
+ * - enable syscall per default because its emulated by KVM
+ * - enable LME and LMA per default on 64 bit KVM
+ */
+#ifdef CONFIG_X86_64
+static u64 __read_mostly efer_reserved_bits = 0xfffffffffffffafeULL;
+#else
+static u64 __read_mostly efer_reserved_bits = 0xfffffffffffffffeULL;
+#endif
 
 #define VM_STAT(x) offsetof(struct kvm, stat.x), KVM_STAT_VM
 #define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU