Skip to content

Commit f285c63

Browse files
Ben Gardonbonzini
authored andcommitted
kvm: mmu: Used range based flushing in slot_handle_level_range
Replace kvm_flush_remote_tlbs with kvm_flush_remote_tlbs_with_address in slot_handle_level_range. When range based flushes are not enabled kvm_flush_remote_tlbs_with_address falls back to kvm_flush_remote_tlbs. This changes the behavior of many functions that indirectly use slot_handle_level_range, iff the range based flushes are enabled. The only potential problem I see with this is that kvm->tlbs_dirty will be cleared less often, however the only caller of slot_handle_level_range that checks tlbs_dirty is kvm_mmu_notifier_invalidate_range_start which checks it and does a kvm_flush_remote_tlbs after calling kvm_unmap_hva_range anyway. Tested: Ran all kvm-unit-tests on a Intel Haswell machine with and without this patch. The patch introduced no new failures. Signed-off-by: Ben Gardon <bgardon@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 3d9683c commit f285c63

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

arch/x86/kvm/mmu.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5526,15 +5526,18 @@ slot_handle_level_range(struct kvm *kvm, struct kvm_memory_slot *memslot,
55265526

55275527
if (need_resched() || spin_needbreak(&kvm->mmu_lock)) {
55285528
if (flush && lock_flush_tlb) {
5529-
kvm_flush_remote_tlbs(kvm);
5529+
kvm_flush_remote_tlbs_with_address(kvm,
5530+
start_gfn,
5531+
iterator.gfn - start_gfn + 1);
55305532
flush = false;
55315533
}
55325534
cond_resched_lock(&kvm->mmu_lock);
55335535
}
55345536
}
55355537

55365538
if (flush && lock_flush_tlb) {
5537-
kvm_flush_remote_tlbs(kvm);
5539+
kvm_flush_remote_tlbs_with_address(kvm, start_gfn,
5540+
end_gfn - start_gfn + 1);
55385541
flush = false;
55395542
}
55405543

0 commit comments

Comments
 (0)