From patchwork Mon Sep 19 08:13:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 76515 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp837954qgf; Mon, 19 Sep 2016 01:14:02 -0700 (PDT) X-Received: by 10.98.22.21 with SMTP id 21mr15150805pfw.4.1474272842696; Mon, 19 Sep 2016 01:14:02 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id j1si27783674pac.116.2016.09.19.01.14.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Sep 2016 01:14:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; 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 198.145.21.10 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 32F1C1A1E2B; Mon, 19 Sep 2016 01:14:02 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wm0-x231.google.com (mail-wm0-x231.google.com [IPv6:2a00:1450:400c:c09::231]) (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 64BD41A1E0E for ; Mon, 19 Sep 2016 01:14:00 -0700 (PDT) Received: by mail-wm0-x231.google.com with SMTP id w84so62423027wmg.1 for ; Mon, 19 Sep 2016 01:14:00 -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:in-reply-to:references; bh=0S3/uJ6BMUVZj83R2J//oRptr1J18sEMvbDfl2rBXvE=; b=DIOJX34jrbSUxYPnPJZeyNHOKZckoyhYTYYz3HdKlE9IFtPFmhPdCY9CebBdZGjgD+ RbhRc0+QKZjX1CII7Xp5pfH2GEzVmEFAsn4jrLRpf1uBdCnjgDFZDoGWZbMwmgqFI5qg aovcl9pBkICiWiIHHGp/cHBbCZf4F6JV7sdLc= 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:in-reply-to :references; bh=0S3/uJ6BMUVZj83R2J//oRptr1J18sEMvbDfl2rBXvE=; b=f6HIYjzcNKnVOOU2U7PgcU87TYilzAyqEpdnWSZhnTYlIiugHm2625BAAwUrN8CPYn JFDgR012J7oNoWdjOwOy5WAJX0NB8WiNrRQ/8djPlBlc+xKJmBVCbCzltx90iSbNwuiX klVnDrpXdbfuWdBZAwmDMxkzj+qyt2w+MXcPsElBNtVGsXizdPPcHBtflNM9bGQ9nDkP FTjIE3cMYFraArys/x3JwlmV85H3N4Ar+YH/DAtm4D3cu9m1gJKRZ7v6ohPCnbD9pEDK 98jrY53se4o6FUv5IYDcuFJLtmubvsXrZUV39du7HrG98Y9nbxG2f4647JuQ2/dtDV8p hv6A== X-Gm-Message-State: AE9vXwMiJBk4Cs0nePlsp6rWnN2BGN58OWDo6kFQ3ZRGQzBWadFOgpW0Xh8WVPxsqCgiR64u X-Received: by 10.28.67.2 with SMTP id q2mr8858874wma.123.1474272838873; Mon, 19 Sep 2016 01:13:58 -0700 (PDT) Received: from localhost.localdomain ([160.161.71.58]) by smtp.gmail.com with ESMTPSA id lj2sm21679784wjc.38.2016.09.19.01.13.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Sep 2016 01:13:58 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, liming.gao@intel.com Date: Mon, 19 Sep 2016 09:13:49 +0100 Message-Id: <1474272831-20840-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474272831-20840-1-git-send-email-ard.biesheuvel@linaro.org> References: <1474272831-20840-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 1/3] 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: vishalo@qti.qualcomm.com, 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