mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
crypto: x86/serpent - stop using the SIMD helper
Stop wrapping skcipher and aead algorithms with the crypto SIMD helper (crypto/simd.c). The only purpose of doing so was to work around x86 not always supporting kernel-mode FPU in softirqs. Specifically, if a hardirq interrupted a task context kernel-mode FPU section and then a softirqs were run at the end of that hardirq, those softirqs could not use kernel-mode FPU. This has now been fixed. In combination with the fact that the skcipher and aead APIs only support task and softirq contexts, these can now just use kernel-mode FPU unconditionally on x86. This simplifies the code and improves performance. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
@@ -134,7 +134,6 @@ config CRYPTO_SERPENT_SSE2_X86_64
|
||||
depends on X86 && 64BIT
|
||||
select CRYPTO_SKCIPHER
|
||||
select CRYPTO_SERPENT
|
||||
select CRYPTO_SIMD
|
||||
imply CRYPTO_CTR
|
||||
help
|
||||
Length-preserving ciphers: Serpent cipher algorithm
|
||||
@@ -150,7 +149,6 @@ config CRYPTO_SERPENT_SSE2_586
|
||||
depends on X86 && !64BIT
|
||||
select CRYPTO_SKCIPHER
|
||||
select CRYPTO_SERPENT
|
||||
select CRYPTO_SIMD
|
||||
imply CRYPTO_CTR
|
||||
help
|
||||
Length-preserving ciphers: Serpent cipher algorithm
|
||||
@@ -166,7 +164,6 @@ config CRYPTO_SERPENT_AVX_X86_64
|
||||
depends on X86 && 64BIT
|
||||
select CRYPTO_SKCIPHER
|
||||
select CRYPTO_SERPENT
|
||||
select CRYPTO_SIMD
|
||||
imply CRYPTO_XTS
|
||||
imply CRYPTO_CTR
|
||||
help
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <linux/crypto.h>
|
||||
#include <linux/err.h>
|
||||
#include <crypto/algapi.h>
|
||||
#include <crypto/internal/simd.h>
|
||||
#include <crypto/serpent.h>
|
||||
|
||||
#include "serpent-avx.h"
|
||||
@@ -65,10 +64,9 @@ static int cbc_decrypt(struct skcipher_request *req)
|
||||
|
||||
static struct skcipher_alg serpent_algs[] = {
|
||||
{
|
||||
.base.cra_name = "__ecb(serpent)",
|
||||
.base.cra_driver_name = "__ecb-serpent-avx2",
|
||||
.base.cra_name = "ecb(serpent)",
|
||||
.base.cra_driver_name = "ecb-serpent-avx2",
|
||||
.base.cra_priority = 600,
|
||||
.base.cra_flags = CRYPTO_ALG_INTERNAL,
|
||||
.base.cra_blocksize = SERPENT_BLOCK_SIZE,
|
||||
.base.cra_ctxsize = sizeof(struct serpent_ctx),
|
||||
.base.cra_module = THIS_MODULE,
|
||||
@@ -78,10 +76,9 @@ static struct skcipher_alg serpent_algs[] = {
|
||||
.encrypt = ecb_encrypt,
|
||||
.decrypt = ecb_decrypt,
|
||||
}, {
|
||||
.base.cra_name = "__cbc(serpent)",
|
||||
.base.cra_driver_name = "__cbc-serpent-avx2",
|
||||
.base.cra_name = "cbc(serpent)",
|
||||
.base.cra_driver_name = "cbc-serpent-avx2",
|
||||
.base.cra_priority = 600,
|
||||
.base.cra_flags = CRYPTO_ALG_INTERNAL,
|
||||
.base.cra_blocksize = SERPENT_BLOCK_SIZE,
|
||||
.base.cra_ctxsize = sizeof(struct serpent_ctx),
|
||||
.base.cra_module = THIS_MODULE,
|
||||
@@ -94,8 +91,6 @@ static struct skcipher_alg serpent_algs[] = {
|
||||
},
|
||||
};
|
||||
|
||||
static struct simd_skcipher_alg *serpent_simd_algs[ARRAY_SIZE(serpent_algs)];
|
||||
|
||||
static int __init serpent_avx2_init(void)
|
||||
{
|
||||
const char *feature_name;
|
||||
@@ -110,15 +105,13 @@ static int __init serpent_avx2_init(void)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
return simd_register_skciphers_compat(serpent_algs,
|
||||
ARRAY_SIZE(serpent_algs),
|
||||
serpent_simd_algs);
|
||||
return crypto_register_skciphers(serpent_algs,
|
||||
ARRAY_SIZE(serpent_algs));
|
||||
}
|
||||
|
||||
static void __exit serpent_avx2_fini(void)
|
||||
{
|
||||
simd_unregister_skciphers(serpent_algs, ARRAY_SIZE(serpent_algs),
|
||||
serpent_simd_algs);
|
||||
crypto_unregister_skciphers(serpent_algs, ARRAY_SIZE(serpent_algs));
|
||||
}
|
||||
|
||||
module_init(serpent_avx2_init);
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <linux/crypto.h>
|
||||
#include <linux/err.h>
|
||||
#include <crypto/algapi.h>
|
||||
#include <crypto/internal/simd.h>
|
||||
#include <crypto/serpent.h>
|
||||
|
||||
#include "serpent-avx.h"
|
||||
@@ -71,10 +70,9 @@ static int cbc_decrypt(struct skcipher_request *req)
|
||||
|
||||
static struct skcipher_alg serpent_algs[] = {
|
||||
{
|
||||
.base.cra_name = "__ecb(serpent)",
|
||||
.base.cra_driver_name = "__ecb-serpent-avx",
|
||||
.base.cra_name = "ecb(serpent)",
|
||||
.base.cra_driver_name = "ecb-serpent-avx",
|
||||
.base.cra_priority = 500,
|
||||
.base.cra_flags = CRYPTO_ALG_INTERNAL,
|
||||
.base.cra_blocksize = SERPENT_BLOCK_SIZE,
|
||||
.base.cra_ctxsize = sizeof(struct serpent_ctx),
|
||||
.base.cra_module = THIS_MODULE,
|
||||
@@ -84,10 +82,9 @@ static struct skcipher_alg serpent_algs[] = {
|
||||
.encrypt = ecb_encrypt,
|
||||
.decrypt = ecb_decrypt,
|
||||
}, {
|
||||
.base.cra_name = "__cbc(serpent)",
|
||||
.base.cra_driver_name = "__cbc-serpent-avx",
|
||||
.base.cra_name = "cbc(serpent)",
|
||||
.base.cra_driver_name = "cbc-serpent-avx",
|
||||
.base.cra_priority = 500,
|
||||
.base.cra_flags = CRYPTO_ALG_INTERNAL,
|
||||
.base.cra_blocksize = SERPENT_BLOCK_SIZE,
|
||||
.base.cra_ctxsize = sizeof(struct serpent_ctx),
|
||||
.base.cra_module = THIS_MODULE,
|
||||
@@ -100,8 +97,6 @@ static struct skcipher_alg serpent_algs[] = {
|
||||
},
|
||||
};
|
||||
|
||||
static struct simd_skcipher_alg *serpent_simd_algs[ARRAY_SIZE(serpent_algs)];
|
||||
|
||||
static int __init serpent_init(void)
|
||||
{
|
||||
const char *feature_name;
|
||||
@@ -112,15 +107,13 @@ static int __init serpent_init(void)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
return simd_register_skciphers_compat(serpent_algs,
|
||||
ARRAY_SIZE(serpent_algs),
|
||||
serpent_simd_algs);
|
||||
return crypto_register_skciphers(serpent_algs,
|
||||
ARRAY_SIZE(serpent_algs));
|
||||
}
|
||||
|
||||
static void __exit serpent_exit(void)
|
||||
{
|
||||
simd_unregister_skciphers(serpent_algs, ARRAY_SIZE(serpent_algs),
|
||||
serpent_simd_algs);
|
||||
crypto_unregister_skciphers(serpent_algs, ARRAY_SIZE(serpent_algs));
|
||||
}
|
||||
|
||||
module_init(serpent_init);
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <linux/err.h>
|
||||
#include <crypto/algapi.h>
|
||||
#include <crypto/b128ops.h>
|
||||
#include <crypto/internal/simd.h>
|
||||
#include <crypto/serpent.h>
|
||||
|
||||
#include "serpent-sse2.h"
|
||||
@@ -74,10 +73,9 @@ static int cbc_decrypt(struct skcipher_request *req)
|
||||
|
||||
static struct skcipher_alg serpent_algs[] = {
|
||||
{
|
||||
.base.cra_name = "__ecb(serpent)",
|
||||
.base.cra_driver_name = "__ecb-serpent-sse2",
|
||||
.base.cra_name = "ecb(serpent)",
|
||||
.base.cra_driver_name = "ecb-serpent-sse2",
|
||||
.base.cra_priority = 400,
|
||||
.base.cra_flags = CRYPTO_ALG_INTERNAL,
|
||||
.base.cra_blocksize = SERPENT_BLOCK_SIZE,
|
||||
.base.cra_ctxsize = sizeof(struct serpent_ctx),
|
||||
.base.cra_module = THIS_MODULE,
|
||||
@@ -87,10 +85,9 @@ static struct skcipher_alg serpent_algs[] = {
|
||||
.encrypt = ecb_encrypt,
|
||||
.decrypt = ecb_decrypt,
|
||||
}, {
|
||||
.base.cra_name = "__cbc(serpent)",
|
||||
.base.cra_driver_name = "__cbc-serpent-sse2",
|
||||
.base.cra_name = "cbc(serpent)",
|
||||
.base.cra_driver_name = "cbc-serpent-sse2",
|
||||
.base.cra_priority = 400,
|
||||
.base.cra_flags = CRYPTO_ALG_INTERNAL,
|
||||
.base.cra_blocksize = SERPENT_BLOCK_SIZE,
|
||||
.base.cra_ctxsize = sizeof(struct serpent_ctx),
|
||||
.base.cra_module = THIS_MODULE,
|
||||
@@ -103,8 +100,6 @@ static struct skcipher_alg serpent_algs[] = {
|
||||
},
|
||||
};
|
||||
|
||||
static struct simd_skcipher_alg *serpent_simd_algs[ARRAY_SIZE(serpent_algs)];
|
||||
|
||||
static int __init serpent_sse2_init(void)
|
||||
{
|
||||
if (!boot_cpu_has(X86_FEATURE_XMM2)) {
|
||||
@@ -112,15 +107,13 @@ static int __init serpent_sse2_init(void)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
return simd_register_skciphers_compat(serpent_algs,
|
||||
ARRAY_SIZE(serpent_algs),
|
||||
serpent_simd_algs);
|
||||
return crypto_register_skciphers(serpent_algs,
|
||||
ARRAY_SIZE(serpent_algs));
|
||||
}
|
||||
|
||||
static void __exit serpent_sse2_exit(void)
|
||||
{
|
||||
simd_unregister_skciphers(serpent_algs, ARRAY_SIZE(serpent_algs),
|
||||
serpent_simd_algs);
|
||||
crypto_unregister_skciphers(serpent_algs, ARRAY_SIZE(serpent_algs));
|
||||
}
|
||||
|
||||
module_init(serpent_sse2_init);
|
||||
|
||||
Reference in New Issue
Block a user