summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/vmx/vmx.c
diff options
context:
space:
mode:
authorLan Tianyu2018-12-06 08:34:36 +0100
committerPaolo Bonzini2018-12-14 18:00:02 +0100
commit53963a70ac268c8e813e6d5cd24cbd1b03f56059 (patch)
tree8c7a8e61c15a2fd0695caeb3acd8f2f432cb37ba /arch/x86/kvm/vmx/vmx.c
parentKVM nVMX: MSRs should not be stored if VM-entry fails during or after loading... (diff)
downloadkernel-qcow2-linux-53963a70ac268c8e813e6d5cd24cbd1b03f56059.tar.gz
kernel-qcow2-linux-53963a70ac268c8e813e6d5cd24cbd1b03f56059.tar.xz
kernel-qcow2-linux-53963a70ac268c8e813e6d5cd24cbd1b03f56059.zip
KVM/VMX: Check ept_pointer before flushing ept tlb
This patch is to initialize ept_pointer to INVALID_PAGE and check it before flushing ept tlb. If ept_pointer is invalid, bypass the flush request. Signed-off-by: Lan Tianyu <Tianyu.Lan@microsoft.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/vmx/vmx.c')
-rw-r--r--arch/x86/kvm/vmx/vmx.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index ddaae1d4cd49..c3461f835445 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -423,11 +423,18 @@ static int vmx_hv_remote_flush_tlb(struct kvm *kvm)
/*
* FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE hypercall needs the address of the
* base of EPT PML4 table, strip off EPT configuration information.
+ * If ept_pointer is invalid pointer, bypass the flush request.
*/
if (to_kvm_vmx(kvm)->ept_pointers_match != EPT_POINTERS_MATCH) {
- kvm_for_each_vcpu(i, vcpu, kvm)
+ kvm_for_each_vcpu(i, vcpu, kvm) {
+ u64 ept_pointer = to_vmx(vcpu)->ept_pointer;
+
+ if (!VALID_PAGE(ept_pointer))
+ continue;
+
ret |= hyperv_flush_guest_mapping(
- to_vmx(kvm_get_vcpu(kvm, i))->ept_pointer & PAGE_MASK);
+ ept_pointer & PAGE_MASK);
+ }
} else {
ret = hyperv_flush_guest_mapping(
to_vmx(kvm_get_vcpu(kvm, 0))->ept_pointer & PAGE_MASK);
@@ -6433,6 +6440,8 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
vmx->pi_desc.nv = POSTED_INTR_VECTOR;
vmx->pi_desc.sn = 1;
+ vmx->ept_pointer = INVALID_PAGE;
+
return &vmx->vcpu;
free_vmcs: