aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/x86.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/kvm/x86.c')
-rw-r--r--drivers/kvm/x86.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index 9618fcba887e..935e2769b787 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -937,6 +937,37 @@ static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
937 return r; 937 return r;
938} 938}
939 939
940/*
941 * Get (and clear) the dirty memory log for a memory slot.
942 */
943int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
944 struct kvm_dirty_log *log)
945{
946 int r;
947 int n;
948 struct kvm_memory_slot *memslot;
949 int is_dirty = 0;
950
951 mutex_lock(&kvm->lock);
952
953 r = kvm_get_dirty_log(kvm, log, &is_dirty);
954 if (r)
955 goto out;
956
957 /* If nothing is dirty, don't bother messing with page tables. */
958 if (is_dirty) {
959 kvm_mmu_slot_remove_write_access(kvm, log->slot);
960 kvm_flush_remote_tlbs(kvm);
961 memslot = &kvm->memslots[log->slot];
962 n = ALIGN(memslot->npages, BITS_PER_LONG) / 8;
963 memset(memslot->dirty_bitmap, 0, n);
964 }
965 r = 0;
966out:
967 mutex_unlock(&kvm->lock);
968 return r;
969}
970
940long kvm_arch_vm_ioctl(struct file *filp, 971long kvm_arch_vm_ioctl(struct file *filp,
941 unsigned int ioctl, unsigned long arg) 972 unsigned int ioctl, unsigned long arg)
942{ 973{