diff options
author | Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> | 2010-04-12 06:35:35 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-04-20 06:06:55 -0400 |
commit | 87bf6e7de1134f48681fd2ce4b7c1ec45458cb6d (patch) | |
tree | ae8ce63cecab98c036c0d76422de42cf78e042f4 /arch/powerpc/kvm | |
parent | 77662e0028c7c63e34257fda03ff9625c59d939d (diff) |
KVM: fix the handling of dirty bitmaps to avoid overflows
Int is not long enough to store the size of a dirty bitmap.
This patch fixes this problem with the introduction of a wrapper
function to calculate the sizes of dirty bitmaps.
Note: in mark_page_dirty(), we have to consider the fact that
__set_bit() takes the offset as int, not long.
Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/powerpc/kvm')
-rw-r--r-- | arch/powerpc/kvm/book3s.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index 25da07fd9f77..604af29b71ed 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c | |||
@@ -1004,7 +1004,8 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, | |||
1004 | struct kvm_vcpu *vcpu; | 1004 | struct kvm_vcpu *vcpu; |
1005 | ulong ga, ga_end; | 1005 | ulong ga, ga_end; |
1006 | int is_dirty = 0; | 1006 | int is_dirty = 0; |
1007 | int r, n; | 1007 | int r; |
1008 | unsigned long n; | ||
1008 | 1009 | ||
1009 | mutex_lock(&kvm->slots_lock); | 1010 | mutex_lock(&kvm->slots_lock); |
1010 | 1011 | ||
@@ -1022,7 +1023,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, | |||
1022 | kvm_for_each_vcpu(n, vcpu, kvm) | 1023 | kvm_for_each_vcpu(n, vcpu, kvm) |
1023 | kvmppc_mmu_pte_pflush(vcpu, ga, ga_end); | 1024 | kvmppc_mmu_pte_pflush(vcpu, ga, ga_end); |
1024 | 1025 | ||
1025 | n = ALIGN(memslot->npages, BITS_PER_LONG) / 8; | 1026 | n = kvm_dirty_bitmap_bytes(memslot); |
1026 | memset(memslot->dirty_bitmap, 0, n); | 1027 | memset(memslot->dirty_bitmap, 0, n); |
1027 | } | 1028 | } |
1028 | 1029 | ||