From patchwork Thu Jul 28 14:51:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 72984 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp894820qga; Thu, 28 Jul 2016 07:54:45 -0700 (PDT) X-Received: by 10.107.13.70 with SMTP id 67mr38838672ion.75.1469717685053; Thu, 28 Jul 2016 07:54:45 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id m66si13474027ioe.33.2016.07.28.07.54.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jul 2016 07:54:45 -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 1bSmfI-0002pT-T6; Thu, 28 Jul 2016 14:52:00 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSmfH-0002nx-R3 for xen-devel@lists.xen.org; Thu, 28 Jul 2016 14:51:59 +0000 Received: from [85.158.139.211] by server-4.bemta-5.messagelabs.com id 12/B1-12285-F0C1A975; Thu, 28 Jul 2016 14:51:59 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTZdPZla 4QdcvTYslHxezODB6HN39mymAMYo1My8pvyKBNWPrrkPsBRPEKr581W1gvMbfxcjFISSwiVHi 1rqTbBDOaUaJ/RfvM3cxcnKwCWhK3Pn8iQnEFhGQlrj2+TIjSBGzQDujxNr+XrAiYQF/icdN5 xhBbBYBVYnDR/aydjFycPAKOEu8fMIBEpYQkJM4eWwyWJhTwEXidbcQSFgIqGL6zKWMExi5Fz AyrGLUKE4tKkst0jWy0EsqykzPKMlNzMzRNTQw1ctNLS5OTE/NSUwq1kvOz93ECPRuPQMD4w7 GvlV+hxglOZiURHnDQmeGC/El5adUZiQWZ8QXleakFh9ilOHgUJLgvSU1K1xIsCg1PbUiLTMH GGYwaQkOHiURXjlpoDRvcUFibnFmOkTqFKOilDgvL0hCACSRUZoH1wYL7UuMslLCvIwMDAxCP AWpRbmZJajyrxjFORiVhHkNQKbwZOaVwE1/BbSYCWhxcewMkMUliQgpqQZGu7cXmSLf/g0obH VqXPkv8diWE5ufBrBL7E18xnPw4wX/xb8a/tz9z9gjOsNqh+bOJ4e2Tf4YKzn9Z8DahI/dRlM cg0+/Pj4lKHG5ip5T6j63T0VFUmzXVnMd0dAL3jJph+764O9bp7J4R+dOsuKSqlzc907ahnl3 JnvN/iPKf7bIKKca3ZCMV2Ipzkg01GIuKk4EAOzZ90hoAgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-9.tower-206.messagelabs.com!1469717518!51933076!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 11323 invoked from network); 28 Jul 2016 14:51:58 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-9.tower-206.messagelabs.com with SMTP; 28 Jul 2016 14:51:58 -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 18CBDBA6; Thu, 28 Jul 2016 07:53:15 -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 D71CA3F21A; Thu, 28 Jul 2016 07:51:56 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 28 Jul 2016 15:51:27 +0100 Message-Id: <1469717505-8026-5-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1469717505-8026-1-git-send-email-julien.grall@arm.com> References: <1469717505-8026-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] [RFC 04/22] xen/arm: p2m: Use typesafe gfn in p2m_mem_access_radix_set 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" p2m_mem_access_radix_set is expecting a gfn in a parameter. Rename the parameter 'pfn' to 'gfn' to match its content and use the typesafe gfn to avoid possible misusage. Also rename the parameter to gfn to match its content. Signed-off-by: Julien Grall --- xen/arch/arm/p2m.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index ff82f12..aecdd1e 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -542,7 +542,7 @@ static int __p2m_get_mem_access(struct domain *d, gfn_t gfn, return 0; } -static int p2m_mem_access_radix_set(struct p2m_domain *p2m, unsigned long pfn, +static int p2m_mem_access_radix_set(struct p2m_domain *p2m, gfn_t gfn, p2m_access_t a) { int rc; @@ -552,18 +552,18 @@ static int p2m_mem_access_radix_set(struct p2m_domain *p2m, unsigned long pfn, if ( p2m_access_rwx == a ) { - radix_tree_delete(&p2m->mem_access_settings, pfn); + radix_tree_delete(&p2m->mem_access_settings, gfn_x(gfn)); return 0; } - rc = radix_tree_insert(&p2m->mem_access_settings, pfn, + rc = radix_tree_insert(&p2m->mem_access_settings, gfn_x(gfn), radix_tree_int_to_ptr(a)); if ( rc == -EEXIST ) { /* If a setting already exists, change it to the new one */ radix_tree_replace_slot( radix_tree_lookup_slot( - &p2m->mem_access_settings, pfn), + &p2m->mem_access_settings, gfn_x(gfn)), radix_tree_int_to_ptr(a)); rc = 0; } @@ -707,7 +707,7 @@ static int apply_one_level(struct domain *d, */ (level == 3 || (!p2m_table(orig_pte) && !p2m->mem_access_enabled)) ) { - rc = p2m_mem_access_radix_set(p2m, paddr_to_pfn(*addr), a); + rc = p2m_mem_access_radix_set(p2m, _gfn(paddr_to_pfn(*addr)), a); if ( rc < 0 ) return rc; @@ -825,7 +825,8 @@ static int apply_one_level(struct domain *d, *flush = true; p2m_remove_pte(entry, p2m->clean_pte); - p2m_mem_access_radix_set(p2m, paddr_to_pfn(*addr), p2m_access_rwx); + p2m_mem_access_radix_set(p2m, _gfn(paddr_to_pfn(*addr)), + p2m_access_rwx); *addr += level_size; *maddr += level_size; @@ -896,7 +897,8 @@ static int apply_one_level(struct domain *d, if ( p2m_valid(pte) ) { - rc = p2m_mem_access_radix_set(p2m, paddr_to_pfn(*addr), a); + rc = p2m_mem_access_radix_set(p2m, _gfn(paddr_to_pfn(*addr)), + a); if ( rc < 0 ) return rc;