From patchwork Fri Mar 27 16:04:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 46428 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E45C621585 for ; Fri, 27 Mar 2015 16:05:43 +0000 (UTC) Received: by lahp7 with SMTP id p7sf13350580lah.0 for ; Fri, 27 Mar 2015 09:05:42 -0700 (PDT) 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=Ni9Yqo/23LhloVo7PgZ3JCDBQn+bmzdY/fxwqPE3sQ4=; b=iyfC2sHC5WNX4iH/+DYch+7gP24sR8xJ4fP23yCKCYReMHN6ekqIz/cnNiT2XoMCi9 YdbmFtblfK0kiyNye4e67Bqrtfbd7/vkLxQGDyL5QEit5Ff0yZpvgC0DNKh5CL2texlq KwpyPr6vobKG8C8uycU52eoxdqBAdK3oyxu2xs80nV01Ue7aHkVIT9gIN8leR/l8VPGl LLjF8Vku6bRKVArKrOjtPJ4GpMzxjzG6n1YZ8LuloiUE6ei93tHSCfokmvXV3ziFVERq iOlyd75INo40jABv0HzrdfGB+um8HZQwJNyuMtY8E62lvxjFF5+tQfYsMycFvJEVnYzb MNGg== X-Gm-Message-State: ALoCoQm8QBHexae/v8dRkRckMnh69vDrlRY3xdTlfUGakXzLqd9gwaLQPqFlJBegHuqqBYfp4TAp X-Received: by 10.180.126.37 with SMTP id mv5mr3641286wib.3.1427472342881; Fri, 27 Mar 2015 09:05:42 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.181.137 with SMTP id dw9ls364723lac.85.gmail; Fri, 27 Mar 2015 09:05:42 -0700 (PDT) X-Received: by 10.152.26.136 with SMTP id l8mr18396575lag.109.1427472342528; Fri, 27 Mar 2015 09:05:42 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id f7si1679628lbs.25.2015.03.27.09.05.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Mar 2015 09:05:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lboc7 with SMTP id c7so10096099lbo.1 for ; Fri, 27 Mar 2015 09:05:42 -0700 (PDT) X-Received: by 10.112.201.231 with SMTP id kd7mr18705520lbc.35.1427472342289; Fri, 27 Mar 2015 09:05:42 -0700 (PDT) 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.57.201 with SMTP id k9csp1354270lbq; Fri, 27 Mar 2015 09:05:41 -0700 (PDT) X-Received: by 10.50.43.227 with SMTP id z3mr10217571igl.6.1427472340577; Fri, 27 Mar 2015 09:05:40 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id gb8si2108873igd.61.2015.03.27.09.05.10 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 27 Mar 2015 09:05:40 -0700 (PDT) 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-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YbWkk-0004Dz-JI; Fri, 27 Mar 2015 16:04:58 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1YbWkj-0004Ds-Br for edk2-devel@lists.sourceforge.net; Fri, 27 Mar 2015 16:04:57 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of linaro.org designates 74.125.82.50 as permitted sender) client-ip=74.125.82.50; envelope-from=ard.biesheuvel@linaro.org; helo=mail-wg0-f50.google.com; Received: from mail-wg0-f50.google.com ([74.125.82.50]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1YbWki-0004vz-9J for edk2-devel@lists.sourceforge.net; Fri, 27 Mar 2015 16:04:57 +0000 Received: by wgbgs4 with SMTP id gs4so13173717wgb.0 for ; Fri, 27 Mar 2015 09:04:50 -0700 (PDT) X-Received: by 10.194.104.99 with SMTP id gd3mr37677348wjb.114.1427472290190; Fri, 27 Mar 2015 09:04:50 -0700 (PDT) Received: from ards-macbook-pro.local ([90.174.5.29]) by mx.google.com with ESMTPSA id pm6sm4015898wic.20.2015.03.27.09.04.48 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Mar 2015 09:04:49 -0700 (PDT) From: Ard Biesheuvel To: lersek@redhat.com, edk2-devel@lists.sourceforge.net Date: Fri, 27 Mar 2015 17:04:45 +0100 Message-Id: <1427472286-20051-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: 1YbWki-0004vz-9J Subject: [edk2] [PATCH 1/2] 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.217.177 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 Reviewed-by: Ronald Cron 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