From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MODcW-0003j4-FM for qemu-devel@nongnu.org; Tue, 07 Jul 2009 12:34:16 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MODcR-0003ct-F2 for qemu-devel@nongnu.org; Tue, 07 Jul 2009 12:34:15 -0400 Received: from [199.232.76.173] (port=40841 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MODcR-0003cj-7m for qemu-devel@nongnu.org; Tue, 07 Jul 2009 12:34:11 -0400 Received: from mx2.redhat.com ([66.187.237.31]:48864) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MODcQ-0000Wk-O9 for qemu-devel@nongnu.org; Tue, 07 Jul 2009 12:34:11 -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 n67GY9of022644 for ; Tue, 7 Jul 2009 12:34:09 -0400 Message-ID: <4A5378BB.9070601@redhat.com> Date: Tue, 07 Jul 2009 18:32:59 +0200 From: Kevin Wolf 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> <4A537735.9060904@redhat.com> In-Reply-To: <4A537735.9060904@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: qemu-devel@nongnu.org Avi Kivity schrieb: > 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. Good point. I guess there are more places where we could use qemu_memalign, so I would prefer to change them all in another patch. Kevin