From patchwork Wed Jul 20 16:10:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 72449 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp66547qga; Wed, 20 Jul 2016 09:14:24 -0700 (PDT) X-Received: by 10.107.16.77 with SMTP id y74mr99891ioi.161.1469031257777; Wed, 20 Jul 2016 09:14:17 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id j8si17351257ita.29.2016.07.20.09.14.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jul 2016 09:14:17 -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 1bPu5t-0007Xl-30; Wed, 20 Jul 2016 16:11:33 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bPu5r-0007WM-At for xen-devel@lists.xen.org; Wed, 20 Jul 2016 16:11:31 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 8C/34-21406-2B2AF875; Wed, 20 Jul 2016 16:11:30 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTXfTov5 wg92rWC2WfFzM4sDocXT3b6YAxijWzLyk/IoE1oxFR9YzFqzlqjhz9xVLA+Mcji5GLg4hgU2M EnvnbmKBcE4zSrw7O5Wti5GTg01AU+LO509MILaIgLTEtc+XGUGKmAXaGSWWb/wH1MHBISxgJ 3HkFStIDYuAqsTl5v+MIDavgItE299NYL0SAnISJ49NBqvhFHCVOH/yJ1iNEFDNprffmCcwci 9gZFjFqF6cWlSWWqRrqJdUlJmeUZKbmJmja2hgppebWlycmJ6ak5hUrJecn7uJEehfBiDYwbj zudMhRkkOJiVRXlXR3nAhvqT8lMqMxOKM+KLSnNTiQ4wyHBxKEryLF/aHCwkWpaanVqRl5gAD DSYtwcGjJMJ7HCTNW1yQmFucmQ6ROsWoKCXOuw0kIQCSyCjNg2uDBfclRlkpYV5GoEOEeApSi 3IzS1DlXzGKczAqCfO2gkzhycwrgZv+CmgxE9DiOQJgi0sSEVJSDYzOb58yPjXYKDLp4q6jU2 QF1nJqLKhJMeI7/lLjw4k8vxjdOVoN0kwqRzzfHj76/E5b2Z6T7QcPfnXRcY45LLdsb88F2Vv XL//0kSwpvH/pvaFh07mHWtWVV7/+uNuewfttiktl7qIKv5+vt1UV6C/42vpKmVW7/QBv9mm9 5+qiP+qs/UM/hz5SYinOSDTUYi4qTgQAwNxMcWkCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1469031089!24841993!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 4502 invoked from network); 20 Jul 2016 16:11:29 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-5.tower-21.messagelabs.com with SMTP; 20 Jul 2016 16:11:29 -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 EE209959; Wed, 20 Jul 2016 09:12:39 -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 4D8353F387; Wed, 20 Jul 2016 09:11:28 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 20 Jul 2016 17:10:47 +0100 Message-Id: <1469031064-23344-6-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 05/22] xen/arm: p2m: Clean-up 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" The physical address is computed from the machine frame number, so checking if the physical address is page aligned is pointless. Furthermore, directly assigned the MFN to the corresponding field in the entry rather than converting to a physical address and orring the value. It will avoid to rely on the field position and make the code clearer. Signed-off-by: Julien Grall --- xen/arch/arm/p2m.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 79095f1..d82349c 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -327,7 +327,6 @@ 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, p2m_type_t t, p2m_access_t a) { - paddr_t pa = ((paddr_t) mfn) << PAGE_SHIFT; /* * sh, xn and write bit will be defined in the following switches * based on mattr and t. @@ -359,10 +358,9 @@ static lpae_t mfn_to_p2m_entry(unsigned long mfn, unsigned int mattr, p2m_set_permission(&e, t, a); - ASSERT(!(pa & ~PAGE_MASK)); - ASSERT(!(pa & ~PADDR_MASK)); + ASSERT(!(pfn_to_paddr(mfn) & ~PADDR_MASK)); - e.bits |= pa; + e.p2m.base = mfn; return e; }