From patchwork Wed Nov 1 23:30:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 13443117 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1EB8AC4332F for ; Wed, 1 Nov 2023 23:30:34 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.626672.977132 (Exim 4.92) (envelope-from ) id 1qyKfI-0003uD-1b; Wed, 01 Nov 2023 23:30:24 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 626672.977132; Wed, 01 Nov 2023 23:30:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qyKfH-0003u3-Tf; Wed, 01 Nov 2023 23:30:23 +0000 Received: by outflank-mailman (input) for mailman id 626672; Wed, 01 Nov 2023 23:30:23 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qyKfH-0003qb-1G for xen-devel@lists.xenproject.org; Wed, 01 Nov 2023 23:30:23 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qyKfG-0008Dg-OZ; Wed, 01 Nov 2023 23:30:22 +0000 Received: from 54-240-197-232.amazon.com ([54.240.197.232] 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 1qyKfG-0007xN-Gd; Wed, 01 Nov 2023 23:30:22 +0000 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=odBcBVL9cWHvRFL9NbKIk3kHR3WNFMecqyNNuQSt4r8=; b=NtUFjz6xs5m3RzGg8Siu88cIdf YrOvVjHxc0Z2ejwtorMvVdUYGMyRzR0tasbf5c9ZI3b65cF9tYrijCojClY+uxna1z4oOUUGUqDD4 82Bp//nPQILsxv8r+fjnw2cRM/llm8slJuHIR9MzJ+ylp4lMGQe6NmKnCoR6qrZy0llk=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: Henry.Wang@arm.com, michal.orzel@amd.com, ayan.kumar.halder@amd.com, Julien Grall , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH 1/2] xen/arm32: head: Rework how the fixmap and early UART mapping are prepared Date: Wed, 1 Nov 2023 23:30:10 +0000 Message-Id: <20231101233011.83098-2-julien@xen.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231101233011.83098-1-julien@xen.org> References: <20231101233011.83098-1-julien@xen.org> MIME-Version: 1.0 From: Julien Grall Since commit 5e213f0f4d2c ("xen/arm32: head: Widen the use of the temporary mapping"), boot_second (used to cover regions like Xen and the fixmap) will not be mapped if the identity mapping overlap. So it is ok to prepare the fixmap table and link it in boot_second earlier. With that, the fixmap can also be used earlier via the temporary mapping. Therefore split setup_fixmap() in two: * The table is now linked in create_page_tables() because the boot page tables needs to be recreated for every CPU. * The early UART mapping is only added for the boot CPU0 as the fixmap table is not cleared when secondary CPUs boot. Signed-off-by: Julien Grall Reviewed-by: Michal Orzel --- xen/arch/arm/arm32/head.S | 48 ++++++++------------------------------- 1 file changed, 9 insertions(+), 39 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index 33b038e7e0ca..fec2433e568f 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -183,12 +183,16 @@ past_zImage: bl check_cpu_mode bl cpu_init bl create_page_tables + /* Add the UART mapping if requested */ +#ifdef CONFIG_EARLY_PRINTK + mov_w r0, EARLY_UART_VIRTUAL_ADDRESS + create_mapping_entry xen_fixmap, r0, r11, type=PT_DEV_L3 +#endif /* Address in the runtime mapping to jump to after the MMU is enabled */ mov_w lr, primary_switched b enable_mmu primary_switched: - bl setup_fixmap #ifdef CONFIG_EARLY_PRINTK /* Use a virtual address to access the UART. */ mov_w r11, EARLY_UART_VIRTUAL_ADDRESS @@ -456,11 +460,6 @@ ENDPROC(cpu_init) * Rebuild the boot pagetable's first-level entries. The structure * is described in mm.c. * - * After the CPU enables paging it will add the fixmap mapping - * to these page tables, however this may clash with the 1:1 - * mapping. So each CPU must rebuild the page tables here with - * the 1:1 in place. - * * Inputs: * r9 : paddr(start) * r10: phys offset @@ -488,6 +487,10 @@ create_page_tables: add r5, r5, #PAGE_SIZE /* r5 := Next table */ .endr + /* Map the fixmap into boot_second */ + mov_w r0, FIXMAP_ADDR(0) + create_table_entry boot_second, xen_fixmap, r0, 2 + /* * Find the size of Xen in pages and multiply by the size of a * PTE. This will then be compared in the mapping loop below. @@ -718,39 +721,6 @@ remove_temporary_mapping: mov pc, lr ENDPROC(remove_temporary_mapping) -/* - * Map the UART in the fixmap (when earlyprintk is used) and hook the - * fixmap table in the page tables. - * - * The fixmap cannot be mapped in create_page_tables because it may - * clash with the 1:1 mapping. - * - * Inputs: - * r10: Physical offset - * r11: Early UART base physical address - * - * Clobbers r0 - r4 - */ -setup_fixmap: -#if defined(CONFIG_EARLY_PRINTK) - /* Add UART to the fixmap table */ - mov_w r0, EARLY_UART_VIRTUAL_ADDRESS - create_mapping_entry xen_fixmap, r0, r11, type=PT_DEV_L3 -#endif - /* Map fixmap into boot_second */ - mov_w r0, FIXMAP_ADDR(0) - create_table_entry boot_second, xen_fixmap, r0, 2 - /* Ensure any page table updates made above have occurred. */ - dsb nshst - /* - * The fixmap area will be used soon after. So ensure no hardware - * translation happens before the dsb completes. - */ - isb - - mov pc, lr -ENDPROC(setup_fixmap) - /* * Setup the initial stack and jump to the C world *