linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Megha Dey <megha.dey@intel.com>
Cc: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org
Subject: Re: [RFC] crypto: Remove mcryptd
Date: Thu, 16 Aug 2018 14:55:20 +0800	[thread overview]
Message-ID: <20180816065520.pojqi7pplpnknlv5@gondor.apana.org.au> (raw)
In-Reply-To: <1533868833.19050.19.camel@megha-Z97X-UD7-TH>

On Thu, Aug 09, 2018 at 07:40:33PM -0700, Megha Dey wrote:
>
> 1. 
> @@ -495,7 +534,10 @@ static void cryptd_skcipher_encrypt(struct
> crypto_async_request *base,
>         skcipher_request_set_crypt(subreq, req->src, req->dst,
> req->cryptlen, req->iv);
>  
> -       err = crypto_skcipher_encrypt(subreq);
> +       subreq->base.data = req->base.data;
> +       subreq->base.complete = rctx->complete;
> +       rctx->desc = *subreq;
> +       err = crypto_skcipher_encrypt(&rctx->desc);
>         skcipher_request_zero(subreq);
> 
> This change is necessary because for the multibuffer algorithms, the
> inner algorithm needs a pointer to the original request. In the slow
> path, since we allocate a skcipher_request on the stack, there is no
> easy way to retrieve the request. In the mcryptd_layer, we had extra
> logic to store this pointer. 

Why do you need the original request?

I think the fact that you need this at all indicates that you're
not using cryptd correctly.  cryptd should be completely transparent
to the underlying algorithm.  All it's doing is making sure that
the underlying algorithm gets called in a context that allows SIMD
use.

> Lastly, for hashes, we have
> struct cryptd_hash_request_ctx {
>         crypto_completion_t complete;
>         struct shash_desc desc;
> };
> 
> If we were to use this(with the added fields for multibuffer), we should
> update the shash_desc to ahash_request since we are an async algorithm
> right?

That's a good point.  More importantly, you also need to extend
cryptd to allow an ASYNC underlying algorithm, for skcipher as well
as hashes.  This is not as simple as just modifying the type/mask
during algorithm creation.  But you also need to modify the run-time
(e.g., cryptd_skcipher_encrypt) to defer the completion in case of an
async return value.

The same change also needs to be made to crypto/simd.c, but at least
there the run-time doesn't need any changes AFAICS.

Thanks,
-- 
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

      reply	other threads:[~2018-08-16  6:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-12  1:44 [RFC] crypto: Remove mcryptd Megha Dey
2018-05-31 18:15 ` Megha Dey
2018-07-20  3:53 ` Herbert Xu
2018-07-27  0:25   ` Megha Dey
2018-08-08  9:56     ` Herbert Xu
2018-08-10  2:40       ` Megha Dey
2018-08-16  6:55         ` Herbert Xu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180816065520.pojqi7pplpnknlv5@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=megha.dey@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).