From patchwork Thu Jul 28 14:20:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 72953 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp880131qga; Thu, 28 Jul 2016 07:23:47 -0700 (PDT) X-Received: by 10.36.82.81 with SMTP id d78mr38296052itb.65.1469715827153; Thu, 28 Jul 2016 07:23:47 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id u17si28797164itc.119.2016.07.28.07.23.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jul 2016 07:23:47 -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 1bSmAp-00077a-9m; Thu, 28 Jul 2016 14:20:31 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSmAn-000778-HZ for xen-devel@lists.xen.org; Thu, 28 Jul 2016 14:20:29 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id EE/43-09160-CA41A975; Thu, 28 Jul 2016 14:20:28 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRWlGSWpSXmKPExsVysyfVTXeNyKx wg8nt0hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bmLddZC+4LV0zatJKpgXEfXxcjF4eQwCZG ifMTTjNCOKcZJQ7OngHkcHKwCWhK3Pn8iQnEFhGQlrj2+TJYEbNAO6PE2v5eZpCEsECAxOfGr 6xdjBwcLAKqEsu+VIGYvALOEuu++4JUSAjISZw8NpkVxOYUcJG41/YdzBYCKjl9dzv7BEbuBY wMqxg1ilOLylKLdA0N9JKKMtMzSnITM3OAPGO93NTi4sT01JzEpGK95PzcTYxA/9YzMDDuYNz W5XyIUZKDSUmUNyx0ZrgQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCd5TQrPChQSLUtNTK9Iyc4CB BpOW4OBREuF9BpLmLS5IzC3OTIdInWJUlBLn/QWSEABJZJTmwbXBgvsSo6yUMC8jAwODEE9Ba lFuZgmq/CtGcQ5GJWFeA2GgKTyZeSVw018BLWYCWlwcOwNkcUkiQkqqgXFho+ri2hvvzI5Hrx T5ea9E0cIq3OjFukUTU2pO8JdyTViwgm/z1safYWdrbwT7zbqeeThm1232op65j4uvfp5esD3 h2verjce4qz4JMWx7sOmxZ9tJieozzrktMxyevinx/PAlctpJP/WqVRZ3S3o6ZjvXlduvWbln vt9qHb1PeVnLeRQLxKOVWIozEg21mIuKEwHjTG1raQIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-6.tower-31.messagelabs.com!1469715627!26635105!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 32626 invoked from network); 28 Jul 2016 14:20:28 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-6.tower-31.messagelabs.com with SMTP; 28 Jul 2016 14:20:28 -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 C0A6530C; Thu, 28 Jul 2016 07:21:44 -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 90DB83F21A; Thu, 28 Jul 2016 07:20:26 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 28 Jul 2016 15:20:06 +0100 Message-Id: <1469715620-4670-2-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1469715620-4670-1-git-send-email-julien.grall@arm.com> References: <1469715620-4670-1-git-send-email-julien.grall@arm.com> Cc: proskurin@sec.in.tum.de, Julien Grall , sstabellini@kernel.org, steve.capper@arm.com, wei.chen@linaro.org Subject: [Xen-devel] [PATCH v2 01/15] 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 Reviewed-by: Stefano Stabellini --- Changes in v2: - Compute the mfn at every loop rather than incrementing - Add Stefano's reviewed-by --- xen/arch/arm/p2m.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index d82349c..851b110 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,7 +420,7 @@ 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)), + pte = mfn_to_p2m_entry(mfn_add(mfn, i << (level_shift - LPAE_SHIFT)), MATTR_MEM, t, p2m->default_access); /* @@ -443,7 +443,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 +693,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 */