From: Eric Biggers <ebiggers@kernel.org>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "Sean Anderson" <sean.anderson@linux.dev>,
"Horia Geantă" <horia.geanta@nxp.com>,
"Pankaj Gupta" <pankaj.gupta@nxp.com>,
"Gaurav Jain" <gaurav.jain@nxp.com>,
linux-crypto@vger.kernel.org,
"David S. Miller" <davem@davemloft.net>,
linux-kernel@vger.kernel.org,
"Valentin Ciocoi Radulescu" <valentin.ciocoi@nxp.com>
Subject: Re: [PATCH] crypto: api - Add support for duplicating algorithms before registration
Date: Sun, 13 Apr 2025 09:03:04 -0700 [thread overview]
Message-ID: <20250413160304.GA16145@quark.localdomain> (raw)
In-Reply-To: <Z_n3O_IZhbgQE02q@gondor.apana.org.au>
On Sat, Apr 12, 2025 at 01:16:43PM +0800, Herbert Xu wrote:
> On Fri, Apr 11, 2025 at 09:36:27AM +0800, Herbert Xu wrote:
> >
> > The patch goes on top of cryptodev. But it won't do anything
> > without a corresponding patch to caam that moves the algorithm
> > data structures into dynamically allocated memory, and adds a
> > cra_destroy hook to free that memory.
>
> Here's a patch on top that allows drivers to do this easily.
> Unfortunately it still won't help caam because it embeds the
> algorithm in a bigger structure, so the duplication needs to
> be done by hand.
>
> ---8<---
> If the bit CRYPTO_ALG_DUP_FIRST is set, an algorithm will be
> duplicated by kmemdup before registration. This is inteded for
> hardware-based algorithms that may be unplugged at will.
>
> Do not use this if the algorithm data structure is embedded in a
> bigger data structure. Perform the duplication in the driver
> instead.
>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Why does this make any sense? The lifetime of the algorithm struct memory
should be the same as that of the owning module, and drivers should ensure that.
In which case hacks like this are not needed.
- Eric
next prev parent reply other threads:[~2025-04-13 16:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 23:16 [BUG] CAAM refcount warnings Sean Anderson
2025-04-08 5:17 ` [PATCH] crypto: caam/qi - Fix drv_ctx refcount bug Herbert Xu
2025-04-08 7:59 ` Horia Geanta
2025-04-08 15:44 ` Sean Anderson
2025-04-09 2:58 ` Herbert Xu
2025-04-09 3:29 ` [PATCH] crypto: api - Allow delayed algorithm destruction Herbert Xu
2025-04-10 23:24 ` Sean Anderson
2025-04-11 1:36 ` Herbert Xu
2025-04-12 5:16 ` [PATCH] crypto: api - Add support for duplicating algorithms before registration Herbert Xu
2025-04-13 16:03 ` Eric Biggers [this message]
2025-04-14 5:16 ` Herbert Xu
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=20250413160304.GA16145@quark.localdomain \
--to=ebiggers@kernel.org \
--cc=davem@davemloft.net \
--cc=gaurav.jain@nxp.com \
--cc=herbert@gondor.apana.org.au \
--cc=horia.geanta@nxp.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pankaj.gupta@nxp.com \
--cc=sean.anderson@linux.dev \
--cc=valentin.ciocoi@nxp.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