From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Cc: leif.lindholm@linaro.org, vishalo@qti.qualcomm.com, Ard Biesheuvel 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: [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: , X-List-Received-Date: Mon, 19 Sep 2016 08:14:00 -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