mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Akhil R <akhilrajeev@nvidia.com>
Cc: davem@davemloft.net, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org,
	thierry.reding@gmail.com, jonathanh@nvidia.com,
	catalin.marinas@arm.com, will@kernel.org, mperttunen@nvidia.com,
	linux-crypto@vger.kernel.org, devicetree@vger.kernel.org,
	linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org,
	krzk@kernel.org
Subject: Re: [PATCH v4 3/5] crypto: tegra: Add Tegra Security Engine driver
Date: Fri, 2 Feb 2024 17:44:12 +0800	[thread overview]
Message-ID: <Zby5bLEgz/UktarE@gondor.apana.org.au> (raw)
In-Reply-To: <20240124083846.46487-4-akhilrajeev@nvidia.com>

On Wed, Jan 24, 2024 at 02:08:44PM +0530, Akhil R wrote:
>
> +static void tegra_sha_init_fallback(struct tegra_sha_ctx *ctx, const char *algname)
> +{
> +	ctx->fallback_tfm = crypto_alloc_ahash(algname, 0, CRYPTO_ALG_ASYNC |
> +						CRYPTO_ALG_NEED_FALLBACK);
> +
> +	if (IS_ERR(ctx->fallback_tfm)) {
> +		dev_warn(ctx->se->dev, "failed to allocate fallback for %s %ld\n",
> +			 algname, PTR_ERR(ctx->fallback_tfm));
> +		ctx->fallback_tfm = NULL;
> +	}
> +}

This should check that the fallback state size is smaller than
that of tegra.  As otherwise the fallback export/import will break.

> +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;
> +
> +	if (ctx->fallback)
> +		return tegra_sha_fallback_import(req, in);
> +
> +	memcpy(rctx, in, sizeof(*rctx));
> +
> +	/* Paste all intermediate results */
> +	for (i = 0; i < HASH_RESULT_REG_COUNT; i++)
> +		writel(rctx->result[i],
> +		       ctx->se->base + ctx->se->hw->regs->result + (i * 4));

What happens when multiple requests of the same tfm import at
the same time?  Normally we don't actually touch the hardware
in the import function.  Instead, all the hard work happens at
the end of the update function, which moves hardware state into
the request object.

The import/export function then simply copies the request object
state to the in/out buffer.

Cheers,
-- 
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:[~2024-02-02  9:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-24  8:38 [PATCH v4 0/5] " Akhil R
2024-01-24  8:38 ` [PATCH v4 1/5] dt-bindings: crypto: Add Tegra Security Engine Akhil R
2024-01-24  8:38 ` [PATCH v4 2/5] gpu: host1x: Add Tegra SE to SID table Akhil R
2024-01-24  8:38 ` [PATCH v4 3/5] crypto: tegra: Add Tegra Security Engine driver Akhil R
2024-02-02  9:44   ` Herbert Xu [this message]
2024-02-06  5:50     ` Akhil R
2024-02-06  5:54       ` Herbert Xu
2024-02-06  5:58         ` Akhil R
2024-01-24  8:38 ` [PATCH v4 4/5] arm64: defconfig: Enable Tegra Security Engine Akhil R
2024-01-24  8:38 ` [PATCH v4 5/5] arm64: tegra: Add Tegra Security Engine DT nodes Akhil R

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=Zby5bLEgz/UktarE@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=akhilrajeev@nvidia.com \
    --cc=catalin.marinas@arm.com \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=krzk@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mperttunen@nvidia.com \
    --cc=robh+dt@kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=will@kernel.org \
    /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

all inboxes | Powered by JetHome®