public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: edk2-devel@lists.01.org, liming.gao@intel.com
Cc: leif.lindholm@linaro.org, Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH 1/2] MdePkg/BaseMemoryLibOptDxe ARM: fix Thumb-2 bug in ScanMem()
Date: Mon, 26 Sep 2016 15:59:15 -0700	[thread overview]
Message-ID: <1474930756-6536-1-git-send-email-ard.biesheuvel@linaro.org> (raw)

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

diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/Arm/ScanMem.S b/MdePkg/Library/BaseMemoryLibOptDxe/Arm/ScanMem.S
index dc0e74e8657c..1c269547b072 100644
--- a/MdePkg/Library/BaseMemoryLibOptDxe/Arm/ScanMem.S
+++ b/MdePkg/Library/BaseMemoryLibOptDxe/Arm/ScanMem.S
@@ -134,11 +134,12 @@ ASM_PFX(InternalMemScanMem8):
     bne     61f
     adds    r0, r0, #1
     tst     r5, #CHARTSTMASK(1)     // 2nd character
-    ittt    eq
-    addeq   r0, r0 ,#1
-    tsteq   r5, #(3 << 15)          // 2nd & 3rd character
+    bne     61f
+    adds    r0, r0 ,#1
+    tst     r5, #(3 << 15)          // 2nd & 3rd character
     // If not the 3rd must be the last one
-    addeq   r0, r0, #1
+    it      eq
+    addeq.n r0, r0, #1
 
 61:
     pop     {r4-r7}
-- 
2.7.4



             reply	other threads:[~2016-09-26 22:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-26 22:59 Ard Biesheuvel [this message]
2016-09-26 22:59 ` [PATCH 2/2] MdePkg/BaseMemoryLibOptDxe: replace deprecated uses of IT blocks Ard Biesheuvel
2016-09-27  4:21 ` [PATCH 1/2] MdePkg/BaseMemoryLibOptDxe ARM: fix Thumb-2 bug in ScanMem() Gao, Liming

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1474930756-6536-1-git-send-email-ard.biesheuvel@linaro.org \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox