From nobody Fri Apr 19 17:24:54 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557837153; cv=none; d=zoho.com; s=zohoarc; b=Qu7ze92x9+3Ko90LA3hqSzp66jWnH42gd05hn80db/geYTp9Z9zK6X4Qh/VP+5jbL0NKLe43CJpMbSn+Wc0Xxb1XexV0JcqAchFEi0nmTkwmfalCocEs2080kceI5tjnPV6Hr61BlPGHpprGXfvA+81rAT0ikPK8SxNFhFywKQ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557837153; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=asJQ6oXkvoubr6wNyHe0lSspww4TN4X8SItzDIZBE0Q=; b=UUCBEO8ZGtSTzoymCcc1xe4MbKNlz4i2uK3Qv8z/Eal4oSoNqvv4HeIv0vVwjWklz7yOrS0ybyCeJE0sq8fmyIHfL3la9qNNtEmXNd6xIfY3f1+lsdmu5/YEV9j8seDQgqvk8ymKFHclSlJo7RW/t3oCapxOqK/oPEc0wXu1GfE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557837153147716.7203679390115; Tue, 14 May 2019 05:32:33 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hQWaw-0005Qu-55; Tue, 14 May 2019 12:31:46 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hQWav-0005Q2-GG for xen-devel@lists.xenproject.org; Tue, 14 May 2019 12:31:45 +0000 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 3be35306-7644-11e9-9745-a782c9656c67; Tue, 14 May 2019 12:31:44 +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 70476341; Tue, 14 May 2019 05:31:44 -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 3C40F3F71E; Tue, 14 May 2019 05:31:43 -0700 (PDT) X-Inumbo-ID: 3be35306-7644-11e9-9745-a782c9656c67 From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 14 May 2019 13:31:22 +0100 Message-Id: <20190514123125.29086-10-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190514123125.29086-1-julien.grall@arm.com> References: <20190514123125.29086-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH MM-PART3 v2 09/12] xen/arm: mm: Use {, un}map_domain_page() to map/unmap Xen page-tables 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: Oleksandr_Tyshchenko@epam.com, Julien Grall , Stefano Stabellini , Andrii Anisov MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Currently, the virtual address of the 3rd level page-tables is obtained using mfn_to_virt(). On Arm32, mfn_to_virt can only work on xenheap page. While in practice all the page-tables updated will reside in xenheap, in practive the page-tables covering Xen memory (e.g xen_mapping) is part of Xen binary. Furthermore, a follow-up change will update xen_pt_update_entry() to walk all the levels and therefore be more generic. Some of the page-tables will also part of Xen memory and therefore will not be reachable using mfn_to_virt(). The easiest way to reach those pages is to use {, un}map_domain_page(). While on arm32 this means an extra mapping in the normal cases, this is not very important as xen page-tables are not updated often. In order to allow future change in the way Xen page-tables are mapped, two new helpers are introduced to map/unmap the page-tables. Signed-off-by: Julien Grall Reviewed-by: Andrii Anisov Acked-by: Stefano Stabellini --- Changes in v2: - Add Andrii's reviewed-by --- xen/arch/arm/mm.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 651e296041..f5979f549b 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -974,6 +974,16 @@ static int create_xen_table(lpae_t *entry) return 0; } =20 +static lpae_t *xen_map_table(mfn_t mfn) +{ + return map_domain_page(mfn); +} + +static void xen_unmap_table(const lpae_t *table) +{ + unmap_domain_page(table); +} + /* Sanity check of the entry */ static bool xen_pt_check_entry(lpae_t entry, mfn_t mfn, unsigned int flags) { @@ -1036,6 +1046,7 @@ static bool xen_pt_check_entry(lpae_t entry, mfn_t mf= n, unsigned int flags) static int xen_pt_update_entry(unsigned long addr, mfn_t mfn, unsigned int flags) { + int rc; lpae_t pte, *entry; lpae_t *third =3D NULL; =20 @@ -1054,15 +1065,17 @@ static int xen_pt_update_entry(unsigned long addr, = mfn_t mfn, =20 BUG_ON(!lpae_is_valid(*entry)); =20 - third =3D mfn_to_virt(lpae_get_mfn(*entry)); + third =3D xen_map_table(lpae_get_mfn(*entry)); entry =3D &third[third_table_offset(addr)]; =20 + rc =3D -EINVAL; if ( !xen_pt_check_entry(*entry, mfn, flags) ) - return -EINVAL; + goto out; =20 /* If we are only populating page-table, then we are done. */ + rc =3D 0; if ( flags & _PAGE_POPULATE ) - return 0; + goto out; =20 /* We are removing the page */ if ( !(flags & _PAGE_PRESENT) ) @@ -1087,7 +1100,12 @@ static int xen_pt_update_entry(unsigned long addr, m= fn_t mfn, =20 write_pte(entry, pte); =20 - return 0; + rc =3D 0; + +out: + xen_unmap_table(third); + + return rc; } =20 static DEFINE_SPINLOCK(xen_pt_lock); --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel