From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH RFC 2/5] KVM: use a rapper function to calculate the sizes of dirty bitmaps Date: Sun, 11 Apr 2010 20:12:09 +0300 Message-ID: <4BC202E9.6060300@redhat.com> References: <20100409182732.857de4db.yoshikawa.takuya@oss.ntt.co.jp> <20100409183242.caa4e304.yoshikawa.takuya@oss.ntt.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: mtosatti@redhat.com, kvm@vger.kernel.org, fernando@oss.ntt.co.jp To: Takuya Yoshikawa Return-path: Received: from mx1.redhat.com ([209.132.183.28]:61955 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752233Ab0DKRMS (ORCPT ); Sun, 11 Apr 2010 13:12:18 -0400 In-Reply-To: <20100409183242.caa4e304.yoshikawa.takuya@oss.ntt.co.jp> Sender: kvm-owner@vger.kernel.org List-ID: On 04/09/2010 12:32 PM, Takuya Yoshikawa wrote: > We will use this later in other parts. > > s/rapper/wrapper/... > > +static inline int kvm_dirty_bitmap_bytes(struct kvm_memory_slot *memslot) > +{ > + return ALIGN(memslot->npages, BITS_PER_LONG) / 8; > +} > + > 'int' may overflow. > struct kvm_kernel_irq_routing_entry { > u32 gsi; > u32 type; > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index 9379533..5ab581e 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -645,7 +645,7 @@ skip_lpage: > > /* Allocate page dirty bitmap if needed */ > if ((new.flags& KVM_MEM_LOG_DIRTY_PAGES)&& !new.dirty_bitmap) { > - unsigned dirty_bytes = ALIGN(npages, BITS_PER_LONG) / 8; > + int dirty_bytes = kvm_dirty_bitmap_bytes(&new); > Ah, an existing bug. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.