mbox series

[v5,0/5] Add Tegra Security Engine driver

Message ID 20240219172530.20517-1-akhilrajeev@nvidia.com
Headers show
Series Add Tegra Security Engine driver | expand

Message

Akhil R Feb. 19, 2024, 5:25 p.m. UTC
Add support for Tegra Security Engine which can accelerates various
crypto algorithms. The Engine has two separate instances within for
AES and HASH algorithms respectively.

The driver registers two crypto engines - one for AES and another for
HASH algorithms and these operate independently and both uses the host1x
bus. Additionally, it provides  hardware-assisted key protection for up to
15 symmetric keys which it can use for the cipher operations.

v4->v5:
* Move copy/paste of intermediate results in export()/import() to
  'update()' callback
v3->v4:
* Remove unused header in bindings doc.
* Update commit message in host1x change.
* Fix test bot warning.
v2->v3:
* Update compatible in driver and device trees.
* Remove extra new lines and symbols in binding doc.
v1->v2:
* Update probe errors with 'dev_err_probe'.
* Clean up function prototypes and redundant prints.
* Remove readl/writel wrappers.
* Fix test bot warnings.

Akhil R (5):
  dt-bindings: crypto: Add Tegra Security Engine
  gpu: host1x: Add Tegra SE to SID table
  crypto: tegra: Add Tegra Security Engine driver
  arm64: defconfig: Enable Tegra Security Engine
  arm64: tegra: Add Tegra Security Engine DT nodes

 .../crypto/nvidia,tegra234-se-aes.yaml        |   52 +
 .../crypto/nvidia,tegra234-se-hash.yaml       |   52 +
 MAINTAINERS                                   |    5 +
 arch/arm64/boot/dts/nvidia/tegra234.dtsi      |   16 +
 arch/arm64/configs/defconfig                  |    1 +
 drivers/crypto/Kconfig                        |    8 +
 drivers/crypto/Makefile                       |    1 +
 drivers/crypto/tegra/Makefile                 |    9 +
 drivers/crypto/tegra/tegra-se-aes.c           | 1932 +++++++++++++++++
 drivers/crypto/tegra/tegra-se-hash.c          | 1048 +++++++++
 drivers/crypto/tegra/tegra-se-key.c           |  156 ++
 drivers/crypto/tegra/tegra-se-main.c          |  439 ++++
 drivers/crypto/tegra/tegra-se.h               |  569 +++++
 drivers/gpu/host1x/dev.c                      |   24 +
 14 files changed, 4312 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/crypto/nvidia,tegra234-se-aes.yaml
 create mode 100644 Documentation/devicetree/bindings/crypto/nvidia,tegra234-se-hash.yaml
 create mode 100644 drivers/crypto/tegra/Makefile
 create mode 100644 drivers/crypto/tegra/tegra-se-aes.c
 create mode 100644 drivers/crypto/tegra/tegra-se-hash.c
 create mode 100644 drivers/crypto/tegra/tegra-se-key.c
 create mode 100644 drivers/crypto/tegra/tegra-se-main.c
 create mode 100644 drivers/crypto/tegra/tegra-se.h

Comments

Akhil R Feb. 29, 2024, 9:20 a.m. UTC | #1
> +
> +static int tegra_sha_export(struct ahash_request *req, void *out)
> +{
> +	struct tegra_sha_reqctx *rctx = ahash_request_ctx(req);
> +	struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
> +	struct tegra_sha_ctx *ctx = crypto_ahash_ctx(tfm);
> +	int i;
> +
> +	if (ctx->fallback)
> +		return tegra_sha_fallback_export(req, out);
> +
> +	memcpy(out, rctx, sizeof(*rctx));
> +
> +	return 0;
> +}
> +
> +static int tegra_sha_import(struct ahash_request *req, const void *in)
> +{
> +	struct tegra_sha_reqctx *rctx = ahash_request_ctx(req);
> +	struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
> +	struct tegra_sha_ctx *ctx = crypto_ahash_ctx(tfm);
> +	int i;
Got a warning from testbot for an unused variable here as well as in the export()
function. I will fix that in the next revision.

Do we have any other concerns with the driver currently, which I can address
in the next revision?

Regards,
Akhil
Herbert Xu Feb. 29, 2024, 9:44 a.m. UTC | #2
On Thu, Feb 29, 2024 at 09:20:48AM +0000, Akhil R wrote:
>
> Do we have any other concerns with the driver currently, which I can address
> in the next revision?

The sha export/import code looks good now.  Does it pass all the
self-tests, including extra fuzzing?

The same export/import issue still exists with cmac so please fix
that.

Thanks,
Akhil R March 2, 2024, 2:44 a.m. UTC | #3
> >
> > Do we have any other concerns with the driver currently, which I can
> > address in the next revision?
> 
> The sha export/import code looks good now.  Does it pass all the self-tests,
> including extra fuzzing?
> 
> The same export/import issue still exists with cmac so please fix that.
> 
I do see some warnings for some AES algorithms with extra fuzzing.
Will send a new version with the CMAC import/export update and the
extra fuzzing warning fixes.

Thanks,
Akhil