From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53889) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjpn3-0002ge-Q2 for qemu-devel@nongnu.org; Fri, 03 Mar 2017 11:10:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cjpn0-0003Hv-Iv for qemu-devel@nongnu.org; Fri, 03 Mar 2017 11:10:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58812) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cjpn0-0003Gs-De for qemu-devel@nongnu.org; Fri, 03 Mar 2017 11:10:42 -0500 Date: Fri, 3 Mar 2017 17:10:39 +0100 From: Andrea Arcangeli Message-ID: <20170303161039.GB7496@redhat.com> References: <20170303113255.28262-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170303113255.28262-1-berrange@redhat.com> Subject: Re: [Qemu-devel] [PATCH v3] os: don't corrupt pre-existing memory-backend data with prealloc List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: qemu-devel@nongnu.org, Michal Privoznik , Jitendra Kolhe , Stefan Hajnoczi , Paolo Bonzini , Eric Blake On Fri, Mar 03, 2017 at 11:32:55AM +0000, Daniel P. Berrange wrote: > When using a memory-backend object with prealloc turned on, QEMU > will memset() the first byte in every memory page to zero. While > this might have been acceptable for memory backends associated > with RAM, this corrupts application data for NVDIMMs. > > Instead of setting every page to zero, read the current byte > value and then just write that same value back, so we are not > corrupting the original data. Directly write the value instead > of memset()ing it, since there's no benefit to memset for a > single byte write. > > Signed-off-by: Daniel P. Berrange > --- > > Changed in v3: Reviewed-by: Andrea Arcangeli Thanks, Andrea