Message ID | 20201027212346.23409-11-sean.j.christopherson@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: VMX: Clean up Hyper-V PV TLB flush | expand |
Sean Christopherson <sean.j.christopherson@intel.com> writes: > Skip additional EPTP flushes if one fails when processing EPTPs for > Hyper-V's paravirt TLB flushing. If _any_ flush fails, KVM falls back > to a full global flush, i.e. additional flushes are unnecessary (and > will likely fail anyways). > > Continue processing the loop unless a mismatch was already detected, > e.g. to handle the case where the first flush fails and there is a > yet-to-be-detected mismatch. > > Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com> > --- > arch/x86/kvm/vmx/vmx.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > index 5b7c5b2fd2c7..40a67dd45c8c 100644 > --- a/arch/x86/kvm/vmx/vmx.c > +++ b/arch/x86/kvm/vmx/vmx.c > @@ -528,7 +528,15 @@ static int hv_remote_flush_tlb_with_range(struct kvm *kvm, > if (++nr_unique_valid_eptps == 1) > kvm_vmx->hv_tlb_eptp = tmp_eptp; > > - ret |= hv_remote_flush_eptp(tmp_eptp, range); > + if (!ret) > + ret = hv_remote_flush_eptp(tmp_eptp, range); > + > + /* > + * Stop processing EPTPs if a failure occurred and > + * there is already a detected EPTP mismatch. > + */ > + if (ret && nr_unique_valid_eptps > 1) > + break; > } > > /* This should never happen (famous last words) but why not optimize the impossibility :-) Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 5b7c5b2fd2c7..40a67dd45c8c 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -528,7 +528,15 @@ static int hv_remote_flush_tlb_with_range(struct kvm *kvm, if (++nr_unique_valid_eptps == 1) kvm_vmx->hv_tlb_eptp = tmp_eptp; - ret |= hv_remote_flush_eptp(tmp_eptp, range); + if (!ret) + ret = hv_remote_flush_eptp(tmp_eptp, range); + + /* + * Stop processing EPTPs if a failure occurred and + * there is already a detected EPTP mismatch. + */ + if (ret && nr_unique_valid_eptps > 1) + break; } /*
Skip additional EPTP flushes if one fails when processing EPTPs for Hyper-V's paravirt TLB flushing. If _any_ flush fails, KVM falls back to a full global flush, i.e. additional flushes are unnecessary (and will likely fail anyways). Continue processing the loop unless a mismatch was already detected, e.g. to handle the case where the first flush fails and there is a yet-to-be-detected mismatch. Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com> --- arch/x86/kvm/vmx/vmx.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)