]> err.no Git - linux-2.6/commitdiff
KVM: Fix dirty page log bitmap size/access calculation
authorUri Lublin <uril@qumranet.com>
Thu, 22 Feb 2007 14:43:09 +0000 (16:43 +0200)
committerAvi Kivity <avi@qumranet.com>
Sun, 4 Mar 2007 09:12:42 +0000 (11:12 +0200)
Since dirty_bitmap is an unsigned long array, the alignment and size need
to take that into account.

Signed-off-by: Uri Lublin <uril@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
drivers/kvm/kvm_main.c

index edff4055b32bd75f15230b3b764a31374775f9a7..e7108105c50bfa8ecc6d8a76f127c0e3cae47319 100644 (file)
@@ -792,9 +792,9 @@ static int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
        if (!memslot->dirty_bitmap)
                goto out;
 
-       n = ALIGN(memslot->npages, 8) / 8;
+       n = ALIGN(memslot->npages, BITS_PER_LONG) / 8;
 
-       for (i = 0; !any && i < n; ++i)
+       for (i = 0; !any && i < n/sizeof(long); ++i)
                any = memslot->dirty_bitmap[i];
 
        r = -EFAULT;