On 12.04.2010, at 12:35, Takuya Yoshikawa wrote:

> This patch fixes a bug found by Avi during the review process
> of my dirty bitmap related work.
> 
> To ppc and ia64 people:
>  The fix is really simple but touches all architectures using
>  dirty bitmaps. So please check this will not suffer your part.
> 
> ===
> 
> 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.tak...@oss.ntt.co.jp>
> ---
> arch/ia64/kvm/kvm-ia64.c  |    9 +++++----
> arch/powerpc/kvm/book3s.c |    5 +++--
> arch/x86/kvm/x86.c        |    5 +++--
> include/linux/kvm_host.h  |    5 +++++
> virt/kvm/kvm_main.c       |   13 ++++++++-----
> 5 files changed, 24 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
> index b0ed80c..566aff6 100644
> --- a/arch/ia64/kvm/kvm-ia64.c
> +++ b/arch/ia64/kvm/kvm-ia64.c
> @@ -1806,7 +1806,8 @@ static int kvm_ia64_sync_dirty_log(struct kvm *kvm,
> {
>       struct kvm_memory_slot *memslot;
>       int r, i;
> -     long n, base;
> +     long base;
> +     unsigned long n;
>       unsigned long *dirty_bitmap = (unsigned long *)(kvm->arch.vm_base +
>                       offsetof(struct kvm_vm_data, kvm_mem_dirty_log));
> 
> @@ -1819,7 +1820,7 @@ static int kvm_ia64_sync_dirty_log(struct kvm *kvm,
>       if (!memslot->dirty_bitmap)
>               goto out;
> 
> -     n = ALIGN(memslot->npages, BITS_PER_LONG) / 8;
> +     n = kvm_dirty_bitmap_bytes(memslot);
>       base = memslot->base_gfn / BITS_PER_LONG;
> 
>       for (i = 0; i < n/sizeof(long); ++i) {
> @@ -1835,7 +1836,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
>               struct kvm_dirty_log *log)
> {
>       int r;
> -     int n;
> +     unsigned long n;
>       struct kvm_memory_slot *memslot;
>       int is_dirty = 0;
> 
> @@ -1854,7 +1855,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
>       if (is_dirty) {
>               kvm_flush_remote_tlbs(kvm);
>               memslot = &kvm->memslots->memslots[log->slot];
> -             n = ALIGN(memslot->npages, BITS_PER_LONG) / 8;
> +             n = kvm_dirty_bitmap_bytes(memslot);
>               memset(memslot->dirty_bitmap, 0, n);
>       }
>       r = 0;
> diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c
> index a7ab2ea..4ac7b15 100644
> --- a/arch/powerpc/kvm/book3s.c
> +++ b/arch/powerpc/kvm/book3s.c
> @@ -1118,7 +1118,8 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
>       struct kvm_vcpu *vcpu;
>       ulong ga, ga_end;
>       int is_dirty = 0;
> -     int r, n;
> +     int r;
> +     unsigned long n;
> 
>       mutex_lock(&kvm->slots_lock);
> 
> @@ -1136,7 +1137,7 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
>               kvm_for_each_vcpu(n, vcpu, kvm)
>                       kvmppc_mmu_pte_pflush(vcpu, ga, ga_end);
> 
> -             n = ALIGN(memslot->npages, BITS_PER_LONG) / 8;
> +             n = kvm_dirty_bitmap_bytes(memslot);

Looks like a pretty mechanical change, so no objections from me.

Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to