Skip to content

Commit 526e609

Browse files
committed
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>
1 parent 7971801 commit 526e609

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

arch/x86/kvm/mmu/tdp_mmu.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,9 +1205,11 @@ static __always_inline bool kvm_tdp_mmu_handle_gfn(struct kvm *kvm,
12051205

12061206
/*
12071207
* Don't support rescheduling, none of the MMU notifiers that funnel
1208-
* into this helper allow blocking; it'd be dead, wasteful code.
1208+
* into this helper allow blocking; it'd be dead, wasteful code. Note,
1209+
* this helper must NOT be used to unmap GFNs, as it processes only
1210+
* valid roots!
12091211
*/
1210-
for_each_tdp_mmu_root(kvm, root, range->slot->as_id) {
1212+
for_each_valid_tdp_mmu_root(kvm, root, range->slot->as_id) {
12111213
rcu_read_lock();
12121214

12131215
tdp_root_for_each_leaf_pte(iter, root, range->start, range->end)

0 commit comments

Comments
 (0)