Received: from eggs.gnu.org ([2001:4830:134:3::10]:36790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvqGr-0005I3-NF for qemu-devel@nongnu.org; Mon, 09 Nov 2015 12:30:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZvqGm-00053M-1z for qemu-devel@nongnu.org; Mon, 09 Nov 2015 12:30:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40732) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvqGl-00053H-Rj for qemu-devel@nongnu.org; Mon, 09 Nov 2015 12:30:15 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 980B7C0BEA93 for ; Mon, 9 Nov 2015 17:30:15 +0000 (UTC) From: Juan Quintela Date: Mon, 9 Nov 2015 18:28:49 +0100 Message-Id: <1447090141-29074-46-git-send-email-quintela@redhat.com> In-Reply-To: <1447090141-29074-1-git-send-email-quintela@redhat.com> References: <1447090141-29074-1-git-send-email-quintela@redhat.com> Subject: [Qemu-devel] [PULL 45/57] postcopy: Check order of received target pages List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: amit.shah@redhat.com, dgilbert@redhat.com From: "Dr. David Alan Gilbert" Ensure that target pages received within a host page are in order. This shouldn't trigger, but in the cases where the sender goes wrong and sends stuff out of order it produces a corruption that's really nasty to debug. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/ram.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index af5f369..8bf0841 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2097,6 +2097,7 @@ static int ram_load_postcopy(QEMUFile *f) MigrationIncomingState *mis = migration_incoming_get_current(); /* Temporary page that is later 'placed' */ void *postcopy_host_page = postcopy_get_tmp_page(mis); + void *last_host = NULL; while (!ret && !(flags & RAM_SAVE_FLAG_EOS)) { ram_addr_t addr; @@ -2133,8 +2134,17 @@ static int ram_load_postcopy(QEMUFile *f) /* If all TP are zero then we can optimise the place */ if (!((uintptr_t)host & ~qemu_host_page_mask)) { all_zero = true; + } else { + /* not the 1st TP within the HP */ + if (host != (last_host + TARGET_PAGE_SIZE)) { + error_report("Non-sequential target page %p/%p\n", + host, last_host); + ret = -EINVAL; + break; + } } + /* * If it's the last part of a host page then we place the host * page @@ -2143,6 +2153,7 @@ static int ram_load_postcopy(QEMUFile *f) ~qemu_host_page_mask) == 0; place_source = postcopy_host_page; } + last_host = host; switch (flags & ~RAM_SAVE_FLAG_CONTINUE) { case RAM_SAVE_FLAG_COMPRESS: -- 2.5.0