Skip to contentSkip to conversation

xen/arm: Flush TLBs before turning on the MMU to avoid stale entries

PATCH New Julien Grall 1 participant 1 message Feb 27, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm: Flush TLBs before turning on the MMU to avoid stale entries

We don't know what is the state of the TLBs when booting Xen. To avoid stale entries, it is necessary to flush the TLBs before turning on the MMU.

---
 xen/arch/arm/arm32/head.S | 7 +++++++
 xen/arch/arm/arm64/head.S | 7 +++++++
 2 files changed, 14 insertions(+)
xen/arch/arm/arm32/head.S +7 -0
index 43374e77c6..612fc8fc3c 100644
@@ -360,6 +360,13 @@ virtphys_clash:
 1:
         PRINT("- Turning on paging -\r\n")
 
+        /*
+         * The state of the TLBs is unknown before turning on the MMU.
+         * Flush them to avoid stale one.
+         */
+        mcr   CP32(r0, TLBIALLH)     /* Flush hypervisor TLBs */
+        dsb   nsh
+
         ldr   r1, =paging            /* Explicit vaddr, not RIP-relative */
         mrc   CP32(r0, HSCTLR)
         orr   r0, r0, #(SCTLR_M|SCTLR_C) /* Enable MMU and D-cache */
xen/arch/arm/arm64/head.S +7 -0
index 35cf8e5cc9..5ba4832cf3 100644
@@ -498,6 +498,13 @@ virtphys_clash:
 1:
         PRINT("- Turning on paging -\r\n")
 
+        /*
+         * The state of the TLBs is unknown before turning on the MMU.
+         * Flush them to avoid stale one.
+         */
+        tlbi  alle2                  /* Flush hypervisor TLBs */
+        dsb   nsh
+
         ldr   x1, =paging            /* Explicit vaddr, not RIP-relative */
         mrs   x0, SCTLR_EL2
         orr   x0, x0, #SCTLR_M       /* Enable MMU */
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel