From patchwork Thu Aug 17 14:44:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9906525 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 F13726038C for ; Thu, 17 Aug 2017 14:49:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E271C28B3B for ; Thu, 17 Aug 2017 14:49:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6FE828B3D; Thu, 17 Aug 2017 14:49:46 +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 5A4B228B3B for ; Thu, 17 Aug 2017 14:49: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 1diM55-0002jd-C5; Thu, 17 Aug 2017 14:47:31 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1diM53-0002hc-PD for xen-devel@lists.xenproject.org; Thu, 17 Aug 2017 14:47:29 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id E3/D0-02962-18CA5995; Thu, 17 Aug 2017 14:47:29 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEIsWRWlGSWpSXmKPExsXitHSDvW7Dmqm RBlMWC1p83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBnHn1xhK2iwqtg08yhzA+NJ7S5GTg4JAX+J a19mMIHYbALKEj87e9lAbBEBPYmmA88Zuxi5OJgF5jBKTJ3bxQiSEBZwkej7PpsZxGYRUJXYe 3oymM0rYCmx8vtOdoih8hK72i6ygticQPFDkxaD1QgJWEjM/tDODmErSHRMP8YE0SsocXLmEx YQm1lAQuLgixfMExh5ZyFJzUKSWsDItIpRozi1qCy1SNfITC+pKDM9oyQ3MTNH19DATC83tbg 4MT01JzGpWC85P3cTIzB8GIBgB+OZBYGHGCU5mJREeX/PmhIpxJeUn1KZkVicEV9UmpNafIhR hoNDSYK3cPXUSCHBotT01Iq0zBxgIMOkJTh4lER4/68CSvMWFyTmFmemQ6ROMepyvJrw/xuTE Etefl6qlDhvNEiRAEhRRmke3AhYVF1ilJUS5mUEOkqIpyC1KDezBFX+FaM4B6OSMK8vyCU8mX klcJteAR3BBHTElfZJIEeUJCKkpBoYGfZff7VhmpaS+OfLInHs/39+KnZI4i6493B+ga0C//d p+1XPKpos6WmdYXE4PaHEb0tEr73GA8/WPJVdnbMbPHtmvNq3dZ8Hm8BS3YjlFzVSE4Szm0vr 37bHbHywYs6KKrbXep6/fzj8OifA3fIt3Cmr8E9Q9cmHG2vfVXUmJaeuff93muZGJZbijERDL eai4kQANM8FDKUCAAA= X-Env-Sender: prvs=395e6b081=wei.liu2@citrix.com X-Msg-Ref: server-9.tower-27.messagelabs.com!1502981245!112361240!1 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.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 41830 invoked from network); 17 Aug 2017 14:47:27 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-9.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 17 Aug 2017 14:47:27 -0000 X-IronPort-AV: E=Sophos;i="5.41,388,1498521600"; d="scan'208";a="444178787" From: Wei Liu To: Xen-devel Date: Thu, 17 Aug 2017 15:44:48 +0100 Message-ID: <20170817144456.18989-24-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 23/31] x86/mm: export more get/put page 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 Export some of the get/put functions so that we can move PV mm code trunk by trunk. When moving code is done some of the functions might be made static again. Also fix coding style issues and use bool when appropriate. Signed-off-by: Wei Liu --- xen/arch/x86/mm.c | 40 ++++++++++++++++++++-------------------- xen/include/asm-x86/mm.h | 17 +++++++++++++++-- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 1fdae6e1e6..fb6485500f 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -555,9 +555,8 @@ bool get_page_from_mfn(mfn_t mfn, struct domain *d) } -static int get_page_and_type_from_mfn( - mfn_t mfn, unsigned long type, struct domain *d, - int partial, int preemptible) +int get_page_and_type_from_mfn(mfn_t mfn, unsigned long type, struct domain *d, + int partial, bool preemptible) { struct page_info *page = mfn_to_page(mfn_x(mfn)); int rc; @@ -940,7 +939,7 @@ get_page_from_l1e( * <0 => error code */ define_get_linear_pagetable(l2); -static int +int get_page_from_l2e( l2_pgentry_t l2e, unsigned long pfn, struct domain *d) { @@ -959,7 +958,8 @@ get_page_from_l2e( if ( !(l2e_get_flags(l2e) & _PAGE_PSE) ) { - rc = get_page_and_type_from_mfn(_mfn(mfn), PGT_l1_page_table, d, 0, 0); + rc = get_page_and_type_from_mfn(_mfn(mfn), PGT_l1_page_table, d, 0, + false); if ( unlikely(rc == -EINVAL) && get_l2_linear_pagetable(l2e, pfn, d) ) rc = 0; return rc; @@ -976,7 +976,7 @@ get_page_from_l2e( * <0 => error code */ define_get_linear_pagetable(l3); -static int +int get_page_from_l3e( l3_pgentry_t l3e, unsigned long pfn, struct domain *d, int partial) { @@ -992,8 +992,8 @@ get_page_from_l3e( return -EINVAL; } - rc = get_page_and_type_from_mfn( - _mfn(l3e_get_pfn(l3e)), PGT_l2_page_table, d, partial, 1); + rc = get_page_and_type_from_mfn(_mfn(l3e_get_pfn(l3e)), PGT_l2_page_table, + d, partial, true); if ( unlikely(rc == -EINVAL) && !is_pv_32bit_domain(d) && get_l3_linear_pagetable(l3e, pfn, d) ) @@ -1009,7 +1009,7 @@ get_page_from_l3e( * <0 => error code */ define_get_linear_pagetable(l4); -static int +int get_page_from_l4e( l4_pgentry_t l4e, unsigned long pfn, struct domain *d, int partial) { @@ -1025,8 +1025,8 @@ get_page_from_l4e( return -EINVAL; } - rc = get_page_and_type_from_mfn( - _mfn(l4e_get_pfn(l4e)), PGT_l3_page_table, d, partial, 1); + rc = get_page_and_type_from_mfn(_mfn(l4e_get_pfn(l4e)), PGT_l3_page_table, + d, partial, true); if ( unlikely(rc == -EINVAL) && get_l4_linear_pagetable(l4e, pfn, d) ) rc = 0; @@ -1097,7 +1097,7 @@ void put_page_from_l1e(l1_pgentry_t l1e, struct domain *l1e_owner) * NB. Virtual address 'l2e' maps to a machine address within frame 'pfn'. * Note also that this automatically deals correctly with linear p.t.'s. */ -static int put_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn) +int put_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn) { if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) || (l2e_get_pfn(l2e) == pfn) ) return 1; @@ -1117,8 +1117,8 @@ static int put_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn) static int __put_page_type(struct page_info *, int preemptible); -static int put_page_from_l3e(l3_pgentry_t l3e, unsigned long pfn, - int partial, bool defer) +int put_page_from_l3e(l3_pgentry_t l3e, unsigned long pfn, int partial, + bool defer) { struct page_info *pg; @@ -1155,8 +1155,8 @@ static int put_page_from_l3e(l3_pgentry_t l3e, unsigned long pfn, return put_page_and_type_preemptible(pg); } -static int put_page_from_l4e(l4_pgentry_t l4e, unsigned long pfn, - int partial, bool defer) +int put_page_from_l4e(l4_pgentry_t l4e, unsigned long pfn, int partial, + bool defer) { if ( (l4e_get_flags(l4e) & _PAGE_PRESENT) && (l4e_get_pfn(l4e) != pfn) ) @@ -1340,7 +1340,7 @@ static int alloc_l3_table(struct page_info *page) else rc = get_page_and_type_from_mfn( _mfn(l3e_get_pfn(pl3e[i])), - PGT_l2_page_table | PGT_pae_xen_l2, d, partial, 1); + PGT_l2_page_table | PGT_pae_xen_l2, d, partial, true); } else if ( !is_guest_l3_slot(i) || (rc = get_page_from_l3e(pl3e[i], pfn, d, partial)) > 0 ) @@ -1992,7 +1992,7 @@ int get_page(struct page_info *page, struct domain *domain) * acquired reference again. * Due to get_page() reserving one reference, this call cannot fail. */ -static void get_page_light(struct page_info *page) +void get_page_light(struct page_info *page) { unsigned long x, nx, y = page->count_info; @@ -2525,7 +2525,7 @@ int pv_new_guest_cr3(unsigned long mfn) rc = paging_mode_refcounts(currd) ? (get_page_from_mfn(_mfn(mfn), currd) ? 0 : -EINVAL) : get_page_and_type_from_mfn(_mfn(mfn), PGT_root_page_table, - currd, 0, 1); + currd, 0, true); switch ( rc ) { case 0: @@ -2901,7 +2901,7 @@ long do_mmuext_op( if ( op.arg1.mfn != 0 ) { rc = get_page_and_type_from_mfn( - _mfn(op.arg1.mfn), PGT_root_page_table, currd, 0, 1); + _mfn(op.arg1.mfn), PGT_root_page_table, currd, 0, true); if ( unlikely(rc) ) { diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index a5662f327b..07d4c06fc3 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -339,10 +339,23 @@ int get_page_type(struct page_info *page, unsigned long type); int put_page_type_preemptible(struct page_info *page); int get_page_type_preemptible(struct page_info *page, unsigned long type); int put_old_guest_table(struct vcpu *); -int get_page_from_l1e( - l1_pgentry_t l1e, struct domain *l1e_owner, struct domain *pg_owner); +int get_page_from_l1e(l1_pgentry_t l1e, struct domain *l1e_owner, + struct domain *pg_owner); void put_page_from_l1e(l1_pgentry_t l1e, struct domain *l1e_owner); +int get_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn, struct domain *d); +int put_page_from_l2e(l2_pgentry_t l2e, unsigned long pfn); +int get_page_from_l3e(l3_pgentry_t l3e, unsigned long pfn, struct domain *d, + int partial); +int put_page_from_l3e(l3_pgentry_t l3e, unsigned long pfn, int partial, + bool defer); +int get_page_from_l4e(l4_pgentry_t l4e, unsigned long pfn, struct domain *d, + int partial); +int put_page_from_l4e(l4_pgentry_t l4e, unsigned long pfn, int partial, + bool defer); +void get_page_light(struct page_info *page); bool get_page_from_mfn(mfn_t mfn, struct domain *d); +int get_page_and_type_from_mfn(mfn_t mfn, unsigned long type, struct domain *d, + int partial, bool preemptible); static inline void put_page_and_type(struct page_info *page) {