From patchwork Tue Sep 17 16:15:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 2903151 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6ED109F1BF for ; Tue, 17 Sep 2013 16:16:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5E7C12035E for ; Tue, 17 Sep 2013 16:16:29 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1969E20351 for ; Tue, 17 Sep 2013 16:16:28 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VLxwr-0006Ks-G1; Tue, 17 Sep 2013 16:16:21 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VLxwp-0001eV-Bw; Tue, 17 Sep 2013 16:16:19 +0000 Received: from mail-ea0-f180.google.com ([209.85.215.180]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VLxwm-0001cK-Gp for linux-arm-kernel@lists.infradead.org; Tue, 17 Sep 2013 16:16:17 +0000 Received: by mail-ea0-f180.google.com with SMTP id h10so2823699eaj.39 for ; Tue, 17 Sep 2013 09:15:53 -0700 (PDT) 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=TDQEHHxiITDQMW2g07Byzwr5a+UhL0gl1vUw34PL5BM=; b=IrTbJRyXmAXfvxnGyR6n4nnztu2NfvhCwa4KBP4V29CNxYOY49vB7KoUgNE6+yp5pQ qGnfYBizSwX+Ge1gIj6FXMkDqXrN2+Q/IrjSBL2TMPVpaHoCVFswp1yK6mWMYPWdpiSh AvuTEkdkEgEFpdsYLufgiGimAxd7ZMpr0hR1JA5rfO+a59uvgsIoFRKa5XWbt0byIU5w tFk+91VMh0qEr9cP38fpbwKUBFa3kU0cj2Ek72TZBtYdJFuE6MhuEcu3MCp2io1zE4oi Xlm/81dAviDPndPQeyEbOfpNVXYVAci2UYSvYpvc07YNOscESG/IX5svUd/rNIm8SMbd SY5A== X-Gm-Message-State: ALoCoQknPxfWGvgiGwtN0SqBtlt1XMsRMgybNLWvjtZoPCzVxJJE5hXxSAgMSnC9xgJ8MW79fLq2 X-Received: by 10.15.43.13 with SMTP id w13mr52093210eev.37.1379434553347; Tue, 17 Sep 2013 09:15:53 -0700 (PDT) Received: from ards-mac-mini.local (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by mx.google.com with ESMTPSA id h52sm52185475eez.3.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 17 Sep 2013 09:15:52 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] ARM: fix Thumb-2 bug in AES assembler code Date: Tue, 17 Sep 2013 18:15:19 +0200 Message-Id: <1379434519-23299-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.1.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130917_121616_673097_DF2CB97B X-CRM114-Status: UNSURE ( 9.16 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.6 (--) Cc: Ard Biesheuvel , dave.martin@arm.com, nico@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Patch 638591c enabled building the AES assembler code in Thumb2 mode. However, this code uses arithmetic involving PC rather than adr{l} instructions to generate PC-relative references to the lookup tables, and this needs to take into account the different PC offset when running in Thumb mode. Signed-off-by: Ard Biesheuvel --- This needs cc to stable for 3.10/3.11 as well. arch/arm/crypto/aes-armv4.S | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/arm/crypto/aes-armv4.S b/arch/arm/crypto/aes-armv4.S index 19d6cd6..33c30ab 100644 --- a/arch/arm/crypto/aes-armv4.S +++ b/arch/arm/crypto/aes-armv4.S @@ -148,7 +148,8 @@ AES_Te: @ const AES_KEY *key) { .align 5 ENTRY(AES_encrypt) - sub r3,pc,#8 @ AES_encrypt +ARM( sub r3,pc,#8 ) @ AES_encrypt +THUMB( sub r3,pc,#4 ) stmdb sp!,{r1,r4-r12,lr} mov r12,r0 @ inp mov r11,r2 @@ -381,7 +382,8 @@ _armv4_AES_encrypt: .align 5 ENTRY(private_AES_set_encrypt_key) _armv4_AES_set_encrypt_key: - sub r3,pc,#8 @ AES_set_encrypt_key +ARM( sub r3,pc,#8 ) @ AES_set_encrypt_key +THUMB( sub r3,pc,#4 ) teq r0,#0 moveq r0,#-1 beq .Labrt @@ -843,8 +845,9 @@ AES_Td: @ const AES_KEY *key) { .align 5 ENTRY(AES_decrypt) - sub r3,pc,#8 @ AES_decrypt - stmdb sp!,{r1,r4-r12,lr} +ARM( sub r3,pc,#8 ) @ AES_decrypt +THUMB( sub r3,pc,#4 ) + stmdb sp!,{r1,r4-r12,lr} mov r12,r0 @ inp mov r11,r2 sub r10,r3,#AES_decrypt-AES_Td @ Td