aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>2010-06-23 02:00:29 -0400
committerAvi Kivity <avi@redhat.com>2010-08-01 03:47:16 -0400
commit979586e0b5809c46ebe5d784794a9f6d859b665e (patch)
tree92988306f9aa606b777b219ade16a6f244e4cdef
parent4482b06c0459469c101a1da3f4b24594da557f99 (diff)
KVM: ia64: cleanup kvm_ia64_sync_dirty_log()
kvm_ia64_sync_dirty_log() is a helper function for kvm_vm_ioctl_get_dirty_log() which copies ia64's arch specific dirty bitmap to general one in memslot. So doing sanity checks in this function is unnatural. We move these checks outside of this and change the prototype appropriately. Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r--arch/ia64/kvm/kvm-ia64.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index d85b5d2d52d1..5cb58655cd5f 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -1795,25 +1795,15 @@ void kvm_arch_exit(void)
1795 kvm_vmm_info = NULL; 1795 kvm_vmm_info = NULL;
1796} 1796}
1797 1797
1798static int kvm_ia64_sync_dirty_log(struct kvm *kvm, 1798static void kvm_ia64_sync_dirty_log(struct kvm *kvm,
1799 struct kvm_dirty_log *log) 1799 struct kvm_memory_slot *memslot)
1800{ 1800{
1801 struct kvm_memory_slot *memslot; 1801 int i;
1802 int r, i;
1803 long base; 1802 long base;
1804 unsigned long n; 1803 unsigned long n;
1805 unsigned long *dirty_bitmap = (unsigned long *)(kvm->arch.vm_base + 1804 unsigned long *dirty_bitmap = (unsigned long *)(kvm->arch.vm_base +
1806 offsetof(struct kvm_vm_data, kvm_mem_dirty_log)); 1805 offsetof(struct kvm_vm_data, kvm_mem_dirty_log));
1807 1806
1808 r = -EINVAL;
1809 if (log->slot >= KVM_MEMORY_SLOTS)
1810 goto out;
1811
1812 memslot = &kvm->memslots->memslots[log->slot];
1813 r = -ENOENT;
1814 if (!memslot->dirty_bitmap)
1815 goto out;
1816
1817 n = kvm_dirty_bitmap_bytes(memslot); 1807 n = kvm_dirty_bitmap_bytes(memslot);
1818 base = memslot->base_gfn / BITS_PER_LONG; 1808 base = memslot->base_gfn / BITS_PER_LONG;
1819 1809
@@ -1823,9 +1813,6 @@ static int kvm_ia64_sync_dirty_log(struct kvm *kvm,
1823 dirty_bitmap[base + i] = 0; 1813 dirty_bitmap[base + i] = 0;
1824 } 1814 }
1825 spin_unlock(&kvm->arch.dirty_log_lock); 1815 spin_unlock(&kvm->arch.dirty_log_lock);
1826 r = 0;
1827out:
1828 return r;
1829} 1816}
1830 1817
1831int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, 1818int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
@@ -1838,10 +1825,16 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
1838 1825
1839 mutex_lock(&kvm->slots_lock); 1826 mutex_lock(&kvm->slots_lock);
1840 1827
1841 r = kvm_ia64_sync_dirty_log(kvm, log); 1828 r = -EINVAL;
1842 if (r) 1829 if (log->slot >= KVM_MEMORY_SLOTS)
1830 goto out;
1831
1832 memslot = &kvm->memslots->memslots[log->slot];
1833 r = -ENOENT;
1834 if (!memslot->dirty_bitmap)
1843 goto out; 1835 goto out;
1844 1836
1837 kvm_ia64_sync_dirty_log(kvm, memslot);
1845 r = kvm_get_dirty_log(kvm, log, &is_dirty); 1838 r = kvm_get_dirty_log(kvm, log, &is_dirty);
1846 if (r) 1839 if (r)
1847 goto out; 1840 goto out;
@@ -1849,7 +1842,6 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
1849 /* If nothing is dirty, don't bother messing with page tables. */ 1842 /* If nothing is dirty, don't bother messing with page tables. */
1850 if (is_dirty) { 1843 if (is_dirty) {
1851 kvm_flush_remote_tlbs(kvm); 1844 kvm_flush_remote_tlbs(kvm);
1852 memslot = &kvm->memslots->memslots[log->slot];
1853 n = kvm_dirty_bitmap_bytes(memslot); 1845 n = kvm_dirty_bitmap_bytes(memslot);
1854 memset(memslot->dirty_bitmap, 0, n); 1846 memset(memslot->dirty_bitmap, 0, n);
1855 } 1847 }