]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg/BaseMemoryLibOptDxe ARM: fix Thumb-2 bug in ScanMem()
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 26 Sep 2016 22:51:45 +0000 (15:51 -0700)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 27 Sep 2016 16:12:14 +0000 (09:12 -0700)
The ARM ScanMem() in BaseMemoryLibOptDxe contains code from the open
source cortex-strings library, and inherited a bug from it where the
conditional execution of a sequence of instructions is erroneously
made dependent on the same condition. Since the final 'addeq' is
supposed to be dependent on the preceding 'tsteq' instruction, they
cannot be part of the same IT block.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdePkg/Library/BaseMemoryLibOptDxe/Arm/ScanMem.S

index dc0e74e8657c49066f620248e3e3beaaae03c1e5..1c269547b07263a93047c32924af1109c8d4b417 100644 (file)
@@ -134,11 +134,12 @@ ASM_PFX(InternalMemScanMem8):
     bne     61f\r
     adds    r0, r0, #1\r
     tst     r5, #CHARTSTMASK(1)     // 2nd character\r
-    ittt    eq\r
-    addeq   r0, r0 ,#1\r
-    tsteq   r5, #(3 << 15)          // 2nd & 3rd character\r
+    bne     61f\r
+    add   r0, r0 ,#1\r
+    tst     r5, #(3 << 15)          // 2nd & 3rd character\r
     // If not the 3rd must be the last one\r
-    addeq   r0, r0, #1\r
+    it      eq\r
+    addeq.n r0, r0, #1\r
 \r
 61:\r
     pop     {r4-r7}\r