[RFC 09/14] KVM: x86/MMU: Only make pages available on Shadow MMU fault

From: Ben Gardon
Date: Wed Dec 21 2022 - 17:25:26 EST


Now that the Shadow MMU has been factored out of mmu.c and the naming
sheme has been cleaned up, it's clear that there's an unnecessary
operation in direct_page_fault(). Since the MMU page quota is only
applied to the Shadow MMU, there's no point to calling
kvm_shadow_mmu_make_pages_available on a fault where the TDP MMU is
going to handle installing new TDP PTEs.

Signed-off-by: Ben Gardon <bgardon@xxxxxxxxxx>
---
arch/x86/kvm/mmu/mmu.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index bacb519ba7b4..568b36de9eeb 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -1469,14 +1469,14 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault
if (is_page_fault_stale(vcpu, fault, mmu_seq))
goto out_unlock;

- r = kvm_shadow_mmu_make_pages_available(vcpu);
- if (r)
- goto out_unlock;
-
if (is_tdp_mmu_fault)
r = kvm_tdp_mmu_map(vcpu, fault);
- else
+ else {
+ r = kvm_shadow_mmu_make_pages_available(vcpu);
+ if (r)
+ goto out_unlock;
r = kvm_shadow_mmu_direct_map(vcpu, fault);
+ }

out_unlock:
if (is_tdp_mmu_fault)
--
2.39.0.314.g84b9a713c41-goog