From patchwork Mon Jul 16 17:27:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 142078 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2677695ljj; Mon, 16 Jul 2018 10:29:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeMJ+Sd/Jf/xQiHSypIQr7MqopGSpYSiW+rAbZ8cKFpPwEF6SVdJzdO5XJxsUqJpm/dZfQ1 X-Received: by 2002:a24:4511:: with SMTP id y17-v6mr14220247ita.67.1531762181256; Mon, 16 Jul 2018 10:29:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531762181; cv=none; d=google.com; s=arc-20160816; b=T5enJv/1M5Y9uGmeo6oIDmMY2xNWG4kKTLdIxwi5SesJTphIGbV9WH8iMR2g2xNoB4 QgQQSstuhxApsUNTKzRTAhYp9M/fomHGerveGABPfsBtWIJkMZN3Bz1nEd1PamQ7l0TR jUpJv3+ZIeubF1BNH7qNvHyBTBWgXC5IoF2OQOh3z82NweG+d+9xe8EhMudSUHzzj+MZ xEiS22gDYCWUcxdiMC7gTCHeJ+MHz5CAwmqd1pnGX6nNt7s4GIOwAnNsPKjTjEW897oy 0XnuAHBcdph1EoeiZ3Wv8nbPCMjKJJ+VcgwOxTMoPzpEHry6+vf5S55cNErK2lRYPoBp VZ3Q== 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:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from :arc-authentication-results; bh=kwl3rfqgVAkbzitN1LSAn/ZnpgauZRzo+p5bYaT8Euw=; b=xRyoOjABU2t/Y522DOyjN+pU+zjbjPKJwQlwecwb8I4jv6W6PWvl2Yf0qSzcbFPTfl Z3gchd0of2ED8aamXY+rpgznFQnhCQBnhAaYeBbdN69+MpJtcPc/symNFiTR1CcWaM1o yC29Ks1E+gZ0XHJaOqDOdiAvhujV3SLG6JLZ6H/1YiNieGQFUT85DK8KeKtCSRi3467A JvuN4UtqEC8GXdtBXmu0pG3dcFWu4JI7fw771h9xoGjuswxEBRU+oSYjjVtiFrwJEuVZ izDIPGS0ij+6u6BqwaSkf+wa7iIyEFp2retCrGQJY/yGdR1cKH9IW3axvDaYkH9TORYT 6UaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id q14-v6si1161855itc.3.2018.07.16.10.29.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Jul 2018 10:29:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ff7HT-0006Rn-Iz; Mon, 16 Jul 2018 17:27:27 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ff7HT-0006RU-4B for xen-devel@lists.xenproject.org; Mon, 16 Jul 2018 17:27:27 +0000 X-Inumbo-ID: 87551e46-891d-11e8-a6a9-d7ebe60f679a Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 87551e46-891d-11e8-a6a9-d7ebe60f679a; Mon, 16 Jul 2018 17:27:35 +0000 (UTC) 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 AF1E07A9; Mon, 16 Jul 2018 10:27:25 -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 E880B3F5B1; Mon, 16 Jul 2018 10:27:24 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 16 Jul 2018 18:27:03 +0100 Message-Id: <20180716172712.20294-7-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180716172712.20294-1-julien.grall@arm.com> References: <20180716172712.20294-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 06/15] xen/arm: Rework lpae_mapping X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Julien Grall , sstabellini@kernel.org MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Currently, lpae_mapping can only work on entry from any level other than 3. Make it work with any level by extending the prototype to pass the level. At the same time, rename the function to lpae_is_mapping so naming stay consistent accross lpae_* helpers. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/p2m.c | 12 +++++++----- xen/include/asm-arm/lpae.h | 13 +++++++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index ebf74760fa..72a84a33fd 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -241,7 +241,8 @@ static int p2m_create_table(struct p2m_domain *p2m, lpae_t *entry); * GUEST_TABLE_SUPER_PAGE: The next entry points to a superpage. */ static int p2m_next_level(struct p2m_domain *p2m, bool read_only, - lpae_t **table, unsigned int offset) + unsigned int level, lpae_t **table, + unsigned int offset) { lpae_t *entry; int ret; @@ -260,7 +261,8 @@ 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 ( lpae_mapping(*entry) ) + ASSERT(level < 3); + if ( lpae_is_mapping(*entry, level) ) return GUEST_TABLE_SUPER_PAGE; mfn = _mfn(entry->p2m.base); @@ -331,7 +333,7 @@ mfn_t p2m_get_entry(struct p2m_domain *p2m, gfn_t gfn, for ( level = P2M_ROOT_LEVEL; level < 3; level++ ) { - rc = p2m_next_level(p2m, true, &table, offsets[level]); + rc = p2m_next_level(p2m, true, level, &table, offsets[level]); if ( rc == GUEST_TABLE_MAP_FAILED ) goto out_unmap; else if ( rc != GUEST_TABLE_NORMAL_PAGE ) @@ -804,7 +806,7 @@ static int __p2m_set_entry(struct p2m_domain *p2m, * is about to be removed (i.e mfn == INVALID_MFN). */ rc = p2m_next_level(p2m, mfn_eq(smfn, INVALID_MFN), - &table, offsets[level]); + level, &table, offsets[level]); if ( rc == GUEST_TABLE_MAP_FAILED ) { /* @@ -861,7 +863,7 @@ static int __p2m_set_entry(struct p2m_domain *p2m, /* then move to the level we want to make real changes */ for ( ; level < target; level++ ) { - rc = p2m_next_level(p2m, true, &table, offsets[level]); + rc = p2m_next_level(p2m, true, level, &table, offsets[level]); /* * The entry should be found and either be a table diff --git a/xen/include/asm-arm/lpae.h b/xen/include/asm-arm/lpae.h index b30853e79d..4cf188ff82 100644 --- a/xen/include/asm-arm/lpae.h +++ b/xen/include/asm-arm/lpae.h @@ -134,7 +134,7 @@ static inline bool lpae_valid(lpae_t pte) } /* - * These two can only be used on L0..L2 ptes because L3 mappings set + * This one 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. */ @@ -143,14 +143,19 @@ static inline bool lpae_table(lpae_t pte) return lpae_valid(pte) && pte.walk.table; } -static inline bool lpae_mapping(lpae_t pte) +static inline bool lpae_is_mapping(lpae_t pte, unsigned int level) { - return lpae_valid(pte) && !pte.walk.table; + if ( !lpae_valid(pte) ) + return false; + else if ( level == 3 ) + return pte.walk.table; + else + return !pte.walk.table; } static inline bool lpae_is_superpage(lpae_t pte, unsigned int level) { - return (level < 3) && lpae_mapping(pte); + return (level < 3) && lpae_is_mapping(pte, level); } static inline bool lpae_is_page(lpae_t pte, unsigned int level)