From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UlysF-0002EI-FK for qemu-devel@nongnu.org; Mon, 10 Jun 2013 05:58:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UlysC-0004Vh-AF for qemu-devel@nongnu.org; Mon, 10 Jun 2013 05:58:51 -0400 Received: from mx.ipv6.kamp.de ([2a02:248:0:51::16]:41508 helo=mx01.kamp.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1UlysC-0004VI-0F for qemu-devel@nongnu.org; Mon, 10 Jun 2013 05:58:48 -0400 Message-ID: <51B5A351.4010401@kamp.de> Date: Mon, 10 Jun 2013 11:58:41 +0200 From: Peter Lieven MIME-Version: 1.0 References: <1370847839-5594-1-git-send-email-pl@kamp.de> In-Reply-To: <1370847839-5594-1-git-send-email-pl@kamp.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH] migration: ensure memory is zeroized at the destination List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Lieven Cc: quintela@redhat.com, aik@ozlabs.ru, qemu-devel@nongnu.org, owasserm@redhat.com, pbonzini@redhat.com, xiawenc@linux.vnet.ibm.com, david@gibson.dropbear.id.au please ignore this one. Peter On 10.06.2013 09:03, Peter Lieven wrote: > migration relies on the target memory to be zeroed out since commit > f1c72795 (migration: do not sent zero pages in bulk stage). however, > there is a subtle case where this breaks migration. if for some reason > a page is zero at the source but not at the destination the destination > memory is corrupted. > > this was reported to break migration on pseries and also other platforms > might be affected. to ultimatively make sure the destination memory is zero > at the destination check for it on negotiation of ram blocks. > > note: the better fix for this would be to pass a flag to the machine > init functions of all architectures to indicate that the machine is a > migration target and then avoid copying ram images etc. to physical > ram in this case. but this would require a lot of code to be changed > and reviewed. > > Signed-off-by: Peter Lieven > --- > arch_init.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/arch_init.c b/arch_init.c > index 5d32ecf..458bf8c 100644 > --- a/arch_init.c > +++ b/arch_init.c > @@ -799,6 +799,8 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) > while (total_ram_bytes) { > RAMBlock *block; > uint8_t len; > + void *base; > + ram_addr_t offset; > > len = qemu_get_byte(f); > qemu_get_buffer(f, (uint8_t *)id, len); > @@ -822,6 +824,14 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id) > goto done; > } > > + base = memory_region_get_ram_ptr(block->mr); > + for (offset = 0; offset < block->length; > + offset += TARGET_PAGE_SIZE) { > + if (!is_zero_page(base + offset)) { > + memset(base + offset, 0x00, TARGET_PAGE_SIZE); > + } > + } > + > total_ram_bytes -= length; > } > } -- Mit freundlichen Grüßen Peter Lieven ........................................................... KAMP Netzwerkdienste GmbH Vestische Str. 89-91 | 46117 Oberhausen Tel: +49 (0) 208.89 402-50 | Fax: +49 (0) 208.89 402-40 pl@kamp.de | http://www.kamp.de Geschäftsführer: Heiner Lante | Michael Lante Amtsgericht Duisburg | HRB Nr. 12154 USt-Id-Nr.: DE 120607556 ...........................................................