From patchwork Fri Jun 30 16:07:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Druzhinin X-Patchwork-Id: 9819991 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 C63C5603F3 for ; Fri, 30 Jun 2017 16:09:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1E382865F for ; Fri, 30 Jun 2017 16:09:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B61C228699; Fri, 30 Jun 2017 16:09: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 F13BE28676 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 1dQySQ-0003hf-HO; Fri, 30 Jun 2017 16:07:46 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQySO-0003hW-AW for xen-devel@lists.xenproject.org; Fri, 30 Jun 2017 16:07:44 +0000 Received: from [85.158.137.68] by server-3.bemta-3.messagelabs.com id 0D/0E-01987-F4776595; Fri, 30 Jun 2017 16:07:43 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprDIsWRWlGSWpSXmKPExsWyU9JRQte/PCz S4HWdxfctk5kcGD0Of7jCEsAYxZqZl5RfkcCacfHaB5aCs1IV296/YW9gbBPpYuTkkBDwk3jx /DcbiM0mYCBxatMiFhBbRMBWYvbfqcxdjFwczAIzGCVePm0AKxIWcJPY+vUOkM3BwSKgKjH1r DBImFfAU+LxwUusEDPlJG6e62QGsTkFvCRmHPwB1ioEVLOtaQYjRL2gxMmZT8B2MQtISBx88Y IZokZN4mjXLhaIOWkS7fevsU5g5JuFpGUWkpYFjEyrGDWKU4vKUot0DS30kooy0zNKchMzc3Q NDYz1clOLixPTU3MSk4r1kvNzNzECQ6qegYFxB+Pv056HGCU5mJREeVdeC40U4kvKT6nMSCzO iC8qzUktPsQow8GhJMHbXhoWKSRYlJqeWpGWmQMMbpi0BAePkgivbBBQmre4IDG3ODMdInWKU Zfj1YT/35iEWPLy81KlxHl9QGYIgBRllObBjYBF2iVGWSlhXkYGBgYhnoLUotzMElT5V4ziHI xKwrwJIFN4MvNK4Da9AjqCCegI4RkhIEeUJCKkpBoY41Xqzt5SPn9pmuGGckeXk3HOH+8sn3B AKrLOv3HWPHGGx19bBHMs56l5Bd5krnk4ZVpMnfDHrPzcKWnBTzTff7/ibHPiT0vK7SPRdj3b pl1rK/L9veryAvd92zfVcVptDs/fPoE99UuDYbnFDtZ1FZVfBbd5tdTf/BNT58fznGnydxvWw y+3KbEUZyQaajEXFScCAHor/yevAgAA X-Env-Sender: prvs=3478c7289=igor.druzhinin@citrix.com X-Msg-Ref: server-7.tower-31.messagelabs.com!1498838862!95841775!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.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31367 invoked from network); 30 Jun 2017 16:07:42 -0000 Received: from smtp.eu.citrix.com (HELO SMTP.EU.CITRIX.COM) (185.25.65.24) by server-7.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 30 Jun 2017 16:07:42 -0000 X-IronPort-AV: E=Sophos;i="5.40,287,1496102400"; d="scan'208";a="48683284" From: Igor Druzhinin To: , Date: Fri, 30 Jun 2017 17:07:02 +0100 Message-ID: <1498838825-23701-2-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 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 --- 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,