diff mbox series

[2/3] crypto: tcrypt - permit tcrypt.ko to be builtin

Message ID 20201109083143.2884-3-ardb@kernel.org
State New
Headers show
Series crypto: tcrypt enhancements | expand

Commit Message

Ard Biesheuvel Nov. 9, 2020, 8:31 a.m. UTC
When working on crypto algorithms, being able to run tcrypt quickly
without booting an entire Linux installation can be very useful. For
instance, QEMU/kvm can be used to boot a kernel from the command line,
and having tcrypt.ko builtin would allow tcrypt to be executed to run
benchmarks, or to run tests for algortithms that need to be instantiated
from templates, without the need to make it past the point where the
rootfs is mounted.

So let's relax the requirement that tcrypt can only be built as a
module when CRYPTO_MANAGER_EXTRA_TESTS is enabled, as this is already
documented as a crypto development-only symbol.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 crypto/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Herbert Xu Nov. 20, 2020, 3:44 a.m. UTC | #1
On Mon, Nov 09, 2020 at 09:31:42AM +0100, Ard Biesheuvel wrote:
> When working on crypto algorithms, being able to run tcrypt quickly

> without booting an entire Linux installation can be very useful. For

> instance, QEMU/kvm can be used to boot a kernel from the command line,

> and having tcrypt.ko builtin would allow tcrypt to be executed to run

> benchmarks, or to run tests for algortithms that need to be instantiated

> from templates, without the need to make it past the point where the

> rootfs is mounted.

> 

> So let's relax the requirement that tcrypt can only be built as a

> module when CRYPTO_MANAGER_EXTRA_TESTS is enabled, as this is already

> documented as a crypto development-only symbol.

> 

> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>

> ---

>  crypto/Kconfig | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/crypto/Kconfig b/crypto/Kconfig

> index 094ef56ab7b4..9ff2d687e334 100644

> --- a/crypto/Kconfig

> +++ b/crypto/Kconfig

> @@ -201,7 +201,7 @@ config CRYPTO_AUTHENC

>  

>  config CRYPTO_TEST

>  	tristate "Testing module"

> -	depends on m

> +	depends on m || CRYPTO_MANAGER_EXTRA_TESTS

>  	select CRYPTO_MANAGER

>  	help

>  	  Quick & dirty crypto test module.


This breaks the build:

crypto/Kconfig:150:error: recursive dependency detected!
crypto/Kconfig:150:     symbol CRYPTO_MANAGER_EXTRA_TESTS depends on CRYPTO_MANAGER
crypto/Kconfig:119:     symbol CRYPTO_MANAGER is selected by CRYPTO_TEST
crypto/Kconfig:206:     symbol CRYPTO_TEST depends on CRYPTO_MANAGER_EXTRA_TESTS
For a resolution refer to Documentation/kbuild/kconfig-language.rst
subsection "Kconfig recursive dependency limitations"

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Ard Biesheuvel Nov. 20, 2020, 9:24 a.m. UTC | #2
On Fri, 20 Nov 2020 at 04:44, Herbert Xu <herbert@gondor.apana.org.au> wrote:
>

> On Mon, Nov 09, 2020 at 09:31:42AM +0100, Ard Biesheuvel wrote:

> > When working on crypto algorithms, being able to run tcrypt quickly

> > without booting an entire Linux installation can be very useful. For

> > instance, QEMU/kvm can be used to boot a kernel from the command line,

> > and having tcrypt.ko builtin would allow tcrypt to be executed to run

> > benchmarks, or to run tests for algortithms that need to be instantiated

> > from templates, without the need to make it past the point where the

> > rootfs is mounted.

> >

> > So let's relax the requirement that tcrypt can only be built as a

> > module when CRYPTO_MANAGER_EXTRA_TESTS is enabled, as this is already

> > documented as a crypto development-only symbol.

> >

> > Signed-off-by: Ard Biesheuvel <ardb@kernel.org>

> > ---

> >  crypto/Kconfig | 2 +-

> >  1 file changed, 1 insertion(+), 1 deletion(-)

> >

> > diff --git a/crypto/Kconfig b/crypto/Kconfig

> > index 094ef56ab7b4..9ff2d687e334 100644

> > --- a/crypto/Kconfig

> > +++ b/crypto/Kconfig

> > @@ -201,7 +201,7 @@ config CRYPTO_AUTHENC

