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

Re: [PATCH v6 08/13] xen/arm: Fold mmu_init_secondary_cpu() to head.S


  • To: Julien Grall <julien@xxxxxxx>, Henry Wang <Henry.Wang@xxxxxxx>
  • From: Ayan Kumar Halder <ayankuma@xxxxxxx>
  • Date: Mon, 11 Sep 2023 17:30:32 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; 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=9DL81iP3XqN17ao8y+idnBJa20HNdvb/ZbwonSzEyR8=; b=hCse1ZGlkf5oQd6TSmydeklVUcLZAorKwQNIWo6D7qFhsb9bmPEysOgSSQAIcoSnxoVplZmDiu6R5/np5Jk9YaV4A2LiIgxQ3crnPK8gvAtaLtaQl98wdsDG0+SIN/V2NJgLiQO+sohQC75NyoCF4HZGd9gb78fEm+0WXj/bQOkFMLxZUCqjbZ8qa5uMZ1vPRExnAHOKgz+S4oor+a+QmMrUWrHKcEVy5OKQKo7R0Zc2JYWi/u4VX+F7h2SanOwxyqjwOaDkJBquEOBTWqaIRaEMZt6lpJtxJJaAd6Rgs9PwW7N+abb5eUw8t0fXZprWTerEROtSQ/jWmXXr3EhetA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dKlZCgSYFPNfErTkM8A/JaVmQsZD7429ZtUYgiDhY6Z+VlQ1vI+sactBsdGgr3rHkP0pODJPV2UzUj0ha4c5Gp+pf+pm8wb4rtqhXUxrTYpPB6ePe+8HJ8ggDchvbZnIyCb/tVdOjDEN/BAv3uGbmgsmI415i7RfLci9lhuH3bcSNxnUOBm/F8jz5yIEGQJH3mkHEfiJ5nIXXGQgk/PPsmJrlL71JAre80FE/Pre6o7ZNzsRZzmO98IDq0A/pe9XS98765ASwY1fopzW7fEWSYfRwwyWwUxAaSL7EmYBtdbz6/Kz1oMjdSVMdyJwqcUKLEARrWQ8+hJaGH+qJJ07Jw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Wei Chen <Wei.Chen@xxxxxxx>, Penny Zheng <Penny.Zheng@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Mon, 11 Sep 2023 16:30:52 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Julien,

On 11/09/2023 15:51, Julien Grall wrote:


On 31/08/2023 10:16, Henry Wang wrote:
On Aug 31, 2023, at 17:12, Ayan Kumar Halder <ayankuma@xxxxxxx> wrote:

Hi Henry,

On 28/08/2023 02:32, Henry Wang wrote:

diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S
index 33b038e7e0..39218cf15f 100644
--- a/xen/arch/arm/arm32/head.S
+++ b/xen/arch/arm/arm32/head.S
@@ -83,6 +83,25 @@
          isb
  .endm

+/*
+ * Enforce Xen page-tables do not contain mapping that are both
+ * Writable and eXecutables.
+ *
+ * This should be called on each secondary CPU.
+ */
+.macro pt_enforce_wxn tmp
+        mrc   CP32(\tmp, HSCTLR)
+        orr   \tmp, \tmp, #SCTLR_Axx_ELx_WXN
+        dsb
+        mcr   CP32(\tmp, HSCTLR)
+        /*
+         * The TLBs may cache SCTLR_EL2.WXN. So ensure it is synchronized
+         * before flushing the TLBs.
+         */
+        isb
+        flush_xen_tlb_local \tmp
+.endm
+
  /*
   * Common register usage in this file:
   *   r0  -
@@ -254,6 +273,7 @@ secondary_switched:
          /* Use a virtual address to access the UART. */
          mov_w r11, EARLY_UART_VIRTUAL_ADDRESS
  #endif
+        pt_enforce_wxn

Can you move ^^^ to before "#ifdef CONFIG_EARLY_PRINTK" so that the MMU related functionality are bundled together?

Also AFAIU, mov_w has not effect on pt_enforce_wxn().

So that I can create a function "enable_secondary_cpu_mm()" - similar to one you introduced for arm64

Sure, I am good with this if other maintainers do not have any objections.

I am objecting. It would be quite handy to print a message on the console to indicate that we are enforce WXN. So we want to update UART address (stored in r11) before hand.

You mean you want to add this snippet in the current patch

diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S
index 39218cf15f..282b89a96e 100644
--- a/xen/arch/arm/arm32/head.S
+++ b/xen/arch/arm/arm32/head.S
@@ -273,6 +273,7 @@ secondary_switched:
         /* Use a virtual address to access the UART. */
         mov_w r11, EARLY_UART_VIRTUAL_ADDRESS
 #endif
+        PRINT("- Enforce WXN -\r\n")
         pt_enforce_wxn r0
         PRINT("- Ready -\r\n")
         /* Jump to C world */

- Ayan


Cheers,




 


Rackspace

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