From patchwork Wed Dec 23 22:38:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 351507 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.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 1105FC433E0 for ; Wed, 23 Dec 2020 22:39:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C6B7522571 for ; Wed, 23 Dec 2020 22:39:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726047AbgLWWjm (ORCPT ); Wed, 23 Dec 2020 17:39:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:59208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725811AbgLWWjm (ORCPT ); Wed, 23 Dec 2020 17:39:42 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id BB3A322273; Wed, 23 Dec 2020 22:38:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608763140; bh=0MbCcCmyG2J0vKLMvj0T420mPbqg0OGMmaFqvD2qC+M=; h=From:To:Cc:Subject:Date:From; b=iCN/cs8nX9i/zsgLfpunfNkjsC+lJFZfoAIc0+ZkMHplaUyS1X665+6hXZEdQYNYV t3ZjHfatim88YY3TOFvXr63ZPob5rjz5NDSSX8X+yhQVC+Y+iD6IlG89GVFoB77fV1 2AwQkff7/HempggHD9b3u0MAwif4421qsm6cJbj2pnMUBDM6jqZpXnVfoDxRg6qoSD kq7deVSGkVuBQeb8l/iM6U1JyAF6P4SKvrf9hooA+urGR9fpzIeL76WFuSqEncjxm4 Rz+eZ3e+S79pn1oRwZxVZu5GeqVCjS3Nbv5eeT8fSuYH3kx9mxnxoPAjl8aL8mU2By fkbZbv0Bry4xw== From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: dm-devel@redhat.com, Ard Biesheuvel , Megha Dey , Eric Biggers , Herbert Xu , Milan Broz , Mike Snitzer Subject: [RFC PATCH 00/10] crypto: x86 - remove XTS and CTR glue helper code Date: Wed, 23 Dec 2020 23:38:31 +0100 Message-Id: <20201223223841.11311-1-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org After applying my performance fixes for AES-NI in XTS mode, the only remaining users of the x86 glue helper module are the niche algorithms camellia, cast6, serpent and twofish. It is not clear from the history why all these different versions of these algorithms in XTS and CTR modes were added in the first place: the only in-kernel references that seem to exist are to cbc(serpent), cbc(camellia) and cbc(twofish) in the IPsec stack. The XTS spec only mentions AES, and CTR modes don't seem to be widely used either. Since the glue helper code relies heavily on indirect calls for small chunks of in/output, it needs some work to recover from the performance hit caused by the retpoline changes. However, it makes sense to only expend the effort for algorithms that are being used in the first place, and this does not seem to be the case for XTS and CTR. CTR mode can simply be removed: it is not used in the kernel, and it is highly unlikely that it is being relied upon via algif_skcipher. And even if it was, the generic CTR mode driver can still provide the CTR transforms if necessary. XTS mode may actually be in use by dm-crypt users, so we cannot simply drop this code entirely. However, as it turns out, the XTS template wrapped around the ECB mode skciphers perform roughly on par *, and so there is no need to retain all the complicated XTS helper logic. In the unlikely case that dm-crypt users are relying on xts(camellia) or xts(serpent) in the field, they should not be impacted by these changes at all. As a follow-up, it makes sense to rework the ECB and CBC mode implementations to get rid of the indirect calls. Or perhaps we could drop [some of] these algorithms entirely ... * tcrypt results for various XTS implementations below, captured on a Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz Cc: Megha Dey Cc: Eric Biggers Cc: Herbert Xu Cc: Milan Broz Cc: Mike Snitzer Ard Biesheuvel (10): crypto: x86/camellia - switch to XTS template crypto: x86/cast6 - switch to XTS template crypto: x86/serpent- switch to XTS template crypto: x86/twofish - switch to XTS template crypto: x86/glue-helper - drop XTS helper routines crypto: x86/camellia - drop CTR mode implementation crypto: x86/cast6 - drop CTR mode implementation crypto: x86/serpent - drop CTR mode implementation crypto: x86/twofish - drop CTR mode implementation crypto: x86/glue-helper - drop CTR helper routines arch/x86/crypto/camellia-aesni-avx-asm_64.S | 297 ---------------- arch/x86/crypto/camellia-aesni-avx2-asm_64.S | 350 ------------------- arch/x86/crypto/camellia_aesni_avx2_glue.c | 111 ------ arch/x86/crypto/camellia_aesni_avx_glue.c | 141 +------- arch/x86/crypto/camellia_glue.c | 68 ---- arch/x86/crypto/cast6-avx-x86_64-asm_64.S | 84 ----- arch/x86/crypto/cast6_avx_glue.c | 146 -------- arch/x86/crypto/glue_helper-asm-avx.S | 104 ------ arch/x86/crypto/glue_helper-asm-avx2.S | 136 ------- arch/x86/crypto/glue_helper.c | 226 ------------ arch/x86/crypto/serpent-avx-x86_64-asm_64.S | 68 ---- arch/x86/crypto/serpent-avx2-asm_64.S | 87 ----- arch/x86/crypto/serpent_avx2_glue.c | 110 ------ arch/x86/crypto/serpent_avx_glue.c | 152 -------- arch/x86/crypto/serpent_sse2_glue.c | 67 ---- arch/x86/crypto/twofish-avx-x86_64-asm_64.S | 80 ----- arch/x86/crypto/twofish_avx_glue.c | 136 ------- arch/x86/crypto/twofish_glue_3way.c | 72 ---- arch/x86/include/asm/crypto/camellia.h | 24 -- arch/x86/include/asm/crypto/glue_helper.h | 44 --- arch/x86/include/asm/crypto/serpent-avx.h | 21 -- arch/x86/include/asm/crypto/twofish.h | 4 - 22 files changed, 1 insertion(+), 2527 deletions(-) Acked-by: Eric Biggers