> >

> >  config CRYPTO_TEST

> >       tristate "Testing module"

> > -     depends on m

> > +     depends on m || CRYPTO_MANAGER_EXTRA_TESTS

> >       select CRYPTO_MANAGER

> >       help

> >         Quick & dirty crypto test module.

>

> This breaks the build:

>

> crypto/Kconfig:150:error: recursive dependency detected!

> crypto/Kconfig:150:     symbol CRYPTO_MANAGER_EXTRA_TESTS depends on CRYPTO_MANAGER

> crypto/Kconfig:119:     symbol CRYPTO_MANAGER is selected by CRYPTO_TEST

> crypto/Kconfig:206:     symbol CRYPTO_TEST depends on CRYPTO_MANAGER_EXTRA_TESTS

> For a resolution refer to Documentation/kbuild/kconfig-language.rst

> subsection "Kconfig recursive dependency limitations"

>


OK, I'll apply this on top

diff --git a/crypto/Kconfig b/crypto/Kconfig
index 9ff2d687e334..959ee48f66a8 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -202,7 +202,7 @@ config CRYPTO_AUTHENC
 config CRYPTO_TEST
        tristate "Testing module"
        depends on m || CRYPTO_MANAGER_EXTRA_TESTS
-       select CRYPTO_MANAGER
+       depends on CRYPTO_MANAGER
        help
          Quick & dirty crypto test module.
Herbert Xu Nov. 20, 2020, 10:09 a.m. UTC | #3
On Fri, Nov 20, 2020 at 10:24:44AM +0100, Ard Biesheuvel wrote:
>

> OK, I'll apply this on top

> 

> diff --git a/crypto/Kconfig b/crypto/Kconfig

> index 9ff2d687e334..959ee48f66a8 100644

> --- a/crypto/Kconfig

> +++ b/crypto/Kconfig

> @@ -202,7 +202,7 @@ config CRYPTO_AUTHENC

>  config CRYPTO_TEST

>         tristate "Testing module"

>         depends on m || CRYPTO_MANAGER_EXTRA_TESTS

> -       select CRYPTO_MANAGER

> +       depends on CRYPTO_MANAGER


How about just removing the depends line altogether?

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Ard Biesheuvel Nov. 20, 2020, 10:34 a.m. UTC | #4
On Fri, 20 Nov 2020 at 11:09, Herbert Xu <herbert@gondor.apana.org.au> wrote:
>

> On Fri, Nov 20, 2020 at 10:24:44AM +0100, Ard Biesheuvel wrote:

> >

> > OK, I'll apply this on top

> >

> > diff --git a/crypto/Kconfig b/crypto/Kconfig

> > index 9ff2d687e334..959ee48f66a8 100644

> > --- a/crypto/Kconfig

> > +++ b/crypto/Kconfig

> > @@ -202,7 +202,7 @@ config CRYPTO_AUTHENC

> >  config CRYPTO_TEST

> >         tristate "Testing module"

> >         depends on m || CRYPTO_MANAGER_EXTRA_TESTS

> > -       select CRYPTO_MANAGER

> > +       depends on CRYPTO_MANAGER

>

> How about just removing the depends line altogether?

>


That may break the build, and therefore randconfig build testing:


crypto/tcrypt.o: In function `do_mult_aead_op':
tcrypt.c:(.text+0x180): undefined reference to `crypto_aead_encrypt'
tcrypt.c:(.text+0x194): undefined reference to `crypto_aead_decrypt'
crypto/tcrypt.o: In function `do_mult_acipher_op':
tcrypt.c:(.text+0x2a0): undefined reference to `crypto_skcipher_encrypt'
tcrypt.c:(.text+0x2b4): undefined reference to `crypto_skcipher_decrypt'
crypto/tcrypt.o: In function `test_skcipher_speed':
tcrypt.c:(.text+0xf60): undefined reference to `crypto_alloc_skcipher'
tcrypt.c:(.text+0x1088): undefined reference to `crypto_skcipher_setkey'
tcrypt.c:(.text+0x1534): undefined reference to `crypto_skcipher_encrypt'
tcrypt.c:(.text+0x1570): undefined reference to `crypto_skcipher_decrypt'
tcrypt.c:(.text+0x15e8): undefined reference to `crypto_skcipher_encrypt'
tcrypt.c:(.text+0x1624): undefined reference to `crypto_skcipher_decrypt'
tcrypt.c:(.text+0x168c): undefined reference to `crypto_skcipher_encrypt'
tcrypt.c:(.text+0x16a8): undefined reference to `crypto_skcipher_decrypt'
crypto/tcrypt.o: In function `test_mb_aead_speed.constprop.23':
tcrypt.c:(.text+0x2020): undefined reference to `crypto_alloc_aead'
tcrypt.c:(.text+0x2048): undefined reference to `crypto_aead_setauthsize'
tcrypt.c:(.text+0x23a4): undefined reference to `crypto_aead_setkey'
tcrypt.c:(.text+0x27d0): undefined reference to `crypto_aead_encrypt'
crypto/tcrypt.o: In function `test_mb_skcipher_speed':
tcrypt.c:(.text+0x28ec): undefined reference to `crypto_alloc_skcipher'
tcrypt.c:(.text+0x2c08): undefined reference to `crypto_skcipher_setkey'
crypto/tcrypt.o: In function `test_aead_speed.constprop.22':
tcrypt.c:(.text+0x320c): undefined reference to `crypto_alloc_aead'
tcrypt.c:(.text+0x331c): undefined reference to `crypto_aead_setkey'
tcrypt.c:(.text+0x3328): undefined reference to `crypto_aead_setauthsize'
tcrypt.c:(.text+0x33ec): undefined reference to `crypto_aead_encrypt'
tcrypt.c:(.text+0x3428): undefined reference to `crypto_aead_decrypt'
tcrypt.c:(.text+0x3488): undefined reference to `crypto_aead_encrypt'
tcrypt.c:(.text+0x34c4): undefined reference to `crypto_aead_decrypt'
tcrypt.c:(.text+0x3528): undefined reference to `crypto_aead_encrypt'
tcrypt.c:(.text+0x3564): undefined reference to `crypto_aead_decrypt'
tcrypt.c:(.text+0x3744): undefined reference to `crypto_aead_encrypt'
crypto/tcrypt.o: In function `do_test':
tcrypt.c:(.text+0x3ad0): undefined reference to `alg_test'
tcrypt.c:(.text+0x3af4): undefined reference to `alg_test'
tcrypt.c:(.text+0x3b18): undefined reference to `alg_test'
tcrypt.c:(.text+0x3b34): undefined reference to `alg_test'
tcrypt.c:(.text+0x3b50): undefined reference to `alg_test'
Herbert Xu Nov. 20, 2020, 10:37 a.m. UTC | #5
On Fri, Nov 20, 2020 at 11:34:14AM +0100, Ard Biesheuvel wrote:
> On Fri, 20 Nov 2020 at 11:09, Herbert Xu <herbert@gondor.apana.org.au> wrote:

> >

> > On Fri, Nov 20, 2020 at 10:24:44AM +0100, Ard Biesheuvel wrote:

> > >

> > > OK, I'll apply this on top

> > >

> > > diff --git a/crypto/Kconfig b/crypto/Kconfig

> > > index 9ff2d687e334..959ee48f66a8 100644

> > > --- a/crypto/Kconfig

> > > +++ b/crypto/Kconfig

> > > @@ -202,7 +202,7 @@ config CRYPTO_AUTHENC

> > >  config CRYPTO_TEST

> > >         tristate "Testing module"

> > >         depends on m || CRYPTO_MANAGER_EXTRA_TESTS

> > > -       select CRYPTO_MANAGER

> > > +       depends on CRYPTO_MANAGER

> >

> > How about just removing the depends line altogether?

> 

> That may break the build, and therefore randconfig build testing:

> 

> crypto/tcrypt.o: In function `do_mult_aead_op':

> tcrypt.c:(.text+0x180): undefined reference to `crypto_aead_encrypt'

