Skip to content

Commit a2855af

Browse files
Ben Gardonbonzini
authored andcommitted
KVM: x86/mmu: Allow parallel page faults for the TDP MMU
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: Peter Feiner <[email protected]> Signed-off-by: Ben Gardon <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent e25f0e0 commit a2855af

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

arch/x86/kvm/mmu/mmu.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3718,7 +3718,12 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code,
37183718
return r;
37193719

37203720
r = RET_PF_RETRY;
3721-
write_lock(&vcpu->kvm->mmu_lock);
3721+
3722+
if (is_tdp_mmu_root(vcpu->kvm, vcpu->arch.mmu->root_hpa))
3723+
read_lock(&vcpu->kvm->mmu_lock);
3724+
else
3725+
write_lock(&vcpu->kvm->mmu_lock);
3726+
37223727
if (mmu_notifier_retry(vcpu->kvm, mmu_seq))
37233728
goto out_unlock;
37243729
r = make_mmu_pages_available(vcpu);
@@ -3733,7 +3738,10 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code,
37333738
prefault, is_tdp);
37343739

37353740
out_unlock:
3736-
write_unlock(&vcpu->kvm->mmu_lock);
3741+
if (is_tdp_mmu_root(vcpu->kvm, vcpu->arch.mmu->root_hpa))
3742+
read_unlock(&vcpu->kvm->mmu_lock);
3743+
else
3744+
write_unlock(&vcpu->kvm->mmu_lock);
37373745
kvm_release_pfn_clean(pfn);
37383746
return r;
37393747
}

0 commit comments

Comments
 (0)