Revision: 18749
          http://sourceforge.net/p/edk2/code/18749
Author:   abiesheuvel
Date:     2015-11-09 13:25:12 +0000 (Mon, 09 Nov 2015)
Log Message:
-----------
ArmPkg/ArmLib: fix barriers in AArch64 ArmEnableMmu

The ARM architecture requires a DSB to complete TLB maintenance, with a
subsequent ISB being required to synchronize subsequent items in the
current instruction stream against the completed TLB maintenance.

The ArmEnableMmu function is currently missing the DSB, and hence the
TLB maintenance is not guaranteed to have completed at the point the MMU
is enabled. This may result in unpredictable behaviour.

The DSB subsequent to the write to SCTLR_EL1 is unnecessary; the ISB
alone is sufficient to complete all prior instructions and to
synchronise the new context with any subsequent instructions.

This patch adds missing DSBs to complete TLB maintenance, and removes
the unnecessary trailing DSB.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Mark Rutland <[email protected]>
Reviewed-by: Ard Biesheuvel <[email protected]>
Reviewed-by: Leif Lindholm <[email protected]>

Modified Paths:
--------------
    trunk/edk2/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S

Modified: trunk/edk2/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S
===================================================================
--- trunk/edk2/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S   2015-11-09 
13:13:37 UTC (rev 18748)
+++ trunk/edk2/ArmPkg/Library/ArmLib/AArch64/AArch64Support.S   2015-11-09 
13:25:12 UTC (rev 18749)
@@ -123,18 +123,20 @@
 4: orr     x0, x0, #CTRL_M_BIT // Set MMU enable bit
    EL1_OR_EL2_OR_EL3(x1)
 1: tlbi    vmalle1
+   dsb     nsh
    isb
    msr     sctlr_el1, x0       // Write back
    b       4f
 2: tlbi    alle2
+   dsb     nsh
    isb
    msr     sctlr_el2, x0       // Write back
    b       4f
 3: tlbi    alle3
+   dsb     nsh
    isb
    msr     sctlr_el3, x0       // Write back
-4: dsb     sy
-   isb
+4: isb
    ret
 
 


------------------------------------------------------------------------------
Presto, an open source distributed SQL query engine for big data, initially
developed by Facebook, enables you to easily query your data on Hadoop in a 
more interactive manner. Teradata is also now providing full enterprise
support for Presto. Download a free open source copy now.
http://pubads.g.doubleclick.net/gampad/clk?id=250295911&iu=/4140
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to