crypto: testmgr - Add a flag allowing the self-tests to be disabled at runtime.
authorRichard W.M. Jones <rjones@redhat.com>
Tue, 3 May 2016 09:00:17 +0000 (10:00 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 5 May 2016 06:36:53 +0000 (14:36 +0800)
Running self-tests for a short-lived KVM VM takes 28ms on my laptop.
This commit adds a flag 'cryptomgr.notests' which allows them to be
disabled.

However if fips=1 as well, we ignore this flag as FIPS mode mandates
that the self-tests are run.

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Documentation/kernel-parameters.txt
crypto/testmgr.c

index ecc74fa4bfde8a55d9fee00d96ae5ae4123560e9..c799c045161e6e60e4305d21b1107f3b4011f40f 100644 (file)
@@ -826,6 +826,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
                        It will be ignored when crashkernel=X,high is not used
                        or memory reserved is below 4G.
 
+       cryptomgr.notests
+                        [KNL] Disable crypto self-tests
+
        cs89x0_dma=     [HW,NET]
                        Format: <dma>
 
index b86883aedca11a617ad2e19bafe646bfecac583a..fcd89fe4068aaae0406d229d3058307f4838cfcd 100644 (file)
 
 #include "internal.h"
 
+static bool notests;
+module_param(notests, bool, 0644);
+MODULE_PARM_DESC(notests, "disable crypto self-tests");
+
 #ifdef CONFIG_CRYPTO_MANAGER_DISABLE_TESTS
 
 /* a perfect nop */
@@ -3868,6 +3872,11 @@ int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
        int j;
        int rc;
 
+       if (!fips_enabled && notests) {
+               printk_once(KERN_INFO "alg: self-tests disabled\n");
+               return 0;
+       }
+
        alg_test_descs_check_order();
 
        if ((type & CRYPTO_ALG_TYPE_MASK) == CRYPTO_ALG_TYPE_CIPHER) {