lkml.org 
[lkml]   [2020]   [Oct]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v2 04/10] KVM: VMX: Do Hyper-V TLB flush iff vCPU's EPTP hasn't been flushed
Date
Sean Christopherson <sean.j.christopherson@intel.com> writes:

> Combine the for-loops for Hyper-V TLB EPTP checking and flushing, and in
> doing so skip flushes for vCPUs whose EPTP matches the target EPTP.
>
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
> arch/x86/kvm/vmx/vmx.c | 20 ++++++--------------
> 1 file changed, 6 insertions(+), 14 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index bba6d91f1fe1..52cb9eec1db3 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -502,31 +502,23 @@ static int hv_remote_flush_tlb_with_range(struct kvm *kvm,
>
> spin_lock(&kvm_vmx->ept_pointer_lock);
>
> - if (kvm_vmx->ept_pointers_match == EPT_POINTERS_CHECK) {
> + if (kvm_vmx->ept_pointers_match != EPT_POINTERS_MATCH) {
> kvm_vmx->ept_pointers_match = EPT_POINTERS_MATCH;
> kvm_vmx->hv_tlb_eptp = INVALID_PAGE;
>
> kvm_for_each_vcpu(i, vcpu, kvm) {
> tmp_eptp = to_vmx(vcpu)->ept_pointer;
> - if (!VALID_PAGE(tmp_eptp))
> + if (!VALID_PAGE(tmp_eptp) ||
> + tmp_eptp == kvm_vmx->hv_tlb_eptp)
> continue;
>
> - if (!VALID_PAGE(kvm_vmx->hv_tlb_eptp)) {
> + if (!VALID_PAGE(kvm_vmx->hv_tlb_eptp))
> kvm_vmx->hv_tlb_eptp = tmp_eptp;
> - } else if (kvm_vmx->hv_tlb_eptp != tmp_eptp) {
> + else
> kvm_vmx->ept_pointers_match
> = EPT_POINTERS_MISMATCH;
> - break;
> - }
> - }
> - }
>
> - if (kvm_vmx->ept_pointers_match != EPT_POINTERS_MATCH) {
> - kvm_for_each_vcpu(i, vcpu, kvm) {
> - /* If ept_pointer is invalid pointer, bypass flush request. */
> - if (VALID_PAGE(to_vmx(vcpu)->ept_pointer))
> - ret |= hv_remote_flush_eptp(to_vmx(vcpu)->ept_pointer,
> - range);
> + ret |= hv_remote_flush_eptp(tmp_eptp, range);
> }
> } else if (VALID_PAGE(kvm_vmx->hv_tlb_eptp)) {
> ret = hv_remote_flush_eptp(kvm_vmx->hv_tlb_eptp, range);

Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>

I have an unrelated question though. Does it make sense to call
hv_remote_flush_eptp() in case all EPTPs matches with ept_pointer_lock
spinlock held? Like if we had a match by the time of the call, does it
make a difference if the situation will change before or right after we
do the hypercall?

--
Vitaly

\
 
 \ /
  Last update: 2020-10-21 14:24    [W:0.131 / U:3.364 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site