From patchwork Mon Jun 10 07:03:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lieven X-Patchwork-Id: 250182 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2E26D2C02EE for ; Mon, 10 Jun 2013 17:05:57 +1000 (EST) Received: from localhost ([::1]:60916 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UlwAs-00016i-Oe for incoming@patchwork.ozlabs.org; Mon, 10 Jun 2013 03:05:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UlwAV-00016L-3p for qemu-devel@nongnu.org; Mon, 10 Jun 2013 03:05:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UlwAQ-0003yP-TM for qemu-devel@nongnu.org; Mon, 10 Jun 2013 03:05:31 -0400 Received: from mx.ipv6.kamp.de ([2a02:248:0:51::16]:56361 helo=mx01.kamp.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1UlwAQ-0003y4-JF for qemu-devel@nongnu.org; Mon, 10 Jun 2013 03:05:26 -0400 Received: (qmail 11929 invoked by uid 89); 10 Jun 2013 07:05:24 -0000 Received: from [82.141.1.145] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2.01 (clamdscan: 0.97.8/17328. hbedv: 8.2.12.30/7.11.74.24. spamassassin: 3.3.1. Clear:RC:1(82.141.1.145):SA:0(-1.6/5.0):. Processed in 0.575301 secs); 10 Jun 2013 07:05:24 -0000 Received: from ns.kamp-intra.net (HELO dns.kamp-intra.net) ([82.141.1.145]) by mx01.kamp.de with SMTP; 10 Jun 2013 07:05:24 -0000 X-GL_Whitelist: yes Received: from lieven-pc.kamp-intra.net (lieven-pc.kamp-intra.net [172.21.12.60]) by dns.kamp-intra.net (Postfix) with ESMTP id 43EF320688; Mon, 10 Jun 2013 09:04:14 +0200 (CEST) Received: by lieven-pc.kamp-intra.net (Postfix, from userid 1000) id 365265FD19; Mon, 10 Jun 2013 09:04:14 +0200 (CEST) From: Peter Lieven To: qemu-devel@nongnu.org Date: Mon, 10 Jun 2013 09:03:59 +0200 Message-Id: <1370847839-5594-1-git-send-email-pl@kamp.de> X-Mailer: git-send-email 1.7.9.5 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a02:248:0:51::16 Cc: quintela@redhat.com, aik@ozlabs.ru, Peter Lieven , owasserm@redhat.com, pbonzini@redhat.com, xiawenc@linux.vnet.ibm.com, david@gibson.dropbear.id.au Subject: [Qemu-devel] [PATCH] migration: ensure memory is zeroized at the destination X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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; } }