aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2013-03-13 11:06:41 -0400
committerGleb Natapov <gleb@redhat.com>2013-03-14 04:00:55 -0400
commitc18911a23ce1dec27fa3325b50587de2569d26f8 (patch)
tree97b89423b1dfdbab7c18ce59073057d4a8d0221e
parenteabeaaccfca0ed61b8e00a09b8cfa703c4f11b59 (diff)
KVM: nVMX: Provide EFER.LMA saving support
We will need EFER.LMA saving to provide unrestricted guest mode. All what is missing for this is picking up EFER.LMA from VM_ENTRY_CONTROLS on L2->L1 switches. If the host does not support EFER.LMA saving, no change is performed, otherwise we properly emulate for L1 what the hardware does for L0. Advertise the support, depending on the host feature. Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Gleb Natapov <gleb@redhat.com>
-rw-r--r--arch/x86/include/asm/vmx.h2
-rw-r--r--arch/x86/kvm/vmx.c13
2 files changed, 14 insertions, 1 deletions
diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
index 3c9f455bacee..056bda586a45 100644
--- a/arch/x86/include/asm/vmx.h
+++ b/arch/x86/include/asm/vmx.h
@@ -95,6 +95,8 @@
95 95
96#define VM_ENTRY_ALWAYSON_WITHOUT_TRUE_MSR 0x000011ff 96#define VM_ENTRY_ALWAYSON_WITHOUT_TRUE_MSR 0x000011ff
97 97
98#define VMX_MISC_SAVE_EFER_LMA 0x00000020
99
98/* VMCS Encodings */ 100/* VMCS Encodings */
99enum vmcs_field { 101enum vmcs_field {
100 VIRTUAL_PROCESSOR_ID = 0x00000000, 102 VIRTUAL_PROCESSOR_ID = 0x00000000,
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 8eaabfb20232..02f8c32b9b08 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2022,6 +2022,7 @@ static u32 nested_vmx_secondary_ctls_low, nested_vmx_secondary_ctls_high;
2022static u32 nested_vmx_pinbased_ctls_low, nested_vmx_pinbased_ctls_high; 2022static u32 nested_vmx_pinbased_ctls_low, nested_vmx_pinbased_ctls_high;
2023static u32 nested_vmx_exit_ctls_low, nested_vmx_exit_ctls_high; 2023static u32 nested_vmx_exit_ctls_low, nested_vmx_exit_ctls_high;
2024static u32 nested_vmx_entry_ctls_low, nested_vmx_entry_ctls_high; 2024static u32 nested_vmx_entry_ctls_low, nested_vmx_entry_ctls_high;
2025static u32 nested_vmx_misc_low, nested_vmx_misc_high;
2025static __init void nested_vmx_setup_ctls_msrs(void) 2026static __init void nested_vmx_setup_ctls_msrs(void)
2026{ 2027{
2027 /* 2028 /*
@@ -2106,6 +2107,11 @@ static __init void nested_vmx_setup_ctls_msrs(void)
2106 nested_vmx_secondary_ctls_high &= 2107 nested_vmx_secondary_ctls_high &=
2107 SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES | 2108 SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES |
2108 SECONDARY_EXEC_WBINVD_EXITING; 2109 SECONDARY_EXEC_WBINVD_EXITING;
2110
2111 /* miscellaneous data */
2112 rdmsr(MSR_IA32_VMX_MISC, nested_vmx_misc_low, nested_vmx_misc_high);
2113 nested_vmx_misc_low &= VMX_MISC_SAVE_EFER_LMA;
2114 nested_vmx_misc_high = 0;
2109} 2115}
2110 2116
2111static inline bool vmx_control_verify(u32 control, u32 low, u32 high) 2117static inline bool vmx_control_verify(u32 control, u32 low, u32 high)
@@ -2176,7 +2182,8 @@ static int vmx_get_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata)
2176 nested_vmx_entry_ctls_high); 2182 nested_vmx_entry_ctls_high);
2177 break; 2183 break;
2178 case MSR_IA32_VMX_MISC: 2184 case MSR_IA32_VMX_MISC:
2179 *pdata = 0; 2185 *pdata = vmx_control_msr(nested_vmx_misc_low,
2186 nested_vmx_misc_high);
2180 break; 2187 break;
2181 /* 2188 /*
2182 * These MSRs specify bits which the guest must keep fixed (on or off) 2189 * These MSRs specify bits which the guest must keep fixed (on or off)
@@ -7398,6 +7405,10 @@ static void prepare_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12)
7398 vmcs12->guest_pending_dbg_exceptions = 7405 vmcs12->guest_pending_dbg_exceptions =
7399 vmcs_readl(GUEST_PENDING_DBG_EXCEPTIONS); 7406 vmcs_readl(GUEST_PENDING_DBG_EXCEPTIONS);
7400 7407
7408 vmcs12->vm_entry_controls =
7409 (vmcs12->vm_entry_controls & ~VM_ENTRY_IA32E_MODE) |
7410 (vmcs_read32(VM_ENTRY_CONTROLS) & VM_ENTRY_IA32E_MODE);
7411
7401 /* TODO: These cannot have changed unless we have MSR bitmaps and 7412 /* TODO: These cannot have changed unless we have MSR bitmaps and
7402 * the relevant bit asks not to trap the change */ 7413 * the relevant bit asks not to trap the change */
7403 vmcs12->guest_ia32_debugctl = vmcs_read64(GUEST_IA32_DEBUGCTL); 7414 vmcs12->guest_ia32_debugctl = vmcs_read64(GUEST_IA32_DEBUGCTL);