From patchwork Thu Sep 15 11:28:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 76295 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp2387463qgf; Thu, 15 Sep 2016 04:31:11 -0700 (PDT) X-Received: by 10.107.144.86 with SMTP id s83mr18718974iod.97.1473939071402; Thu, 15 Sep 2016 04:31:11 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id x11si3215363itb.118.2016.09.15.04.31.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Sep 2016 04:31:11 -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 1bkUqd-0004bf-RU; Thu, 15 Sep 2016 11:28:55 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bkUqc-0004bC-JE for xen-devel@lists.xen.org; Thu, 15 Sep 2016 11:28:54 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id B6/C5-05127-5F58AD75; Thu, 15 Sep 2016 11:28:53 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsVysyfVTfdr661 wgyd7BC2WfFzM4sDocXT3b6YAxijWzLyk/IoE1oy9B6+zFbSKVyy/M42pgXGTQBcjF4eQwCZG iZmHdjFCOKcZJb6v2MPexcjJwSagKXHn8ycmEFtEQFri2ufLYEXMAu2MEmv7e5lBEsICsRJzt t5nA7FZBFQlfiy7A9bAK+AicX/aOzBbQkBO4uSxyaxdjBwcnAKuEkuei4KEhYBKjp3YyTaBkX sBI8MqRo3i1KKy1CJdI1O9pKLM9IyS3MTMHF1DA1O93NTi4sT01JzEpGK95PzcTYxAD9czMDD uYNzV7neIUZKDSUmU1y3tVrgQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCV6rFqCcYFFqempFWmYO MNRg0hIcPEoivOwgad7igsTc4sx0iNQpRkUpcV4PkIQASCKjNA+uDRbelxhlpYR5GRkYGIR4C lKLcjNLUOVfMYpzMCoJ83aBTOHJzCuBm/4KaDET0OIta66DLC5JREhJNTCK2eku0kxcPoGTl7 U9Nt3g0M2kOdqXzRtmbDmxhqNn4V2BM4953s9dcnDlM7O+CbqubftMb/J4r0mQrCz/nt9nIpy V+PeIYEmugJj5/G3l+YXyWSJHLvpl/ElzXea87+7ErNvpykJsB1fVRakxCxVPL9JZ5sRpdEB0 ScGTmRa7wo0UPOTvSyqxFGckGmoxFxUnAgB7USQ7agIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-5.tower-206.messagelabs.com!1473938932!58086168!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.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54176 invoked from network); 15 Sep 2016 11:28:53 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-5.tower-206.messagelabs.com with SMTP; 15 Sep 2016 11:28:53 -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 79B2B23F; Thu, 15 Sep 2016 04:28:52 -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 775453F251; Thu, 15 Sep 2016 04:28:51 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 15 Sep 2016 12:28:20 +0100 Message-Id: <1473938919-31976-5-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1473938919-31976-1-git-send-email-julien.grall@arm.com> References: <1473938919-31976-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] [for-4.8][PATCH v2 04/23] 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 Reviewed-by: Stefano Stabellini --- Changes in v2: - Add Stefano's reviewed-by --- 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 5a1d45b..950a607 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -550,7 +550,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; @@ -560,18 +560,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; } @@ -715,7 +715,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; @@ -833,7 +833,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; @@ -904,7 +905,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;