[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 12/52] xen/mmu: extract early uart mapping from setup_fixmap


  • To: Julien Grall <julien@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Penny Zheng <penny.zheng@xxxxxxx>
  • Date: Thu, 6 Jul 2023 16:01:35 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=xen.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IjFlBriCUqIiYxpiIcklky5G1qQ7Ym6ZrrTYNXjCpO4=; b=J89jVbwh70o6LhbZQglRBt9SZ70oEUlHkbzq6fJuA0OFyf6jZUhZhD958UrB4AHBA7BFjp0AbM75ST8cuhxGitITQJ4jxnhT+vd6CDm6wWJWmCtJMZr/N7WHjXtP05u4XbKsKg7PPJ6L96QeeBerT128m2fR8K3NRfBD/Oc6DJ09kzT/359pXpNTH/OKninXbKtJfFgkxrfR5P2AAJKLeqGBPxXnkvmoQoBFUj7HR4Kl378KjNdBSxmRNo3mZiWGFuBWO1iyC3bl/cbi918bio6rJO88KnTxJ62Y5YQ6Iyv2ToHiVVCf9AHbRncs9Ge3YOYB98vvHQBHB9YPZk8YVA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WWP1V9GP7jBnLn6sET0Hg8EFRCScpdSw7pIafUACdCfbZnfPFBJHrT7V9VWxzqPclAF6b5uiokJK7aws+w5yPw5oOHjCbXVNGBvD6Ac1Gna7T67fzQhozhuVBADsI+nBhghdnqtP/ZofIKVWJ0ckdc5sd+yCG+tB0mNHCTnQtRd+q4HTikhuGSFbV6ijxouSNxGx8VtX6jMOxdA2X5RzMgdW7TYIICh+aVTqzYa9dqATo2ZsNdxkqTmwLfJpjJZC8JzV8g8s7Q9t3OlknYrlKFaJDlg1pby9U3pNV5OYyRBE6rao9JHcfslShSi5jTBNmry+QF4g52LVpWmpDgtqxA==
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Wei Chen <wei.chen@xxxxxxx>
  • Delivery-date: Thu, 06 Jul 2023 08:02:03 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true

Hi Julien

On 2023/7/5 18:35, Julien Grall wrote:
Hi Penny,

On 05/07/2023 10:03, Penny Zheng wrote:
On 2023/7/5 06:25, Julien Grall wrote:
Hi Penny,

Title: You want to clarify that this change is arm64 only. So:

xen/arm64: mmu: ...

On 26/06/2023 04:34, Penny Zheng wrote:
Original setup_fixmap is actually doing two seperate tasks, one is enabling the early UART when earlyprintk on, and the other is to set up the fixmap
even when earlyprintk is not configured.

To be more dedicated and precise, the old function shall be split into two
functions, setup_early_uart and new setup_fixmap.
While some of the split before would be warrant even without the MPU support. This one is not because there is limited point to have 3 lines function. So I think you want to justify based on what you plan to do with the MPU code.

That said, I don't think we need to introduce setup_fixmap. See below.



Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx>
Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
---
v3:
- new patch
---
  xen/arch/arm/arm64/head.S     |  3 +++
  xen/arch/arm/arm64/mmu/head.S | 24 +++++++++++++++++-------
  2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
index e63886b037..55a4cfe69e 100644
--- a/xen/arch/arm/arm64/head.S
+++ b/xen/arch/arm/arm64/head.S
@@ -258,7 +258,10 @@ real_start_efi:
          b     enable_boot_mm
  primary_switched:
+        bl    setup_early_uart
+#ifdef CONFIG_HAS_FIXMAP
          bl    setup_fixmap
+#endif
  #ifdef CONFIG_EARLY_PRINTK
          /* Use a virtual address to access the UART. */
          ldr   x23, =EARLY_UART_VIRTUAL_ADDRESS
diff --git a/xen/arch/arm/arm64/mmu/head.S b/xen/arch/arm/arm64/mmu/head.S
index 2b209fc3ce..295596aca1 100644
--- a/xen/arch/arm/arm64/mmu/head.S
+++ b/xen/arch/arm/arm64/mmu/head.S
@@ -367,24 +367,34 @@ identity_mapping_removed:
  ENDPROC(remove_identity_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.

Since commit 9d267c049d92 ("xen/arm64: Rework the memory layout"), there is no chance that the fixmap will clash with the 1:1 mapping. So rather than introducing a new function, I would move the creation of the fixmap in create_pagetables().


Understood. I'll move the creation of the fixmap in create_pagetables().

This would avoid the #ifdef CONFIG_HAS_FIXMAP in head.S.

+ * Map the UART in the fixmap (when earlyprintk is used)
   *
   * Inputs:
- *   x20: Physical offset
   *   x23: Early UART base physical address
   *
   * Clobbers x0 - x3
   */
-ENTRY(setup_fixmap)
+ENTRY(setup_early_uart)
  #ifdef CONFIG_EARLY_PRINTK
          /* Add UART to the fixmap table */
          ldr   x0, =EARLY_UART_VIRTUAL_ADDRESS
          create_mapping_entry xen_fixmap, x0, x23, x1, x2, x3, type=PT_DEV_L3
+        /* Ensure any page table updates made above have occurred. */
+        dsb   nshst
+
+        ret

The 'ret' needs to be outside of the '#ifdef' block. But, in this case, I would prefer if we don't call setup_early_uart() when !CONFIG_EARLY_PRINTK in head.S


okay. I'll move the #ifdef to the caller in head.S.

Thinking about this again. I think you can actually move the mapping of the UART in create_pagetables() because it will also not clash with the 1:1.

For the MPU, the mapping could then be moved in prepare_early_mappings().

This would reduce the number of functions exposed.

Understood! will do.


Cheers,




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.