Commit 8cb410ec authored by Ben Gardon's avatar Ben Gardon Committed by Yu Zhang
Browse files

KVM: x86/mmu: Allow parallel page faults for the TDP MMU

mainline inclusion
from mainline-v5.12-rc1
commit a2855afc
category: feature
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I7S3VQ
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a2855afc7ee88475e8feb16840b23f787bfc994d



----------------------------------------------------------------------

Make the last few changes necessary to enable the TDP MMU to handle page
faults in parallel while holding the mmu_lock in read mode.

Reviewed-by: default avatarPeter Feiner <pfeiner@google.com>
Signed-off-by: default avatarBen Gardon <bgardon@google.com>
Message-Id: <20210202185734.1680553-24-bgardon@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarYu Zhang <yu.c.zhang@linux.intel.com>
parent 240cdbe3
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -3761,7 +3761,12 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code,
		return r;

	r = RET_PF_RETRY;

	if (is_tdp_mmu_root(vcpu->kvm, vcpu->arch.mmu->root_hpa))
		read_lock(&vcpu->kvm->mmu_lock);
	else
		write_lock(&vcpu->kvm->mmu_lock);

	if (mmu_notifier_retry(vcpu->kvm, mmu_seq))
		goto out_unlock;
	r = make_mmu_pages_available(vcpu);
@@ -3776,6 +3781,9 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code,
				 prefault, is_tdp);

out_unlock:
	if (is_tdp_mmu_root(vcpu->kvm, vcpu->arch.mmu->root_hpa))
		read_unlock(&vcpu->kvm->mmu_lock);
	else
		write_unlock(&vcpu->kvm->mmu_lock);
	kvm_release_pfn_clean(pfn);
	return r;