aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2008-01-31 08:57:38 -0500
committerAvi Kivity <avi@qumranet.com>2008-04-27 04:53:18 -0400
commit50a37eb4e05efaa7bac6a948fd4db1a48c728b99 (patch)
tree34195810be002db84cfafb9ed706d48bb6752d52
parentf2b4b7ddf633ffa24ce7c89c9e0d8a06463484e3 (diff)
KVM: align valid EFER bits with the features of the host system
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>
-rw-r--r--arch/x86/kvm/svm.c3
-rw-r--r--arch/x86/kvm/vmx.c4
-rw-r--r--arch/x86/kvm/x86.c10
3 files changed, 16 insertions, 1 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 1a582f1090e8..ff3bc74af728 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -403,6 +403,9 @@ static __init int svm_hardware_setup(void)
403 set_msr_interception(msrpm_va, MSR_IA32_SYSENTER_ESP, 1, 1); 403 set_msr_interception(msrpm_va, MSR_IA32_SYSENTER_ESP, 1, 1);
404 set_msr_interception(msrpm_va, MSR_IA32_SYSENTER_EIP, 1, 1); 404 set_msr_interception(msrpm_va, MSR_IA32_SYSENTER_EIP, 1, 1);
405 405
406 if (boot_cpu_has(X86_FEATURE_NX))
407 kvm_enable_efer_bits(EFER_NX);
408
406 for_each_online_cpu(cpu) { 409 for_each_online_cpu(cpu) {
407 r = svm_cpu_init(cpu); 410 r = svm_cpu_init(cpu);
408 if (r) 411 if (r)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 1157e8a4059b..a509910f6b53 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1117,6 +1117,10 @@ static __init int hardware_setup(void)
1117{ 1117{
1118 if (setup_vmcs_config(&vmcs_config) < 0) 1118 if (setup_vmcs_config(&vmcs_config) < 0)
1119 return -EIO; 1119 return -EIO;
1120
1121 if (boot_cpu_has(X86_FEATURE_NX))
1122 kvm_enable_efer_bits(EFER_NX);
1123
1120 return alloc_kvm_area(); 1124 return alloc_kvm_area();
1121} 1125}
1122 1126
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index ec9265b354b0..db16f2353e4b 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -41,7 +41,15 @@
41 | X86_CR4_OSXMMEXCPT | X86_CR4_VMXE)) 41 | X86_CR4_OSXMMEXCPT | X86_CR4_VMXE))
42 42
43#define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR) 43#define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR)
44static u64 __read_mostly efer_reserved_bits = 0xfffffffffffff2fe; 44/* EFER defaults:
45 * - enable syscall per default because its emulated by KVM
46 * - enable LME and LMA per default on 64 bit KVM
47 */
48#ifdef CONFIG_X86_64
49static u64 __read_mostly efer_reserved_bits = 0xfffffffffffffafeULL;
50#else
51static u64 __read_mostly efer_reserved_bits = 0xfffffffffffffffeULL;
52#endif
45 53
46#define VM_STAT(x) offsetof(struct kvm, stat.x), KVM_STAT_VM 54#define VM_STAT(x) offsetof(struct kvm, stat.x), KVM_STAT_VM
47#define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU 55#define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU