Skip to content

Commit a5c214d

Browse files
Lan Tianyubonzini
authored andcommitted
KVM/VMX: Change hv flush logic when ept tables are mismatched.
If ept table pointers are mismatched, flushing tlb for each vcpus via hv flush interface still helps to reduce vmexits which are triggered by IPI and INEPT emulation. Signed-off-by: Lan Tianyu <Tianyu.Lan@microsoft.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 44c2d66 commit a5c214d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

arch/x86/kvm/vmx.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,22 +1571,23 @@ static void check_ept_pointer_match(struct kvm *kvm)
15711571

15721572
static int vmx_hv_remote_flush_tlb(struct kvm *kvm)
15731573
{
1574-
int ret;
1574+
struct kvm_vcpu *vcpu;
1575+
int ret = -ENOTSUPP, i;
15751576

15761577
spin_lock(&to_kvm_vmx(kvm)->ept_pointer_lock);
15771578

15781579
if (to_kvm_vmx(kvm)->ept_pointers_match == EPT_POINTERS_CHECK)
15791580
check_ept_pointer_match(kvm);
15801581

15811582
if (to_kvm_vmx(kvm)->ept_pointers_match != EPT_POINTERS_MATCH) {
1582-
ret = -ENOTSUPP;
1583-
goto out;
1583+
kvm_for_each_vcpu(i, vcpu, kvm)
1584+
ret |= hyperv_flush_guest_mapping(
1585+
to_vmx(kvm_get_vcpu(kvm, i))->ept_pointer);
1586+
} else {
1587+
ret = hyperv_flush_guest_mapping(
1588+
to_vmx(kvm_get_vcpu(kvm, 0))->ept_pointer);
15841589
}
15851590

1586-
ret = hyperv_flush_guest_mapping(
1587-
to_vmx(kvm_get_vcpu(kvm, 0))->ept_pointer);
1588-
1589-
out:
15901591
spin_unlock(&to_kvm_vmx(kvm)->ept_pointer_lock);
15911592
return ret;
15921593
}

0 commit comments

Comments
 (0)