> tcrypt.c:(.text+0x194): undefined reference to `crypto_aead_decrypt'


Did you keep the select CRYPTO_MANAGER? That should bring in
everything that's needed.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Ard Biesheuvel Nov. 20, 2020, 10:40 a.m. UTC | #6
On Fri, 20 Nov 2020 at 11:37, Herbert Xu <herbert@gondor.apana.org.au> wrote:
>

> On Fri, Nov 20, 2020 at 11:34:14AM +0100, Ard Biesheuvel wrote:

> > On Fri, 20 Nov 2020 at 11:09, Herbert Xu <herbert@gondor.apana.org.au> wrote:

> > >

> > > On Fri, Nov 20, 2020 at 10:24:44AM +0100, Ard Biesheuvel wrote:

> > > >

> > > > OK, I'll apply this on top

> > > >

> > > > diff --git a/crypto/Kconfig b/crypto/Kconfig

> > > > index 9ff2d687e334..959ee48f66a8 100644

> > > > --- a/crypto/Kconfig

> > > > +++ b/crypto/Kconfig

> > > > @@ -202,7 +202,7 @@ config CRYPTO_AUTHENC

> > > >  config CRYPTO_TEST

> > > >         tristate "Testing module"

> > > >         depends on m || CRYPTO_MANAGER_EXTRA_TESTS

> > > > -       select CRYPTO_MANAGER

> > > > +       depends on CRYPTO_MANAGER

> > >

> > > How about just removing the depends line altogether?

> >

> > That may break the build, and therefore randconfig build testing:

> >

> > crypto/tcrypt.o: In function `do_mult_aead_op':

> > tcrypt.c:(.text+0x180): undefined reference to `crypto_aead_encrypt'

> > tcrypt.c:(.text+0x194): undefined reference to `crypto_aead_decrypt'

>

> Did you keep the select CRYPTO_MANAGER? That should bring in

> everything that's needed.

>


Ah right, you mean the /other/ depends line.

Yeah, that would work, but enabling it as a builtin produces a lot of
bogus output if you fail to set the tcrypt.mode=xxx kernel command
line option, so it is really only intended for deliberate use.
Herbert Xu Nov. 20, 2020, 10:42 a.m. UTC | #7
On Fri, Nov 20, 2020 at 11:40:24AM +0100, Ard Biesheuvel wrote:
>

> Yeah, that would work, but enabling it as a builtin produces a lot of

> bogus output if you fail to set the tcrypt.mode=xxx kernel command

> line option, so it is really only intended for deliberate use.


Perhaps replace it with a depends on m || EXPERT?

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Ard Biesheuvel Nov. 20, 2020, 10:43 a.m. UTC | #8
On Fri, 20 Nov 2020 at 11:42, Herbert Xu <herbert@gondor.apana.org.au> wrote:
>

> On Fri, Nov 20, 2020 at 11:40:24AM +0100, Ard Biesheuvel wrote:

> >

> > Yeah, that would work, but enabling it as a builtin produces a lot of

> > bogus output if you fail to set the tcrypt.mode=xxx kernel command

> > line option, so it is really only intended for deliberate use.

>

> Perhaps replace it with a depends on m || EXPERT?

>


That would be an option, but since we basically already have our own
local 'EXPERT' option when it comes to crypto testing, I thought I'd
use that instead.
Herbert Xu Nov. 20, 2020, 10:45 a.m. UTC | #9
On Fri, Nov 20, 2020 at 11:43:40AM +0100, Ard Biesheuvel wrote:
>

> That would be an option, but since we basically already have our own

> local 'EXPERT' option when it comes to crypto testing, I thought I'd

> use that instead.


Well that creates a loop and changing the select into a dependency
may confuse non-expert users who actually want to use this.

So I think using EXPERT is the way to go.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Ard Biesheuvel Nov. 20, 2020, 10:45 a.m. UTC | #10
On Fri, 20 Nov 2020 at 11:45, Herbert Xu <herbert@gondor.apana.org.au> wrote:
>

> On Fri, Nov 20, 2020 at 11:43:40AM +0100, Ard Biesheuvel wrote:

> >

> > That would be an option, but since we basically already have our own

> > local 'EXPERT' option when it comes to crypto testing, I thought I'd

> > use that instead.

>

> Well that creates a loop and changing the select into a dependency

> may confuse non-expert users who actually want to use this.

>

> So I think using EXPERT is the way to go.

>


Fair enough.
diff mbox series

Patch

diff --git a/crypto/Kconfig b/crypto/Kconfig
index 094ef56ab7b4..9ff2d687e334 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -201,7 +201,7 @@  config CRYPTO_AUTHENC
 
 config CRYPTO_TEST
 	tristate "Testing module"
-	depends on m
+	depends on m || CRYPTO_MANAGER_EXTRA_TESTS
 	select CRYPTO_MANAGER
 	help
 	  Quick & dirty crypto test module.