summaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorPeter Xu <peterx@redhat.com>2019-05-08 11:15:46 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2019-05-08 13:43:28 +0200
commit53eac7a8f8cf3d7dc5ecac1946f31442f5eee5f3 (patch)
treeea638c4eda3b0e85c23b5a28342e5f028a3dacdf /virt
parentKVM: Fix the bitmap range to copy during clear dirty (diff)
downloadlinux-53eac7a8f8cf3d7dc5ecac1946f31442f5eee5f3.tar.xz
linux-53eac7a8f8cf3d7dc5ecac1946f31442f5eee5f3.zip
KVM: Fix kvm_clear_dirty_log_protect off-by-(minus-)one
Just imaging the case where num_pages < BITS_PER_LONG, then the loop will be skipped while it shouldn't. Signed-off-by: Peter Xu <peterx@redhat.com> Fixes: 2a31b9db153530df4aa02dac8c32837bf5f47019 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/kvm_main.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index ad39c57de82d..7883e0ad07fe 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1264,8 +1264,8 @@ int kvm_clear_dirty_log_protect(struct kvm *kvm,
return -EFAULT;
spin_lock(&kvm->mmu_lock);
- for (offset = log->first_page,
- i = offset / BITS_PER_LONG, n = log->num_pages / BITS_PER_LONG; n--;
+ for (offset = log->first_page, i = offset / BITS_PER_LONG,
+ n = DIV_ROUND_UP(log->num_pages, BITS_PER_LONG); n--;
i++, offset += BITS_PER_LONG) {
unsigned long mask = *dirty_bitmap_buffer++;
atomic_long_t *p = (atomic_long_t *) &dirty_bitmap[i];