From patchwork Wed Oct 31 03:43:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 195728 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 180BA2C0097 for ; Wed, 31 Oct 2012 14:42:00 +1100 (EST) Received: from localhost ([::1]:53472 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTPBm-0000RX-9o for incoming@patchwork.ozlabs.org; Tue, 30 Oct 2012 23:41:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:36648) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTPBg-0000RI-AD for qemu-devel@nongnu.org; Tue, 30 Oct 2012 23:41:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TTPBf-00082L-8E for qemu-devel@nongnu.org; Tue, 30 Oct 2012 23:41:52 -0400 Received: from ozlabs.org ([203.10.76.45]:47076) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTPBe-00080V-TS for qemu-devel@nongnu.org; Tue, 30 Oct 2012 23:41:51 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id D439F2C0098; Wed, 31 Oct 2012 14:41:44 +1100 (EST) From: David Gibson To: aliguori@us.ibm.com Date: Wed, 31 Oct 2012 14:43:08 +1100 Message-Id: <1351654988-13165-1-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 1.7.10.4 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 203.10.76.45 Cc: qemu-devel@nongnu.org, David Gibson Subject: [Qemu-devel] [PATCH] Fix off-by-1 error in RAM migration code 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 The code for migrating (or savevm-ing) memory pages starts off by creating a dirty bitmap and filling it with 1s. Except, actually, because bit addresses are 0-based it fills every bit except bit 0 with 1s and puts an extra 1 beyond the end of the bitmap, potentially corrupting unrelated memory. Oops. This patch fixes it. Signed-off-by: David Gibson Reviewed-by: Orit Wasserman Reviewed-by: Juan Quintela --- arch_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch_init.c b/arch_init.c index e6effe8..b75a4c5 100644 --- a/arch_init.c +++ b/arch_init.c @@ -568,7 +568,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) int64_t ram_pages = last_ram_offset() >> TARGET_PAGE_BITS; migration_bitmap = bitmap_new(ram_pages); - bitmap_set(migration_bitmap, 1, ram_pages); + bitmap_set(migration_bitmap, 0, ram_pages); migration_dirty_pages = ram_pages; bytes_transferred = 0;