From patchwork Thu Mar 16 11:48:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 9628009 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 7B91A60244 for ; Thu, 16 Mar 2017 11:50:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CF19285D4 for ; Thu, 16 Mar 2017 11:50:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52069285EF; Thu, 16 Mar 2017 11:50:54 +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 D4DFF285D4 for ; Thu, 16 Mar 2017 11:50:53 +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 1coTta-0005Lj-Ch; Thu, 16 Mar 2017 11:48:42 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1coTtY-0005Ks-J7 for xen-devel@lists.xenproject.org; Thu, 16 Mar 2017 11:48:40 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id 2C/D2-21675-79B7AC85; Thu, 16 Mar 2017 11:48:39 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNIsWRWlGSWpSXmKPExsXitHRDpO706lM RBvdb5S2+b5nM5MDocfjDFZYAxijWzLyk/IoE1ozLL/+zFDzSrOh5vompgbFDtouRk0NCwF/i 7ImLrCA2m4COxMW5O9m6GDk4RARUJG7vNQAxmQXKJWbciAepEBaIkdh9dy1YNYuAqsSJloNMI DavgKXEnfeXWCAm6knsOvIbrIZTwEqid8tcsLgQUM3rfZeh6gUlTs58AhZnFtCUaN3+mx3Clp do3jqbGaJeUaJ/3gO2CYx8s5C0zELSMgtJywJG5lWMGsWpRWWpRbpGxnpJRZnpGSW5iZk5uoY GZnq5qcXFiempOYlJxXrJ+bmbGIGBxgAEOxj/zA88xCjJwaQkyqsieCJCiC8pP6UyI7E4I76o NCe1+BCjDAeHkgTv5DSgnGBRanpqRVpmDjDkYdISHDxKIrwzQdK8xQWJucWZ6RCpU4yKUuK8T SAJAZBERmkeXBsszi4xykoJ8zICHSLEU5BalJtZgir/ilGcg1FJmDcdZApPZl4J3PRXQIuZgB Yn/jwCsrgkESEl1cCYvprv3RMb1r1e6YxB5/8XrXIX3toRWb6X95zQk7a1v099PfxGWkBhj/0 GJb2Oh/kppVULl25w2LVdLmhGvdeLFRffneix7FuxfZ+IcJDXVMb2XcsMrzrdSLB4Ff6A6Tm/ is+b8M0Me+yE1cyLOD9VrrC9eUXsf3z/lcjz/16wzbCw8Uzd5XpfiaU4I9FQi7moOBEAl6sh6 K4CAAA= X-Env-Sender: prvs=241026746=roger.pau@citrix.com X-Msg-Ref: server-3.tower-27.messagelabs.com!1489664914!91802291!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 4686 invoked from network); 16 Mar 2017 11:48:38 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-3.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 16 Mar 2017 11:48:38 -0000 X-IronPort-AV: E=Sophos;i="5.36,172,1486425600"; d="scan'208";a="414112590" From: Roger Pau Monne To: Date: Thu, 16 Mar 2017 11:48:22 +0000 Message-ID: <20170316114822.27611-5-roger.pau@citrix.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20170316114822.27611-1-roger.pau@citrix.com> References: <20170316114822.27611-1-roger.pau@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Jan Beulich , Roger Pau Monne Subject: [Xen-devel] [PATCH v4 4/4] x86/PVHv2: move pvh_setup_e820 together with the other pvh functions 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 This function is only used by PVHv2 domain build, so move it together with the other PVH domain build functions. Just code motion, no functional change. Signed-off-by: Roger Pau Monné Acked-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper --- xen/arch/x86/domain_build.c | 134 ++++++++++++++++++++++---------------------- 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/xen/arch/x86/domain_build.c b/xen/arch/x86/domain_build.c index a0d5812..00ce5f2 100644 --- a/xen/arch/x86/domain_build.c +++ b/xen/arch/x86/domain_build.c @@ -467,73 +467,6 @@ static void __init process_dom0_ioports_disable(struct domain *dom0) } } -static __init void pvh_setup_e820(struct domain *d, unsigned long nr_pages) -{ - struct e820entry *entry, *entry_guest; - unsigned int i; - unsigned long pages, cur_pages = 0; - uint64_t start, end; - - /* - * Craft the e820 memory map for Dom0 based on the hardware e820 map. - */ - d->arch.e820 = xzalloc_array(struct e820entry, e820.nr_map); - if ( !d->arch.e820 ) - panic("Unable to allocate memory for Dom0 e820 map"); - entry_guest = d->arch.e820; - - /* Clamp e820 memory map to match the memory assigned to Dom0 */ - for ( i = 0, entry = e820.map; i < e820.nr_map; i++, entry++ ) - { - if ( entry->type != E820_RAM ) - { - *entry_guest = *entry; - goto next; - } - - if ( nr_pages == cur_pages ) - { - /* - * We already have all the assigned memory, - * skip this entry - */ - continue; - } - - /* - * Make sure the start and length are aligned to PAGE_SIZE, because - * that's the minimum granularity of the 2nd stage translation. Since - * the p2m code uses PAGE_ORDER_4K internally, also use it here in - * order to prevent this code from getting out of sync. - */ - start = ROUNDUP(entry->addr, PAGE_SIZE << PAGE_ORDER_4K); - end = (entry->addr + entry->size) & - ~((PAGE_SIZE << PAGE_ORDER_4K) - 1); - if ( start >= end ) - continue; - - entry_guest->type = E820_RAM; - entry_guest->addr = start; - entry_guest->size = end - start; - pages = PFN_DOWN(entry_guest->size); - if ( (cur_pages + pages) > nr_pages ) - { - /* Truncate region */ - entry_guest->size = (nr_pages - cur_pages) << PAGE_SHIFT; - cur_pages = nr_pages; - } - else - { - cur_pages += pages; - } - next: - d->arch.nr_e820++; - entry_guest++; - } - ASSERT(cur_pages == nr_pages); - ASSERT(d->arch.nr_e820 <= e820.nr_map); -} - static __init void dom0_update_physmap(struct domain *d, unsigned long pfn, unsigned long mfn, unsigned long vphysmap_s) { @@ -1682,6 +1615,73 @@ static void __init pvh_steal_low_ram(struct domain *d, unsigned long start, } } +static __init void pvh_setup_e820(struct domain *d, unsigned long nr_pages) +{ + struct e820entry *entry, *entry_guest; + unsigned int i; + unsigned long pages, cur_pages = 0; + uint64_t start, end; + + /* + * Craft the e820 memory map for Dom0 based on the hardware e820 map. + */ + d->arch.e820 = xzalloc_array(struct e820entry, e820.nr_map); + if ( !d->arch.e820 ) + panic("Unable to allocate memory for Dom0 e820 map"); + entry_guest = d->arch.e820; + + /* Clamp e820 memory map to match the memory assigned to Dom0 */ + for ( i = 0, entry = e820.map; i < e820.nr_map; i++, entry++ ) + { + if ( entry->type != E820_RAM ) + { + *entry_guest = *entry; + goto next; + } + + if ( nr_pages == cur_pages ) + { + /* + * We already have all the assigned memory, + * skip this entry + */ + continue; + } + + /* + * Make sure the start and length are aligned to PAGE_SIZE, because + * that's the minimum granularity of the 2nd stage translation. Since + * the p2m code uses PAGE_ORDER_4K internally, also use it here in + * order to prevent this code from getting out of sync. + */ + start = ROUNDUP(entry->addr, PAGE_SIZE << PAGE_ORDER_4K); + end = (entry->addr + entry->size) & + ~((PAGE_SIZE << PAGE_ORDER_4K) - 1); + if ( start >= end ) + continue; + + entry_guest->type = E820_RAM; + entry_guest->addr = start; + entry_guest->size = end - start; + pages = PFN_DOWN(entry_guest->size); + if ( (cur_pages + pages) > nr_pages ) + { + /* Truncate region */ + entry_guest->size = (nr_pages - cur_pages) << PAGE_SHIFT; + cur_pages = nr_pages; + } + else + { + cur_pages += pages; + } + next: + d->arch.nr_e820++; + entry_guest++; + } + ASSERT(cur_pages == nr_pages); + ASSERT(d->arch.nr_e820 <= e820.nr_map); +} + static int __init pvh_setup_p2m(struct domain *d) { struct vcpu *v = d->vcpu[0];