From patchwork Fri Jun 30 15:54:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9819925 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 CE4E2602B1 for ; Fri, 30 Jun 2017 15:57:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF1DA285C8 for ; Fri, 30 Jun 2017 15:57:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3A60286B0; Fri, 30 Jun 2017 15:57: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=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM 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 5C73D285C8 for ; Fri, 30 Jun 2017 15:57: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 1dQyFn-0000P3-8I; Fri, 30 Jun 2017 15:54:43 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQyFl-0000NS-QU for xen-devel@lists.xen.org; Fri, 30 Jun 2017 15:54:41 +0000 Received: from [85.158.139.211] by server-15.bemta-5.messagelabs.com id 0E/82-01736-14476595; Fri, 30 Jun 2017 15:54:41 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTdehJCz SYOVHBYslHxezODB6HN39mymAMYo1My8pvyKBNeNhzxH2ggbpiq3dq9kaGPeIdjFycQgJbGKU uLBjGROEc5pRYk/bTNYuRk4ONgFNiTufPzGB2CIC0hLXPl9mBLGZBRwk3ny8xwJiCwvESJw8t IgZxGYRUJV413UVrIZXwFKi+/QCsBoJAXmJXW0XwWZyClhJHP/3AGymEFDN61lXWSYwci9gZF jFqFGcWlSWWqRrbKCXVJSZnlGSm5iZo2toYKqXm1pcnJiempOYVKyXnJ+7iRHo4XoGBsYdjBN W+R1ilORgUhLlXXktNFKILyk/pTIjsTgjvqg0J7X4EKMMB4eSBO+84rBIIcGi1PTUirTMHGCo waQlOHiURHhlg4DSvMUFibnFmekQqVOMuhyvJvz/xiTEkpeflyolzhsCMkMApCijNA9uBCzsL zHKSgnzMjIwMAjxFKQW5WaWoMq/YhTnYFQS5nUGmcKTmVcCt+kV0BFMQEcIzwgBOaIkESEl1c Co4yez+ULvaUXLuuDup8mLHiqfn8PCaBO654HZlYXWmoXyd6bXaz2qXaV0eJZR6Upfbr0FgtY ucWdWTeO9V/yF+6rHuwfxYXw+jRObFwvXVU7m2Mb2Z16hVGJwgMC5Qrtqvaxqb0HpYJ9barU8 kdu6Iw8Eml83mnpvBVfUn+9caYfO6HL2FCmxFGckGmoxFxUnAgDgtwHvdgIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-12.tower-206.messagelabs.com!1498838080!64583846!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 44687 invoked from network); 30 Jun 2017 15:54:40 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-206.messagelabs.com with SMTP; 30 Jun 2017 15:54:40 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ABE0980D; Fri, 30 Jun 2017 08:54:39 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 15B733F41F; Fri, 30 Jun 2017 08:54:38 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 30 Jun 2017 16:54:18 +0100 Message-Id: <20170630155431.23824-4-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170630155431.23824-1-julien.grall@arm.com> References: <20170630155431.23824-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v3 03/16] xen/arm: p2m: Redefine mfn_to_page and page_to_mfn to use typesafe 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The file xen/arch/arm/p2m.c is using typesafe MFN in most of the place. This requires caller to mfn_to_page and page_to_mfn to use _mfn/mfn_x. To avoid extra _mfn/mfn_x, re-define mfn_to_page and page_to_mfn within xen/arch/arm/p2m.c to handle typesafe MFN. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- The idea behind redefining locally mfn_to_page and page_to_mfn is splitting the introduction of typesafe MFN in smaller series and between multiple people. We know the file is typesafe ready and if we decide to make the main helper typesafe, we would just need to drop the definition at the top of the file. Changes in v3: - Use __page_to_mfn(...) rather than mfn_x(page_to_mfn(...)) --- xen/arch/arm/p2m.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 05eb584e89..3e20a1ec82 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -38,6 +38,12 @@ static unsigned int __read_mostly max_vmid = MAX_VMID_8_BIT; #define P2M_ROOT_PAGES (1<domain_id, addr); printk("P2M @ %p mfn:0x%lx\n", - p2m->root, page_to_mfn(p2m->root)); + p2m->root, __page_to_mfn(p2m->root)); dump_pt_walk(page_to_maddr(p2m->root), addr, P2M_ROOT_LEVEL, P2M_ROOT_PAGES); @@ -591,7 +597,7 @@ static int p2m_create_table(struct p2m_domain *p2m, lpae_t *entry) * The access value does not matter because the hardware will ignore * the permission fields for table entry. */ - pte = mfn_to_p2m_entry(_mfn(page_to_mfn(page)), p2m_invalid, + pte = mfn_to_p2m_entry(page_to_mfn(page), p2m_invalid, p2m->default_access); p2m_write_pte(entry, pte, p2m->clean_pte); @@ -650,9 +656,9 @@ static void p2m_put_l3_page(const lpae_t pte) */ if ( p2m_is_foreign(pte.p2m.type) ) { - unsigned long mfn = pte.p2m.base; + mfn_t mfn = _mfn(pte.p2m.base); - ASSERT(mfn_valid(_mfn(mfn))); + ASSERT(mfn_valid(mfn)); put_page(mfn_to_page(mfn)); } } @@ -702,7 +708,7 @@ static void p2m_free_entry(struct p2m_domain *p2m, mfn = _mfn(entry.p2m.base); ASSERT(mfn_valid(mfn)); - pg = mfn_to_page(mfn_x(mfn)); + pg = mfn_to_page(mfn); page_list_del(pg, &p2m->pages); free_domheap_page(pg); @@ -780,7 +786,7 @@ static bool p2m_split_superpage(struct p2m_domain *p2m, lpae_t *entry, unmap_domain_page(table); - pte = mfn_to_p2m_entry(_mfn(page_to_mfn(page)), p2m_invalid, + pte = mfn_to_p2m_entry(page_to_mfn(page), p2m_invalid, p2m->default_access); /* @@ -1442,7 +1448,7 @@ struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va, if ( !mfn_valid(maddr_to_mfn(maddr)) ) goto err; - page = mfn_to_page(mfn_x(maddr_to_mfn(maddr))); + page = mfn_to_page(maddr_to_mfn(maddr)); ASSERT(page); if ( unlikely(!get_page(page, d)) )