From patchwork Fri Jun 30 15:54:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 106739 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2507642qge; Fri, 30 Jun 2017 08:57:17 -0700 (PDT) X-Received: by 10.107.24.5 with SMTP id 5mr25105404ioy.217.1498838237790; Fri, 30 Jun 2017 08:57:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498838237; cv=none; d=google.com; s=arc-20160816; b=myrpGRv1xMPzkqzg2FnBeJUVurNCXttC1nMOpH1ZLGrZJ4kI4CUh7i4OxEJ1SS13/A e/lF9o/M7LO+3r6P+pauGYd4ekqfHrYC2Spo/I6VLO+s7qxFjbmQU2HLY0CdFzL5MeSH FZrmDD7WkosIRdyTPHelhaSo+I0VZbX5oy1lqJ9PWq9WHYsSaoXc5H0EhHvuLWWk4oMJ B3+cDKRC5Jk5JKwIK2gQaA+WlolgLGO7BRAJtUIJYKay5i0mnIMbfFvczQvD6qeOrxJJ E0Vfejh4Qi0nFpCF7QAfx9z5JHZbOPE5fNGE0uQzcRI2nE02N5NGTBm/Vr7dKjx5DINH q4wQ== 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=elwbJdEDphUQt8gB6BSOZQK+qSEKBQpdjtEwpDy8szQ=; b=mDoS+nX5fLujZWOu9coyAx9KxsHrH2XLSFhEAGqo5a3/rztO45vm4O8rZqh93VPz6W vVFo5/7SZbQqN3LU+7l20klGLQoZL/6C+Pa0HLi7PnBytVjBOFRTrLxHvCeoTHXSz6j1 2W6wo/ewLjiHD4OFbWsQk0Op1p/HomuvDcdWz6MRZCSsPmTpc4xLfcorNMjHX113A9ul 0/brHlq00oGb43uVa1k65yMUAiBmr8WaftbCIlgIkN8cCAQUFnzh/INPP00Lg1oxca+J gh7iEYTRtxFhUgbeddPAgVybct/UnmwH01p4XzBqAGbFCiod9V06nUPUKY4GiARzfKlF NiNA== 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 g10si7750954iog.207.2017.06.30.08.57.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Jun 2017 08:57: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 1dQyFu-0000YX-GO; Fri, 30 Jun 2017 15:54:50 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQyFt-0000Vz-3p for xen-devel@lists.xen.org; Fri, 30 Jun 2017 15:54:49 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 12/98-03577-84476595; Fri, 30 Jun 2017 15:54:48 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRWlGSWpSXmKPExsVysyfVTde9JCz SYO5+U4slHxezODB6HN39mymAMYo1My8pvyKBNaNtwx7mgjd6Ffef7mBqYOxV6WLk4hAS2Mwo 8XXDdTYI5zSjxLqO4yxdjJwcbAKaEnc+f2ICsUUEpCWufb7M2MXIwcEsECXxfxoniCkskCoxd W88SAWLgKrE9aNPwKp5BawkLn57xgpiSwjIS+xquwhmcwLFj/97AFYjJGAp8XrWVZYJjNwLGB lWMWoUpxaVpRbpGhnoJRVlpmeU5CZm5ugaGpjp5aYWFyemp+YkJhXrJefnbmIEepcBCHYw/lo WcIhRkoNJSZR35bXQSCG+pPyUyozE4oz4otKc1OJDjDIcHEoSvIrFYZFCgkWp6akVaZk5wDCD SUtw8CiJ8MoGAaV5iwsSc4sz0yFSpxh1OV5N+P+NSYglLz8vVUqcNwRkhgBIUUZpHtwIWMhfY pSVEuZlBDpKiKcgtSg3swRV/hWjOAejkjCvM8gUnsy8ErhNr4COYAI6QnhGCMgRJYkIKakGxt DuZStOiylvvPjxwbNHMUfXFT98/Ta88ICgVZHoXx32xc47/K+skpBavct7d9FaTmXd9B/Fh2t EVIqjVpdINInNORo9d/++Zbv73e+vlLZsKy9es3xz2cyMIisHj805i/5L8xW4dquKvhOV63QN ve8w58uivWcZzHiVXc/Pa1hs2cA0RSeqQYmlOCPRUIu5qDgRACWeBj50AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-10.tower-21.messagelabs.com!1498838087!64493537!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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 9890 invoked from network); 30 Jun 2017 15:54:47 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-10.tower-21.messagelabs.com with SMTP; 30 Jun 2017 15:54:47 -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 0E8CB15B2; Fri, 30 Jun 2017 08:54:47 -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 4D1863F41F; Fri, 30 Jun 2017 08:54:46 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Fri, 30 Jun 2017 16:54:26 +0100 Message-Id: <20170630155431.23824-12-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170630155431.23824-1-julien.grall@arm.com> References: <20170630155431.23824-1-julien.grall@arm.com> Cc: proskurin@sec.in.tum.de, Julien Grall , sstabellini@kernel.org Subject: [Xen-devel] [PATCH v3 11/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 Reviewed-by: Sergej Proskurin --- Cc: proskurin@sec.in.tum.de s/bool_t/bool/ will be done in a separate patch Changes in v2: - Patch added Changes in v3: - Add Stefano's reviewed-by --- 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 3e20a1ec82..381df1f237 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;