From nobody Tue Feb 10 09:40:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1670840282; cv=none; d=zohomail.com; s=zohoarc; b=IecTs1DlboAYsMN6C3dnaWCkVOeZ44So1uiHgr4OcwObbkO5T5pblHKYuPatpCgamVD7HYYHt+HGk5fl2kqrd+7KtOky56joLX+I81sk7I/gxmDSVbT8ke3/v+kocBRdXADpVsEd/gymU0sAB6FsvXK1+PoeLTGAFEswowCWR2c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1670840282; h=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; bh=PT5WPm2NE5wT0NyCnF+h0ITkG97YNTqNChrNhLvYYIs=; b=i4tbejRP5CtslMAr/uT8BMMKwz0fDZRAW1yoUbL5FQIOeThWHgAzBphzuErJfU8ZUWq0YreAgw/uTV0xUaiDnkOlIj7iTVtasl7zcl3e2ia5aQI12mXqE5292zt02Ql2PXtclu0vZRn8vVApAOxOSpmQXs9CtOC1gtfdmsSnj2s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of 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.zohomail.com with SMTPS id 1670840282486577.1245453414442; Mon, 12 Dec 2022 02:18:02 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.459400.717158 (Exim 4.92) (envelope-from ) id 1p4fsT-0007D2-6Y; Mon, 12 Dec 2022 10:17:41 +0000 Received: by outflank-mailman (output) from mailman id 459400.717158; Mon, 12 Dec 2022 10:17:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p4fsS-000797-ML; Mon, 12 Dec 2022 10:17:40 +0000 Received: by outflank-mailman (input) for mailman id 459400; Mon, 12 Dec 2022 10:17:37 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p4fsP-0006gL-UR for xen-devel@lists.xenproject.org; Mon, 12 Dec 2022 10:17:37 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p4fsP-0002CT-Iw; Mon, 12 Dec 2022 10:17:37 +0000 Received: from 54-240-197-224.amazon.com ([54.240.197.224] helo=dev-dsk-jgrall-1b-035652ec.eu-west-1.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1p4fX9-0001lz-Ag; Mon, 12 Dec 2022 09:55:39 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=PT5WPm2NE5wT0NyCnF+h0ITkG97YNTqNChrNhLvYYIs=; b=bZcBHJpO8cHTaWFe24T4aaKYmy 4TQnxgfwq/Hxd6SBUWi5kLSj07sCXM4MSK+Hn6owK01DX4pV4r7QB8de07qJCGNNNoo4NlgMhtG02 ncVAKBVSXO1+aKkRQmXCB7CucMjYMa6UBpdxHJNhLM58xg8pG90Puni34XmR5Ax3FLqQ=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: michal.orzel@amd.com, Luca.Fancellu@arm.com, Julien Grall , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH v3 11/18] xen/arm: Enable use of dump_pt_walk() early during boot Date: Mon, 12 Dec 2022 09:55:16 +0000 Message-Id: <20221212095523.52683-12-julien@xen.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221212095523.52683-1-julien@xen.org> References: <20221212095523.52683-1-julien@xen.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) X-ZM-MESSAGEID: 1670840284694100003 Content-Type: text/plain; charset="utf-8" From: Julien Grall At the moment, dump_pt_walk() is using map_domain_page() to map the page tables. map_domain_page() is only usuable after init_domheap_mappings() is called (arm32) or the xenheap has been initialized (arm64). This means it can be hard to diagnose incorrect page-tables during early boot. So update dump_pt_walk() to xen_{, un}map_table() instead. Note that the two helpers are moved earlier to avoid forward declaring them. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/mm.c | 56 +++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 1315a2c87db7..d0b1cf55f550 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -191,6 +191,30 @@ static void __init __maybe_unused build_assertions(voi= d) #undef CHECK_DIFFERENT_SLOT } =20 +static lpae_t *xen_map_table(mfn_t mfn) +{ + /* + * During early boot, map_domain_page() may be unusable. Use the + * PMAP to map temporarily a page-table. + */ + if ( system_state =3D=3D SYS_STATE_early_boot ) + return pmap_map(mfn); + + return map_domain_page(mfn); +} + +static void xen_unmap_table(const lpae_t *table) +{ + /* + * During early boot, xen_map_table() will not use map_domain_page() + * but the PMAP. + */ + if ( system_state =3D=3D SYS_STATE_early_boot ) + pmap_unmap(table); + else + unmap_domain_page(table); +} + void dump_pt_walk(paddr_t ttbr, paddr_t addr, unsigned int root_level, unsigned int nr_root_tables) @@ -230,7 +254,7 @@ void dump_pt_walk(paddr_t ttbr, paddr_t addr, else root_table =3D 0; =20 - mapping =3D map_domain_page(mfn_add(root_mfn, root_table)); + mapping =3D xen_map_table(mfn_add(root_mfn, root_table)); =20 for ( level =3D root_level; ; level++ ) { @@ -246,11 +270,11 @@ void dump_pt_walk(paddr_t ttbr, paddr_t addr, break; =20 /* For next iteration */ - unmap_domain_page(mapping); - mapping =3D map_domain_page(lpae_get_mfn(pte)); + xen_unmap_table(mapping); + mapping =3D xen_map_table(lpae_get_mfn(pte)); } =20 - unmap_domain_page(mapping); + xen_unmap_table(mapping); } =20 void dump_hyp_walk(vaddr_t addr) @@ -713,30 +737,6 @@ void *ioremap(paddr_t pa, size_t len) return ioremap_attr(pa, len, PAGE_HYPERVISOR_NOCACHE); } =20 -static lpae_t *xen_map_table(mfn_t mfn) -{ - /* - * During early boot, map_domain_page() may be unusable. Use the - * PMAP to map temporarily a page-table. - */ - if ( system_state =3D=3D SYS_STATE_early_boot ) - return pmap_map(mfn); - - return map_domain_page(mfn); -} - -static void xen_unmap_table(const lpae_t *table) -{ - /* - * During early boot, xen_map_table() will not use map_domain_page() - * but the PMAP. - */ - if ( system_state =3D=3D SYS_STATE_early_boot ) - pmap_unmap(table); - else - unmap_domain_page(table); -} - static int create_xen_table(lpae_t *entry) { mfn_t mfn; --=20 2.38.1