Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp33367pxk; Tue, 15 Sep 2020 16:58:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpL2a+1b7YynXuMzGtFewHZcAuxkgavWniwblDGhHHUegI9EyFAzJow0Okt88+VTzaAqXu X-Received: by 2002:a17:906:270f:: with SMTP id z15mr11803936ejc.6.1600214323235; Tue, 15 Sep 2020 16:58:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600214323; cv=none; d=google.com; s=arc-20160816; b=NnNgaL+68e3Lg8wsm3ugjvq7TeF/RURRaiWMTHCvWjZen7SmkSCiXarryo2Ezwaxuo 8ptSISAr5DS9HUcWdTg0RuW4DasWH0FeF7C17boxu5fcob52YhdtyTC5s90bF0G7dt1Y 84xnkgZ1WDc5T2LQLIadACqRi1R5FBfkA/yrbGrg65qt+FDdBysIMNrhAnSqudr6A4Sp l9poIMmObPJ/LaR5O0jH9Y10HLfiNXy60Hb38mplBRNSHHuWz1SLYhve5X6bdRZkjlVG 0lRnvkVkgwh5/pMmJ/QQb0Qd2ek2Z+jkJMnVoLeDNqJyjmsY/Sb14pwwX/7SPyow0OOv yJzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Sn/Sypno4GfL9IE1y53yEPFfiB756BHa96VhDjyiPXk=; b=M0gHFnPMoyyhGpyQofNYRjiq9lrK9BEa5w9pqR29fb308y/lFAKBP8HScPSvRDglf5 TJx1BKfAJN76a5jfYvySA4QQspPnLxayTJca8DR3Gv2CMIsdzJgp7M53vmEaPxo2XsCM APvvWvE/R4flD1gxsDZljCCKE+NrbQqA1DUzDvM0Eb1zzbDZffNTgsHwUa8au1QV3WZ9 HhnVOyivTofiDme0yu4v20ZeVTqN0He1YBMXz2XzLW3C5+HKqhoAxHO13DzUNj8va+zD A5pJJvD6nCnm3abyqL+gMcJ/C3dyscbbCdRlZ1YgPGRu+jT1oawK15FksAlCTM5EOuDS DbPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=csWN6xgF; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gs20si10629952ejb.230.2020.09.15.16.58.11; Tue, 15 Sep 2020 16:58:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=csWN6xgF; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727050AbgIOX4D (ORCPT + 99 others); Tue, 15 Sep 2020 19:56:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727093AbgIOXzx (ORCPT ); Tue, 15 Sep 2020 19:55:53 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07B16C06174A for ; Tue, 15 Sep 2020 16:55:53 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id j7so2180331plk.11 for ; Tue, 15 Sep 2020 16:55:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Sn/Sypno4GfL9IE1y53yEPFfiB756BHa96VhDjyiPXk=; b=csWN6xgFG/5PPRlKG40yGIAH/n/GescweWDsJt+YigcCg1vDDxcG4DBMhTwwQJbr7T 311O16kFBNRT074TyaKKDHaOxl9XBFcl/ekNERQ5RLlyGxW3OHstpLKBsVT6UtLxK8RA E7iSgdONClHUnEeeMpbMNbJRxFbLks13UPd7D602D0GPE0d02GtifYP8g3y4/PxgQ9jb 7L2MCfV2qaQc7DLo56bhC5PzlgjVE8CVUZsS+EbPdUjK9Gyh7IdK/rd9FKfwG5MhESSv 6QTKpk74sQxwcFaZd0Djyo3wdNUVR8hKLdMcdJr0i27kG/dxfwFoLZEooYdPJ//aF3l3 vg/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Sn/Sypno4GfL9IE1y53yEPFfiB756BHa96VhDjyiPXk=; b=HweWbBNeCgqhjdFOthoxx/HgVFXq6ueyELumeJ2XmiJQo2gvaxjXpXJbkM1l/ryRXm mgU6SKbLb+5vD4RfThbgIzomrO92GdkYTovWBnyo6N79I5T593N1QEgafvqzdNlwPhnI 2tGo3Qycfm4HdHGpqWFP2cKoX7oo+JQmkUZfqFQVAJYATrL0hocD+Yg3iDvExQNeqi3K NJmzhQNr/bIM12ZGiLnt3sabUelnq5IuD1BtceLaEtEEJX2sVWXoi0Vz2BbdJzf0k39K CNznKz/NFz9RkYyIwZi8j9eE4RzCc3wcGavma3yg/eHRw5p9WL4XuAhFJKbhzCVjUtni GPPw== X-Gm-Message-State: AOAM531sfU1VZb+xTykt48JZQB7GbpLaF8jWtesWSk9IGIWDS4u28Pn/ qKwfgEdQsIq+Agsu2SxAi3oHuxsTJCw2IYgwtCOGww== X-Received: by 2002:a17:902:a504:b029:d1:e5e7:bdd8 with SMTP id s4-20020a170902a504b02900d1e5e7bdd8mr3735678plq.56.1600214152341; Tue, 15 Sep 2020 16:55:52 -0700 (PDT) MIME-Version: 1.0 References: <20200915094619.32548-1-ardb@kernel.org> In-Reply-To: From: Nick Desaulniers Date: Tue, 15 Sep 2020 16:55:40 -0700 Message-ID: Subject: Re: [PATCH] crypto: arm/sha256-neon - avoid ADRL pseudo instruction To: Ard Biesheuvel Cc: "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , Herbert Xu , Stefan Agner , Peter Smith , Jian Cai , clang-built-linux Content-Type: text/plain; charset="UTF-8" Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Tue, Sep 15, 2020 at 2:32 PM Ard Biesheuvel wrote: > > On Tue, 15 Sep 2020 at 21:50, Nick Desaulniers wrote: > > > > On Tue, Sep 15, 2020 at 2:46 AM Ard Biesheuvel wrote: > > > > > > The ADRL pseudo instruction is not an architectural construct, but a > > > convenience macro that was supported by the ARM proprietary assembler > > > and adopted by binutils GAS as well, but only when assembling in 32-bit > > > ARM mode. Therefore, it can only be used in assembler code that is known > > > to assemble in ARM mode only, but as it turns out, the Clang assembler > > > does not implement ADRL at all, and so it is better to get rid of it > > > entirely. > > > > > > So replace the ADRL instruction with a ADR instruction that refers to > > > a nearer symbol, and apply the delta explicitly using an additional > > > instruction. > > > > > > Cc: Nick Desaulniers > > > Cc: Stefan Agner > > > Cc: Peter Smith > > > Signed-off-by: Ard Biesheuvel > > > --- > > > I will leave it to the Clang folks to decide whether this needs to be > > > backported and how far, but a Cc stable seems reasonable here. > > > > > > arch/arm/crypto/sha256-armv4.pl | 4 ++-- > > > arch/arm/crypto/sha256-core.S_shipped | 4 ++-- > > > 2 files changed, 4 insertions(+), 4 deletions(-) > > > > > > diff --git a/arch/arm/crypto/sha256-armv4.pl b/arch/arm/crypto/sha256-armv4.pl > > > index 9f96ff48e4a8..8aeb2e82f915 100644 > > > --- a/arch/arm/crypto/sha256-armv4.pl > > > +++ b/arch/arm/crypto/sha256-armv4.pl > > > @@ -175,7 +175,6 @@ $code=<<___; > > > #else > > > .syntax unified > > > # ifdef __thumb2__ > > > -# define adrl adr > > > .thumb > > > # else > > > .code 32 > > > @@ -471,7 +470,8 @@ sha256_block_data_order_neon: > > > stmdb sp!,{r4-r12,lr} > > > > > > sub $H,sp,#16*4+16 > > > - adrl $Ktbl,K256 > > > + adr $Ktbl,.Lsha256_block_data_order > > > + add $Ktbl,$Ktbl,#K256-.Lsha256_block_data_order > > > bic $H,$H,#15 @ align for 128-bit stores > > > mov $t2,sp > > > mov sp,$H @ alloca > > > diff --git a/arch/arm/crypto/sha256-core.S_shipped b/arch/arm/crypto/sha256-core.S_shipped > > > index ea04b2ab0c33..1861c4e8a5ba 100644 > > > --- a/arch/arm/crypto/sha256-core.S_shipped > > > +++ b/arch/arm/crypto/sha256-core.S_shipped > > > @@ -56,7 +56,6 @@ > > > #else > > > .syntax unified > > > # ifdef __thumb2__ > > > -# define adrl adr > > > .thumb > > > # else > > > .code 32 > > > @@ -1885,7 +1884,8 @@ sha256_block_data_order_neon: > > > stmdb sp!,{r4-r12,lr} > > > > > > sub r11,sp,#16*4+16 > > > - adrl r14,K256 > > > + adr r14,.Lsha256_block_data_order > > > + add r14,r14,#K256-.Lsha256_block_data_order > > > > Hi Ard, > > Thanks for the patch. With this patch applied: > > > > $ ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make LLVM=1 LLVM_IAS=1 > > -j71 defconfig > > $ ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make LLVM=1 LLVM_IAS=1 -j71 > > ... > > arch/arm/crypto/sha256-core.S:2038:2: error: out of range immediate fixup value > > add r14,r14,#K256-.Lsha256_block_data_order > > ^ > > > > :( > > > > Strange. Could you change it to > > sub r14,r14,#.Lsha256_block_data_order-K256 > > and try again? > > If that does work, it means the Clang assembler does not update the > instruction type for negative addends (add to sub in this case), which > would be unfortunate, since it would be another functionality gap. Works. Can you describe the expected functionality a bit more, so we can come up with a bug report/test case? (an `add` with a negative operand should be converted to a `sub` with a positive operand, IIUC?) Also, there's a similar adrl in arch/arm/crypto/sha512-core.S, err, is that generated? -- Thanks, ~Nick Desaulniers