]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg/BaseMemoryLibOptDxe ARM: fix arithmetic bugs in CompareMem()
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Tue, 13 Sep 2016 17:22:33 +0000 (18:22 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 21 Sep 2016 07:42:48 +0000 (08:42 +0100)
Fix two bugs:
- Erroneous shift of 2 in a bytes to bits conversion.
- Use reverse subtract rather than negate for value that is subsequently
  used as operand #2 in a shift operation.

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/CompareMem.S

index 951d15777a38d7c41a4f15be754b4fc771ff3b32..3aadebace30f1b18ea1dd982d546c3f826b0d019 100644 (file)
@@ -110,9 +110,9 @@ ASM_PFX(InternalMemCompareMem):
     bic     src1, src1, #3\r
     bic     src2, src2, #3\r
     add     limit, limit, tmp1          // Adjust the limit for the extra.\r
     bic     src1, src1, #3\r
     bic     src2, src2, #3\r
     add     limit, limit, tmp1          // Adjust the limit for the extra.\r
-    lsl     tmp1, tmp1, #2              // Bytes beyond alignment -> bits.\r
+    lsl     tmp1, tmp1, #3              // Bytes beyond alignment -> bits.\r
     ldr     data1, [src1], #4\r
     ldr     data1, [src1], #4\r
-    neg     tmp1, tmp1                  // Bits to alignment -32.\r
+    rsb     tmp1, tmp1, #32             // Bits to alignment -32.\r
     ldr     data2, [src2], #4\r
     mov     tmp2, #~0\r
 \r
     ldr     data2, [src2], #4\r
     mov     tmp2, #~0\r
 \r