diff options
author | Sean Christopherson <seanjc@google.com> | 2024-10-10 19:10:45 -0700 |
---|---|---|
committer | Sean Christopherson <seanjc@google.com> | 2024-10-30 14:46:47 -0700 |
commit | 526e609f05676c21aeed6c04115ae777c40081ec (patch) | |
tree | cd2fa7d1085254ee827567d5225871dd42f9958c /arch/x86/kvm/mmu/tdp_mmu.c | |
parent | 7971801b5618e37d7173f615300f640ab590ba6d (diff) | |
download | linux-526e609f05676c21aeed6c04115ae777c40081ec.tar.gz linux-526e609f05676c21aeed6c04115ae777c40081ec.tar.bz2 linux-526e609f05676c21aeed6c04115ae777c40081ec.zip |
KVM: x86/mmu: Process only valid TDP MMU roots when aging a gfn range
Skip invalid TDP MMU roots when aging a gfn range. There is zero reason
to process invalid roots, as they by definition hold stale information.
E.g. if a root is invalid because its from a previous memslot generation,
in the unlikely event the root has a SPTE for the gfn, then odds are good
that the gfn=>hva mapping is different, i.e. doesn't map to the hva that
is being aged by the primary MMU.
Link: https://lore.kernel.org/r/20241011021051.1557902-14-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'arch/x86/kvm/mmu/tdp_mmu.c')
-rw-r--r-- | arch/x86/kvm/mmu/tdp_mmu.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c index f77927b57962..e8c061bf94ec 100644 --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -1205,9 +1205,11 @@ static __always_inline bool kvm_tdp_mmu_handle_gfn(struct kvm *kvm, /* * Don't support rescheduling, none of the MMU notifiers that funnel - * into this helper allow blocking; it'd be dead, wasteful code. + * into this helper allow blocking; it'd be dead, wasteful code. Note, + * this helper must NOT be used to unmap GFNs, as it processes only + * valid roots! */ - for_each_tdp_mmu_root(kvm, root, range->slot->as_id) { + for_each_valid_tdp_mmu_root(kvm, root, range->slot->as_id) { rcu_read_lock(); tdp_root_for_each_leaf_pte(iter, root, range->start, range->end) |