From: "Gupta, Nipun" <nipun.gupta@amd.com>
To: Lukas Wunner <lukas@wunner.de>, herbert@gondor.apana.org.au
Cc: Krzysztof Kozlowski <krzk@kernel.org>,
davem@davemloft.net, dri-devel@lists.freedesktop.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
krzk+dt@kernel.org, gregkh@linuxfoundation.org, robh@kernel.org,
conor+dt@kernel.org, ogabbay@kernel.org,
maarten.lankhorst@linux.intel.com, mripard@kernel.org,
tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch,
derek.kiernan@amd.com, dragan.cvetic@amd.com, arnd@arndb.de,
praveen.jain@amd.com, harpreet.anand@amd.com,
nikhil.agarwal@amd.com, srivatsa@csail.mit.edu, code@tyhicks.com,
ptsm@linux.microsoft.com, linux-crypto@vger.kernel.org,
Ignat Korchagin <ignat@cloudflare.com>,
David Howells <dhowells@redhat.com>
Subject: Re: [PATCH v2 2/3] accel/amdpk: add driver for AMD PKI accelerator
Date: Wed, 16 Apr 2025 20:41:50 +0530 [thread overview]
Message-ID: <deaefc59-f6e4-2d4d-b91d-0ba7db9dfbf4@amd.com> (raw)
In-Reply-To: <Z_wH_uCx558T0__c@wunner.de>
On 14-04-2025 00:22, Lukas Wunner wrote:
> On Fri, Apr 11, 2025 at 10:21:03AM +0530, Gupta, Nipun wrote:
>> On 10-04-2025 13:06, Krzysztof Kozlowski wrote:
>>> On Wed, Apr 09, 2025 at 11:00:32PM GMT, Nipun Gupta wrote:
>>>> The AMD PKI accelerator driver provides a accel interface to interact
>>>> with the device for offloading and accelerating asymmetric crypto
>>>> operations.
>>>>
>>>
>>> For me this is clearly a crypto driver and you are supposed to:
>>> 1. Cc crypto maintaners,
>>> 2. Put it actually into crypto and use crypto API.
>>
>> added crypto maintainers for comments.
>> IMO, as accel framework is designed to support any type of compute
>> accelerators, the PKI crypto accelerator in accel framework is not
>> completely out of place here, as also suggested at:
>> https://lore.kernel.org/all/2025031352-gyration-deceit-5563@gregkh/
>
> To be fair, Greg did suggest drivers/crypto/ as an alternative... :)
>
> "Great, then why isn't this in drivers/accel/ or drivers/crypto/ ?"
> https://lore.kernel.org/r/2025031236-siamese-graffiti-5b98@gregkh/
>
> There are already six drivers for crypto accelerators in drivers/crypto/,
> so that would seem to be a natural fit for your driver:
>
> aspeed/aspeed-acry.c
> caam/caampkc.c
> ccp/ccp-crypto-rsa.c <-- from AMD no less!
> hisilicon/hpre/hpre_crypto.c
> intel/qat/qat_common/qat_asym_algs.c
> starfive/jh7110-rsa.c
>
> You can find these in the tree with:
>
> git grep 'cra_name = "rsa"'
>
> So far there are only drivers to accelerate RSA encryption/decryption.
> The kernel supports a single padding scheme, PKCS1, which is implemented
> by crypto/rsa-pkcs1pad.c. There is no support yet for OAEP.
>
> So the padding of the hash (which is cheap) happens in software and then
> crypto/rsa-pkcs1pad.c performs an RSA encrypt/decrypt operation which is
> either performed in software by crypto/rsa.c, or in hardware if a crypto
> accelerator is present. Drivers for crypto accelerators register the
> "rsa" algorithm with a higher cra_priority than the software
> implementation, hence are generally preferred.
>
> One benefit that you get from implementing a proper akcipher_alg in your
> driver is that virtual machines may take advantage of the hardware
> accelerator through the virtio support implemented by:
> drivers/crypto/virtio/virtio_crypto_akcipher_algs.c
>
> Note that the crypto subsystem currently does not support hardware
> acceleration of signature generation/verification (crypto_sig),
> but only encryption/decryption (crypto_akcipher). One reason is
> that signature generation/verification is generally a synchronous
> operation and doesn't benefit as much from hardware acceleration
> due to the overhead of interacting with the hardware.
Thank you for the feedback.
When establishing TLS connections, OpenSSL requires signature
generation/verification. In scenarios where multiple connections occur
simultaneously, asynchronous operations are beneficial as they lead to
much improved CPU utilization. OpenSSL ASYNC support can very well
utilizes the asynchronous operations while establishing multiple TLS
connections.
>
> So there's no support e.g. for generating or verifying ECDSA signatures
> in hardware. I think that would only really make sense if private keys
> are kept in hardware and cannot be retrieved. So the use case wouldn't
> be acceleration, but security of private keys.
While ECDSA signature generation and verification enhance the security
of private keys when stored in hardware, they also play important role
in the establishment of TLS connections. Offloading these operations to
hardware frees up CPU, enhancing performance during TLS handshakes.
>
> That said, for RSA specifically, signature generation/verification does
> involve an encrypt/decrypt operation internally. The padding is once
> again done in software (by crypto/rsassa-pkcs1.c -- no PSS support yet).
> But the actual encrypt/decrypt operation will be performed in
> hardware if a crypto accelerator is present.
>
> The user space interface Herbert referred to is a set of system calls
> which are usable e.g. via the keyutils library and command line utility:
> https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/keyutils.git/
These system calls can support only synchronous operations, which
precludes their use for asynchronous operations. This limitation
prevents the use of keyutils here.
Thanks,
Nipun
next prev parent reply other threads:[~2025-04-16 15:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-09 17:30 [PATCH v2 1/3] dt-bindings: accel: add device tree for AMD PKI accelerator Nipun Gupta
2025-04-09 17:30 ` [PATCH v2 2/3] accel/amdpk: add driver " Nipun Gupta
2025-04-10 7:36 ` Krzysztof Kozlowski
2025-04-11 4:51 ` Gupta, Nipun
2025-04-11 5:17 ` Herbert Xu
2025-04-11 18:20 ` Gupta, Nipun
2025-04-12 1:23 ` Herbert Xu
2025-04-17 15:32 ` Gupta, Nipun
2025-04-20 6:39 ` Herbert Xu
2025-04-13 18:52 ` Lukas Wunner
2025-04-16 15:11 ` Gupta, Nipun [this message]
2025-04-11 16:34 ` Jeff Hugo
2025-04-16 10:41 ` kernel test robot
2025-04-09 17:30 ` [PATCH v2 3/3] accel/amdpk: add debugfs support Nipun Gupta
2025-04-10 7:29 ` [PATCH v2 1/3] dt-bindings: accel: add device tree for AMD PKI accelerator Krzysztof Kozlowski
2025-04-11 18:18 ` Gupta, Nipun
2025-04-11 16:16 ` Jeff Hugo
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=deaefc59-f6e4-2d4d-b91d-0ba7db9dfbf4@amd.com \
--to=nipun.gupta@amd.com \
--cc=airlied@gmail.com \
--cc=arnd@arndb.de \
--cc=code@tyhicks.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=derek.kiernan@amd.com \
--cc=devicetree@vger.kernel.org \
--cc=dhowells@redhat.com \
--cc=dragan.cvetic@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=harpreet.anand@amd.com \
--cc=herbert@gondor.apana.org.au \
--cc=ignat@cloudflare.com \
--cc=krzk+dt@kernel.org \
--cc=krzk@kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=nikhil.agarwal@amd.com \
--cc=ogabbay@kernel.org \
--cc=praveen.jain@amd.com \
--cc=ptsm@linux.microsoft.com \
--cc=robh@kernel.org \
--cc=simona@ffwll.ch \
--cc=srivatsa@csail.mit.edu \
--cc=tzimmermann@suse.de \
/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