From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-x235.google.com (mail-pf0-x235.google.com [IPv6:2607:f8b0:400e:c00::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4A7511A1E0B for ; Mon, 26 Sep 2016 15:59:20 -0700 (PDT) Received: by mail-pf0-x235.google.com with SMTP id s13so35909326pfd.2 for ; Mon, 26 Sep 2016 15:59:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=Jy3lMcDV5K5dOk8gnP8/mtbbtDRwHlOt5kvcWpMQJ44=; b=hQKOcrDaHmcWWbw2Jc8mRyVVWRDmgThnpTGLA376J3nCiD1AgfWLARHRfUExVsMxxm JO5QHy8wncvuR65V+fIKYR/gFTQOFnZtofJ5/PhhJtGO5F2jt3h/7pby18EwcG3y3Hdb 7U87usMl7b9pgGFBfxdwOXY+hqy4MaPQFBuxE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Jy3lMcDV5K5dOk8gnP8/mtbbtDRwHlOt5kvcWpMQJ44=; b=UjKwuQtJ8Auwd46eu0WoisApRytjnz/RnL4Aa/wKwAgJaudcAScE1Ba56MDlZyt2IV +HuxIfVFLYfmYpZB0KiPvYMVMwDUr+tGvpyMgMpEJtYcjLhS7t4LdIs01Zl3BfiuPy5A OfqbyERrFiWWk3mHju0xFFCez9kolHK+/vVgj+cehXnZCJTPwUkw7vNIKYLXOGMn8yoA 52sQqNNH1CNXCZhBGkKhXUJ0TQetAdBagaYVtG9xIV3dfUpgXpVpm0V9UV/23Z1nj7L4 D1YGpmtlh3o2XuYkQkDMv65qn5NCtCtqjIuk5+7T7+QBQwSRHMspun75cVpKcwlfQ+da 23cQ== X-Gm-Message-State: AE9vXwPYczdKm2RufO0V2rSlRHqz5Hx6m3yZjfervd1qkAd21TzU/JvOgccwHE0wZjxv75Ob X-Received: by 10.98.59.146 with SMTP id w18mr41728693pfj.153.1474930759948; Mon, 26 Sep 2016 15:59:19 -0700 (PDT) Received: from localhost.localdomain ([67.238.99.186]) by smtp.gmail.com with ESMTPSA id d2sm27356238pfe.94.2016.09.26.15.59.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Sep 2016 15:59:18 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, liming.gao@intel.com Cc: leif.lindholm@linaro.org, Ard Biesheuvel Date: Mon, 26 Sep 2016 15:59:15 -0700 Message-Id: <1474930756-6536-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [PATCH 1/2] MdePkg/BaseMemoryLibOptDxe ARM: fix Thumb-2 bug in ScanMem() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Sep 2016 22:59:20 -0000 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 --- 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