From: Uri Lublin Date: Thu, 22 Feb 2007 14:43:09 +0000 (+0200) Subject: KVM: Fix dirty page log bitmap size/access calculation X-Git-Tag: v2.6.21-rc3~108 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd1a4a982a78e793125db2f386e91dc7c89c9ed1;p=linux-2.6 KVM: Fix dirty page log bitmap size/access calculation Since dirty_bitmap is an unsigned long array, the alignment and size need to take that into account. Signed-off-by: Uri Lublin Signed-off-by: Avi Kivity --- diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index edff4055b3..e7108105c5 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c @@ -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;