From patchwork Mon Oct 8 18:33:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 148424 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp3982039lji; Mon, 8 Oct 2018 11:36:14 -0700 (PDT) X-Google-Smtp-Source: ACcGV60C8jA3vZcuRa6hxHyuc3UOsv4286MYQ/Xnd8k6Ts9KnWDeLZnAyYMGufOe/P2QHMrSHktl X-Received: by 2002:a24:f982:: with SMTP id l124-v6mr220375ith.65.1539023774846; Mon, 08 Oct 2018 11:36:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539023774; cv=none; d=google.com; s=arc-20160816; b=xxKzDDFKBTCNrpRA8DpAhBHriEV12oioD62qFTWLsgE4+eVI+JwxJvDUcKrR5bzLB0 wFDMJncy6M1iQcFOiYkNV7vYZBUnrTHUJS5Q0RWyoIqGO7pAwHeWVpe/Yej3AnfymSSf fBh7OfNJoHwYO1aKyplQAkYalo9l77Rb5iPRoSTWF4i/G5aYxCEKMC9KN5QYGMnUJBkt ErsWHQWGB1Lfx+rTlV7dyB1PYc64tOOBo9/RZ/yD3G9tCrGvHCX97BJ01ifhlj3qDb+G dZSRhtdAqImPtmwchspxPEYxuN4+CWurQKk4iIBvinV4zj25L1jTCzxoeVcvNTspNZ9u AfkQ== 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; bh=891B/hX1lG34VHZvfF4AZk4NIAmHiPKZjYBtlr7GHbg=; b=GDFfChWbTvWiNSlIl8rLMbC2Kl5BGWiSk0FJDlnCohHapCH59D4vyWFK3j2/LzBKRH qEzDX4XFeKyEPi6JO8u09TfWeft2au1oCGOvwb0Tdujay6ontXnK7DWiqGGaodgYLHx5 5eU/FhvUrPFL6ZQgUJLTQr6+sqd9Z8vMc9mrG/Dt1eXgEP0msDULp0elBm+Od2pYtqKS aDLE3zin0s7FUtGR26zr8vJaMDSI9Q+g/Awjo1brHVuRHipAKKRXfTtjZTCaFDvc1vq9 lIlt55zdtDD7WZayJm3oBRLh+6Pb8CjSgqUCtcHAlCCdeaWSJuW2QYh8uclAy57XdBfv nqcg== 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 t75-v6si9650342iof.159.2018.10.08.11.36.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Oct 2018 11:36:14 -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 1g9aM7-0005fg-6D; Mon, 08 Oct 2018 18:34:11 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1g9aM4-0005f3-Sx for xen-devel@lists.xen.org; Mon, 08 Oct 2018 18:34:08 +0000 X-Inumbo-ID: ebbbabe0-cb28-11e8-a6a9-d7ebe60f679a Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id ebbbabe0-cb28-11e8-a6a9-d7ebe60f679a; Mon, 08 Oct 2018 18:35:25 +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 04E5E1596; Mon, 8 Oct 2018 11:34:08 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1AE243F5B3; Mon, 8 Oct 2018 11:34:06 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 8 Oct 2018 19:33:42 +0100 Message-Id: <20181008183352.16291-7-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181008183352.16291-1-julien.grall@arm.com> References: <20181008183352.16291-1-julien.grall@arm.com> Subject: [Xen-devel] [RFC 06/16] xen/arm: p2m: Introduce a helper to generate P2M table entry from a page 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, andre.przywara@linaro.org MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Generate P2M table entry requires to set some default values which are worth to explain in a comment. At the moment, there are 2 places where such entry are created but only one as proper comment. Some move the code to generate P2M table entry in a separate helper. This will be helpful in a follow-up patch to make modification on the defaults. At the same time, switch the default access from p2m->default_access to p2m_access_rwx. This should not matter as permission are ignored for table by the hardware. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/p2m.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 8fffb42889..6c76298ebc 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -538,6 +538,16 @@ static lpae_t mfn_to_p2m_entry(mfn_t mfn, p2m_type_t t, p2m_access_t a) return e; } +/* Generate table entry with correct attributes. */ +static lpae_t page_to_p2m_table(struct page_info *page) +{ + /* + * The access value does not matter because the hardware will ignore + * the permission fields for table entry. + */ + return mfn_to_p2m_entry(page_to_mfn(page), p2m_invalid, p2m_access_rwx); +} + static inline void p2m_write_pte(lpae_t *p, lpae_t pte, bool clean_pte) { write_pte(p, pte); @@ -558,7 +568,6 @@ static int p2m_create_table(struct p2m_domain *p2m, lpae_t *entry) { struct page_info *page; lpae_t *p; - lpae_t pte; ASSERT(!lpae_is_valid(*entry)); @@ -576,14 +585,7 @@ static int p2m_create_table(struct p2m_domain *p2m, lpae_t *entry) unmap_domain_page(p); - /* - * The access value does not matter because the hardware will ignore - * the permission fields for table entry. - */ - pte = mfn_to_p2m_entry(page_to_mfn(page), p2m_invalid, - p2m->default_access); - - p2m_write_pte(entry, pte, p2m->clean_pte); + p2m_write_pte(entry, page_to_p2m_table(page), p2m->clean_pte); return 0; } @@ -764,14 +766,11 @@ static bool p2m_split_superpage(struct p2m_domain *p2m, lpae_t *entry, unmap_domain_page(table); - pte = mfn_to_p2m_entry(page_to_mfn(page), p2m_invalid, - p2m->default_access); - /* * Even if we failed, we should install the newly allocated LPAE * entry. The caller will be in charge to free the sub-tree. */ - p2m_write_pte(entry, pte, p2m->clean_pte); + p2m_write_pte(entry, page_to_p2m_table(page), p2m->clean_pte); return rv; }