From: Eric Biggers <ebiggers@kernel.org>
To: Herbert Xu <herbert@gondor.apana.org.au>, linux-crypto@vger.kernel.org
Cc: Danny Tsen <dtsen@linux.ibm.com>, Eric Biggers <ebiggers@kernel.org>
Subject: [PATCH 1/5] crypto: simd - Remove unused crypto_simd module
Date: Thu, 3 Dec 2026 00:03:29 -0800 [thread overview]
Message-ID: <20261203080333.145409-2-ebiggers@kernel.org> (raw)
In-Reply-To: <20261203080333.145409-1-ebiggers@kernel.org>
CRYPTO_SIMD is no longer selected by anything, so remove the unused
code.
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
crypto/Kconfig | 5 -
crypto/Makefile | 2 -
crypto/simd.c | 264 ---------------------------------
include/crypto/internal/simd.h | 9 --
4 files changed, 280 deletions(-)
delete mode 100644 crypto/simd.c
diff --git a/crypto/Kconfig b/crypto/Kconfig
index 6682ac091b387..d9f8fd521a2f1 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -247,11 +247,6 @@ config CRYPTO_BENCHMARK
algorithms in the kernel. It should not be enabled in production
kernels.
-config CRYPTO_SIMD
- tristate
- select CRYPTO_AEAD
- select CRYPTO_CRYPTD
-
config CRYPTO_ENGINE
tristate
select CRYPTO_AEAD
diff --git a/crypto/Makefile b/crypto/Makefile
index 42a4a0d5a466b..872d2dac11986 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -191,8 +191,6 @@ obj-$(CONFIG_CRYPTO_ECRDSA) += ecrdsa_generic.o
#
obj-$(CONFIG_ASYNC_CORE) += async_tx/
obj-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys/
-crypto_simd-y := simd.o
-obj-$(CONFIG_CRYPTO_SIMD) += crypto_simd.o
#
# Key derivation function
diff --git a/crypto/simd.c b/crypto/simd.c
deleted file mode 100644
index 4e29f797709b0..0000000000000
--- a/crypto/simd.c
+++ /dev/null
@@ -1,264 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Shared crypto simd helpers
- *
- * Copyright (c) 2012 Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
- * Copyright (c) 2016 Herbert Xu <herbert@gondor.apana.org.au>
- * Copyright (c) 2019 Google LLC
- *
- * Based on aesni-intel_glue.c by:
- * Copyright (C) 2008, Intel Corp.
- * Author: Huang Ying <ying.huang@intel.com>
- */
-
-/*
- * Shared crypto SIMD helpers. These functions dynamically create and register
- * an AEAD algorithm that wraps another, internal algorithm. The wrapper
- * ensures that the internal algorithm is only executed in a context where SIMD
- * instructions are usable, i.e. where may_use_simd() returns true. If SIMD is
- * already usable, the wrapper directly calls the internal algorithm. Otherwise
- * it defers execution to a workqueue via cryptd.
- *
- * This is an alternative to the internal algorithm implementing a fallback for
- * the !may_use_simd() case itself.
- *
- * Note that the wrapper algorithm is asynchronous, i.e. it has the
- * CRYPTO_ALG_ASYNC flag set. Therefore it won't be found by users who
- * explicitly allocate a synchronous algorithm.
- */
-
-#include <crypto/cryptd.h>
-#include <crypto/internal/aead.h>
-#include <crypto/internal/simd.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/preempt.h>
-#include <asm/simd.h>
-
-struct simd_aead_alg {
- const char *ialg_name;
- struct aead_alg alg;
-};
-
-struct simd_aead_ctx {
- struct cryptd_aead *cryptd_tfm;
-};
-
-static int simd_aead_setkey(struct crypto_aead *tfm, const u8 *key,
- unsigned int key_len)
-{
- struct simd_aead_ctx *ctx = crypto_aead_ctx(tfm);
- struct crypto_aead *child = &ctx->cryptd_tfm->base;
-
- crypto_aead_clear_flags(child, CRYPTO_TFM_REQ_MASK);
- crypto_aead_set_flags(child, crypto_aead_get_flags(tfm) &
- CRYPTO_TFM_REQ_MASK);
- return crypto_aead_setkey(child, key, key_len);
-}
-
-static int simd_aead_setauthsize(struct crypto_aead *tfm, unsigned int authsize)
-{
- struct simd_aead_ctx *ctx = crypto_aead_ctx(tfm);
- struct crypto_aead *child = &ctx->cryptd_tfm->base;
-
- return crypto_aead_setauthsize(child, authsize);
-}
-
-static int simd_aead_encrypt(struct aead_request *req)
-{
- struct crypto_aead *tfm = crypto_aead_reqtfm(req);
- struct simd_aead_ctx *ctx = crypto_aead_ctx(tfm);
- struct aead_request *subreq;
- struct crypto_aead *child;
-
- subreq = aead_request_ctx(req);
- *subreq = *req;
-
- if (!crypto_simd_usable() ||
- (in_atomic() && cryptd_aead_queued(ctx->cryptd_tfm)))
- child = &ctx->cryptd_tfm->base;
- else
- child = cryptd_aead_child(ctx->cryptd_tfm);
-
- aead_request_set_tfm(subreq, child);
-
- return crypto_aead_encrypt(subreq);
-}
-
-static int simd_aead_decrypt(struct aead_request *req)
-{
- struct crypto_aead *tfm = crypto_aead_reqtfm(req);
- struct simd_aead_ctx *ctx = crypto_aead_ctx(tfm);
- struct aead_request *subreq;
- struct crypto_aead *child;
-
- subreq = aead_request_ctx(req);
- *subreq = *req;
-
- if (!crypto_simd_usable() ||
- (in_atomic() && cryptd_aead_queued(ctx->cryptd_tfm)))
- child = &ctx->cryptd_tfm->base;
- else
- child = cryptd_aead_child(ctx->cryptd_tfm);
-
- aead_request_set_tfm(subreq, child);
-
- return crypto_aead_decrypt(subreq);
-}
-
-static void simd_aead_exit(struct crypto_aead *tfm)
-{
- struct simd_aead_ctx *ctx = crypto_aead_ctx(tfm);
-
- cryptd_free_aead(ctx->cryptd_tfm);
-}
-
-static int simd_aead_init(struct crypto_aead *tfm)
-{
- struct simd_aead_ctx *ctx = crypto_aead_ctx(tfm);
- struct cryptd_aead *cryptd_tfm;
- struct simd_aead_alg *salg;
- struct aead_alg *alg;
- unsigned reqsize;
-
- alg = crypto_aead_alg(tfm);
- salg = container_of(alg, struct simd_aead_alg, alg);
-
- cryptd_tfm = cryptd_alloc_aead(salg->ialg_name, CRYPTO_ALG_INTERNAL,
- CRYPTO_ALG_INTERNAL);
- if (IS_ERR(cryptd_tfm))
- return PTR_ERR(cryptd_tfm);
-
- ctx->cryptd_tfm = cryptd_tfm;
-
- reqsize = max(crypto_aead_reqsize(cryptd_aead_child(cryptd_tfm)),
- crypto_aead_reqsize(&cryptd_tfm->base));
- reqsize += sizeof(struct aead_request);
-
- crypto_aead_set_reqsize(tfm, reqsize);
-
- return 0;
-}
-
-static struct simd_aead_alg *simd_aead_create_compat(struct aead_alg *ialg,
- const char *algname,
- const char *drvname,
- const char *basename)
-{
- struct simd_aead_alg *salg;
- struct aead_alg *alg;
- int err;
-
- salg = kzalloc_obj(*salg);
- if (!salg) {
- salg = ERR_PTR(-ENOMEM);
- goto out;
- }
-
- salg->ialg_name = basename;
- alg = &salg->alg;
-
- err = -ENAMETOOLONG;
- if (snprintf(alg->base.cra_name, CRYPTO_MAX_ALG_NAME, "%s", algname) >=
- CRYPTO_MAX_ALG_NAME)
- goto out_free_salg;
-
- if (snprintf(alg->base.cra_driver_name, CRYPTO_MAX_ALG_NAME, "%s",
- drvname) >= CRYPTO_MAX_ALG_NAME)
- goto out_free_salg;
-
- alg->base.cra_flags = CRYPTO_ALG_ASYNC |
- (ialg->base.cra_flags & CRYPTO_ALG_INHERITED_FLAGS);
- alg->base.cra_priority = ialg->base.cra_priority;
- alg->base.cra_blocksize = ialg->base.cra_blocksize;
- alg->base.cra_alignmask = ialg->base.cra_alignmask;
- alg->base.cra_module = ialg->base.cra_module;
- alg->base.cra_ctxsize = sizeof(struct simd_aead_ctx);
-
- alg->ivsize = ialg->ivsize;
- alg->maxauthsize = ialg->maxauthsize;
- alg->chunksize = ialg->chunksize;
-
- alg->init = simd_aead_init;
- alg->exit = simd_aead_exit;
-
- alg->setkey = simd_aead_setkey;
- alg->setauthsize = simd_aead_setauthsize;
- alg->encrypt = simd_aead_encrypt;
- alg->decrypt = simd_aead_decrypt;
-
- err = crypto_register_aead(alg);
- if (err)
- goto out_free_salg;
-
-out:
- return salg;
-
-out_free_salg:
- kfree(salg);
- salg = ERR_PTR(err);
- goto out;
-}
-
-static void simd_aead_free(struct simd_aead_alg *salg)
-{
- crypto_unregister_aead(&salg->alg);
- kfree(salg);
-}
-
-int simd_register_aeads_compat(struct aead_alg *algs, int count,
- struct simd_aead_alg **simd_algs)
-{
- int err;
- int i;
- const char *algname;
- const char *drvname;
- const char *basename;
- struct simd_aead_alg *simd;
-
- for (i = 0; i < count; i++) {
- if (WARN_ON(strncmp(algs[i].base.cra_name, "__", 2) ||
- strncmp(algs[i].base.cra_driver_name, "__", 2)))
- return -EINVAL;
- }
-
- err = crypto_register_aeads(algs, count);
- if (err)
- return err;
-
- for (i = 0; i < count; i++) {
- algname = algs[i].base.cra_name + 2;
- drvname = algs[i].base.cra_driver_name + 2;
- basename = algs[i].base.cra_driver_name;
- simd = simd_aead_create_compat(algs + i, algname, drvname, basename);
- err = PTR_ERR(simd);
- if (IS_ERR(simd))
- goto err_unregister;
- simd_algs[i] = simd;
- }
- return 0;
-
-err_unregister:
- simd_unregister_aeads(algs, count, simd_algs);
- return err;
-}
-EXPORT_SYMBOL_GPL(simd_register_aeads_compat);
-
-void simd_unregister_aeads(struct aead_alg *algs, int count,
- struct simd_aead_alg **simd_algs)
-{
- int i;
-
- crypto_unregister_aeads(algs, count);
-
- for (i = 0; i < count; i++) {
- if (simd_algs[i]) {
- simd_aead_free(simd_algs[i]);
- simd_algs[i] = NULL;
- }
- }
-}
-EXPORT_SYMBOL_GPL(simd_unregister_aeads);
-
-MODULE_DESCRIPTION("Shared crypto SIMD helpers");
-MODULE_LICENSE("GPL");
diff --git a/include/crypto/internal/simd.h b/include/crypto/internal/simd.h
index f5e5d7b639519..d9e6289adc867 100644
--- a/include/crypto/internal/simd.h
+++ b/include/crypto/internal/simd.h
@@ -10,15 +10,6 @@
#include <linux/percpu.h>
#include <linux/types.h>
-struct simd_aead_alg;
-struct aead_alg;
-
-int simd_register_aeads_compat(struct aead_alg *algs, int count,
- struct simd_aead_alg **simd_algs);
-
-void simd_unregister_aeads(struct aead_alg *algs, int count,
- struct simd_aead_alg **simd_algs);
-
/*
* crypto_simd_usable() - is it allowed at this time to use SIMD instructions or
* access the SIMD register file?
--
2.56.1
next prev parent reply other threads:[~2026-12-03 8:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 8:03 [PATCH 0/5] crypto: Remove crypto_simd and clean up cryptd Eric Biggers
2026-12-03 8:03 ` Eric Biggers [this message]
2026-12-03 8:03 ` [PATCH 2/5] crypto: cryptd - Remove unused AEAD functions Eric Biggers
2026-12-03 8:03 ` [PATCH 3/5] crypto: cryptd - Remove pointless reference count Eric Biggers
2026-12-03 8:03 ` [PATCH 4/5] crypto: cryptd - Remove unused CRYPTO_ALG_INTERNAL support Eric Biggers
2026-12-03 8:03 ` [PATCH 5/5] crypto: cryptd - Remove pointless per-instance queue pointer Eric Biggers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203080333.145409-2-ebiggers@kernel.org \
--to=ebiggers@kernel.org \
--cc=dtsen@linux.ibm.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox