From 60fe5e8a9c8deafcc302c715a91947d75d38e544 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Tue, 13 Sep 2016 18:22:33 +0100 Subject: MdePkg/BaseMemoryLibOptDxe ARM: fix arithmetic bugs in CompareMem() 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 Reviewed-by: Liming Gao --- MdePkg/Library/BaseMemoryLibOptDxe/Arm/CompareMem.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'MdePkg') diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/Arm/CompareMem.S b/MdePkg/Library/BaseMemoryLibOptDxe/Arm/CompareMem.S index 951d15777a..3aadebace3 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 -- cgit v1.2.3