From patchwork Wed Jul 20 16:10:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 72445 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp66475qga; Wed, 20 Jul 2016 09:14:15 -0700 (PDT) X-Received: by 10.107.134.93 with SMTP id i90mr46176800iod.153.1469031250290; Wed, 20 Jul 2016 09:14:10 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id n21si2535493ita.71.2016.07.20.09.14.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jul 2016 09:14:10 -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 1bPu6P-0008Hn-3R; Wed, 20 Jul 2016 16:12:05 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bPu6O-0008Fl-3J for xen-devel@lists.xen.org; Wed, 20 Jul 2016 16:12:04 +0000 Received: from [193.109.254.147] by server-5.bemta-14.messagelabs.com id 15/CD-28701-4B2AF875; Wed, 20 Jul 2016 16:11:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsVysyfVTXfzov5 wg9V3pS2WfFzM4sDocXT3b6YAxijWzLyk/IoE1owz51+xFuwQrpjRf4W5gXEKXxcjF4eQwCZG icNTrrNCOKcZJS48PwTkcHKwCWhK3Pn8iQnEFhGQlrj2+TIjSBGzQDujxPKN/1i6GDk4hAV8J S7cAKthEVCVWH52CRuIzSvgInHh6imwORICchInj00GszkFXCXOn/zJCGILAdVsevuNeQIj9w JGhlWMGsWpRWWpRbqGlnpJRZnpGSW5iZk5uoaGJnq5qcXFiempOYlJxXrJ+bmbGIEermdgYNz B+OuY3yFGSQ4mJVFeVdHecCG+pPyUyozE4oz4otKc1OJDjDIcHEoSvFIL+8OFBItS01Mr0jJz gKEGk5bg4FES4eUCSfMWFyTmFmemQ6ROMSpKifNuA0kIgCQySvPg2mDhfYlRVkqYl5GBgUGIp yC1KDezBFX+FaM4B6OSMO9hkCk8mXklcNNfAS1mAlo8RwBscUkiQkqqgbFA0WmvYaXWrdshHA 9WNb9tM7A20ypaLPLceefqiK1vbnD/sHYWF7VPX/lx1/fA9Q7TY5kD5tYtLdBOvyWcJf784au HRp+KdixtXTxB3ULg+qf38Tt0kvYHLzg9W5G7yJ/5bub5W+0yictYdIs62/7xZXr/nDhb+8fj HQ/TTx1MKnjBdmWpyl0lluKMREMt5qLiRABwXXyfagIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1469031090!2451284!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 3190 invoked from network); 20 Jul 2016 16:11:31 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-15.tower-27.messagelabs.com with SMTP; 20 Jul 2016 16:11:31 -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 49BCBBB1; Wed, 20 Jul 2016 09:12:41 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.218.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9DB863F387; Wed, 20 Jul 2016 09:11:29 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 20 Jul 2016 17:10:48 +0100 Message-Id: <1469031064-23344-7-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1469031064-23344-1-git-send-email-julien.grall@arm.com> References: <1469031064-23344-1-git-send-email-julien.grall@arm.com> Cc: proskurin@sec.in.tum.de, Julien Grall , sstabellini@kernel.org, wei.chen@linaro.org, steve.capper@arm.com Subject: [Xen-devel] [PATCH 06/22] xen/arm: p2m: Use the typesafe MFN in mfn_to_p2m_entry 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" Signed-off-by: Julien Grall --- xen/arch/arm/p2m.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index d82349c..99be9be 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -324,7 +324,7 @@ static void p2m_set_permission(lpae_t *e, p2m_type_t t, p2m_access_t a) } } -static lpae_t mfn_to_p2m_entry(unsigned long mfn, unsigned int mattr, +static lpae_t mfn_to_p2m_entry(mfn_t mfn, unsigned int mattr, p2m_type_t t, p2m_access_t a) { /* @@ -358,9 +358,9 @@ static lpae_t mfn_to_p2m_entry(unsigned long mfn, unsigned int mattr, p2m_set_permission(&e, t, a); - ASSERT(!(pfn_to_paddr(mfn) & ~PADDR_MASK)); + ASSERT(!(pfn_to_paddr(mfn_x(mfn)) & ~PADDR_MASK)); - e.p2m.base = mfn; + e.p2m.base = mfn_x(mfn); return e; } @@ -411,7 +411,7 @@ static int p2m_create_table(struct domain *d, lpae_t *entry, if ( splitting ) { p2m_type_t t = entry->p2m.type; - unsigned long base_pfn = entry->p2m.base; + mfn_t mfn = _mfn(entry->p2m.base); int i; /* @@ -420,8 +420,9 @@ static int p2m_create_table(struct domain *d, lpae_t *entry, */ for ( i=0 ; i < LPAE_ENTRIES; i++ ) { - pte = mfn_to_p2m_entry(base_pfn + (i<<(level_shift-LPAE_SHIFT)), - MATTR_MEM, t, p2m->default_access); + pte = mfn_to_p2m_entry(mfn, MATTR_MEM, t, p2m->default_access); + + mfn = mfn_add(mfn, 1UL << (level_shift - LPAE_SHIFT)); /* * First and second level super pages set p2m.table = 0, but @@ -443,7 +444,7 @@ static int p2m_create_table(struct domain *d, lpae_t *entry, unmap_domain_page(p); - pte = mfn_to_p2m_entry(page_to_mfn(page), MATTR_MEM, p2m_invalid, + pte = mfn_to_p2m_entry(_mfn(page_to_mfn(page)), MATTR_MEM, p2m_invalid, p2m->default_access); p2m_write_pte(entry, pte, flush_cache); @@ -693,7 +694,7 @@ static int apply_one_level(struct domain *d, return rc; /* New mapping is superpage aligned, make it */ - pte = mfn_to_p2m_entry(*maddr >> PAGE_SHIFT, mattr, t, a); + pte = mfn_to_p2m_entry(_mfn(*maddr >> PAGE_SHIFT), mattr, t, a); if ( level < 3 ) pte.p2m.table = 0; /* Superpage entry */