From patchwork Tue Jul 4 15:47:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Druzhinin X-Patchwork-Id: 9825373 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 A4FDD604D9 for ; Tue, 4 Jul 2017 15:50:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9701D28535 for ; Tue, 4 Jul 2017 15:50:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B126284FC; Tue, 4 Jul 2017 15:50:23 +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 D1B6C28511 for ; Tue, 4 Jul 2017 15:50: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 1dSQ3h-0003JO-FX; Tue, 04 Jul 2017 15:48:13 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dSQ3f-0003J5-GN for xen-devel@lists.xenproject.org; Tue, 04 Jul 2017 15:48:11 +0000 Received: from [85.158.143.35] by server-8.bemta-6.messagelabs.com id 30/41-03704-AB8BB595; Tue, 04 Jul 2017 15:48:10 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRWlGSWpSXmKPExsWyU9JRQnfXjuh Ig483xSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyL1z6wFJyVqtj2/g17A2ObSBcjJ4eEgJ/E jGuP2EBsNgEDiVObFrGA2CICthKz/05l7mLk4mAWmMEo8fJpA1iRsICnxMJvnYwgNouAisS/K XNYQWxeoPiWGXvZIIbKSdw818kMYnMKeElcbl3DDmILAdWcu/CBCaJeUOLkzCdgy5gFJCQOvn jBDFGjJnG0axcLxJx0iRV7T7FMYOSbhaRlFpKWBYxMqxg1ilOLylKLdI2N9ZKKMtMzSnITM3N 0DQ3M9HJTi4sT01NzEpOK9ZLzczcxAsOKAQh2MO5cH3iIUZKDSUmUN9YsOlKILyk/pTIjsTgj vqg0J7X4EKMMB4eSBK/XdqCcYFFqempFWmYOMMBh0hIcPEoivBLbgNK8xQWJucWZ6RCpU4y6H K8m/P/GJMSSl5+XKiXOywUyQwCkKKM0D24ELNouMcpKCfMyAh0lxFOQWpSbWYIq/4pRnINRSZ h3PsgUnsy8ErhNr4COYAI6oqEnAuSIkkSElFQDY+HOkDr59G6PnuKcPbabd1nxb53dcPJYRvG LIp//kfIfp/LEMXnZ/5n71HHjzMm9XwR1CubGRU/IVdhgYxIQu8yXX1z34cVZQQY6vpW3RHYk Xj8wq7Vqt9JFwwlimeXypkft/31eG7HDhCVRZm9CSXl214OghPc/ahfrLGfsmvYhbPvd2TWbl FiKMxINtZiLihMBt8Z9cLECAAA= X-Env-Sender: prvs=3512ce2cb=igor.druzhinin@citrix.com X-Msg-Ref: server-15.tower-21.messagelabs.com!1499183286!71516320!2 X-Originating-IP: [185.25.65.24] X-SpamReason: No, hits=0.0 required=7.0 tests=received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30327 invoked from network); 4 Jul 2017 15:48:10 -0000 Received: from smtp.ctxuk.citrix.com (HELO SMTP.EU.CITRIX.COM) (185.25.65.24) by server-15.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 4 Jul 2017 15:48:10 -0000 X-IronPort-AV: E=Sophos;i="5.40,309,1496102400"; d="scan'208";a="48812834" From: Igor Druzhinin To: , Date: Tue, 4 Jul 2017 16:47:44 +0100 Message-ID: <1499183267-28623-2-git-send-email-igor.druzhinin@citrix.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499183267-28623-1-git-send-email-igor.druzhinin@citrix.com> References: <1499183267-28623-1-git-send-email-igor.druzhinin@citrix.com> MIME-Version: 1.0 X-ClientProxiedBy: FTLPEX02CAS01.citrite.net (10.13.99.120) To AMSPEX02CL01.citrite.net (10.69.22.125) Cc: anthony.perard@citrix.com, Igor Druzhinin , sstabellini@kernel.org, paul.durrant@citrix.com, pbonzini@redhat.com Subject: [Xen-devel] [PATCH v2 1/4] xen: move physmap saving into a separate function 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 Non-functional change. Signed-off-by: Igor Druzhinin Reviewed-by: Paul Durrant --- hw/i386/xen/xen-hvm.c | 57 ++++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index cffa7e2..d259cf7 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -305,6 +305,36 @@ static hwaddr xen_phys_offset_to_gaddr(hwaddr start_addr, return start_addr; } +static int xen_save_physmap(XenIOState *state, XenPhysmap *physmap) +{ + char path[80], value[17]; + + snprintf(path, sizeof(path), + "/local/domain/0/device-model/%d/physmap/%"PRIx64"/start_addr", + xen_domid, (uint64_t)physmap->phys_offset); + snprintf(value, sizeof(value), "%"PRIx64, (uint64_t)physmap->start_addr); + if (!xs_write(state->xenstore, 0, path, value, strlen(value))) { + return -1; + } + snprintf(path, sizeof(path), + "/local/domain/0/device-model/%d/physmap/%"PRIx64"/size", + xen_domid, (uint64_t)physmap->phys_offset); + snprintf(value, sizeof(value), "%"PRIx64, (uint64_t)physmap->size); + if (!xs_write(state->xenstore, 0, path, value, strlen(value))) { + return -1; + } + if (physmap->name) { + snprintf(path, sizeof(path), + "/local/domain/0/device-model/%d/physmap/%"PRIx64"/name", + xen_domid, (uint64_t)physmap->phys_offset); + if (!xs_write(state->xenstore, 0, path, + physmap->name, strlen(physmap->name))) { + return -1; + } + } + return 0; +} + static int xen_add_to_physmap(XenIOState *state, hwaddr start_addr, ram_addr_t size, @@ -316,7 +346,6 @@ static int xen_add_to_physmap(XenIOState *state, XenPhysmap *physmap = NULL; hwaddr pfn, start_gpfn; hwaddr phys_offset = memory_region_get_ram_addr(mr); - char path[80], value[17]; const char *mr_name; if (get_physmapping(state, start_addr, size)) { @@ -368,31 +397,7 @@ go_physmap: start_addr >> TARGET_PAGE_BITS, (start_addr + size - 1) >> TARGET_PAGE_BITS, XEN_DOMCTL_MEM_CACHEATTR_WB); - - snprintf(path, sizeof(path), - "/local/domain/0/device-model/%d/physmap/%"PRIx64"/start_addr", - xen_domid, (uint64_t)phys_offset); - snprintf(value, sizeof(value), "%"PRIx64, (uint64_t)start_addr); - if (!xs_write(state->xenstore, 0, path, value, strlen(value))) { - return -1; - } - snprintf(path, sizeof(path), - "/local/domain/0/device-model/%d/physmap/%"PRIx64"/size", - xen_domid, (uint64_t)phys_offset); - snprintf(value, sizeof(value), "%"PRIx64, (uint64_t)size); - if (!xs_write(state->xenstore, 0, path, value, strlen(value))) { - return -1; - } - if (mr_name) { - snprintf(path, sizeof(path), - "/local/domain/0/device-model/%d/physmap/%"PRIx64"/name", - xen_domid, (uint64_t)phys_offset); - if (!xs_write(state->xenstore, 0, path, mr_name, strlen(mr_name))) { - return -1; - } - } - - return 0; + return xen_save_physmap(state, physmap); } static int xen_remove_from_physmap(XenIOState *state,