Skip to content

Commit

Permalink
kvm: x86/mmu: Flush TLB before zap_gfn_range releases RCU
Browse files Browse the repository at this point in the history
Since "KVM: x86/mmu: Zap only TDP MMU leafs in kvm_zap_gfn_range()"
is going to be reverted, it's not going to be true anymore that
the zap-page flow does not free any 'struct kvm_mmu_page'.  Introduce
an early flush before tdp_mmu_zap_leafs() returns, to preserve
bisectability.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Paolo Bonzini committed Mar 21, 2022
1 parent 714797c commit fcb93eb
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions arch/x86/kvm/mmu/tdp_mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -941,13 +941,17 @@ static bool tdp_mmu_zap_leafs(struct kvm *kvm, struct kvm_mmu_page *root,
flush = true;
}

rcu_read_unlock();

/*
* Because this flow zaps _only_ leaf SPTEs, the caller doesn't need
* to provide RCU protection as no 'struct kvm_mmu_page' will be freed.
* Need to flush before releasing RCU. TODO: do it only if intermediate
* page tables were zapped; there is no need to flush under RCU protection
* if no 'struct kvm_mmu_page' is freed.
*/
return flush;
if (flush)
kvm_flush_remote_tlbs_with_address(kvm, start, end - start);

rcu_read_unlock();

return false;
}

/*
Expand Down

0 comments on commit fcb93eb

Please sign in to comment.