Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1437003ybz; Wed, 29 Apr 2020 22:33:03 -0700 (PDT) X-Google-Smtp-Source: APiQypI+GFE4ZDsrX9QWoy0rVSbfSgAv+Ebj04YZJNT/GV193Vyyi+m6zdHDmSgBatPlSYyY1qN0 X-Received: by 2002:a05:6402:1773:: with SMTP id da19mr1175398edb.2.1588224783428; Wed, 29 Apr 2020 22:33:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588224783; cv=none; d=google.com; s=arc-20160816; b=rY2Y3zHFnrdMFKZFxg/kxsSNBHZil8k/MB96OHzVuaVSODyEmGpWClXtxQDHFVVRPC yXway/EblTEtNo/Ip72+bibRwoxSC3JMJSVYydP9UA7Az4v670KcMQVKK+/9gfphXyYs iMizyHoMTcaCGOMqyDACOuJNh892HwkMxhAh/3WlswfpAMEF/D9TPNtnMu4Huxmvs1A+ vw0kTzRR3773HPNm1zew95AR4zCNDasl+UAQlfwIHFzWsiV3lfRa/HZeuzqeuUiJC9ZX XEppIU923gKBoBdYTUJVTR+qmNUyYLkCi5z21LaayHqpZifpeIl6sY7dmF3mFT6bNNxS 3ezQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=UVzgZA9Bx2kPv+7XyYkLxNlwPLichPBkPBk5lT5+W+w=; b=oYe8Lw/lCBw0Hbr+QF70BjLyJsbyDJbHfPF4yUMiWr+r8AmZRzI/+UMk6lIvG1E8TX CyvWPpNVImFVjlNIv50IY1PLbZT+oWOdUIEcKT8WS0gAf1P5Z2+In5F0Nbi8laDOGWD/ ec1NBDXsW+lKAaBpExuxQklryLQ9R8QNS9icjHNf/zfuvtP1pt+EUeUBHEzNoaYSyKZG 7JZ1hRQFdFq17PQXCNM37XApiIIInpoSfB1xGju4sxF+gnYoDhtePcw9XpYJbpuAkgVY K0b/WSP3zNNFpRmbS94i7okNVYwKLQjGc/DSnJm7SGWg8cp774hPiWXs37nfY0MefJ4g sewg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g15si4684448edr.14.2020.04.29.22.32.40; Wed, 29 Apr 2020 22:33:03 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726547AbgD3Fbm (ORCPT + 99 others); Thu, 30 Apr 2020 01:31:42 -0400 Received: from helcar.hmeau.com ([216.24.177.18]:60368 "EHLO fornost.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726378AbgD3Fbm (ORCPT ); Thu, 30 Apr 2020 01:31:42 -0400 Received: from gwarestrin.me.apana.org.au ([192.168.0.7] helo=gwarestrin.arnor.me.apana.org.au) by fornost.hmeau.com with smtp (Exim 4.89 #2 (Debian)) id 1jU1lk-0005LQ-8L; Thu, 30 Apr 2020 15:29:57 +1000 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Thu, 30 Apr 2020 15:30:49 +1000 Date: Thu, 30 Apr 2020 15:30:49 +1000 From: Herbert Xu To: "Jason A. Donenfeld" Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, Eric Biggers , Ard Biesheuvel , Sebastian Andrzej Siewior , stable@vger.kernel.org Subject: Re: [PATCH crypto-stable v3 1/2] crypto: arch/lib - limit simd usage to 4k chunks Message-ID: <20200430053049.GA11838@gondor.apana.org.au> References: <20200422200344.239462-1-Jason@zx2c4.com> <20200422231854.675965-1-Jason@zx2c4.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200422231854.675965-1-Jason@zx2c4.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, Apr 22, 2020 at 05:18:53PM -0600, Jason A. Donenfeld wrote: > The initial Zinc patchset, after some mailing list discussion, contained > code to ensure that kernel_fpu_enable would not be kept on for more than > a 4k chunk, since it disables preemption. The choice of 4k isn't totally > scientific, but it's not a bad guess either, and it's what's used in > both the x86 poly1305, blake2s, and nhpoly1305 code already (in the form > of PAGE_SIZE, which this commit corrects to be explicitly 4k for the > former two). > > Ard did some back of the envelope calculations and found that > at 5 cycles/byte (overestimate) on a 1ghz processor (pretty slow), 4k > means we have a maximum preemption disabling of 20us, which Sebastian > confirmed was probably a good limit. > > Unfortunately the chunking appears to have been left out of the final > patchset that added the glue code. So, this commit adds it back in. > > Fixes: 84e03fa39fbe ("crypto: x86/chacha - expose SIMD ChaCha routine as library function") > Fixes: b3aad5bad26a ("crypto: arm64/chacha - expose arm64 ChaCha routine as library function") > Fixes: a44a3430d71b ("crypto: arm/chacha - expose ARM ChaCha routine as library function") > Fixes: d7d7b8535662 ("crypto: x86/poly1305 - wire up faster implementations for kernel") > Fixes: f569ca164751 ("crypto: arm64/poly1305 - incorporate OpenSSL/CRYPTOGAMS NEON implementation") > Fixes: a6b803b3ddc7 ("crypto: arm/poly1305 - incorporate OpenSSL/CRYPTOGAMS NEON implementation") > Fixes: ed0356eda153 ("crypto: blake2s - x86_64 SIMD implementation") > Cc: Eric Biggers > Cc: Ard Biesheuvel > Cc: Sebastian Andrzej Siewior > Cc: stable@vger.kernel.org > Signed-off-by: Jason A. Donenfeld > --- > Changes v2->v3: > - [Eric] Split nhpoly1305 changes into separate commit, since it's not > related to the library interface. > > Changes v1->v2: > - [Ard] Use explicit 4k chunks instead of PAGE_SIZE. > - [Eric] Prefer do-while over for (;;). > > arch/arm/crypto/chacha-glue.c | 14 +++++++++++--- > arch/arm/crypto/poly1305-glue.c | 15 +++++++++++---- > arch/arm64/crypto/chacha-neon-glue.c | 14 +++++++++++--- > arch/arm64/crypto/poly1305-glue.c | 15 +++++++++++---- > arch/x86/crypto/blake2s-glue.c | 10 ++++------ > arch/x86/crypto/chacha_glue.c | 14 +++++++++++--- > arch/x86/crypto/poly1305_glue.c | 13 ++++++------- > 7 files changed, 65 insertions(+), 30 deletions(-) All applied. Thanks. -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt