From patchwork Tue Jul 25 14:11:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 9862093 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 D001D600F5 for ; Tue, 25 Jul 2017 14:13:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C133526AE3 for ; Tue, 25 Jul 2017 14:13:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3F282621B; Tue, 25 Jul 2017 14:13:57 +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 F21B82621B for ; Tue, 25 Jul 2017 14:13:55 +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 1da0YX-0006pR-Hh; Tue, 25 Jul 2017 14:11:25 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1da0YV-0006p4-Tm for xen-devel@lists.xen.org; Tue, 25 Jul 2017 14:11:24 +0000 Received: from [85.158.139.211] by server-12.bemta-5.messagelabs.com id 56/CD-01731-B8157795; Tue, 25 Jul 2017 14:11:23 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRWlGSWpSXmKPExsXitHSDvW5nYHm kwfQ/EhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8abq6kFh9QrZl6aw9bAOE+6i5GTQ0LAX2LS 0gPMIDabgL7E7hefmEBsEQF1idMdF1m7GLk4mAXmMEpMnbOHESQhLBAosfnBDHYQm0VAVeLGj 7VgcV4BT4n39++zQAyVkzh//CfYUCEBNYlr/ZfYIWoEJU7OfAJWwywgIXHwxQvmCYzcs5CkZi FJLWBkWsWoXpxaVJZapGuul1SUmZ5RkpuYmaNraGCql5taXJyYnpqTmFSsl5yfu4kRGAoMQLC D8dhk50OMkhxMSqK833TLI4X4kvJTKjMSizPii0pzUosPMcpwcChJ8JYFAOUEi1LTUyvSMnOA QQmTluDgURLh5QVJ8xYXJOYWZ6ZDpE4x6nK8mvD/G5MQS15+XqqUOC8zSJEASFFGaR7cCFiEX GKUlRLmZQQ6SoinILUoN7MEVf4VozgHo5IwbzDIFJ7MvBK4Ta+AjmACOmLOjFKQI0oSEVJSDY wz+tbPscr8dm9Nd3Rv64Rtec2SLV039R7qfGfWijdMD8t4XjAtaTK7+Kbv9t6zS2bUVPye7hH quOtC+x1Bk7X2HcXzAl6WT9hVGvBQ8MGODZPi5n07WNonzvZ6917bmFumzl9PtX1sNZGc/jd0 5cnP+zYdujvnn9TXy1HP3wckH4xYMNeX52uiEktxRqKhFnNRcSIACowhy4sCAAA= X-Env-Sender: prvs=3721034a5=Andrew.Cooper3@citrix.com X-Msg-Ref: server-15.tower-206.messagelabs.com!1500991878!90425716!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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 36956 invoked from network); 25 Jul 2017 14:11:21 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-15.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 25 Jul 2017 14:11:21 -0000 X-IronPort-AV: E=Sophos;i="5.40,411,1496102400"; d="scan'208";a="441221388" From: Andrew Cooper To: Xen-devel Date: Tue, 25 Jul 2017 15:11:07 +0100 Message-ID: <1500991868-25798-1-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Cc: George Dunlap , Andrew Cooper , Wei Liu , Jan Beulich Subject: [Xen-devel] [PATCH 1/2] x86/mm: Rename get_page_from_pagenr() to get_page_from_mfn() 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 'pagenr' is actually an mfn. Rename the function to use consistent terminology, switching it to use a typesafe mfn_t and boolean return type. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Wei Liu --- CC: Jan Beulich CC: George Dunlap CC: Wei Liu --- xen/arch/x86/mm.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 19f672d..6075be6 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -716,18 +716,18 @@ int map_ldt_shadow_page(unsigned int off) } -static int get_page_from_pagenr(unsigned long page_nr, struct domain *d) +static bool get_page_from_mfn(mfn_t mfn, struct domain *d) { - struct page_info *page = mfn_to_page(page_nr); + struct page_info *page = mfn_to_page(mfn_x(mfn)); - if ( unlikely(!mfn_valid(_mfn(page_nr))) || unlikely(!get_page(page, d)) ) + if ( unlikely(!mfn_valid(mfn)) || unlikely(!get_page(page, d)) ) { gdprintk(XENLOG_WARNING, - "Could not get page ref for mfn %"PRI_mfn"\n", page_nr); - return 0; + "Could not get page ref for mfn %"PRI_mfn"\n", mfn_x(mfn)); + return false; } - return 1; + return true; } @@ -741,7 +741,7 @@ static int get_page_and_type_from_pagenr(unsigned long page_nr, int rc; if ( likely(partial >= 0) && - unlikely(!get_page_from_pagenr(page_nr, d)) ) + unlikely(!get_page_from_mfn(_mfn(page_nr), d)) ) return -EINVAL; rc = (preemptible ? @@ -795,7 +795,7 @@ get_##level##_linear_pagetable( \ if ( (pfn = level##e_get_pfn(pde)) != pde_pfn ) \ { \ /* Make sure the mapped frame belongs to the correct domain. */ \ - if ( unlikely(!get_page_from_pagenr(pfn, d)) ) \ + if ( unlikely(!get_page_from_mfn(_mfn(pfn), d)) ) \ return 0; \ \ /* \ @@ -3001,7 +3001,7 @@ int new_guest_cr3(unsigned long mfn) } rc = paging_mode_refcounts(d) - ? (get_page_from_pagenr(mfn, d) ? 0 : -EINVAL) + ? (get_page_from_mfn(_mfn(mfn), d) ? 0 : -EINVAL) : get_page_and_type_from_pagenr(mfn, PGT_root_page_table, d, 0, 1); switch ( rc ) { @@ -3924,7 +3924,7 @@ long do_mmu_update( xsm_checked = xsm_needed; } - if ( unlikely(!get_page_from_pagenr(mfn, pg_owner)) ) + if ( unlikely(!get_page_from_mfn(_mfn(mfn), pg_owner)) ) { gdprintk(XENLOG_WARNING, "Could not get page for mach->phys update\n"); @@ -4138,7 +4138,7 @@ static int create_grant_va_mapping( return GNTST_general_error; } - if ( !get_page_from_pagenr(gl1mfn, current->domain) ) + if ( !get_page_from_mfn(_mfn(gl1mfn), current->domain) ) { guest_unmap_l1e(pl1e); return GNTST_general_error; @@ -4188,7 +4188,7 @@ static int replace_grant_va_mapping( return GNTST_general_error; } - if ( !get_page_from_pagenr(gl1mfn, current->domain) ) + if ( !get_page_from_mfn(_mfn(gl1mfn), current->domain) ) { rc = GNTST_general_error; goto out; @@ -4357,7 +4357,7 @@ int replace_grant_host_mapping( return GNTST_general_error; } - if ( !get_page_from_pagenr(gl1mfn, current->domain) ) + if ( !get_page_from_mfn(_mfn(gl1mfn), current->domain) ) { guest_unmap_l1e(pl1e); return GNTST_general_error; @@ -4528,7 +4528,7 @@ static int __do_update_va_mapping( rc = -EINVAL; pl1e = guest_map_l1e(va, &gl1mfn); - if ( unlikely(!pl1e || !get_page_from_pagenr(gl1mfn, d)) ) + if ( unlikely(!pl1e || !get_page_from_mfn(_mfn(gl1mfn), d)) ) goto out; gl1pg = mfn_to_page(gl1mfn); @@ -4900,7 +4900,7 @@ int xenmem_add_to_physmap_one( put_gfn(d, gfn); return -ENOMEM; } - if ( !get_page_from_pagenr(idx, d) ) + if ( !get_page_from_mfn(_mfn(idx), d) ) break; mfn = idx; page = mfn_to_page(mfn); @@ -5440,7 +5440,7 @@ int ptwr_do_page_fault(struct vcpu *v, unsigned long addr, /* We are looking only for read-only mappings of p.t. pages. */ if ( ((l1e_get_flags(pte) & (_PAGE_PRESENT|_PAGE_RW)) != _PAGE_PRESENT) || rangeset_contains_singleton(mmio_ro_ranges, l1e_get_pfn(pte)) || - !get_page_from_pagenr(l1e_get_pfn(pte), d) ) + !get_page_from_mfn(_mfn(l1e_get_pfn(pte)), d) ) goto bail; page = l1e_get_page(pte);