From patchwork Tue Jun 13 16:13: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: 105382 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp486300qgd; Tue, 13 Jun 2017 09:15:10 -0700 (PDT) X-Received: by 10.107.164.219 with SMTP id d88mr827109ioj.157.1497370509947; Tue, 13 Jun 2017 09:15:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497370509; cv=none; d=google.com; s=arc-20160816; b=f1BRoAbob7dlZIRIXT1EgI4vh6tpodZDir190804ME/sQ39jr2z88kmsiNEHtrUwDZ meBjhDpmG00bdcf4o7yGSemNAiVKrb1WAqYhW+q0kAnWgm65wd+5uu3mr6tJD9VbONHx 6vzZgD6jGZMWUXDoFapJA2gBhxs0LI96ldiFN/RWoeQoSsqCJG00176FQcZu9v2bFX4l ETW4udSCr5eZ0067fiGLeZc7uCpmwm5JwisqcUDepwB1PcubEnIDGcVNWicfLFJvv8sh H/MZT9ADHWJuwFs92qEABHnxSAr/gO/y04qpr7UO5Fyr9o5p2huv3uSCBAInNfR9EATN jnfQ== 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=ENAXNsPqBtFRLBZNrj+WWgFgWOj8D/GyqG9avc3j7EQ=; b=CzEqkswB6yjvBWgUobLy5bS339XRUdmnnmfkvJ6w4cuor7o8L+WFRywoYvQ4jPGxKm lGclXMcv0z7BjAUbo5kZqz61KtM958WcTLB+T7G5sFyvZSsNHeiPgcFqUL9bZcPmSh4O xcEngHuO6j3TsfgK+crVAgW9lkU8kUSa1p+noMV6mMzkBJAbqbRAx+EMWSqLPWmSchwF sMm4rHWlASayNS6bUDNunJwKuXuZQ+ARcyuCqoTgRjF1o5udnZs57uvKpqmE7kWrDhCB v9qbXnQrUtHpv/u+Io7wOHS/ZfuDKXM/7O4xC2v4h3Zh/HjXuF/N3yCKVJtkpFYm/RrZ I8uw== 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 e70si405186ioj.189.2017.06.13.09.15.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 09:15:09 -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 1dKoS2-0008SF-O6; Tue, 13 Jun 2017 16:13:54 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dKoS1-0008Os-64 for xen-devel@lists.xen.org; Tue, 13 Jun 2017 16:13:53 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id 3E/53-03696-04F00495; Tue, 13 Jun 2017 16:13:52 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCLMWRWlGSWpSXmKPExsVysyfVTdeB3yH SYPsrVoslHxezODB6HN39mymAMYo1My8pvyKBNWPK16msBQ/EK3btNmhg/CPUxcjFISSwmVHi +Is2xi5GTiDnNKNE15JSEJtNQFPizudPTCC2iIC0xLXPl8FqmAUiJJoW7AWKc3AIC0RKbF9cD hJmEVCV2PPhETOIzStgJbH2zA02EFtCQF5iV9tFVhCbEyh+6XkT1CpLiebd65kmMHIvYGRYxa hRnFpUllqka2yol1SUmZ5RkpuYmaNraGCml5taXJyYnpqTmFSsl5yfu4kR6FsGINjB2LQo8BC jJAeTkijvlis2kUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeHfwOkQKCRalpqdWpGXmAIMMJi3B waMkwnufBSjNW1yQmFucmQ6ROsWoKCXO+wekTwAkkVGaB9cGC+xLjLJSwryMQIcI8RSkFuVml qDKv2IU52BUEuZt4QGawpOZVwI3/RXQYiagxddBbuYtLklESEk1MGaFXnm497qjVtXGr5vmMg ZbzKn89stqx68lvbG3c3fote5lmCrzNlF9LufBW8G23+aVJV421hJLl1u12qbS4AbnZMP76zd JvE7osusWtlXcecVw19YfWQcsLXR6lnmIxEyuijsyqftokrv8v2xf6+KSx4avS17bS017e3S1 hEWsh+eSjQ8DpZVYijMSDbWYi4oTAXcAt2FnAgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1497370431!54632337!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.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33967 invoked from network); 13 Jun 2017 16:13:51 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-15.tower-27.messagelabs.com with SMTP; 13 Jun 2017 16:13:51 -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 636FC15A2; Tue, 13 Jun 2017 09:13:51 -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 9C95B3F557; Tue, 13 Jun 2017 09:13:50 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 13 Jun 2017 17:13:18 +0100 Message-Id: <20170613161323.25196-20-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613161323.25196-1-julien.grall@arm.com> References: <20170613161323.25196-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, punit.agrawal@arm.com Subject: [Xen-devel] [PATCH 19/24] 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 --- 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 266d1c3bd6..6c1ac70044 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, mfn_x(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); /* @@ -1443,7 +1449,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)) )