linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lucas Segarra <lucas.segarra.fernandez@intel.com>
To: Eric Biggers <ebiggers@kernel.org>
Cc: herbert@gondor.apana.org.au, linux-crypto@vger.kernel.org,
	qat-linux@intel.com, stable@vger.kernel.org,
	"Mikulas Patocka" <mpatocka@redhat.com>,
	"Marco Chiappero" <marco.chiappero@intel.com>,
	"Wojciech Ziemba" <wojciech.ziemba@intel.com>,
	"Giovanni Cabiddu" <giovanni.cabiddu@intel.com>,
	"Horia Geantă" <horia.geanta@nxp.com>,
	dm-devel@redhat.com
Subject: Re: [PATCH v3 1/3] crypto: qat - use pre-allocated buffers in datapath
Date: Mon, 11 Jul 2022 17:09:07 +0200	[thread overview]
Message-ID: <Ysw9E2Az2oK4jfCf@lucas-Virtual-Machine> (raw)
In-Reply-To: <Yswx1myaFwJR22FQ@silpixa00400314>

On Mon, Jul 11, 2022 at 03:21:39PM +0100, Giovanni Cabiddu wrote:
> On Mon, Apr 11, 2022 at 05:37:24PM +0000, Eric Biggers wrote:
> > On Sun, Apr 10, 2022 at 08:47:05PM +0100, Giovanni Cabiddu wrote:
> > > If requests exceed 4 entries buffers, memory is allocated dynamically.
> > > 
> > > In addition, remove the CRYPTO_ALG_ALLOCATES_MEMORY flag from both aead
> > > and skcipher alg structures.
> > > 
> > 
> > There is nothing that says that algorithms can ignore
> > !CRYPTO_ALG_ALLOCATES_MEMORY if there are too many scatterlist entries.  See the
> > comment above the definition of CRYPTO_ALG_ALLOCATES_MEMORY.
> > 
> > If you need to introduce this constraint, then you will need to audit the users
> > of !CRYPTO_ALG_ALLOCATES_MEMORY to verify that none of them are issuing requests
> > that violate this constraint, then add this to the documentation comment for
> > CRYPTO_ALG_ALLOCATES_MEMORY.
> Belatedly...
> 
> Adding to this thread my colleague Lucas who did an audit of the users
> of !CRYPTO_ALG_ALLOCATES_MEMORY to understand if we can add a constraint
> to the definition of CRYPTO_ALG_ALLOCATES_MEMORY.
> 
> Regards,
> 
> -- 
> Giovanni

An audit was done on users of !CRYPTO_ALG_ALLOCATES_MEMORY: dm-crypt and dm-integrity. dm-crypt uses scatterlists with at most 4 entries, but dm-integrity may allocate memory for scatterlist with arch-dependent and system-bounded number of entries. Therefore the constraint in https://lore.kernel.org/linux-crypto/20200722072932.GA27544@gondor.apana.org.au/ cannot be introduced.

A way to solve the problem might be to forward requests with more than 4 entries in a scatterlist to an implementation that does not allocate memory. This will introduce always a performance penalty for requests with scatterlists greater than 4 in algorithms backed up by HW accelerators, even if the requestor does not requires this restriction. A way to solve this might be to register two versions of the same algorithm, one without CRYPTO_ALG_ALLOCATES_MEMORY that forwards to SW and one with CRYPTO_ALG_ALLOCATES_MEMORY set that doesn’t. Any suggestions?

Adding Horia Geantă and dm-devel based on the previous thread.

Thanks.
---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN.
Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.

  reply	other threads:[~2022-07-11 15:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-10 19:47 [PATCH v3 0/3] crypto: qat - fix dm-crypt related issues Giovanni Cabiddu
2022-04-10 19:47 ` [PATCH v3 1/3] crypto: qat - use pre-allocated buffers in datapath Giovanni Cabiddu
2022-04-11 17:37   ` Eric Biggers
2022-04-19 10:31     ` Giovanni Cabiddu
2022-07-11 14:21     ` Giovanni Cabiddu
2022-07-11 15:09       ` Lucas Segarra [this message]
2022-04-10 19:47 ` [PATCH v3 2/3] crypto: qat - refactor submission logic Giovanni Cabiddu
2022-04-10 19:47 ` [PATCH v3 3/3] crypto: qat - add backlog mechanism Giovanni Cabiddu

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=Ysw9E2Az2oK4jfCf@lucas-Virtual-Machine \
    --to=lucas.segarra.fernandez@intel.com \
    --cc=dm-devel@redhat.com \
    --cc=ebiggers@kernel.org \
    --cc=giovanni.cabiddu@intel.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=horia.geanta@nxp.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=marco.chiappero@intel.com \
    --cc=mpatocka@redhat.com \
    --cc=qat-linux@intel.com \
    --cc=stable@vger.kernel.org \
    --cc=wojciech.ziemba@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).