2010-05-24 09:36:38

by Alexander Shishkin

[permalink] [raw]
Subject: [RFC][PATCH] crypto: disable tests when they are not enabled

Don't compile in and don't schedule cryptomanager's tests when
CONFIG_CRYPTO_TESTS is not set. This saves quite some time during
kernel initialization.

Signed-off-by: Alexander Shishkin <[email protected]>
CC: Herbert Xu <[email protected]>
CC: [email protected]
CC: [email protected]
---
crypto/algboss.c | 4 ++++
crypto/testmgr.c | 14 ++++++++++++++
2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/crypto/algboss.c b/crypto/algboss.c
index c3c196b..4814a44 100644
--- a/crypto/algboss.c
+++ b/crypto/algboss.c
@@ -206,6 +206,7 @@ err:
return NOTIFY_OK;
}

+#ifdef CONFIG_CRYPTO_TEST
static int cryptomgr_test(void *data)
{
struct crypto_test_param *param = data;
@@ -266,6 +267,7 @@ err_put_module:
err:
return NOTIFY_OK;
}
+#endif /* CONFIG_CRYPTO_TEST */

static int cryptomgr_notify(struct notifier_block *this, unsigned long msg,
void *data)
@@ -273,8 +275,10 @@ static int cryptomgr_notify(struct notifier_block *this, unsigned long msg,
switch (msg) {
case CRYPTO_MSG_ALG_REQUEST:
return cryptomgr_schedule_probe(data);
+#ifdef CONFIG_CRYPTO_TEST
case CRYPTO_MSG_ALG_REGISTER:
return cryptomgr_schedule_test(data);
+#endif
}

return NOTIFY_DONE;
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 5c8aaa0..3529484 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -22,6 +22,17 @@
#include <crypto/rng.h>

#include "internal.h"
+
+#ifndef CONFIG_CRYPTO_TEST
+
+/* a perfect nop */
+int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
+{
+ return 0;
+}
+
+#else
+
#include "testmgr.h"

/*
@@ -2530,4 +2541,7 @@ notest:
non_fips_alg:
return -EINVAL;
}
+
+#endif
+
EXPORT_SYMBOL_GPL(alg_test);
--
1.7.1.1.g15764


2010-05-24 11:27:30

by Herbert Xu

[permalink] [raw]
Subject: Re: [RFC][PATCH] crypto: disable tests when they are not enabled

On Mon, May 24, 2010 at 12:35:24PM +0300, Alexander Shishkin wrote:
> Don't compile in and don't schedule cryptomanager's tests when
> CONFIG_CRYPTO_TESTS is not set. This saves quite some time during
> kernel initialization.

You're disabling the self-testing infrastructure. This is not
the same thing as the tcrypt module.

Is this for fast booting?

Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2010-05-24 12:20:50

by Alexander Shishkin

[permalink] [raw]
Subject: Re: [RFC][PATCH] crypto: disable tests when they are not enabled

On Mon, May 24, 2010 at 09:27:26 +1000, Herbert Xu wrote:
> On Mon, May 24, 2010 at 12:35:24PM +0300, Alexander Shishkin wrote:
> > Don't compile in and don't schedule cryptomanager's tests when
> > CONFIG_CRYPTO_TESTS is not set. This saves quite some time during
> > kernel initialization.
>
> You're disabling the self-testing infrastructure. This is not
> the same thing as the tcrypt module.

It is my intention to disable these tests since in my running them at
every boot doesn't add any value. I thought about adding a separate
Kconfig option for that, too. I want to make sure it's a sensible thing
to do.

> Is this for fast booting?

Yes, it saves ~180 miliseconds for me at prng_mod_init(), for example.

Regards,
--
Alex

2010-05-26 00:44:00

by Herbert Xu

[permalink] [raw]
Subject: Re: [RFC][PATCH] crypto: disable tests when they are not enabled

On Mon, May 24, 2010 at 03:20:50PM +0300, Alexander Shishkin wrote:
>
> Yes, it saves ~180 miliseconds for me at prng_mod_init(), for example.

I see. In that case please introduce a new Kconfig option for
this that defaults to testing being enabled.

Thanks!
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2010-05-26 09:29:53

by Alexander Shishkin

[permalink] [raw]
Subject: [PATCH] crypto: add an option to disable cryptoalgos' self-tests

By default, CONFIG_CRYPTO_MANAGER_TESTS will be enabled and thus
self-tests will still run, but it is now possible to disable them
to gain some time during bootup.

Signed-off-by: Alexander Shishkin <[email protected]>
CC: Herbert Xu <[email protected]>
CC: [email protected]
CC: [email protected]
---
crypto/Kconfig | 8 ++++++++
crypto/algboss.c | 4 ++++
crypto/testmgr.c | 14 ++++++++++++++
3 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/crypto/Kconfig b/crypto/Kconfig
index 9d9434f..df332c1 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -96,6 +96,14 @@ config CRYPTO_MANAGER2
select CRYPTO_BLKCIPHER2
select CRYPTO_PCOMP

+config CRYPTO_MANAGER_TESTS
+ bool "Run algolithms' self-tests"
+ default y
+ depends on CRYPTO_MANAGER2
+ help
+ Run cryptomanager's tests for the new crypto algorithms being
+ registered.
+
config CRYPTO_GF128MUL
tristate "GF(2^128) multiplication functions (EXPERIMENTAL)"
depends on EXPERIMENTAL
diff --git a/crypto/algboss.c b/crypto/algboss.c
index c3c196b..40bd391 100644
--- a/crypto/algboss.c
+++ b/crypto/algboss.c
@@ -206,6 +206,7 @@ err:
return NOTIFY_OK;
}

+#ifdef CONFIG_CRYPTO_MANAGER_TESTS
static int cryptomgr_test(void *data)
{
struct crypto_test_param *param = data;
@@ -266,6 +267,7 @@ err_put_module:
err:
return NOTIFY_OK;
}
+#endif /* CONFIG_CRYPTO_MANAGER_TESTS */

static int cryptomgr_notify(struct notifier_block *this, unsigned long msg,
void *data)
@@ -273,8 +275,10 @@ static int cryptomgr_notify(struct notifier_block *this, unsigned long msg,
switch (msg) {
case CRYPTO_MSG_ALG_REQUEST:
return cryptomgr_schedule_probe(data);
+#ifdef CONFIG_CRYPTO_MANAGER_TESTS
case CRYPTO_MSG_ALG_REGISTER:
return cryptomgr_schedule_test(data);
+#endif
}

return NOTIFY_DONE;
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 5c8aaa0..abd980c 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -22,6 +22,17 @@
#include <crypto/rng.h>

#include "internal.h"
+
+#ifndef CONFIG_CRYPTO_MANAGER_TESTS
+
+/* a perfect nop */
+int alg_test(const char *driver, const char *alg, u32 type, u32 mask)
+{
+ return 0;
+}
+
+#else
+
#include "testmgr.h"

/*
@@ -2530,4 +2541,7 @@ notest:
non_fips_alg:
return -EINVAL;
}
+
+#endif /* CONFIG_CRYPTO_MANAGER_TESTS */
+
EXPORT_SYMBOL_GPL(alg_test);
--
1.5.6.5

2010-06-03 10:34:31

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: add an option to disable cryptoalgos' self-tests

On Wed, May 26, 2010 at 12:28:34PM +0300, Alexander Shishkin wrote:
> By default, CONFIG_CRYPTO_MANAGER_TESTS will be enabled and thus
> self-tests will still run, but it is now possible to disable them
> to gain some time during bootup.

While reviewing this patch I found a bug in the current PCOMP
Kconfig entry.

commit bc94e59662c13516d13e117b6edab4bec487d5a0
Author: Herbert Xu <[email protected]>
Date: Thu Jun 3 20:33:06 2010 +1000

crypto: pcomp - Fix illegal Kconfig configuration

The PCOMP Kconfig entry current allows the following combination
which is illegal:

ZLIB=y
PCOMP=y
ALGAPI=m
ALGAPI2=y
MANAGER=m
MANAGER2=m

This patch fixes this by adding PCOMP2 so that PCOMP can select
ALGAPI to propagate the setting to MANAGER2.

Signed-off-by: Herbert Xu <[email protected]>

diff --git a/crypto/Kconfig b/crypto/Kconfig
index 9d9434f..11d0f21 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -80,6 +80,11 @@ config CRYPTO_RNG2

config CRYPTO_PCOMP
tristate
+ select CRYPTO_PCOMP2
+ select CRYPTO_ALGAPI
+
+config CRYPTO_PCOMP2
+ tristate
select CRYPTO_ALGAPI2

config CRYPTO_MANAGER
@@ -94,7 +99,7 @@ config CRYPTO_MANAGER2
select CRYPTO_AEAD2
select CRYPTO_HASH2
select CRYPTO_BLKCIPHER2
- select CRYPTO_PCOMP
+ select CRYPTO_PCOMP2

config CRYPTO_GF128MUL
tristate "GF(2^128) multiplication functions (EXPERIMENTAL)"
diff --git a/crypto/Makefile b/crypto/Makefile
index d7e6441..d1cfa05 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -26,7 +26,7 @@ crypto_hash-objs += ahash.o
crypto_hash-objs += shash.o
obj-$(CONFIG_CRYPTO_HASH2) += crypto_hash.o

-obj-$(CONFIG_CRYPTO_PCOMP) += pcompress.o
+obj-$(CONFIG_CRYPTO_PCOMP2) += pcompress.o

cryptomgr-objs := algboss.o testmgr.o

Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2010-06-03 10:53:59

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: add an option to disable cryptoalgos' self-tests

On Wed, May 26, 2010 at 12:28:34PM +0300, Alexander Shishkin wrote:
> By default, CONFIG_CRYPTO_MANAGER_TESTS will be enabled and thus
> self-tests will still run, but it is now possible to disable them
> to gain some time during bootup.
>
> Signed-off-by: Alexander Shishkin <[email protected]>
> CC: Herbert Xu <[email protected]>
> CC: [email protected]
> CC: [email protected]

Patch applied. Thanks a lot!
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt