]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/ArmLib: fix barriers in AArch64 ArmEnableMmu
authorMark Rutland <mark.rutland@arm.com>
Mon, 9 Nov 2015 13:25:12 +0000 (13:25 +0000)
committerabiesheuvel <abiesheuvel@Edk2>
Mon, 9 Nov 2015 13:25:12 +0000 (13:25 +0000)
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 <mark.rutland@arm.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18749 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Library/ArmLib/AArch64/AArch64Support.S

index bdede48724e62c2759ca56d442ebb05acac22dcb..28cf27fbd1b67cb22fa31779695414cafb346378 100644 (file)
@@ -123,18 +123,20 @@ ASM_PFX(ArmEnableMmu):
 4: orr     x0, x0, #CTRL_M_BIT // Set MMU enable bit\r
    EL1_OR_EL2_OR_EL3(x1)\r
 1: tlbi    vmalle1\r
+   dsb     nsh\r
    isb\r
    msr     sctlr_el1, x0       // Write back\r
    b       4f\r
 2: tlbi    alle2\r
+   dsb     nsh\r
    isb\r
    msr     sctlr_el2, x0       // Write back\r
    b       4f\r
 3: tlbi    alle3\r
+   dsb     nsh\r
    isb\r
    msr     sctlr_el3, x0       // Write back\r
-4: dsb     sy\r
-   isb\r
+4: isb\r
    ret\r
 \r
 \r