From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MODSl-0000FZ-Dl for qemu-devel@nongnu.org; Tue, 07 Jul 2009 12:24:11 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MODSh-0000Co-Tc for qemu-devel@nongnu.org; Tue, 07 Jul 2009 12:24:11 -0400 Received: from [199.232.76.173] (port=37729 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MODSh-0000Ce-PZ for qemu-devel@nongnu.org; Tue, 07 Jul 2009 12:24:07 -0400 Received: from mx2.redhat.com ([66.187.237.31]:41311) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MODSh-0007Ds-06 for qemu-devel@nongnu.org; Tue, 07 Jul 2009 12:24:07 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n67GO56C019798 for ; Tue, 7 Jul 2009 12:24:05 -0400 Message-ID: <4A537735.9060904@redhat.com> Date: Tue, 07 Jul 2009 19:26:29 +0300 From: Avi Kivity MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] qcow2: Fix L1 table memory allocation References: <1246982982-11615-1-git-send-email-kwolf@redhat.com> In-Reply-To: <1246982982-11615-1-git-send-email-kwolf@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org On 07/07/2009 07:09 PM, Kevin Wolf wrote: > Contrary to what one could expect, the size of L1 tables is not cluster > aligned. So as we're writing whole sectors now instead of single entries, > we need to ensure that the L1 table in memory is large enough; otherwise > write would access memory after the end of the L1 table. > > > new_l1_size2 = sizeof(uint64_t) * new_l1_size; > - new_l1_table = qemu_mallocz(new_l1_size2); > + new_l1_table = qemu_mallocz(align_offset(new_l1_size2, 512)); > memcpy(new_l1_table, s->l1_table, s->l1_size * sizeof(uint64_t)); > Unrelated note: using qemu_memalign() here would reduce the copying for cache=none. -- error compiling committee.c: too many arguments to function