From patchwork Thu Aug 17 14:44:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9906501 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 49E6F603B5 for ; Thu, 17 Aug 2017 14:48:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C2C828B2C for ; Thu, 17 Aug 2017 14:48:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3124428B3C; Thu, 17 Aug 2017 14:48: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 D123028B2C for ; Thu, 17 Aug 2017 14:48: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 1diM4F-0001qS-BP; Thu, 17 Aug 2017 14:46:39 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1diM4E-0001pE-B8 for xen-devel@lists.xenproject.org; Thu, 17 Aug 2017 14:46:38 +0000 Received: from [85.158.137.68] by server-3.bemta-3.messagelabs.com id DC/43-01987-D4CA5995; Thu, 17 Aug 2017 14:46:37 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEIsWRWlGSWpSXmKPExsXitHRDpK7vmqm RBld2Mll83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBm39s5hLrgmXXHp+V3WBsZ/gl2MnBwSAv4S U5Z8YwOx2QSUJX529oLZIgJ6Ek0HnjN2MXJxMAvMYZSYOreLESQhLOAg8eNdMzuIzSKgKnHh7 FawBl4BS4kj9/8xQwyVl9jVdpEVxOYEih+atBgsLiRgITH7Qzs7hK0g0TH9GBNEr6DEyZlPWE BsZgEJiYMvXjBPYOSdhSQ1C0lqASPTKkaN4tSistQiXSNDvaSizPSMktzEzBxdQwNjvdzU4uL E9NScxKRiveT83E2MwPCpZ2Bg3MHYs9fvEKMkB5OSKO/vWVMihfiS8lMqMxKLM+KLSnNSiw8x ynBwKEnwFq6eGikkWJSanlqRlpkDDGSYtAQHj5II73qQNG9xQWJucWY6ROoUoy7Hqwn/vzEJs eTl56VKifNGghQJgBRllObBjYBF1SVGWSlhXkYGBgYhnoLUotzMElT5V4ziHIxKwry+IFN4Mv NK4Da9AjqCCeiIK+2TQI4oSURISTUw2vZ/ORCy4bvgrQ/5HerL9CXfpK54uUDeMXr/68ni4sq GRnXxTxandh3dUHjz+Knvpzx8p2RdXrGz3P3J5T17rukVFt/7sMateS1TBKNZy8JJFj/svy5Y GdaXbKJixVhlVqP1edFp6Q3FWZeMVypF1dW+2h2h7pfleLGL6+u80g2HJbcvOFato8RSnJFoq MVcVJwIAFxMzfqlAgAA X-Env-Sender: prvs=395e6b081=wei.liu2@citrix.com X-Msg-Ref: server-15.tower-31.messagelabs.com!1502981187!106404907!3 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 33680 invoked from network); 17 Aug 2017 14:46:36 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-15.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 17 Aug 2017 14:46:36 -0000 X-IronPort-AV: E=Sophos;i="5.41,388,1498521600"; d="scan'208";a="435893572" From: Wei Liu To: Xen-devel Date: Thu, 17 Aug 2017 15:44:44 +0100 Message-ID: <20170817144456.18989-20-wei.liu2@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170817144456.18989-1-wei.liu2@citrix.com> References: <20170817144456.18989-1-wei.liu2@citrix.com> MIME-Version: 1.0 Cc: George Dunlap , Andrew Cooper , Wei Liu , Jan Beulich Subject: [Xen-devel] [PATCH v4 19/31] 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. The new function is also going to contain other PV specific setup code in later patch. Signed-off-by: Wei Liu --- 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 7f175bacc9..fbf402d16f 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -236,6 +236,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; @@ -330,39 +369,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)