Re: [PATCH v6 2/4] crypto: ti - Add support for AES-CTR in DTHEv2 driver

From: Herbert Xu

Date: Thu Nov 20 2025 - 22:11:18 EST


On Tue, Nov 11, 2025 at 04:38:31PM +0530, T Pratham wrote:
>
> @@ -270,12 +326,17 @@ static int dthe_aes_run(struct crypto_engine *engine, void *areq)
> struct scatterlist *src = req->src;
> struct scatterlist *dst = req->dst;
>
> + struct scatterlist src_pad[2], dst_pad[2];
> +
> int src_nents = sg_nents_for_len(src, len);
> - int dst_nents;
> + int dst_nents = sg_nents_for_len(dst, len);
>
> int src_mapped_nents;
> int dst_mapped_nents;
>
> + u8 pad_buf[AES_BLOCK_SIZE] = {0};

You can't put stack memory into an SG list since the ability to
DMA to the stack is not guaranteed.

I suggest that you place the buffer into the request object instead.
The request object is designed to allow DMA and you can allocate as
much memory as you like by setting reqsize.

Cheers,
--
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt