2014-02-14 19:14:52

by Tim Chen

[permalink] [raw]
Subject: [PATCH] crypto: Add soft module dependency to load HW accelerated crypto modules

We added the soft module dependency of various crypto algorithm's module alias
to generic crypto algorithm's module. This loads hardware accelerated
modules and uses them when available.

Signed-off-by: Tim Chen <[email protected]>
---
crypto/blowfish_generic.c | 1 +
crypto/camellia_generic.c | 1 +
crypto/cast5_generic.c | 1 +
crypto/cast6_generic.c | 1 +
crypto/ghash-generic.c | 1 +
crypto/salsa20_generic.c | 1 +
crypto/serpent_generic.c | 1 +
crypto/sha1_generic.c | 1 +
crypto/sha256_generic.c | 2 ++
crypto/sha512_generic.c | 2 ++
crypto/twofish_generic.c | 1 +
11 files changed, 13 insertions(+)

diff --git a/crypto/blowfish_generic.c b/crypto/blowfish_generic.c
index 8baf544..6c09e17 100644
--- a/crypto/blowfish_generic.c
+++ b/crypto/blowfish_generic.c
@@ -139,3 +139,4 @@ module_exit(blowfish_mod_fini);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Blowfish Cipher Algorithm");
MODULE_ALIAS("blowfish");
+MODULE_SOFTDEP("pre: blowfish");
diff --git a/crypto/camellia_generic.c b/crypto/camellia_generic.c
index 26bcd7a..c6a1200 100644
--- a/crypto/camellia_generic.c
+++ b/crypto/camellia_generic.c
@@ -1099,3 +1099,4 @@ module_exit(camellia_fini);
MODULE_DESCRIPTION("Camellia Cipher Algorithm");
MODULE_LICENSE("GPL");
MODULE_ALIAS("camellia");
+MODULE_SOFTDEP("pre: camellia");
diff --git a/crypto/cast5_generic.c b/crypto/cast5_generic.c
index 5558f63..58d8c5f 100644
--- a/crypto/cast5_generic.c
+++ b/crypto/cast5_generic.c
@@ -550,3 +550,4 @@ module_exit(cast5_mod_fini);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Cast5 Cipher Algorithm");
MODULE_ALIAS("cast5");
+MODULE_SOFTDEP("pre: cast5");
diff --git a/crypto/cast6_generic.c b/crypto/cast6_generic.c
index de73252..b277744 100644
--- a/crypto/cast6_generic.c
+++ b/crypto/cast6_generic.c
@@ -292,3 +292,4 @@ module_exit(cast6_mod_fini);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Cast6 Cipher Algorithm");
MODULE_ALIAS("cast6");
+MODULE_SOFTDEP("pre: cast6");
diff --git a/crypto/ghash-generic.c b/crypto/ghash-generic.c
index 9d3f0c6..32814ab 100644
--- a/crypto/ghash-generic.c
+++ b/crypto/ghash-generic.c
@@ -173,3 +173,4 @@ module_exit(ghash_mod_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("GHASH Message Digest Algorithm");
MODULE_ALIAS("ghash");
+MODULE_SOFTDEP("pre: ghash");
diff --git a/crypto/salsa20_generic.c b/crypto/salsa20_generic.c
index 9a4770c..2c7a308 100644
--- a/crypto/salsa20_generic.c
+++ b/crypto/salsa20_generic.c
@@ -249,3 +249,4 @@ module_exit(salsa20_generic_mod_fini);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION ("Salsa20 stream cipher algorithm");
MODULE_ALIAS("salsa20");
+MODULE_SOFTDEP("pre: salsa20");
diff --git a/crypto/serpent_generic.c b/crypto/serpent_generic.c
index 7ddbd7e..61eb7a7 100644
--- a/crypto/serpent_generic.c
+++ b/crypto/serpent_generic.c
@@ -667,3 +667,4 @@ MODULE_DESCRIPTION("Serpent and tnepres (kerneli compatible serpent reversed) Ci
MODULE_AUTHOR("Dag Arne Osvik <[email protected]>");
MODULE_ALIAS("tnepres");
MODULE_ALIAS("serpent");
+MODULE_SOFTDEP("pre: serpent");
diff --git a/crypto/sha1_generic.c b/crypto/sha1_generic.c
index 4279480..0af944b 100644
--- a/crypto/sha1_generic.c
+++ b/crypto/sha1_generic.c
@@ -154,3 +154,4 @@ MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("SHA1 Secure Hash Algorithm");

MODULE_ALIAS("sha1");
+MODULE_SOFTDEP("pre: sha1");
diff --git a/crypto/sha256_generic.c b/crypto/sha256_generic.c
index 5433667..227d570 100644
--- a/crypto/sha256_generic.c
+++ b/crypto/sha256_generic.c
@@ -385,4 +385,6 @@ MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("SHA-224 and SHA-256 Secure Hash Algorithm");

MODULE_ALIAS("sha224");
+MODULE_SOFTDEP("pre: sha224");
MODULE_ALIAS("sha256");
+MODULE_SOFTDEP("pre: sha256");
diff --git a/crypto/sha512_generic.c b/crypto/sha512_generic.c
index 6ed124f..b1cf774 100644
--- a/crypto/sha512_generic.c
+++ b/crypto/sha512_generic.c
@@ -288,4 +288,6 @@ MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("SHA-512 and SHA-384 Secure Hash Algorithms");

MODULE_ALIAS("sha384");
+MODULE_SOFTDEP("pre: sha384");
MODULE_ALIAS("sha512");
+MODULE_SOFTDEP("pre: sha512");
diff --git a/crypto/twofish_generic.c b/crypto/twofish_generic.c
index 2d50005..4239386 100644
--- a/crypto/twofish_generic.c
+++ b/crypto/twofish_generic.c
@@ -212,3 +212,4 @@ module_exit(twofish_mod_fini);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION ("Twofish Cipher Algorithm");
MODULE_ALIAS("twofish");
+MODULE_SOFTDEP("pre: twofish");
--
1.7.11.7


2014-02-14 20:28:44

by Neil Horman

[permalink] [raw]
Subject: Re: [PATCH] crypto: Add soft module dependency to load HW accelerated crypto modules

On Fri, Feb 14, 2014 at 11:14:37AM -0800, Tim Chen wrote:
> We added the soft module dependency of various crypto algorithm's module alias
> to generic crypto algorithm's module. This loads hardware accelerated
> modules and uses them when available.
>
This is great, but have any of the module load utilties been modified to
recognize and handle soft dependencies in the modinfo section? Last I checked
they hadn't. Do you plan to add that functionality?

Neil

2014-02-14 21:16:09

by Tim Chen

[permalink] [raw]
Subject: Re: [PATCH] crypto: Add soft module dependency to load HW accelerated crypto modules

On Fri, 2014-02-14 at 15:28 -0500, Neil Horman wrote:
> On Fri, Feb 14, 2014 at 11:14:37AM -0800, Tim Chen wrote:
> > We added the soft module dependency of various crypto algorithm's module alias
> > to generic crypto algorithm's module. This loads hardware accelerated
> > modules and uses them when available.
> >
> This is great, but have any of the module load utilties been modified to
> recognize and handle soft dependencies in the modinfo section? Last I checked
> they hadn't. Do you plan to add that functionality?
>
> Neil
>

Rusty,

Do you know if the upstream modprobe has the fixes (or plan) to
recognize soft dependencies? I was under the impression that it
is the case.

Thanks.

Tim

2014-02-15 01:24:02

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: Add soft module dependency to load HW accelerated crypto modules

On Fri, Feb 14, 2014 at 11:14:37AM -0800, Tim Chen wrote:
> We added the soft module dependency of various crypto algorithm's module alias
> to generic crypto algorithm's module. This loads hardware accelerated
> modules and uses them when available.
>
> Signed-off-by: Tim Chen <[email protected]>

I don't see the point of this patch. Any users of these modules
would be requesting for their alias and not their real name. So
either it'll already load all the hardware modules or it won't load
the generic version either.

For example, if you request blowfish you'll get every module that
has the alias blowfish. As the software version is called blowfish_generic
it will be treated no differently than any hardware accelerated
version.

Cheers,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2014-02-15 02:01:10

by Tim Chen

[permalink] [raw]
Subject: Re: [PATCH] crypto: Add soft module dependency to load HW accelerated crypto modules

On Sat, 2014-02-15 at 09:23 +0800, Herbert Xu wrote:
> On Fri, Feb 14, 2014 at 11:14:37AM -0800, Tim Chen wrote:
> > We added the soft module dependency of various crypto algorithm's module alias
> > to generic crypto algorithm's module. This loads hardware accelerated
> > modules and uses them when available.
> >
> > Signed-off-by: Tim Chen <[email protected]>
>
> I don't see the point of this patch. Any users of these modules
> would be requesting for their alias and not their real name. So
> either it'll already load all the hardware modules or it won't load
> the generic version either.
>
> For example, if you request blowfish you'll get every module that
> has the alias blowfish. As the software version is called blowfish_generic
> it will be treated no differently than any hardware accelerated
> version.

If we issue an explicit modprobe of the module alias, I don't
think there is a problem.

I am under the impression we may have a scenario like this:

Module A selects CRYPTO_ALG_B in config, which causes the generic
ALG_B to get built and a module dependency to the generic
ALG_B to be established. Then when module A loads,
we will load the generic ALG_B module. So a soft dependency
in the generic ALG_B module is needed
to load all the other alias module along with the generic
module. Otherwise only the generic module is loaded when
module A loads.

Tim

2014-02-15 23:41:35

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: Add soft module dependency to load HW accelerated crypto modules

On Fri, Feb 14, 2014 at 06:01:06PM -0800, Tim Chen wrote:
>
> Module A selects CRYPTO_ALG_B in config, which causes the generic
> ALG_B to get built and a module dependency to the generic
> ALG_B to be established. Then when module A loads,

No, if you select ALG_B then yes it'll get built but it certainly
won't establish a module dependency on ALG_B. Only a softdep could
create such a dependency.

Cheers,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2014-02-17 00:39:34

by Rusty Russell

[permalink] [raw]
Subject: Re: [PATCH] crypto: Add soft module dependency to load HW accelerated crypto modules

Tim Chen <[email protected]> writes:

> On Fri, 2014-02-14 at 15:28 -0500, Neil Horman wrote:
>> On Fri, Feb 14, 2014 at 11:14:37AM -0800, Tim Chen wrote:
>> > We added the soft module dependency of various crypto algorithm's module alias
>> > to generic crypto algorithm's module. This loads hardware accelerated
>> > modules and uses them when available.
>> >
>> This is great, but have any of the module load utilties been modified to
>> recognize and handle soft dependencies in the modinfo section? Last I checked
>> they hadn't. Do you plan to add that functionality?
>>
>> Neil
>>
>
> Rusty,
>
> Do you know if the upstream modprobe has the fixes (or plan) to
> recognize soft dependencies? I was under the impression that it
> is the case.

Marco CC'd...

Cheers,
Rusty.

2014-02-17 01:29:10

by Marco d'Itri

[permalink] [raw]
Subject: Re: [PATCH] crypto: Add soft module dependency to load HW accelerated crypto modules

On Feb 17, Rusty Russell <[email protected]> wrote:

> > Do you know if the upstream modprobe has the fixes (or plan) to
> > recognize soft dependencies? I was under the impression that it
> > is the case.
> Marco CC'd...
I only maintain the Debian package, but Lucas should know.

--
ciao,
Marco

2014-02-17 01:56:43

by Lucas De Marchi

[permalink] [raw]
Subject: Re: [PATCH] crypto: Add soft module dependency to load HW accelerated crypto modules

On Sun, Feb 16, 2014 at 10:21 PM, Marco d'Itri <[email protected]> wrote:
> On Feb 17, Rusty Russell <[email protected]> wrote:
>
>> > Do you know if the upstream modprobe has the fixes (or plan) to
>> > recognize soft dependencies? I was under the impression that it
>> > is the case.
>> Marco CC'd...
> I only maintain the Debian package, but Lucas should know.

The way the softdep is declared e.g. in crc32 pretty much broke the
concept of softdep that we had before: it was intended to pass
dependencies we should try to load, but not bail out if they failed.

For softdeps coming from kernel it means: "this is a dependency, but I
can't express it in terms of symbols, so consider XXXX the module I
depend on". The problem is that depmod has no knowledge of softdeps,
only modprobe, which means the dependency loop check is done only
while loading a module, not while generating modules.dep.

I have a pending patch to make modprobe consider the softdep coming
from kernel, but I think it isn't ideal... I'll take a deeper look on
this issue this week.


Lucas De Marchi

2014-02-17 12:08:25

by Neil Horman

[permalink] [raw]
Subject: Re: [PATCH] crypto: Add soft module dependency to load HW accelerated crypto modules

On Sun, Feb 16, 2014 at 07:41:23AM +0800, Herbert Xu wrote:
> On Fri, Feb 14, 2014 at 06:01:06PM -0800, Tim Chen wrote:
> >
> > Module A selects CRYPTO_ALG_B in config, which causes the generic
> > ALG_B to get built and a module dependency to the generic
> > ALG_B to be established. Then when module A loads,
>
> No, if you select ALG_B then yes it'll get built but it certainly
> won't establish a module dependency on ALG_B. Only a softdep could
> create such a dependency.
>
My understanding was that the soft dependencies were there to work exactly at
the softdep directive was in modprobe.conf. That it to say, "Module B would
like to have Module A installed, but it won't be fatal if it can't be done".
The more correct example I've seen thus far has been the crct10dif crc
algorithm for x86. In lib/crc-t10dif we have a crc-t10dif function which makes
use of the generic crc_t10dif_generic function defined in crct10dif_common.c.
However, x86 has an accelerated version of the function defined in the
crct10dif-pcmul module (thats aliased to crct10dif). So the library funcion in
the kernel lists crct10dif as a soft dependency and modprobe tries to load it,
but just carries on if it fails.

Although as I write that, several things confuse me. When are module
dependencies meant to be satisfied on behalf of the monolithic kernel, where
that dependecy is defined? I'm guessing right before the init routine is
called for that code, but I'm not sure. Also, I'm a bit confused by Marco and
Lukas' statement about how they see soft dependencies working. I'm not sure
where the requirement to recognize soft dependencies comes from in depmod.

Regards
Neil

> Cheers,
> --
> Email: Herbert Xu <[email protected]>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
> --
> To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>