* Clear leaf entries which could be replaced by large mappings, for
* GFNs within the slot.
*/
-static void zap_collapsible_spte_range(struct kvm *kvm,
+static bool zap_collapsible_spte_range(struct kvm *kvm,
struct kvm_mmu_page *root,
- struct kvm_memory_slot *slot)
+ struct kvm_memory_slot *slot,
+ bool flush)
{
gfn_t start = slot->base_gfn;
gfn_t end = start + slot->npages;
struct tdp_iter iter;
kvm_pfn_t pfn;
- bool spte_set = false;
rcu_read_lock();
tdp_root_for_each_pte(iter, root, start, end) {
- if (tdp_mmu_iter_cond_resched(kvm, &iter, spte_set)) {
- spte_set = false;
+ if (tdp_mmu_iter_cond_resched(kvm, &iter, flush)) {
+ flush = false;
continue;
}
tdp_mmu_set_spte(kvm, &iter, 0);
- spte_set = true;
+ flush = true;
}
rcu_read_unlock();
- if (spte_set)
- kvm_flush_remote_tlbs(kvm);
+
+ return flush;
}
/*
struct kvm_memory_slot *slot)
{
struct kvm_mmu_page *root;
+ bool flush = false;
int root_as_id;
for_each_tdp_mmu_root_yield_safe(kvm, root) {
if (root_as_id != slot->as_id)
continue;
- zap_collapsible_spte_range(kvm, root, slot);
+ flush = zap_collapsible_spte_range(kvm, root, slot, flush);
}
+
+ if (flush)
+ kvm_flush_remote_tlbs(kvm);
}
/*