From patchwork Tue Feb 28 17:39:41 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: 9596429 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 1AF1F60453 for ; Tue, 28 Feb 2017 17:42:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 123EB201BC for ; Tue, 28 Feb 2017 17:42:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06A5D205AF; Tue, 28 Feb 2017 17:42:01 +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 81701201BC for ; Tue, 28 Feb 2017 17:42:00 +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 1cilkj-0003o8-BN; Tue, 28 Feb 2017 17:39:57 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cilki-0003lr-0B for xen-devel@lists.xenproject.org; Tue, 28 Feb 2017 17:39:56 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id 8C/79-21675-BE5B5B85; Tue, 28 Feb 2017 17:39:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBIsWRWlGSWpSXmKPExsXitHRDpO7LrVs jDHbttbT4vmUykwOjx+EPV1gCGKNYM/OS8isSWDP2/ZEteKRZsXXaIdYGxg7ZLkYODgkBf4np mx27GDk52AR0JC7O3ckGEhYRUJG4vdcAxGQWKJeYcSMepEJYIEZi1dX3rCA2i4CqROv7DSwgN q+ApcSm/wuYQGwJAT2JXUd+g9VwClhJ7PvQxwxiCwHVXJ7+jhGiXlDi5MwnYL3MApoSrdt/s0 PY8hLNW2dD1StK9M97wDaBkW8WkpZZSFpmIWlZwMi8ilG9OLWoLLVI11AvqSgzPaMkNzEzR9f QwEwvN7W4ODE9NScxqVgvOT93EyMwxBiAYAfjzudOhxglOZiURHmDZmyNEOJLyk+pzEgszogv Ks1JLT7EKMPBoSTB+3kLUE6wKDU9tSItMwcY7DBpCQ4eJRFeDWDAC/EWFyTmFmemQ6ROMSpKi fMqgyQEQBIZpXlwbbAIu8QoKyXMywh0iBBPQWpRbmYJqvwrRnEORiVhXl+QKTyZeSVw018BLW YCWvxCBWxxSSJCSqqBUajl0ZI3czzXlB1ZtXpzsHdW5tdkvqtHGx7n2c8/tVWfmXPK0pv3vr0 3efNrb8EX8br1VZZCrZZ70949TbzS82556upDC5zkA76pqB/em7Zik+v0g76n3ryxNHf2YZrV PfVF3M8fXz594Lv8OOLUnLuCHnvu/cwq+2Dl9JF5u5VybEj+hVM+QoFKLMUZiYZazEXFiQCno V7UqwIAAA== X-Env-Sender: prvs=225b12261=roger.pau@citrix.com X-Msg-Ref: server-3.tower-27.messagelabs.com!1488303592!89042656!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 4129 invoked from network); 28 Feb 2017 17:39:53 -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; 28 Feb 2017 17:39:53 -0000 X-IronPort-AV: E=Sophos;i="5.35,220,1484006400"; d="scan'208";a="410350847" From: Roger Pau Monne To: Date: Tue, 28 Feb 2017 17:39:41 +0000 Message-ID: <20170228173941.69473-4-roger.pau@citrix.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20170228173941.69473-1-roger.pau@citrix.com> References: <20170228173941.69473-1-roger.pau@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Jan Beulich , Roger Pau Monne Subject: [Xen-devel] [PATCH v2 3/3] 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 7d4f5e2..570f262 100644 --- a/xen/arch/x86/domain_build.c +++ b/xen/arch/x86/domain_build.c @@ -470,73 +470,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) { @@ -1685,6 +1618,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];