From patchwork Fri Mar 27 10:42:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Polyakov X-Patchwork-Id: 6105001 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B63E59F2A9 for ; Fri, 27 Mar 2015 10:50:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1A95F203B7 for ; Fri, 27 Mar 2015 10:50:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5EFFE203A4 for ; Fri, 27 Mar 2015 10:50:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752574AbbC0KuP (ORCPT ); Fri, 27 Mar 2015 06:50:15 -0400 Received: from mta.openssl.org ([194.97.150.230]:59086 "EHLO mta.openssl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752522AbbC0KuN (ORCPT ); Fri, 27 Mar 2015 06:50:13 -0400 X-Greylist: delayed 436 seconds by postgrey-1.27 at vger.kernel.org; Fri, 27 Mar 2015 06:50:13 EDT Received: from [127.0.0.1] (localhost [127.0.0.1]) by mta.openssl.org (Postfix) with ESMTP id 1BFE32016A; Fri, 27 Mar 2015 10:42:55 +0000 (UTC) Message-ID: <5515342F.6010703@openssl.org> Date: Fri, 27 Mar 2015 11:42:55 +0100 From: Andy Polyakov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Ard Biesheuvel , Jean-Christophe PLAGNIOL-VILLARD CC: Sami Tolvanen , "linux-arm-kernel@lists.infradead.org" , "linux-crypto@vger.kernel.org" , Herbert Xu , "David S. Miller" Subject: Re: [PATCHv2] arm: crypto: Add optimized SHA-256/224 References: <20150316154835.GA31336@google.com> <20150323135009.GB820@google.com> <20150324122702.GJ14457@ns203013.ovh.net> <20150324130511.GK14457@ns203013.ovh.net> In-Reply-To: Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, T_TVD_MIME_EPI, 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 >> Could you share the error log please? > > OK, I spotted one issue with this code: > > arch/arm/crypto/sha256-core.S: Assembler messages: > arch/arm/crypto/sha256-core.S:1847: Error: invalid constant (ffffefb0) > after fixup > > This is caused by the fact that, when building the integer-only code > for an older architecture, the conditional compilation produces a > slightly bigger preceding function, and the symbol K256 is out of > range for the adr instruction. > > @Jean-Christophe: is that the same problem that you hit? > > @Andy: I propose we do something similar as in the bsaes code: > > #ifdef __thumb__ > #define adrl adr > #endif > > and replace the offending line with > > adrl r14,K256 Sorry about delay. Yes, that would do. I did test all combinations, but all "my" combinations, i.e. without __KERNEL__ defined :-( And without __KERNEL__ there are few extra instructions in integer-only subroutine that "push" instruction in question code toward higher address, so that constant was ffffefc0, which can be encoded. Anyway, I've chosen to add that #define next to .thumb directive. See attached. Ard, you have mentioned that you've verified it on big-endian, but I've spotted little-endian dependency (see #ifndef __ARMEB__ in attached). I guess that it worked for you either because it was NEON that was tested (it does work as is) or __LINUX_ARM_ARCH__ was less than 7 (in which case it uses endian-neutral byte-by-byte data load). Can you confirm either? diff --git a/crypto/sha/asm/sha256-armv4.pl b/crypto/sha/asm/sha256-armv4.pl index 4fee74d..fac0533 100644 --- a/crypto/sha/asm/sha256-armv4.pl +++ b/crypto/sha/asm/sha256-armv4.pl @@ -73,7 +73,9 @@ $code.=<<___ if ($i<16); eor $t0,$e,$e,ror#`$Sigma1[1]-$Sigma1[0]` add $a,$a,$t2 @ h+=Maj(a,b,c) from the past eor $t0,$t0,$e,ror#`$Sigma1[2]-$Sigma1[0]` @ Sigma1(e) +# ifndef __ARMEB__ rev $t1,$t1 +# endif #else @ ldrb $t1,[$inp,#3] @ $i add $a,$a,$t2 @ h+=Maj(a,b,c) from the past @@ -166,6 +168,7 @@ $code=<<___; #else .syntax unified # ifdef __thumb2__ +# define adrl adr .thumb # else .code 32 @@ -460,7 +463,7 @@ sha256_block_data_order_neon: stmdb sp!,{r4-r12,lr} sub $H,sp,#16*4+16 - adr $Ktbl,K256 + adrl $Ktbl,K256 bic $H,$H,#15 @ align for 128-bit stores mov $t2,sp mov sp,$H @ alloca