From patchwork Mon Jun 19 16:57:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 105888 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp942378obh; Mon, 19 Jun 2017 09:59:45 -0700 (PDT) X-Received: by 10.36.237.206 with SMTP id r197mr22891158ith.52.1497891585573; Mon, 19 Jun 2017 09:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497891585; cv=none; d=google.com; s=arc-20160816; b=PBMMLtNmi0uFMeVl6+10NQuZaGKJWp8TYPH3oQIbH+JFDNWmMxCulWogOdLre3aT4i DIjo3q/A+P8jRA4A+RWwBp0x5fUJnEuOw0OYVol7bM6epKbp9UeqasQntiRhmIMC9YfB ah224DTk31P0+0p6i51DZjwIG0rk5Muz4/uhWAXs2d78/Dd0y9UUVztt3p80oNZHHdV1 QzB2TX/5o6KboxPU2meq0TemNoxKxK8W3sXMLcRGwWOHNCEsbuqr/I6qhkXc/kowsk+W YLiKLXi0U0ibKGqaFmZ7STMdmJwU1g99VAD1MwTkoTxI9/dt4ygu8Kr/D2taI7DxmEPQ p7Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=k4Q2ls4cfbOH9o1GcNaFnwWF6Rz1/4NPFAY+rO2ApHs=; b=l6bTGBZfQ3wbqZENsU3SZXGtJmOX2aJBKeEhMZrAJPpYgCKncVMGETlKxR81rcUo3c kjhPTR9HCKKVXELPRWUmSEbRLBT34GqRHozgOfMc3PrzgSOR2cB1IKFmmRDixJDCpvd/ TZdksS1jfEtpmdy9q9yxd1nU70nSYY4rwjSMORrTXuIHk+v+PaGyUqdKQAR2wS9OK4km oHAMI6NzbS+4zILhlxZcLA9s99XapetFkHFal+s47KunsPgECe6utZOn5/jOh+p1lvLo 3GEhsICFTKue7nn3zQQukC89532GsjZpSvjQdxO2UzipZeywdxsw5aMlyOZPzbudM1KL K/KA== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id q73si11286894itb.97.2017.06.19.09.59.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jun 2017 09:59: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 1dN00G-0003uA-6f; Mon, 19 Jun 2017 16:58:16 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dN00F-0003qY-1a for xen-devel@lists.xen.org; Mon, 19 Jun 2017 16:58:15 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id 02/D7-03587-6A208495; Mon, 19 Jun 2017 16:58:14 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRWlGSWpSXmKPExsVysyfVTXcpk0e kQdNDS4slHxezODB6HN39mymAMYo1My8pvyKBNWNO61LGgmO6Fc+eezUw9ih3MXJxCAlsZpR4 /nA7M4RzmlHi8dEZLF2MnBxsApoSdz5/YgKxRQSkJa59vszYxcjBwSwQJfF/GidIWFggVeJP2 zQ2EJtFQFXixZT1YDavgJXEk4ZvjCC2hIC8xK62i6wgNidQ/Pv8a2BxIQFLieNPbrFNYORewM iwilGjOLWoLLVI19hQL6koMz2jJDcxM0fX0MBMLze1uDgxPTUnMalYLzk/dxMj0LsMQLCDsWl R4CFGSQ4mJVHeWf/dI4X4kvJTKjMSizPii0pzUosPMcpwcChJ8KoyekQKCRalpqdWpGXmAMMM Ji3BwaMkwlvzG6iVt7ggMbc4Mx0idYpRUUqcVwGkTwAkkVGaB9cGC+1LjLJSwryMQIcI8RSkF uVmlqDKv2IU52BUEubtArmMJzOvBG76K6DFTECLmc+4gCwuSURISTUwSjDyety8ZlW1sUXr+3 2N9ptJy21fStjPO9jzaVJEZVhAxu7vJoVH6qr590/tXhFm81Xk0mnrWJ7oKbMjnwVn+7PfNo4 VnBqusrx133pTjvvvVc7abp10/qXnzzWlbi6uepeElHNXn29YzPHgiEL9B4MM1yAZxZlm8dz3 I8+/YfnI21nFvUhDiaU4I9FQi7moOBEAnhov3mgCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1497891493!48857678!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 17501 invoked from network); 19 Jun 2017 16:58:13 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-2.tower-27.messagelabs.com with SMTP; 19 Jun 2017 16:58:13 -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 1E03C15BE; Mon, 19 Jun 2017 09:58:13 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 47BA03F41F; Mon, 19 Jun 2017 09:58:12 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 19 Jun 2017 17:57:49 +0100 Message-Id: <20170619165753.25049-13-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170619165753.25049-1-julien.grall@arm.com> References: <20170619165753.25049-1-julien.grall@arm.com> Cc: proskurin@sec.in.tum.de, Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v2 12/16] xen/arm: p2m: Rename p2m_valid, p2m_table, p2m_mapping and p2m_is_superpage 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 helpers p2m_valid, p2m_table, p2m_mapping and p2m_is_superpage are not specific to the stage-2 translation tables. They can also work on any LPAE translation tables. So rename then to lpae_* and use pte.walk to look for the value of the field. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Cc: proskurin@sec.in.tum.de Changes in v2: - Patch added --- xen/arch/arm/p2m.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 6c1ac70044..1136d837fb 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -52,27 +52,27 @@ static const paddr_t level_masks[] = static const uint8_t level_orders[] = { ZEROETH_ORDER, FIRST_ORDER, SECOND_ORDER, THIRD_ORDER }; -static inline bool_t p2m_valid(lpae_t pte) +static inline bool_t lpae_valid(lpae_t pte) { - return pte.p2m.valid; + return pte.walk.valid; } /* * These two can only be used on L0..L2 ptes because L3 mappings set * the table bit and therefore these would return the opposite to what * you would expect. */ -static inline bool_t p2m_table(lpae_t pte) +static inline bool_t lpae_table(lpae_t pte) { - return p2m_valid(pte) && pte.p2m.table; + return lpae_valid(pte) && pte.walk.table; } -static inline bool_t p2m_mapping(lpae_t pte) +static inline bool_t lpae_mapping(lpae_t pte) { - return p2m_valid(pte) && !pte.p2m.table; + return lpae_valid(pte) && !pte.walk.table; } -static inline bool p2m_is_superpage(lpae_t pte, unsigned int level) +static inline bool lpae_is_superpage(lpae_t pte, unsigned int level) { - return (level < 3) && p2m_mapping(pte); + return (level < 3) && lpae_mapping(pte); } static void p2m_flush_tlb(struct p2m_domain *p2m); @@ -281,7 +281,7 @@ static int p2m_next_level(struct p2m_domain *p2m, bool read_only, entry = *table + offset; - if ( !p2m_valid(*entry) ) + if ( !lpae_valid(*entry) ) { if ( read_only ) return GUEST_TABLE_MAP_FAILED; @@ -292,7 +292,7 @@ static int p2m_next_level(struct p2m_domain *p2m, bool read_only, } /* The function p2m_next_level is never called at the 3rd level */ - if ( p2m_mapping(*entry) ) + if ( lpae_mapping(*entry) ) return GUEST_TABLE_SUPER_PAGE; mfn = _mfn(entry->p2m.base); @@ -372,7 +372,7 @@ mfn_t p2m_get_entry(struct p2m_domain *p2m, gfn_t gfn, entry = table[offsets[level]]; - if ( p2m_valid(entry) ) + if ( lpae_valid(entry) ) { *t = entry.p2m.type; @@ -577,7 +577,7 @@ static int p2m_create_table(struct p2m_domain *p2m, lpae_t *entry) lpae_t *p; lpae_t pte; - ASSERT(!p2m_valid(*entry)); + ASSERT(!lpae_valid(*entry)); page = alloc_domheap_page(NULL, 0); if ( page == NULL ) @@ -645,7 +645,7 @@ enum p2m_operation { */ static void p2m_put_l3_page(const lpae_t pte) { - ASSERT(p2m_valid(pte)); + ASSERT(lpae_valid(pte)); /* * TODO: Handle other p2m types @@ -673,11 +673,11 @@ static void p2m_free_entry(struct p2m_domain *p2m, struct page_info *pg; /* Nothing to do if the entry is invalid. */ - if ( !p2m_valid(entry) ) + if ( !lpae_valid(entry) ) return; /* Nothing to do but updating the stats if the entry is a super-page. */ - if ( p2m_is_superpage(entry, level) ) + if ( lpae_is_superpage(entry, level) ) { p2m->stats.mappings[level]--; return; @@ -733,7 +733,7 @@ static bool p2m_split_superpage(struct p2m_domain *p2m, lpae_t *entry, * a superpage. */ ASSERT(level < target); - ASSERT(p2m_is_superpage(*entry, level)); + ASSERT(lpae_is_superpage(*entry, level)); page = alloc_domheap_page(NULL, 0); if ( !page ) @@ -870,7 +870,7 @@ static int __p2m_set_entry(struct p2m_domain *p2m, /* We need to split the original page. */ lpae_t split_pte = *entry; - ASSERT(p2m_is_superpage(*entry, level)); + ASSERT(lpae_is_superpage(*entry, level)); if ( !p2m_split_superpage(p2m, &split_pte, level, target, offsets) ) { @@ -944,12 +944,12 @@ static int __p2m_set_entry(struct p2m_domain *p2m, * sequence when updating the translation table (D4.7.1 in ARM DDI * 0487A.j). */ - if ( p2m_valid(orig_pte) ) + if ( lpae_valid(orig_pte) ) p2m_remove_pte(entry, p2m->clean_pte); if ( mfn_eq(smfn, INVALID_MFN) ) /* Flush can be deferred if the entry is removed */ - p2m->need_flush |= !!p2m_valid(orig_pte); + p2m->need_flush |= !!lpae_valid(orig_pte); else { lpae_t pte = mfn_to_p2m_entry(smfn, t, a); @@ -964,7 +964,7 @@ static int __p2m_set_entry(struct p2m_domain *p2m, * Although, it could be defered when only the permissions are * changed (e.g in case of memaccess). */ - if ( p2m_valid(orig_pte) ) + if ( lpae_valid(orig_pte) ) { if ( likely(!p2m->mem_access_enabled) || P2M_CLEAR_PERM(pte) != P2M_CLEAR_PERM(orig_pte) ) @@ -986,10 +986,11 @@ static int __p2m_set_entry(struct p2m_domain *p2m, * Free the entry only if the original pte was valid and the base * is different (to avoid freeing when permission is changed). */ - if ( p2m_valid(orig_pte) && entry->p2m.base != orig_pte.p2m.base ) + if ( lpae_valid(orig_pte) && entry->p2m.base != orig_pte.p2m.base ) p2m_free_entry(p2m, orig_pte, level); - if ( need_iommu(p2m->domain) && (p2m_valid(orig_pte) || p2m_valid(*entry)) ) + if ( need_iommu(p2m->domain) && + (lpae_valid(orig_pte) || lpae_valid(*entry)) ) rc = iommu_iotlb_flush(p2m->domain, gfn_x(sgfn), 1UL << page_order); else rc = 0;