From patchwork Wed Mar 4 14:29:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 45419 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D3CCF21416 for ; Wed, 4 Mar 2015 14:31:06 +0000 (UTC) Received: by wiwl15 with SMTP id l15sf20507870wiw.0 for ; Wed, 04 Mar 2015 06:31:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:reply-to:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=lks03NAUMzYs4nBr6esVI7IfX9ZZLP8k2jfuXvaDmnw=; b=Oi1lp52dmodEYbopUVGIXdYbamwlZFFrk221q22JPxoHbgbT1Pw8yO+qAisyhBXOtl U3LDmiOUUYVh5x9klPe328hdzxe3zSuu2a/VKAUHSKg1WCtcZ3q5TEaeL7Z/EA/iIQI9 E2/1lA5tex9LL6BbKwmZNbjpvfFxmhZNJ+eBBxvo/2oul8Lup56ndH4ZZQTTP07h/0z8 FGhHiro/nzAzyV8pqT/9rQFUS3Bt+PDefAWrBDWoxjBXGs541GNzL6IoduzF8PrhxyZ1 jjAC+apzfM2JkzDGtCIxKbL+A6WGSG5Ne+8p4WArMgxH5kffPY7IfA0P26T0k1GNScXx /gSg== X-Gm-Message-State: ALoCoQnm9uiK9EgcjuarEDKkHTTQew6kmzeCtBgaWKMUMItVQ02Pz11WRMaLCGAMhHyCpV8wO8c6 X-Received: by 10.180.11.34 with SMTP id n2mr1179050wib.2.1425479465955; Wed, 04 Mar 2015 06:31:05 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.48 with SMTP id t16ls171859lal.55.gmail; Wed, 04 Mar 2015 06:31:05 -0800 (PST) X-Received: by 10.112.172.131 with SMTP id bc3mr3620586lbc.79.1425479465751; Wed, 04 Mar 2015 06:31:05 -0800 (PST) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id cv3si2584691lbb.138.2015.03.04.06.31.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Mar 2015 06:31:05 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by labge10 with SMTP id ge10so44804496lab.12 for ; Wed, 04 Mar 2015 06:31:05 -0800 (PST) X-Received: by 10.112.181.41 with SMTP id dt9mr3849281lbc.56.1425479465636; Wed, 04 Mar 2015 06:31:05 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp1255479lbj; Wed, 4 Mar 2015 06:31:04 -0800 (PST) X-Received: by 10.202.69.2 with SMTP id s2mr2891332oia.107.1425479464160; Wed, 04 Mar 2015 06:31:04 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id o9si5227933iga.7.2015.03.04.06.31.03 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 04 Mar 2015 06:31:04 -0800 (PST) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YTAK2-0002Sf-Fn; Wed, 04 Mar 2015 14:30:50 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YTAK0-0002SY-Ed for edk2-devel@lists.sourceforge.net; Wed, 04 Mar 2015 14:30:48 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of linaro.org designates 74.125.82.176 as permitted sender) client-ip=74.125.82.176; envelope-from=ard.biesheuvel@linaro.org; helo=mail-we0-f176.google.com; Received: from mail-we0-f176.google.com ([74.125.82.176]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YTAJz-00033q-Fp for edk2-devel@lists.sourceforge.net; Wed, 04 Mar 2015 14:30:48 +0000 Received: by wesq59 with SMTP id q59so46773023wes.1 for ; Wed, 04 Mar 2015 06:30:41 -0800 (PST) X-Received: by 10.194.216.34 with SMTP id on2mr9105771wjc.24.1425479441419; Wed, 04 Mar 2015 06:30:41 -0800 (PST) Received: from ards-macbook-pro.local ([213.143.61.51]) by mx.google.com with ESMTPSA id h11sm25441448wic.14.2015.03.04.06.30.38 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 04 Mar 2015 06:30:40 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.sourceforge.net, liming.gao@intel.com Date: Wed, 4 Mar 2015 15:29:56 +0100 Message-Id: <1425479396-26438-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1YTAJz-00033q-Fp Subject: [edk2] [PATCH] MdePkg: fix ARM version of InternalMathSwapBytes64 () X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 The ARM asm implementation of InternalMathSwapBytes64 () does interesting things if bit 7 of operand r1 (upper 32 bits of the input value) is set. After the recursive swap, bit 7 ends up in the sign bit position, after which it is right shifted with sign extension, and or'ed with the upper half of the output value. This means SwapBytes64 (0x00000080_00000000) returns an incorrect value of 0xFFFFFFFF_80000000. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- MdePkg/Library/BaseLib/Arm/Math64.S | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) \ No newline at end of file diff --git a/MdePkg/Library/BaseLib/Arm/Math64.S b/MdePkg/Library/BaseLib/Arm/Math64.S index 4d975739207a..e2512621fe1a 100755 --- a/MdePkg/Library/BaseLib/Arm/Math64.S +++ b/MdePkg/Library/BaseLib/Arm/Math64.S @@ -256,22 +256,14 @@ L30: GCC_ASM_EXPORT(InternalMathSwapBytes64) ASM_PFX(InternalMathSwapBytes64): - @ args = 0, pretend = 0, frame = 0 - @ frame_needed = 1, uses_anonymous_args = 0 - stmfd sp!, {r4, r5, r6, r7, lr} - add r7, sp, #12 + stmfd sp!, {r4, r5, r7, lr} mov r5, r1 bl ASM_PFX(SwapBytes32) - mov r6, r0 + mov r4, r0 mov r0, r5 bl ASM_PFX(SwapBytes32) - mov r4, r6 - mov r5, r4, asr #31 - mov r2, #0 - mov r1, r0, asr #31 - orr r0, r0, r2 - orr r1, r1, r4 - ldmfd sp!, {r4, r5, r6, r7, pc} + mov r1, r4 + ldmfd sp!, {r4, r5, r7, pc} ASM_FUNCTION_REMOVE_IF_UNREFERENCED