From patchwork Fri Jun 30 16:07:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Druzhinin X-Patchwork-Id: 9819993 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B17C760224 for ; Fri, 30 Jun 2017 16:09:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADE8B285EB for ; Fri, 30 Jun 2017 16:09:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A228828676; Fri, 30 Jun 2017 16:09:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EAEED285EB for ; Fri, 30 Jun 2017 16:09:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQySb-0003mK-Br; Fri, 30 Jun 2017 16:07:57 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQySZ-0003l1-G0 for xen-devel@lists.xenproject.org; Fri, 30 Jun 2017 16:07:55 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id 12/83-02176-A5776595; Fri, 30 Jun 2017 16:07:54 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrEIsWRWlGSWpSXmKPExsWyU9JRQjeqPCz S4OR/EYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPd3A62gjmyFYt+1DQw9op3MXJySAj4SbzY 2scMYrMJGEic2rSIBcQWEbCVmP13KlCci4NZYAajxMunDWwgCWEBH4nFe78wdTFycLAIqEoce 2sOEuYV8JSYMf8pM8RMOYmb5zrBbE4BL4kZB3+AtQoB1WxrmsEIUS8ocXLmE7BdzAISEgdfvG CGqFGTONq1iwViTppE+/1rrBMY+WYhaZmFpGUBI9MqRo3i1KKy1CJdQ2O9pKLM9IyS3MTMHF1 DA1O93NTi4sT01JzEpGK95PzcTYzAkGIAgh2M/7Z5HmKU5GBSEuVdeS00UogvKT+lMiOxOCO+ qDQntfgQowwHh5IEL3dZWKSQYFFqempFWmYOMLhh0hIcPEoivLJBQGne4oLE3OLMdIjUKUZjj lUzf35j4ng14f83JiGWvPy8VClx3h2lQKUCIKUZpXlwg2BRd4lRVkqYlxHoNCGegtSi3MwSVP lXjOIcjErCvIIg9/Bk5pXA7XsFdAoT0CnCM0JATilJREhJNTDylwa8CNjeN/P58q7ARXsfvJx Wp21RzHhyZ8+6w1cf6L64Ef3140ubO3OWCBv93/pxYZXGlfP2Odadm/07fB1ri/LrFHr8Dh+a rTkrKKTMTevB+mtzF3Etfqnq37G6NFIme/rk9a+Ut6rsX7pX26J3xo7szQu7X4eLRqblrCuIO 7vseNP0IuHrSizFGYmGWsxFxYkA+ws9ibUCAAA= X-Env-Sender: prvs=3478c7289=igor.druzhinin@citrix.com X-Msg-Ref: server-5.tower-206.messagelabs.com!1498838872!99237906!2 X-Originating-IP: [185.25.65.24] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 50477 invoked from network); 30 Jun 2017 16:07:54 -0000 Received: from smtp.eu.citrix.com (HELO SMTP.EU.CITRIX.COM) (185.25.65.24) by server-5.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 30 Jun 2017 16:07:54 -0000 X-IronPort-AV: E=Sophos;i="5.40,287,1496102400"; d="scan'208";a="48683298" From: Igor Druzhinin To: , Date: Fri, 30 Jun 2017 17:07:05 +0100 Message-ID: <1498838825-23701-5-git-send-email-igor.druzhinin@citrix.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498838825-23701-1-git-send-email-igor.druzhinin@citrix.com> References: <1498838825-23701-1-git-send-email-igor.druzhinin@citrix.com> MIME-Version: 1.0 X-ClientProxiedBy: FTLPEX02CAS03.citrite.net (10.13.99.94) To AMSPEX02CL03.citrite.net (10.69.22.127) Cc: anthony.perard@citrix.com, Igor Druzhinin , sstabellini@kernel.org, paul.durrant@citrix.com, pbonzini@redhat.com Subject: [Xen-devel] [PATCH 4/4] xen: don't use xenstore to save/restore physmap anymore X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP If we have a system with xenforeignmemory_map2() implemented we don't need to save/restore physmap on suspend/restore anymore. In case we resume a VM without physmap - try to recreate the physmap during memory region restore phase and remap map cache entries accordingly. The old code is left for compatibility reasons. Signed-off-by: Igor Druzhinin --- hw/i386/xen/xen-hvm.c | 45 ++++++++++++++++++++++++++++++++++----------- include/hw/xen/xen_common.h | 1 + 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index d259cf7..1b6a5ce 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -305,6 +305,7 @@ static hwaddr xen_phys_offset_to_gaddr(hwaddr start_addr, return start_addr; } +#ifdef XEN_COMPAT_PHYSMAP static int xen_save_physmap(XenIOState *state, XenPhysmap *physmap) { char path[80], value[17]; @@ -334,6 +335,12 @@ static int xen_save_physmap(XenIOState *state, XenPhysmap *physmap) } return 0; } +#else +static int xen_save_physmap(XenIOState *state, XenPhysmap *physmap) +{ + return 0; +} +#endif static int xen_add_to_physmap(XenIOState *state, hwaddr start_addr, @@ -368,6 +375,26 @@ go_physmap: DPRINTF("mapping vram to %"HWADDR_PRIx" - %"HWADDR_PRIx"\n", start_addr, start_addr + size); + mr_name = memory_region_name(mr); + + physmap = g_malloc(sizeof (XenPhysmap)); + + physmap->start_addr = start_addr; + physmap->size = size; + physmap->name = mr_name; + physmap->phys_offset = phys_offset; + + QLIST_INSERT_HEAD(&state->physmap, physmap, list); + + if (runstate_check(RUN_STATE_INMIGRATE)) { + /* Now when we have a physmap entry we can remap a dummy mapping and change + * it to a real one of guest foreign memory. */ + uint8_t *p = xen_remap_cache_entry(phys_offset, size); + assert(p && p == memory_region_get_ram_ptr(mr)); + + return 0; + } + pfn = phys_offset >> TARGET_PAGE_BITS; start_gpfn = start_addr >> TARGET_PAGE_BITS; for (i = 0; i < size >> TARGET_PAGE_BITS; i++) { @@ -382,21 +409,11 @@ go_physmap: } } - mr_name = memory_region_name(mr); - - physmap = g_malloc(sizeof (XenPhysmap)); - - physmap->start_addr = start_addr; - physmap->size = size; - physmap->name = mr_name; - physmap->phys_offset = phys_offset; - - QLIST_INSERT_HEAD(&state->physmap, physmap, list); - xc_domain_pin_memory_cacheattr(xen_xc, xen_domid, start_addr >> TARGET_PAGE_BITS, (start_addr + size - 1) >> TARGET_PAGE_BITS, XEN_DOMCTL_MEM_CACHEATTR_WB); + return xen_save_physmap(state, physmap); } @@ -1158,6 +1175,7 @@ static void xen_exit_notifier(Notifier *n, void *data) xs_daemon_close(state->xenstore); } +#ifdef XEN_COMPAT_PHYSMAP static void xen_read_physmap(XenIOState *state) { XenPhysmap *physmap = NULL; @@ -1205,6 +1223,11 @@ static void xen_read_physmap(XenIOState *state) } free(entries); } +#else +static void xen_read_physmap(XenIOState *state) +{ +} +#endif static void xen_wakeup_notifier(Notifier *notifier, void *data) { diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h index 70a5cad..c04c5c9 100644 --- a/include/hw/xen/xen_common.h +++ b/include/hw/xen/xen_common.h @@ -80,6 +80,7 @@ extern xenforeignmemory_handle *xen_fmem; #if CONFIG_XEN_CTRL_INTERFACE_VERSION < 41000 +#define XEN_COMPAT_PHYSMAP #define xenforeignmemory_map2(h, d, a, p, f, ps, ar, e) \ xenforeignmemory_map(h, d, p, ps, ar, e)