]> xenbits.xensource.com Git - xen.git/commitdiff
xen/arm: Flush TLBs before turning on the MMU to avoid stale entries
authorJulien Grall <julien.grall@arm.com>
Tue, 27 Feb 2018 11:15:57 +0000 (11:15 +0000)
committerStefano Stabellini <sstabellini@kernel.org>
Fri, 2 Mar 2018 23:49:03 +0000 (15:49 -0800)
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.

Reported-by: Iain Hunter <iain@hunterembedded.co.uk>
Signed-off-by: Julien Grall <julien.gralL@arm.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
(cherry picked from commit 1c473c42199a8f4d70533c202e1c57ecd1dad35b)

xen/arch/arm/arm32/head.S
xen/arch/arm/arm64/head.S

index 2df9a982aa069af0905b27901fede8bf1380f5ca..e7ec00426659c0dc235e3f5ae99e0cef6d239768 100644 (file)
@@ -349,6 +349,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 */
index c1a5098e50f542491d8f3efe16bd20e9238bf353..6426fe7274d255895d54264c200e06ebd3c9b76c 100644 (file)
@@ -504,6 +504,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 */