From patchwork Sun Jul 30 15:43:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9870549 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 D9A1E60353 for ; Sun, 30 Jul 2017 15:46:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAFFF28462 for ; Sun, 30 Jul 2017 15:46:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFBD028599; Sun, 30 Jul 2017 15:46:48 +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 419CC28462 for ; Sun, 30 Jul 2017 15:46:48 +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 1dbqNd-0006NE-7e; Sun, 30 Jul 2017 15:43:45 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dbqNb-0006Ld-De for xen-devel@lists.xenproject.org; Sun, 30 Jul 2017 15:43:43 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id B3/70-27137-EAEFD795; Sun, 30 Jul 2017 15:43:42 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIIsWRWlGSWpSXmKPExsXitHRDpO66f7W RBofm8Fl83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBkvn9xiKmiwqrh6/wljA+NJ7S5GTg4JAX+J Ge9vsoDYbALKEj87e9lAbBEBPYmmA88Zuxi5OJgF5jBKTJ3bxQiSEBbwknj4+xUriM0ioCpx8 /w8oAYODl4BC4kV/zMhZspL7Gq7CFbCKWApsWlJFxOILSSQKnHm2Ap2CFtBomP6MbA4r4CgxM mZT8BuYBaQkDj44gXzBEbeWUhSs5CkFjAyrWLUKE4tKkst0jU21EsqykzPKMlNzMzRNTQw08t NLS5OTE/NSUwq1kvOz93ECAweBiDYwdi0KPAQoyQHk5Io7zru2kghvqT8lMqMxOKM+KLSnNTi Q4wyHBxKEryFf4FygkWp6akVaZk5wDCGSUtw8CiJ8E4DSfMWFyTmFmemQ6ROMepyvJrw/xuTE Etefl6qlDhvA0iRAEhRRmke3AhYTF1ilJUS5mUEOkqIpyC1KDezBFX+FaM4B6OSMG8yyBSezL wSuE2vgI5gAjpCshTsiJJEhJRUA6P57FLv/lkLI/YEJoWfuzr5B2vnaytlbb5PR7ZkVN5L8Y2 aeUxoYczMxusGx2N51hh/3ffZ9Nqq5YvVHs52cP9mte4Wq/nk8N1vFaKf/q113z+9Ym3n34/e 6lcWfC+ckPfu5M4FfPP73/3+xv68VqCoOOc5J9uRhg1CJxTYJl+S9Tr33Ftk3552JZbijERDL eai4kQAx2JxiaQCAAA= X-Env-Sender: prvs=37723ee83=wei.liu2@citrix.com X-Msg-Ref: server-3.tower-27.messagelabs.com!1501429419!109213908!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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 18089 invoked from network); 30 Jul 2017 15:43:41 -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; 30 Jul 2017 15:43:41 -0000 X-IronPort-AV: E=Sophos;i="5.40,437,1496102400"; d="scan'208";a="433622812" From: Wei Liu To: Xen-devel Date: Sun, 30 Jul 2017 16:43:26 +0100 Message-ID: <20170730154335.24313-3-wei.liu2@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170730154335.24313-1-wei.liu2@citrix.com> References: <20170720160426.2343-1-wei.liu2@citrix.com> <20170730154335.24313-1-wei.liu2@citrix.com> MIME-Version: 1.0 Cc: George Dunlap , Andrew Cooper , Wei Liu , Jan Beulich Subject: [Xen-devel] [PATCH v3 extra 02/11] 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 a908d70dea..40f9ad9c98 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -559,9 +559,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; @@ -944,7 +943,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) { @@ -963,7 +962,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; @@ -980,7 +980,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) { @@ -996,8 +996,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) ) @@ -1013,7 +1013,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) { @@ -1029,8 +1029,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; @@ -1101,7 +1101,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; @@ -1121,8 +1121,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; @@ -1159,8 +1159,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) ) @@ -1344,7 +1344,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 ) @@ -1996,7 +1996,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; @@ -2529,7 +2529,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: @@ -2905,7 +2905,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) {