From patchwork Thu Sep 14 12:58:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9953097 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 4F90560317 for ; Thu, 14 Sep 2017 13:30:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47C77290FC for ; Thu, 14 Sep 2017 13:30:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3AA2D290FB; Thu, 14 Sep 2017 13:30:50 +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 E6F2D290FC for ; Thu, 14 Sep 2017 13:30:47 +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 1dsUC6-0007u0-BK; Thu, 14 Sep 2017 13:28:38 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsUC4-0007td-JI for xen-devel@lists.xenproject.org; Thu, 14 Sep 2017 13:28:36 +0000 Received: from [193.109.254.147] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-2.bemta-6.messagelabs.com id 87/30-22997-3048AB95; Thu, 14 Sep 2017 13:28:35 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIIsWRWlGSWpSXmKPExsXitHRDpC5zy65 Ig9atLBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aJ6RtYC9ZKV0yd9ZWpgfGWYBcjJ4eEgL/E 10kf2UBsNgFliZ+dvWC2iICeRNOB54xdjFwczAJzGCWmzu1iBEkICzhI3Fu/gAXEZhFQlfj6+ htQnIODV8BS4nRTKsRMeYldbRdZQWxOoHDXh5dMILaQgIVE76X97BC2gkTH9GNgcV4BQYmTM5 +AjWQWkJA4+OIF8wRG3llIUrOQpBYwMq1i1ChOLSpLLdI1NNNLKspMzyjJTczM0TU0MNPLTS0 uTkxPzUlMKtZLzs/dxAgMHgYg2MF4f2PAIUZJDiYlUd69ujsjhfiS8lMqMxKLM+KLSnNSiw8x ynBwKEnwnm3aFSkkWJSanlqRlpkDDGOYtAQHj5II732QNG9xQWJucWY6ROoUoy5Hx827f5iEW PLy81KlxHm1m4GKBECKMkrz4EbAYuoSo6yUMC8j0FFCPAWpRbmZJajyrxjFORiVhHkvg6ziyc wrgdv0CugIJqAjzpzeAXJESSJCSqqBUXB1yLNfPZ1n1v4JXKY2Y9PKPoFYSY//3yT9pyhtFNZ 6pWo/RyKT8WvEojmqnypusehFVn+/H/oj9tYpFXUtqyhP68te4rc01J5ZJ01/8ibNTTTf+aPO vcZFU6bX+M3M/3tR6oPlyV0rl1w8q7Ru3s3Zyd4ioUYf5cUuPlvM//Lk7hWHXGs53ymxFGckG moxFxUnAgBXZeK7pAIAAA== X-Env-Sender: prvs=423b67c62=wei.liu2@citrix.com X-Msg-Ref: server-6.tower-27.messagelabs.com!1505395712!116954911!2 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.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 18394 invoked from network); 14 Sep 2017 13:28:34 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-6.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 14 Sep 2017 13:28:34 -0000 X-IronPort-AV: E=Sophos;i="5.42,393,1500940800"; d="scan'208";a="439758477" From: Wei Liu To: Xen-devel Date: Thu, 14 Sep 2017 13:58:42 +0100 Message-ID: <20170914125852.22129-14-wei.liu2@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170914125852.22129-1-wei.liu2@citrix.com> References: <20170914125852.22129-1-wei.liu2@citrix.com> MIME-Version: 1.0 Cc: George Dunlap , Andrew Cooper , Wei Liu , Jan Beulich Subject: [Xen-devel] [PATCH v5 13/23] x86/mm: factor out pv_arch_init_memory 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 Move the split l4 setup code into the new function. It can then be moved to pv/ in a later patch. Signed-off-by: Wei Liu Acked-by: Jan Beulich --- xen/arch/x86/mm.c | 73 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 8e25d15631..93ca075698 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -249,6 +249,45 @@ static l4_pgentry_t __read_mostly split_l4e; #define root_pgt_pv_xen_slots ROOT_PAGETABLE_PV_XEN_SLOTS #endif +static void pv_arch_init_memory(void) +{ +#ifndef NDEBUG + unsigned int i; + + if ( highmem_start ) + { + unsigned long split_va = (unsigned long)__va(highmem_start); + + if ( split_va < HYPERVISOR_VIRT_END && + split_va - 1 == (unsigned long)__va(highmem_start - 1) ) + { + root_pgt_pv_xen_slots = l4_table_offset(split_va) - + ROOT_PAGETABLE_FIRST_XEN_SLOT; + ASSERT(root_pgt_pv_xen_slots < ROOT_PAGETABLE_PV_XEN_SLOTS); + if ( l4_table_offset(split_va) == l4_table_offset(split_va - 1) ) + { + l3_pgentry_t *l3tab = alloc_xen_pagetable(); + + if ( l3tab ) + { + const l3_pgentry_t *l3idle = + l4e_to_l3e(idle_pg_table[l4_table_offset(split_va)]); + + for ( i = 0; i < l3_table_offset(split_va); ++i ) + l3tab[i] = l3idle[i]; + for ( ; i < L3_PAGETABLE_ENTRIES; ++i ) + l3tab[i] = l3e_empty(); + split_l4e = l4e_from_pfn(virt_to_mfn(l3tab), + __PAGE_HYPERVISOR_RW); + } + else + ++root_pgt_pv_xen_slots; + } + } + } +#endif +} + void __init arch_init_memory(void) { unsigned long i, pfn, rstart_pfn, rend_pfn, iostart_pfn, ioend_pfn; @@ -344,39 +383,7 @@ void __init arch_init_memory(void) mem_sharing_init(); -#ifndef NDEBUG - if ( highmem_start ) - { - unsigned long split_va = (unsigned long)__va(highmem_start); - - if ( split_va < HYPERVISOR_VIRT_END && - split_va - 1 == (unsigned long)__va(highmem_start - 1) ) - { - root_pgt_pv_xen_slots = l4_table_offset(split_va) - - ROOT_PAGETABLE_FIRST_XEN_SLOT; - ASSERT(root_pgt_pv_xen_slots < ROOT_PAGETABLE_PV_XEN_SLOTS); - if ( l4_table_offset(split_va) == l4_table_offset(split_va - 1) ) - { - l3_pgentry_t *l3tab = alloc_xen_pagetable(); - - if ( l3tab ) - { - const l3_pgentry_t *l3idle = - l4e_to_l3e(idle_pg_table[l4_table_offset(split_va)]); - - for ( i = 0; i < l3_table_offset(split_va); ++i ) - l3tab[i] = l3idle[i]; - for ( ; i < L3_PAGETABLE_ENTRIES; ++i ) - l3tab[i] = l3e_empty(); - split_l4e = l4e_from_pfn(virt_to_mfn(l3tab), - __PAGE_HYPERVISOR_RW); - } - else - ++root_pgt_pv_xen_slots; - } - } - } -#endif + pv_arch_init_memory(); } int page_is_ram_type(unsigned long mfn, unsigned long mem_type)