2012-10-21 17:45:31

by Jussi Kivilinna

[permalink] [raw]
Subject: [PATCH] crypto - ablk_helper: add module parameter to allow testing cryptd redirection of requests

Add module parameter to allow forcing redirection of crypto requests to
cryptd worker threads. This allows these code paths to be actually tested
(easier).

Signed-off-by: Jussi Kivilinna <[email protected]>
---
arch/x86/crypto/ablk_helper.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/x86/crypto/ablk_helper.c b/arch/x86/crypto/ablk_helper.c
index 43282fe..52385a3 100644
--- a/arch/x86/crypto/ablk_helper.c
+++ b/arch/x86/crypto/ablk_helper.c
@@ -33,6 +33,8 @@
#include <asm/i387.h>
#include <asm/crypto/ablk_helper.h>

+static int force_cryptd_redirect;
+
int ablk_set_key(struct crypto_ablkcipher *tfm, const u8 *key,
unsigned int key_len)
{
@@ -70,7 +72,7 @@ int ablk_encrypt(struct ablkcipher_request *req)
struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req);
struct async_helper_ctx *ctx = crypto_ablkcipher_ctx(tfm);

- if (!irq_fpu_usable()) {
+ if (force_cryptd_redirect || !irq_fpu_usable()) {
struct ablkcipher_request *cryptd_req =
ablkcipher_request_ctx(req);

@@ -89,7 +91,7 @@ int ablk_decrypt(struct ablkcipher_request *req)
struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req);
struct async_helper_ctx *ctx = crypto_ablkcipher_ctx(tfm);

- if (!irq_fpu_usable()) {
+ if (force_cryptd_redirect || !irq_fpu_usable()) {
struct ablkcipher_request *cryptd_req =
ablkcipher_request_ctx(req);

@@ -146,4 +148,7 @@ int ablk_init(struct crypto_tfm *tfm)
}
EXPORT_SYMBOL_GPL(ablk_init);

+module_param(force_cryptd_redirect, int, 0);
+MODULE_PARM_DESC(force_cryptd_redirect,
+ "Force all crypto request to cryptd worker instead of using current context (Use only for testing purposes!)");
MODULE_LICENSE("GPL");


2012-10-24 13:17:05

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto - ablk_helper: add module parameter to allow testing cryptd redirection of requests

On Sun, Oct 21, 2012 at 08:45:29PM +0300, Jussi Kivilinna wrote:
> Add module parameter to allow forcing redirection of crypto requests to
> cryptd worker threads. This allows these code paths to be actually tested
> (easier).
>
> Signed-off-by: Jussi Kivilinna <[email protected]>

Wouldn't this be applicable in other spots too? Perhaps we need
something that just makes irq_fpu_usable return false?

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

2012-10-25 14:29:12

by Jussi Kivilinna

[permalink] [raw]
Subject: Re: [PATCH] crypto - ablk_helper: add module parameter to allow testing cryptd redirection of requests

Quoting Herbert Xu <[email protected]>:

> On Sun, Oct 21, 2012 at 08:45:29PM +0300, Jussi Kivilinna wrote:
>> Add module parameter to allow forcing redirection of crypto requests to
>> cryptd worker threads. This allows these code paths to be actually tested
>> (easier).
>>
>> Signed-off-by: Jussi Kivilinna <[email protected]>
>
> Wouldn't this be applicable in other spots too? Perhaps we need
> something that just makes irq_fpu_usable return false?

That would make sense. Maybe some sort of debug config option which
gives kernel that forces irq_fpu_usable to false?

-Jussi