From patchwork Thu Jul 20 16:04:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9855321 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 DA01E600F5 for ; Thu, 20 Jul 2017 16:18:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9802286DE for ; Thu, 20 Jul 2017 16:18:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE6CE286E6; Thu, 20 Jul 2017 16:18:24 +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 6EA09286DE for ; Thu, 20 Jul 2017 16:18:24 +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 1dYE7t-0002ub-9f; Thu, 20 Jul 2017 16:16:33 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dYE7r-0002ry-Ep for xen-devel@lists.xenproject.org; Thu, 20 Jul 2017 16:16:31 +0000 Received: from [85.158.139.211] by server-10.bemta-5.messagelabs.com id EB/90-01732-E57D0795; Thu, 20 Jul 2017 16:16:30 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIIsWRWlGSWpSXmKPExsXitHSDvW7c9YJ Ig84z3Bbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8aDs7dYCq5JV8w8dpilgfGfYBcjB4eEgL/E z76MLkZODjYBZYmfnb1sILaIgJ5E04HnjF2MXBzMAnMYJabO7WIESQgLOEicO/OOCcRmEVCVO H39HDuIzStgIfG3sw0sLiEgL7Gr7SIriM0JFF/z6ytYXEjAXGLz/vksELaCRMf0Y0wQvYISJ2 c+AYszC0hIHHzxgnkCI+8sJKlZSFILGJlWMWoUpxaVpRbpGhnoJRVlpmeU5CZm5ugaGpjq5aY WFyemp+YkJhXrJefnbmIEBk89AwPjDsbG2X6HGCU5mJREeVkCCyKF+JLyUyozEosz4otKc1KL DzHKcHAoSfAyXAPKCRalpqdWpGXmAMMYJi3BwaMkwisIkuYtLkjMLc5Mh0idYtTleDXh/zcmI Za8/LxUKXFeG5AiAZCijNI8uBGwmLrEKCslzMvIwMAgxFOQWpSbWYIq/4pRnINRSZg3HmQKT2 ZeCdymV0BHMAEd8cgN7IiSRISUVANj1fOdqq469zLvZG1hCYh7lm7Dv3LeJaYE5wcPuKIM3hW 3Wqf01ty49SD3UWzpQfspvCZcv3cZrb0UNl98b+WWe71t5R8+L1v+rbz5568/9+Z9+JD2vFF3 2omHwSkble0XbPj63+hIYazCV7mUN0FrZu9T+Ov85/yTZw3MmufTAu75aEav/zVNSImlOCPRU Iu5qDgRAFbdzCakAgAA X-Env-Sender: prvs=3674d857a=wei.liu2@citrix.com X-Msg-Ref: server-4.tower-206.messagelabs.com!1500567381!103772445!4 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 64530 invoked from network); 20 Jul 2017 16:16:29 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-4.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 20 Jul 2017 16:16:29 -0000 X-IronPort-AV: E=Sophos;i="5.40,384,1496102400"; d="scan'208";a="440670512" From: Wei Liu To: Xen-devel Date: Thu, 20 Jul 2017 17:04:24 +0100 Message-ID: <20170720160426.2343-20-wei.liu2@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170720160426.2343-1-wei.liu2@citrix.com> References: <20170720160426.2343-1-wei.liu2@citrix.com> MIME-Version: 1.0 Cc: George Dunlap , Andrew Cooper , Wei Liu , Jan Beulich Subject: [Xen-devel] [PATCH v3 19/21] 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 109a109155..c7c989d8f8 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -259,6 +259,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; @@ -353,39 +392,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)