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: 106728 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2507458qge; Fri, 30 Jun 2017 08:57:05 -0700 (PDT) X-Received: by 10.107.136.90 with SMTP id k87mr25493973iod.154.1498838225044; Fri, 30 Jun 2017 08:57:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498838225; cv=none; d=google.com; s=arc-20160816; b=WMVaFPnPw2Aym/dGxyeah2jMJn5HNNrV/0EWQYf47aJbxPMn+Nz+IeThE0g2fgubYZ nj+3MEND/gpBRoOiwVw46PngEDLBcV7A79Q+Z8l57d5ZPrAO9ku4A8A9AoieqjLWcbv6 WirI2B03JeLHFmugp3QNew0Cot7m7CBeX0osEfjraW7FQsuSg3S1mfG+B5jCcRS2qjfw QDMFGxV3gkVokhyxafT4ZpgIZ5Q9WAZI1ThN/GdYpdhfpBPGug+Ww6/C4+SpkAeA3nRf d3v3oUTdecIVsa7AjO+Kg2dm8UNbFYODHCUrZ1iYLx/Vu4zgdQddgpZwPtBV7nDHl/sU NtPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=4ZFZYQpxHl7UsfoWwaNKBtJotVS9e2g7FK/IR1+11GY=; b=vNfJ+KOg3bYp2ukMuKN7am7I9dOAGDSfMeuYRHfbsuf6o1isjcAM2TDm1RFHEfjeqE F42pwNHYR1QhGr4YKR3qQT0i+cGeX+ru8wxFz7piIXoKGj2PMc57pgumNQSAnM7T3fOc kl1MGP6y3OWuWjxSUHGEjKslxvkbfWB4QBetvkemy+OcF5SADdZS6lvBtu6H/xYI2IUf bR7ERaM7X9c3cZfhMGF+cEM0MGb97AxaXcqkNKYdN/tzZ4hSHxmjxccDdILV5mkd44Pu w5F6vS98nviS/kwFWH/td0JiRqc3n1bAONPTcYmbVTGXc9yg6SxOjqZUm4vr3ipBQ57I EJZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id f74si7518676iod.92.2017.06.30.08.57.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 08:57:05 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org 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" 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)) )