From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D8A5C47088 for ; Wed, 26 May 2021 18:17:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1C7E8613C9 for ; Wed, 26 May 2021 18:17:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1C7E8613C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mr3LGijy7GsPYGvbUkoPbysKL1qLV4+JYfDnXG/IrIs=; b=oyto7IDEChQyqv o47hKEyowFRWtdjEfYALV6B7YluHa6qj1o25zSz/ZSVCOoxiIGnckU1Oq68xEe8An0PadekzPhn9t onxEoRBH1R6AFoX7moBSdm7mv7l9l1DmYbdvHV6DDVenRGCtRG12jJnWEpGDpPR9xR5WNZLqQ57Dz R6zJ49m7pYV3N91evGopvb5sfcyjxXmDpRAOcAelF3EDCM8WRc8wAKgq9+EuF3YTGUYTFOreOta93 5f1NjvgdRPoSxhVGQItMhGKhLY3iPYYfnuz/HyLcNnlWT8+PAiAzYu7BTCFKrXVs6+3UEcT6eJjmx Y0f9jERsajtSLHbzDHGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lly3V-00GQRh-Hk; Wed, 26 May 2021 18:14:58 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1llx6g-00G1SD-Kw for linux-arm-kernel@lists.infradead.org; Wed, 26 May 2021 17:14:12 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id E5B81613BE; Wed, 26 May 2021 17:14:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622049250; bh=WilcpziL7v+iMFq6RwDqrjuswQfu7ScP1b0OzDTgk5s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TeyGUyS+o/tyfWuoSfPUXTpBAaif2tajHI4JN7ar+RSvdhpwYvVSnRbjqGSt2Nmw2 MFAKYt5bgVqvLdMGuNBlo6ywpbR53lahzxbM61x8CQxcCD/k5VGYgno5ORwK7h/lyI dioYaVu6WxI+3Iv6Tfm1lJGIS4PvPGypP2ObnDS0ECW5AyD+pKLSVCBeCWgGDGLBJt st8DFwyJ2GLiQoMxFb4yt2O2pvpVbQcoNJXr9FXF8e4pqJMM3wuRATwT6SE9t/Qzo8 fiT563sA1jNHnSRrddsfp+lcUPKEYKG5CvZ2IfdI7lsVKEli9if8SFiUJxgKY0iZDt 7yUI+zXydvbMA== Date: Wed, 26 May 2021 10:14:08 -0700 From: Eric Biggers To: Ard Biesheuvel Cc: linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, herbert@gondor.apana.org.au, will@kernel.org, kernel-team@android.com Subject: Re: [PATCH v6 5/6] crypto: arm64/aes-ccm - reduce NEON begin/end calls for common case Message-ID: References: <20210526100729.12939-1-ardb@kernel.org> <20210526100729.12939-6-ardb@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210526100729.12939-6-ardb@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210526_101410_785773_22C6C563 X-CRM114-Status: GOOD ( 19.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, May 26, 2021 at 12:07:28PM +0200, Ard Biesheuvel wrote: > AES-CCM (as used in WPA2 CCMP, for instance) typically involves > authenticate-only data, and operates on a single network packet, and so > the common case is for the authenticate, en/decrypt and finalize SIMD > helpers to all be called exactly once in sequence. Since > kernel_neon_end() now involves manipulation of the preemption state as > well as the softirq mask state, let's reduce the number of times we are > forced to call it to only once if we are handling this common case. > > Signed-off-by: Ard Biesheuvel > --- > arch/arm64/crypto/aes-ce-ccm-core.S | 1 + > arch/arm64/crypto/aes-ce-ccm-glue.c | 74 +++++++++++--------- > 2 files changed, 43 insertions(+), 32 deletions(-) > > diff --git a/arch/arm64/crypto/aes-ce-ccm-core.S b/arch/arm64/crypto/aes-ce-ccm-core.S > index 99a028e298ed..8adff299fcd3 100644 > --- a/arch/arm64/crypto/aes-ce-ccm-core.S > +++ b/arch/arm64/crypto/aes-ce-ccm-core.S > @@ -124,6 +124,7 @@ SYM_FUNC_START(ce_aes_ccm_final) > SYM_FUNC_END(ce_aes_ccm_final) > > .macro aes_ccm_do_crypt,enc > + cbz x2, 5f > ldr x8, [x6, #8] /* load lower ctr */ > ld1 {v0.16b}, [x5] /* load mac */ > CPU_LE( rev x8, x8 ) /* keep swabbed ctr in reg */ > diff --git a/arch/arm64/crypto/aes-ce-ccm-glue.c b/arch/arm64/crypto/aes-ce-ccm-glue.c > index 54bd2494a000..98159f2c49ae 100644 > --- a/arch/arm64/crypto/aes-ce-ccm-glue.c > +++ b/arch/arm64/crypto/aes-ce-ccm-glue.c > @@ -97,10 +97,8 @@ static int ccm_init_mac(struct aead_request *req, u8 maciv[], u32 msglen) > static void ccm_update_mac(struct crypto_aes_ctx *key, u8 mac[], u8 const in[], > u32 abytes, u32 *macp) > { > - kernel_neon_begin(); > ce_aes_ccm_auth_data(mac, in, abytes, macp, key->key_enc, > num_rounds(key)); > - kernel_neon_end(); > } [...] > + if (req->assoclen) > + ccm_calculate_auth_mac(req, mac); > + This still makes all the associated data be processed under a single kernel_neon_begin() / kernel_neon_end() pair, even if there is a large amount of it. Shouldn't it be limited to a reasonable amount at a time, like 4K? This sort of thing has been considered a bug before, e.g. see commit 706024a52c6 ("crypto: arch/lib - limit simd usage to 4k chunks"). You could do the entire CCM operation under a single pair as long as there isn't more than 4K of associated data. - Eric _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel