]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/AsmMacroIoLibV8: remove undocumented assumption from ELx macros
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Thu, 17 Mar 2016 08:07:28 +0000 (09:07 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 22 Mar 2016 13:39:01 +0000 (14:39 +0100)
The macros EL1_OR_EL2() and EL1_OR_EL2_OR_EL3() allow conditional execution
of assembly sequences based on the current exception level, by jumping to
caller supplied labels 1f, 2f or 3f. However, the jump to 1f is actually
a fallthrough, which means the EL1 code needs to follow right after the
macro invocation, and the 1f label is ignored.

So let's fix this by making all jumps explicit.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Reviewed-by: Eugene Cohen <eugene@hp.com>
ArmPkg/Include/AsmMacroIoLibV8.h

index a9f8491bc92270640f5e27e648032c19fc012b0d..37fa255f842eea05f1c946dd7ac0df84d1affc98 100644 (file)
 #define EL1_OR_EL2(SAFE_XREG)        \\r
         mrs    SAFE_XREG, CurrentEL ;\\r
         cmp    SAFE_XREG, #0x8      ;\\r
+        b.gt   .                    ;\\r
         b.eq   2f                   ;\\r
-        cmp    SAFE_XREG, #0x4      ;\\r
-        b.ne   .                    ;// We should never get here\r
-// EL1 code starts here\r
+        cbnz   SAFE_XREG, 1f        ;\\r
+        b      .                    ;// We should never get here\r
+\r
 \r
 // CurrentEL : 0xC = EL3; 8 = EL2; 4 = EL1\r
 // This only selects between EL1 and EL2 and EL3, else we die.\r
 // Provide the Macro with a safe temp xreg to use.\r
 #define EL1_OR_EL2_OR_EL3(SAFE_XREG) \\r
         mrs    SAFE_XREG, CurrentEL ;\\r
-        cmp    SAFE_XREG, #0xC      ;\\r
-        b.eq   3f                   ;\\r
         cmp    SAFE_XREG, #0x8      ;\\r
+        b.gt   3f                   ;\\r
         b.eq   2f                   ;\\r
-        cmp    SAFE_XREG, #0x4      ;\\r
-        b.ne   .                    ;// We should never get here\r
-// EL1 code starts here\r
+        cbnz   SAFE_XREG, 1f        ;\\r
+        b      .                    ;// We should never get here\r
+\r
 #if defined(__clang__)\r
 \r
 // load x0 with _Data\r