From patchwork Tue Sep 13 17:26:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 76104 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp1471036qgf; Tue, 13 Sep 2016 10:26:57 -0700 (PDT) X-Received: by 10.66.27.44 with SMTP id q12mr3388646pag.58.1473787617657; Tue, 13 Sep 2016 10:26:57 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id lt14si28034480pab.179.2016.09.13.10.26.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Sep 2016 10:26:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E7DE91A1E45; Tue, 13 Sep 2016 10:26:56 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org 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 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: [edk2] [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: , Cc: leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel 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