public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 1/2] MdePkg/BaseMemoryLibOptDxe ARM: fix arithmetic bugs in CompareMem()
@ 2016-09-13 17:26 Ard Biesheuvel
  0 siblings, 0 replies; only message in thread
From: Ard Biesheuvel @ 2016-09-13 17:26 UTC (permalink / raw)
  To: edk2-devel, liming.gao; +Cc: leif.lindholm, Ard Biesheuvel

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>
---
 MdePkg/Library/BaseMemoryLibOptDxe/Arm/CompareMem.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/Arm/CompareMem.S b/MdePkg/Library/BaseMemoryLibOptDxe/Arm/CompareMem.S
index 951d15777a38..3aadebace30f 100644
--- a/MdePkg/Library/BaseMemoryLibOptDxe/Arm/CompareMem.S
+++ b/MdePkg/Library/BaseMemoryLibOptDxe/Arm/CompareMem.S
@@ -110,9 +110,9 @@ ASM_PFX(InternalMemCompareMem):
     bic     src1, src1, #3
     bic     src2, src2, #3
     add     limit, limit, tmp1          // Adjust the limit for the extra.
-    lsl     tmp1, tmp1, #2              // Bytes beyond alignment -> bits.
+    lsl     tmp1, tmp1, #3              // Bytes beyond alignment -> bits.
     ldr     data1, [src1], #4
-    neg     tmp1, tmp1                  // Bits to alignment -32.
+    rsb     tmp1, tmp1, #32             // Bits to alignment -32.
     ldr     data2, [src2], #4
     mov     tmp2, #~0
 
-- 
2.7.4



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-09-13 17:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-13 17:26 [PATCH 1/2] MdePkg/BaseMemoryLibOptDxe ARM: fix arithmetic bugs in CompareMem() Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox