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 <[email protected]>
---
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
On Wed, Dec 21, 2022 at 2:24 PM Ben Gardon <[email protected]> wrote:
>
> 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.
Jinx! An equivalent change recently went into kvm/queue:
https://git.kernel.org/pub/scm/virt/kvm/kvm.git/commit/?h=queue&id=1290f90e77186bf8a06a3a35ebf254f5b004676b