Commit 25af9081 authored by Sean Christopherson's avatar Sean Christopherson Committed by Paolo Bonzini
Browse files

KVM: x86: Refactor kvm_hv_flush_tlb() to reduce indentation



Refactor the "extended" path of kvm_hv_flush_tlb() to reduce the nesting
depth for the non-fast sparse path, and to make the code more similar to
the extended path in kvm_hv_send_ipi().

No functional change intended.

Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
Reviewed-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20211207220926.718794-4-seanjc@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent bd1ba573
Loading
Loading
Loading
Loading
+21 −19
Original line number Diff line number Diff line
@@ -1818,10 +1818,12 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc, bool
		if (hc->var_cnt != bitmap_weight((unsigned long *)&valid_bank_mask, 64))
			return HV_STATUS_INVALID_HYPERCALL_INPUT;

		if (!hc->var_cnt && !all_cpus)
		if (all_cpus)
			goto do_flush;

		if (!hc->var_cnt)
			goto ret_success;

		if (!all_cpus) {
		if (hc->fast) {
			if (hc->var_cnt > HV_HYPERCALL_MAX_XMM_REGISTERS - 1)
				return HV_STATUS_INVALID_HYPERCALL_INPUT;
@@ -1829,20 +1831,20 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc, bool
				sparse_banks[i] = sse128_lo(hc->xmm[i / 2 + 1]);
				sparse_banks[i + 1] = sse128_hi(hc->xmm[i / 2 + 1]);
			}
			} else {
			goto do_flush;
		}

		if (hc->var_cnt > 64)
			return HV_STATUS_INVALID_HYPERCALL_INPUT;

		gpa = hc->ingpa + offsetof(struct hv_tlb_flush_ex,
					   hv_vp_set.bank_contents);
		if (unlikely(kvm_read_guest(kvm, gpa, sparse_banks,
							    hc->var_cnt *
							    sizeof(sparse_banks[0]))))
					    hc->var_cnt * sizeof(sparse_banks[0]))))
			return HV_STATUS_INVALID_HYPERCALL_INPUT;
	}
		}
	}

do_flush:
	/*
	 * vcpu->arch.cr3 may not be up-to-date for running vCPUs so we can't
	 * analyze it here, flush TLB regardless of the specified address space.