aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/kvm_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/kvm/kvm_main.c')
-rw-r--r--drivers/kvm/kvm_main.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index bfb1b6de0584..5dee3024579d 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -803,11 +803,14 @@ static int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
803 if (copy_to_user(log->dirty_bitmap, memslot->dirty_bitmap, n)) 803 if (copy_to_user(log->dirty_bitmap, memslot->dirty_bitmap, n))
804 goto out; 804 goto out;
805 805
806 mutex_lock(&kvm->lock); 806 /* If nothing is dirty, don't bother messing with page tables. */
807 kvm_mmu_slot_remove_write_access(kvm, log->slot); 807 if (any) {
808 kvm_flush_remote_tlbs(kvm); 808 mutex_lock(&kvm->lock);
809 memset(memslot->dirty_bitmap, 0, n); 809 kvm_mmu_slot_remove_write_access(kvm, log->slot);
810 mutex_unlock(&kvm->lock); 810 kvm_flush_remote_tlbs(kvm);
811 memset(memslot->dirty_bitmap, 0, n);
812 mutex_unlock(&kvm->lock);
813 }
811 814
812 r = 0; 815 r = 0;
813 816