From patchwork Mon Jul 10 22:40:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Druzhinin X-Patchwork-Id: 9833825 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 1554E60393 for ; Mon, 10 Jul 2017 22:42:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 079F028487 for ; Mon, 10 Jul 2017 22:42:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F03C32847D; Mon, 10 Jul 2017 22:42:47 +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 231DB282EC for ; Mon, 10 Jul 2017 22:42:46 +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 1dUhLv-0007AO-4W; Mon, 10 Jul 2017 22:40:27 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dUhLt-0007AI-8r for xen-devel@lists.xenproject.org; Mon, 10 Jul 2017 22:40:25 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id 86/56-02962-85204695; Mon, 10 Jul 2017 22:40:24 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRWlGSWpSXmKPExsWyU9JRQjecKSX S4MF+E4vvWyYzOTB6HP5whSWAMYo1My8pvyKBNePEzwusBbukK97+eMPSwPhapIuRk0NCwE/i /JVOFhCbTcBA4tSmRWC2iICtxOy/U5m7GLk4mAVmMEq8fNrABpIQFvCUmHH7NROIzSKgKnFn1 3VGEJsXKP76934WiKFyEjfPdTKD2JwCXhLr2teC9QoB1Tx9/wOqXlDi5MwnYPXMAhISB1+8YI aoUZM42rULak6axP0z55knMPLNQtIyC0nLAkamVYwaxalFZalFuoameklFmekZJbmJmTm6hgZ mermpxcWJ6ak5iUnFesn5uZsYgWHFAAQ7GL8tCzjEKMnBpCTK+3V/cqQQX1J+SmVGYnFGfFFp TmrxIUYZDg4lCd7XDCmRQoJFqempFWmZOcAAh0lLcPAoifAu/wzUyltckJhbnJkOkTrFqMvxa sL/b0xCLHn5ealS4rwRjEAzBECKMkrz4EbAou0So6yUMC8j0FFCPAWpRbmZJajyrxjFORiVhH k1QabwZOaVwG16BXQEE9ARbHUJIEeUJCKkpBoYuR1e13JMiLKqO3hsc1UHy/0pU+T3Zh2famO 19oWKeWTVMSEuzVWieSncLZ2aKg6187JWOvz85HQs+nP8igVf3j46Z+UYtU37RBf/q/tNdzfo nXCI0f9y8AKj2LmTBZnrZC9cDNlz8+kfBg6blmeH9Tnn3Xl//KvxsWeif2pEYlvf3Fih+6DXS 4mlOCPRUIu5qDgRAHAzhnixAgAA X-Env-Sender: prvs=357aabd99=igor.druzhinin@citrix.com X-Msg-Ref: server-13.tower-27.messagelabs.com!1499726423!96969302!1 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 29144 invoked from network); 10 Jul 2017 22:40:23 -0000 Received: from smtp.eu.citrix.com (HELO SMTP.EU.CITRIX.COM) (185.25.65.24) by server-13.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 10 Jul 2017 22:40:23 -0000 X-IronPort-AV: E=Sophos;i="5.40,342,1496102400"; d="scan'208";a="49102140" From: Igor Druzhinin To: , Date: Mon, 10 Jul 2017 23:40:00 +0100 Message-ID: <1499726403-10129-2-git-send-email-igor.druzhinin@citrix.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499726403-10129-1-git-send-email-igor.druzhinin@citrix.com> References: <1499726403-10129-1-git-send-email-igor.druzhinin@citrix.com> MIME-Version: 1.0 X-ClientProxiedBy: FTLPEX02CAS03.citrite.net (10.13.99.94) 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 v3 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: Stefano Stabellini 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,