From patchwork Thu Jan 5 11:40:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 134460 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B8F7A1007D6 for ; Thu, 5 Jan 2012 22:41:29 +1100 (EST) Received: from localhost ([::1]:48821 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RilhB-0006tN-Ua for incoming@patchwork.ozlabs.org; Thu, 05 Jan 2012 06:41:21 -0500 Received: from eggs.gnu.org ([140.186.70.92]:60719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rilh3-0006tI-4P for qemu-devel@nongnu.org; Thu, 05 Jan 2012 06:41:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rilgx-0005bD-7e for qemu-devel@nongnu.org; Thu, 05 Jan 2012 06:41:13 -0500 Received: from smtp.citrix.com ([66.165.176.89]:19787) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rilgx-0005b5-4m for qemu-devel@nongnu.org; Thu, 05 Jan 2012 06:41:07 -0500 X-IronPort-AV: E=Sophos;i="4.71,461,1320642000"; d="scan'208";a="20570660" Received: from ftlpmailmx01.citrite.net ([10.13.107.65]) by FTLPIPO01.CITRIX.COM with ESMTP/TLS/RC4-MD5; 05 Jan 2012 06:41:06 -0500 Received: from smtp01.ad.xensource.com (10.219.128.104) by smtprelay.citrix.com (10.13.107.65) with Microsoft SMTP Server id 8.3.213.0; Thu, 5 Jan 2012 06:41:05 -0500 Received: from perard.uk.xensource.com (dhcp-3-28.uk.xensource.com [10.80.3.28] (may be forged)) by smtp01.ad.xensource.com (8.13.1/8.13.1) with ESMTP id q05Bf3xQ014074; Thu, 5 Jan 2012 03:41:04 -0800 From: Anthony PERARD To: QEMU-devel Date: Thu, 5 Jan 2012 11:40:55 +0000 Message-ID: <1325763655-16032-1-git-send-email-anthony.perard@citrix.com> X-Mailer: git-send-email 1.7.2.5 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.165.176.89 Cc: Anthony PERARD , Avi Kivity , Stefano Stabellini Subject: [Qemu-devel] [PATCH V2] xen: Fix after recent change in dirty bitmap tracking. 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 A recent patch set from Avi break the dirty bitmap support of Xen. But this is because xen_sync_dirty_bitmap will return an error for an unhandled memory range (a0000 - bffff). However this is not a fatal error, so we should just continue instead of aborting. There is now an error printed when the Xen call failed. Signed-off-by: Anthony PERARD --- xen-all.c | 38 ++++++++++++++++++-------------------- 1 files changed, 18 insertions(+), 20 deletions(-) diff --git a/xen-all.c b/xen-all.c index dc23265..2aa8c03 100644 --- a/xen-all.c +++ b/xen-all.c @@ -403,9 +403,9 @@ static void xen_region_del(MemoryListener *listener, xen_set_memory(listener, section, false); } -static int xen_sync_dirty_bitmap(XenIOState *state, - target_phys_addr_t start_addr, - ram_addr_t size) +static void xen_sync_dirty_bitmap(XenIOState *state, + target_phys_addr_t start_addr, + ram_addr_t size) { target_phys_addr_t npages = size >> TARGET_PAGE_BITS; target_phys_addr_t vram_offset = 0; @@ -417,21 +417,27 @@ static int xen_sync_dirty_bitmap(XenIOState *state, physmap = get_physmapping(state, start_addr, size); if (physmap == NULL) { /* not handled */ - return -1; + return; } if (state->log_for_dirtybit == NULL) { state->log_for_dirtybit = physmap; } else if (state->log_for_dirtybit != physmap) { - return -1; + /* Only one range for dirty bitmap can be tracked. */ + return; } vram_offset = physmap->phys_offset; rc = xc_hvm_track_dirty_vram(xen_xc, xen_domid, start_addr >> TARGET_PAGE_BITS, npages, bitmap); - if (rc) { - return rc; + if (rc < 0) { + if (rc != -ENODATA) { + fprintf(stderr, "xen: track_dirty_vram failed (0x" TARGET_FMT_plx + ", 0x" TARGET_FMT_plx "): %s\n", + start_addr, start_addr + size, strerror(-rc)); + } + return; } for (i = 0; i < ARRAY_SIZE(bitmap); i++) { @@ -442,40 +448,32 @@ static int xen_sync_dirty_bitmap(XenIOState *state, cpu_physical_memory_set_dirty(vram_offset + (i * width + j) * TARGET_PAGE_SIZE); }; } - - return 0; } static void xen_log_start(MemoryListener *listener, MemoryRegionSection *section) { XenIOState *state = container_of(listener, XenIOState, memory_listener); - int r; - r = xen_sync_dirty_bitmap(state, section->offset_within_address_space, - section->size); - assert(r >= 0); + xen_sync_dirty_bitmap(state, section->offset_within_address_space, + section->size); } static void xen_log_stop(MemoryListener *listener, MemoryRegionSection *section) { XenIOState *state = container_of(listener, XenIOState, memory_listener); - int r; state->log_for_dirtybit = NULL; /* Disable dirty bit tracking */ - r = xc_hvm_track_dirty_vram(xen_xc, xen_domid, 0, 0, NULL); - assert(r >= 0); + xc_hvm_track_dirty_vram(xen_xc, xen_domid, 0, 0, NULL); } static void xen_log_sync(MemoryListener *listener, MemoryRegionSection *section) { XenIOState *state = container_of(listener, XenIOState, memory_listener); - int r; - r = xen_sync_dirty_bitmap(state, section->offset_within_address_space, - section->size); - assert(r >= 0); + xen_sync_dirty_bitmap(state, section->offset_within_address_space, + section->size); } static void xen_log_global_start(MemoryListener *listener)