summaryrefslogtreecommitdiffstats
path: root/drivers/kvm/x86.c
diff options
context:
space:
mode:
authorZhang Xiantao2007-11-18 13:29:43 +0100
committerAvi Kivity2008-01-30 16:53:05 +0100
commit5bb064dcdeb7ab341e2f8a3e2fc34faa63b1662c (patch)
treeabb976bd8e6f79fca02aeadad31269f281f71c16 /drivers/kvm/x86.c
parentKVM: Make unloading of FPU state when putting vcpu arch-independent (diff)
downloadkernel-qcow2-linux-5bb064dcdeb7ab341e2f8a3e2fc34faa63b1662c.tar.gz
kernel-qcow2-linux-5bb064dcdeb7ab341e2f8a3e2fc34faa63b1662c.tar.xz
kernel-qcow2-linux-5bb064dcdeb7ab341e2f8a3e2fc34faa63b1662c.zip
KVM: Portability: Move kvm_vcpu_ioctl_get_dirty_log to arch-specific file
Meanwhile keep the interface in common, and leave as more logic in common as possible. Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
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)
return r;
}
+/*
+ * Get (and clear) the dirty memory log for a memory slot.
+ */
+int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
+ struct kvm_dirty_log *log)
+{
+ int r;
+ int n;
+ struct kvm_memory_slot *memslot;
+ int is_dirty = 0;
+
+ mutex_lock(&kvm->lock);
+
+ r = kvm_get_dirty_log(kvm, log, &is_dirty);
+ if (r)
+ goto out;
+
+ /* If nothing is dirty, don't bother messing with page tables. */
+ if (is_dirty) {
+ kvm_mmu_slot_remove_write_access(kvm, log->slot);
+ kvm_flush_remote_tlbs(kvm);
+ memslot = &kvm->memslots[log->slot];
+ n = ALIGN(memslot->npages, BITS_PER_LONG) / 8;
+ memset(memslot->dirty_bitmap, 0, n);
+ }
+ r = 0;
+out:
+ mutex_unlock(&kvm->lock);
+ return r;
+}
+
long kvm_arch_vm_ioctl(struct file *filp,
unsigned int ioctl, unsigned long arg)
{