Skip to contentSkip to conversation

crypto - move crypto_simd_disabled_for_test to lib

PATCH In review Eric Biggers 3 participants 3 messages Oct 18, 2024 – Oct 26, 2024

Subsystems (2)
lore
Share & tools
lore

Eric Biggers

author maintainer
#0 lore raw

PATCH 1/1 crypto - move crypto_simd_disabled_for_test to lib

From: Eric Biggers <[email protected]>

Move crypto_simd_disabled_for_test to lib/ so that crypto_simd_usable() can be used by library code.

This was discussed previously
(https://lore.kernel.org/linux-crypto/[email protected]/)
but was not done because there was no use case yet. However, this is now needed for the arm64 CRC32 library code.

Tested with:
export ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- echo CONFIG_CRC32=y > .config
echo CONFIG_MODULES=y >> .config
echo CONFIG_CRYPTO=m >> .config
echo CONFIG_DEBUG_KERNEL=y >> .config
echo CONFIG_CRYPTO_MANAGER_DISABLE_TESTS=n >> .config echo CONFIG_CRYPTO_MANAGER_EXTRA_TESTS=y >> .config make olddefconfig
make -j$(nproc)

---
 crypto/algapi.c     |  6 ------
 lib/crypto/Makefile |  2 ++
 lib/crypto/simd.c   | 11 +++++++++++
 3 files changed, 13 insertions(+), 6 deletions(-)
 create mode 100644 lib/crypto/simd.c
crypto/algapi.c +0 -6
index 74e2261c184ca..429a832f90fe0 100644
@@ -4,11 +4,10 @@
  *
  * Copyright (c) 2006 Herbert Xu <[email protected]>
  */
 
 #include <crypto/algapi.h>
-#include <crypto/internal/simd.h>
 #include <linux/err.h>
 #include <linux/errno.h>
 #include <linux/fips.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -21,15 +20,10 @@
 
 #include "internal.h"
 
 static LIST_HEAD(crypto_template_list);
 
-#ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS
-DEFINE_PER_CPU(bool, crypto_simd_disabled_for_test);
-EXPORT_PER_CPU_SYMBOL_GPL(crypto_simd_disabled_for_test);
-#endif
-
 static inline void crypto_check_module_sig(struct module *mod)
 {
 	if (fips_enabled && mod && !module_sig_ok(mod))
 		panic("Module %s signature verification failed in FIPS mode\n",
 		      module_name(mod));
lib/crypto/Makefile +2 -0
index 969baab8c805f..01fac1cd05a19 100644
@@ -56,5 +56,7 @@ libblake2s-y					+= blake2s-selftest.o
 libchacha20poly1305-y				+= chacha20poly1305-selftest.o
 libcurve25519-y					+= curve25519-selftest.o
 endif
 
 obj-$(CONFIG_MPILIB) += mpi/
+
+obj-$(CONFIG_CRYPTO_MANAGER_EXTRA_TESTS)	+= simd.o
lib/crypto/simd.c new file +11 -0
new file mode 100644
index 0000000000000..9c36cb3bb49c4
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * SIMD testing utility functions
+ *
+ * Copyright 2024 Google LLC
+ */
+
+#include <crypto/internal/simd.h>
+
+DEFINE_PER_CPU(bool, crypto_simd_disabled_for_test);
+EXPORT_PER_CPU_SYMBOL_GPL(crypto_simd_disabled_for_test);

base-commit: 5c20772738e1d1d7bec41664eb9d61497e53c10e

Signature · 1 line
2.47.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 22 lines · Eric Biggers

From: Eric Biggers <[email protected]>

Move crypto_simd_disabled_for_test to lib/ so that crypto_simd_usable() can be used by library code.

This was discussed previously
(https://lore.kernel.org/linux-crypto/[email protected]/)
but was not done because there was no use case yet. However, this is now needed for the arm64 CRC32 library code.

Tested with:
export ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- echo CONFIG_CRC32=y > .config
echo CONFIG_MODULES=y >> .config
echo CONFIG_CRYPTO=m >> .config
echo CONFIG_DEBUG_KERNEL=y >> .config
echo CONFIG_CRYPTO_MANAGER_DISABLE_TESTS=n >> .config echo CONFIG_CRYPTO_MANAGER_EXTRA_TESTS=y >> .config make olddefconfig
make -j$(nproc)

Quoted 1 line
Quoted 73 lines
---
 crypto/algapi.c     |  6 ------
 lib/crypto/Makefile |  2 ++
 lib/crypto/simd.c   | 11 +++++++++++
 3 files changed, 13 insertions(+), 6 deletions(-)
 create mode 100644 lib/crypto/simd.c
crypto/algapi.c +0 -6
index 74e2261c184ca..429a832f90fe0 100644
@@ -4,11 +4,10 @@
  *
  * Copyright (c) 2006 Herbert Xu <[email protected]>
  */
 
 #include <crypto/algapi.h>
-#include <crypto/internal/simd.h>
 #include <linux/err.h>
 #include <linux/errno.h>
 #include <linux/fips.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -21,15 +20,10 @@
 
 #include "internal.h"
 
 static LIST_HEAD(crypto_template_list);
 
-#ifdef CONFIG_CRYPTO_MANAGER_EXTRA_TESTS
-DEFINE_PER_CPU(bool, crypto_simd_disabled_for_test);
-EXPORT_PER_CPU_SYMBOL_GPL(crypto_simd_disabled_for_test);
-#endif
-
 static inline void crypto_check_module_sig(struct module *mod)
 {
        if (fips_enabled && mod && !module_sig_ok(mod))
                panic("Module %s signature verification failed in FIPS mode\n",
                      module_name(mod));
lib/crypto/Makefile +2 -0
index 969baab8c805f..01fac1cd05a19 100644
@@ -56,5 +56,7 @@ libblake2s-y                                  += blake2s-selftest.o
 libchacha20poly1305-y                          += chacha20poly1305-selftest.o
 libcurve25519-y                                        += curve25519-selftest.o
 endif
 
 obj-$(CONFIG_MPILIB) += mpi/
+
+obj-$(CONFIG_CRYPTO_MANAGER_EXTRA_TESTS)       += simd.o
lib/crypto/simd.c new file +11 -0
new file mode 100644
index 0000000000000..9c36cb3bb49c4
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * SIMD testing utility functions
+ *
+ * Copyright 2024 Google LLC
+ */
+
+#include <crypto/internal/simd.h>
+
+DEFINE_PER_CPU(bool, crypto_simd_disabled_for_test);
+EXPORT_PER_CPU_SYMBOL_GPL(crypto_simd_disabled_for_test);

base-commit: 5c20772738e1d1d7bec41664eb9d61497e53c10e --
2.47.0

maintainer
#2 lore raw
In reply to Eric Biggers
Quoted 21 lines · Eric Biggers

From: Eric Biggers <[email protected]>

Move crypto_simd_disabled_for_test to lib/ so that crypto_simd_usable() can be used by library code.

This was discussed previously
(https://lore.kernel.org/linux-crypto/[email protected]/)
but was not done because there was no use case yet. However, this is now needed for the arm64 CRC32 library code.

Tested with:
export ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- echo CONFIG_CRC32=y > .config
echo CONFIG_MODULES=y >> .config
echo CONFIG_CRYPTO=m >> .config
echo CONFIG_DEBUG_KERNEL=y >> .config
echo CONFIG_CRYPTO_MANAGER_DISABLE_TESTS=n >> .config echo CONFIG_CRYPTO_MANAGER_EXTRA_TESTS=y >> .config make olddefconfig
make -j$(nproc)

Quoted 7 lines

---

crypto/algapi.c     |  6 ------
lib/crypto/Makefile |  2 ++
lib/crypto/simd.c   | 11 +++++++++++
3 files changed, 13 insertions(+), 6 deletions(-)

create mode 100644 lib/crypto/simd.c

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt