From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x22b.google.com (mail-wm0-x22b.google.com [IPv6:2a00:1450:400c:c09::22b]) (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 8BE461A1E43 for ; Tue, 13 Sep 2016 10:26:55 -0700 (PDT) Received: by mail-wm0-x22b.google.com with SMTP id 1so214086116wmz.1 for ; Tue, 13 Sep 2016 10:26:55 -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=0S3/uJ6BMUVZj83R2J//oRptr1J18sEMvbDfl2rBXvE=; b=i0/G23VoPSKkThokjg0zRyxYz5sjAJ9LvVpzQ2cdvxjAV7/Q16tEoe3Gb4ZTrFQCWp 9lbDpip7QLBaaSr6Dnxvk7HsB3ikTLDZfqqr1U4ZsQYV6shyuWiYvzhPkIkSD+J3a7kl ZWyWFZt957JVaAFvY4aq9BMuu2a1BS6McSwHs= 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=0S3/uJ6BMUVZj83R2J//oRptr1J18sEMvbDfl2rBXvE=; b=CUYiAMBmjbkIC//TAQZIAyu6JaAAzL9F7bUiA3SPe8phuL8LvbmbqBAjsKUbedxV5d e8vYHul9mPljVHzLLuXm1dHIyePaHQjrVe/iy7lTkh2t6GfrogBIY3ix+8MOyK4H2oRt bQtoqpSMqC9hcaYlCgZ+fZ8vCIgcGy2UUPxDaYSrYDQ0ksP92vnlgYirmBfFeS7hPOga BuMCOPKI6rYEJ2Fj2npQnakcDoohJol8PYFbvg7GvRMBQHtt+K38qiKMEXfHCttWZtAe 3MdJxVIaaH2H65y6il4poP3zq3wYF5OIxYLdubZLDYsQdVG7EnLgDDAlzbmkPrmr8rjG B8ig== X-Gm-Message-State: AE9vXwM6S2X+Oapc4MBBSMYeGZf/5Y1hMQ9AtHs4eOXv+iUYDiiQjAwIv/A2zVyAewgrn3/I X-Received: by 10.28.99.137 with SMTP id x131mr1917280wmb.64.1473787613453; Tue, 13 Sep 2016 10:26:53 -0700 (PDT) Received: from localhost.localdomain ([197.128.106.42]) by smtp.gmail.com with ESMTPSA id r194sm9822461wmf.22.2016.09.13.10.26.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Sep 2016 10:26:52 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, liming.gao@intel.com Cc: leif.lindholm@linaro.org, Ard Biesheuvel Date: Tue, 13 Sep 2016 18:26:41 +0100 Message-Id: <1473787601-26902-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [PATCH 1/2] MdePkg/BaseMemoryLibOptDxe ARM: fix arithmetic bugs in CompareMem() 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: Tue, 13 Sep 2016 17:26:56 -0000 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 --- 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