Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1147155pxu; Mon, 23 Nov 2020 12:53:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzGKijS2yeZdEQxsEmcbZjzZ1lJLEES4+IF+vpORrsCRAxh53Wh959XHycZeB9qvL+lv6wX X-Received: by 2002:a17:906:15cc:: with SMTP id l12mr1230304ejd.363.1606164808230; Mon, 23 Nov 2020 12:53:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606164808; cv=none; d=google.com; s=arc-20160816; b=F6aQUdMqvWqe9m0lmYOsZBKg2kxZm3+QZt8tznd+GNwiqFFW8ILQtEZ6qvpcpqkDgz azyFbkVVuwjQq/UjxmawOnhZIfGKxqJSsY8T1zioAFHFoebDYJtWRbhCwDOJRlG/1Mvo 2ocYsvTh2Zft6NYFSlSGz30GBG608NOATWX7gvJLwHaF2e4en/M/onO8NlinTgGWCvX2 Gu0+dTTSQVEn4+A0cT7dIJSfPDSrQIBfbrIDOx6SciXP8oyBMR5ZXnJhF2mrMYW2vWvU XwPgNG2cxiY6vizZ1ysT4V+T6X1R1kH5EkBtPqPMq1aqBRK7OAVZCJEj8iL5owmr9VAb darw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=aKKg6wsDaykJhzWuyANPFCAYRxtejbFckP15kDzwPrA=; b=N7gSnHCU/tJbSHjJuIHiym9mT7YD+Udb5s8K5iW22jLSaTQSrcX2SvTXH4ZHdf1/2a WzPv3POJFQqk/EZ3wIyP1x2Iv24Z4/COEJNABGG5hz34XbpKoTason35Qj8nl9dQzOKx al2axa45ObIup+UXizQnR+uB4oNCu5mr7CD9tmvTVQRHGfOKF+iDDMptX/b3K9uzgRg5 8Ea3Zlp2+kxuAo3UPpSJYl2WNV2WbZrRcjqWboXhDr6yNHZ/Pm0yTvxxdBAPVvfQZbpS 3/ILjor4GI1vpkSOJ3x9302vbD9viHxIWTVShJ/Yde4Ltb8S+NQiJXSzaprpIyb0LZM3 HTYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 21si8189946edx.390.2020.11.23.12.53.05; Mon, 23 Nov 2020 12:53:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730299AbgKWUtP (ORCPT + 99 others); Mon, 23 Nov 2020 15:49:15 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:58431 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729256AbgKWUtP (ORCPT ); Mon, 23 Nov 2020 15:49:15 -0500 Received: from mail-il1-f199.google.com ([209.85.166.199]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1khIls-0004zx-4E for linux-kernel@vger.kernel.org; Mon, 23 Nov 2020 20:49:12 +0000 Received: by mail-il1-f199.google.com with SMTP id z8so2465300ilq.21 for ; Mon, 23 Nov 2020 12:49:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=aKKg6wsDaykJhzWuyANPFCAYRxtejbFckP15kDzwPrA=; b=edfAoqi1JpO4fM3O7bpLimrnnl2yhRntzMk+P3ekFhDML28cfY26N0GMeAuoAMictn uvMe4W/mO1wA+9w+x21cMA7ZaEYN1eFeeYpdtIIfcwXPWR6oJXL7gjsVbxyG5Z+Ochz3 JcBmzvJBy/MUw2o8sElt+I16Kqqp4sJic9Cksn2UA8z9g0YzilvqOeUKfADIe3zp0924 XU80KuejovGo/tuAcsDR0SGFvUOotETQEOQD91lXokV7OH2oprbnkHTrRFkuebUe6r0K 2lDelBMK85Rgk9sWxsNc9xhhVHk2L9md8vlqOOF+RZs9BNNyDbYPSg4XO+6o1rnEPvTr iGwQ== X-Gm-Message-State: AOAM530RlWsJjtI5+E+q9j0Ggnre/AHkXH5b8UE1HKd7qNkvSAhF+rox IR1B4nykXDtz+Jo9/En+S2F6rlO6lKLZWF+HkO/o8z+am/GdFBcuFDkN9plrEMVjFy3rvIRY53j 2ODfZHepuC25imb2+2qaeaOWqO6XMOyDPD6B5enS/iw== X-Received: by 2002:a92:d591:: with SMTP id a17mr1441548iln.51.1606164551120; Mon, 23 Nov 2020 12:49:11 -0800 (PST) X-Received: by 2002:a92:d591:: with SMTP id a17mr1441531iln.51.1606164550824; Mon, 23 Nov 2020 12:49:10 -0800 (PST) Received: from xps13.dannf (c-71-56-235-36.hsd1.co.comcast.net. [71.56.235.36]) by smtp.gmail.com with ESMTPSA id o3sm8617248ilk.27.2020.11.23.12.49.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 12:49:09 -0800 (PST) Date: Mon, 23 Nov 2020 13:49:07 -0700 From: dann frazier To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Ard Biesheuvel , Matthias Kaehlcke , Herbert Xu , Nathan Chancellor Subject: Re: [PATCH 4.4 17/70] crypto: arm64/sha - avoid non-standard inline asm tricks Message-ID: References: <20181126105046.722096341@linuxfoundation.org> <20181126105048.515352194@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181126105048.515352194@linuxfoundation.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 26, 2018 at 11:50:32AM +0100, Greg Kroah-Hartman wrote: > 4.4-stable review patch. If anyone has any objections, please let me know. fyi, I bisected a regression down to this commit. This apparently causes an ADR_PREL_PG_HI21 relocation to be added to the sha{1,2}_ce modules. Back in 4.4 ADR_PREL_PG_HI21 relocations were forbidden if built with CONFIG_ARM64_ERRATUM_843419=y, so now the sha{1,2}_ce modules fail to load: [ 37.866250] module sha1_ce: unsupported RELA relocation: 275 Looks like it should be an issue for 4.14.y as well, but I haven't yet tested it. -dann > From: Ard Biesheuvel > > commit f4857f4c2ee9aa4e2aacac1a845352b00197fb57 upstream. > > Replace the inline asm which exports struct offsets as ELF symbols > with proper const variables exposing the same values. This works > around an issue with Clang which does not interpret the "i" (or "I") > constraints in the same way as GCC. > > Signed-off-by: Ard Biesheuvel > Tested-by: Matthias Kaehlcke > Signed-off-by: Herbert Xu > Signed-off-by: Nathan Chancellor > Signed-off-by: Greg Kroah-Hartman > --- > arch/arm64/crypto/sha1-ce-core.S | 6 ++++-- > arch/arm64/crypto/sha1-ce-glue.c | 11 +++-------- > arch/arm64/crypto/sha2-ce-core.S | 6 ++++-- > arch/arm64/crypto/sha2-ce-glue.c | 13 +++++-------- > 4 files changed, 16 insertions(+), 20 deletions(-) > > --- a/arch/arm64/crypto/sha1-ce-core.S > +++ b/arch/arm64/crypto/sha1-ce-core.S > @@ -82,7 +82,8 @@ ENTRY(sha1_ce_transform) > ldr dgb, [x0, #16] > > /* load sha1_ce_state::finalize */ > - ldr w4, [x0, #:lo12:sha1_ce_offsetof_finalize] > + ldr_l w4, sha1_ce_offsetof_finalize, x4 > + ldr w4, [x0, x4] > > /* load input */ > 0: ld1 {v8.4s-v11.4s}, [x1], #64 > @@ -132,7 +133,8 @@ CPU_LE( rev32 v11.16b, v11.16b ) > * the padding is handled by the C code in that case. > */ > cbz x4, 3f > - ldr x4, [x0, #:lo12:sha1_ce_offsetof_count] > + ldr_l w4, sha1_ce_offsetof_count, x4 > + ldr x4, [x0, x4] > movi v9.2d, #0 > mov x8, #0x80000000 > movi v10.2d, #0 > --- a/arch/arm64/crypto/sha1-ce-glue.c > +++ b/arch/arm64/crypto/sha1-ce-glue.c > @@ -17,9 +17,6 @@ > #include > #include > > -#define ASM_EXPORT(sym, val) \ > - asm(".globl " #sym "; .set " #sym ", %0" :: "I"(val)); > - > MODULE_DESCRIPTION("SHA1 secure hash using ARMv8 Crypto Extensions"); > MODULE_AUTHOR("Ard Biesheuvel "); > MODULE_LICENSE("GPL v2"); > @@ -32,6 +29,9 @@ struct sha1_ce_state { > asmlinkage void sha1_ce_transform(struct sha1_ce_state *sst, u8 const *src, > int blocks); > > +const u32 sha1_ce_offsetof_count = offsetof(struct sha1_ce_state, sst.count); > +const u32 sha1_ce_offsetof_finalize = offsetof(struct sha1_ce_state, finalize); > + > static int sha1_ce_update(struct shash_desc *desc, const u8 *data, > unsigned int len) > { > @@ -52,11 +52,6 @@ static int sha1_ce_finup(struct shash_de > struct sha1_ce_state *sctx = shash_desc_ctx(desc); > bool finalize = !sctx->sst.count && !(len % SHA1_BLOCK_SIZE); > > - ASM_EXPORT(sha1_ce_offsetof_count, > - offsetof(struct sha1_ce_state, sst.count)); > - ASM_EXPORT(sha1_ce_offsetof_finalize, > - offsetof(struct sha1_ce_state, finalize)); > - > /* > * Allow the asm code to perform the finalization if there is no > * partial data and the input is a round multiple of the block size. > --- a/arch/arm64/crypto/sha2-ce-core.S > +++ b/arch/arm64/crypto/sha2-ce-core.S > @@ -88,7 +88,8 @@ ENTRY(sha2_ce_transform) > ld1 {dgav.4s, dgbv.4s}, [x0] > > /* load sha256_ce_state::finalize */ > - ldr w4, [x0, #:lo12:sha256_ce_offsetof_finalize] > + ldr_l w4, sha256_ce_offsetof_finalize, x4 > + ldr w4, [x0, x4] > > /* load input */ > 0: ld1 {v16.4s-v19.4s}, [x1], #64 > @@ -136,7 +137,8 @@ CPU_LE( rev32 v19.16b, v19.16b ) > * the padding is handled by the C code in that case. > */ > cbz x4, 3f > - ldr x4, [x0, #:lo12:sha256_ce_offsetof_count] > + ldr_l w4, sha256_ce_offsetof_count, x4 > + ldr x4, [x0, x4] > movi v17.2d, #0 > mov x8, #0x80000000 > movi v18.2d, #0 > --- a/arch/arm64/crypto/sha2-ce-glue.c > +++ b/arch/arm64/crypto/sha2-ce-glue.c > @@ -17,9 +17,6 @@ > #include > #include > > -#define ASM_EXPORT(sym, val) \ > - asm(".globl " #sym "; .set " #sym ", %0" :: "I"(val)); > - > MODULE_DESCRIPTION("SHA-224/SHA-256 secure hash using ARMv8 Crypto Extensions"); > MODULE_AUTHOR("Ard Biesheuvel "); > MODULE_LICENSE("GPL v2"); > @@ -32,6 +29,11 @@ struct sha256_ce_state { > asmlinkage void sha2_ce_transform(struct sha256_ce_state *sst, u8 const *src, > int blocks); > > +const u32 sha256_ce_offsetof_count = offsetof(struct sha256_ce_state, > + sst.count); > +const u32 sha256_ce_offsetof_finalize = offsetof(struct sha256_ce_state, > + finalize); > + > static int sha256_ce_update(struct shash_desc *desc, const u8 *data, > unsigned int len) > { > @@ -52,11 +54,6 @@ static int sha256_ce_finup(struct shash_ > struct sha256_ce_state *sctx = shash_desc_ctx(desc); > bool finalize = !sctx->sst.count && !(len % SHA256_BLOCK_SIZE); > > - ASM_EXPORT(sha256_ce_offsetof_count, > - offsetof(struct sha256_ce_state, sst.count)); > - ASM_EXPORT(sha256_ce_offsetof_finalize, > - offsetof(struct sha256_ce_state, finalize)); > - > /* > * Allow the asm code to perform the finalization if there is no > * partial data and the input is a round multiple of the block size. > >