From: Herbert Xu <herbert@gondor.apana.org.au>
To: T Pratham <t-pratham@ti.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Manorit Chawdhry <m-chawdhry@ti.com>,
Kamlesh Gurudasani <kamlesh@ti.com>,
Shiva Tripathi <s-tripathi1@ti.com>,
Kavitha Malarvizhi <k-malarvizhi@ti.com>,
Vishal Mahaveer <vishalm@ti.com>,
Praneeth Bajjuri <praneeth@ti.com>,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v8 1/3] crypto: ti - Add support for AES-CTR in DTHEv2 driver
Date: Fri, 6 Feb 2026 16:53:56 +0800 [thread overview]
Message-ID: <aYWsJAmf05EdotTX@gondor.apana.org.au> (raw)
In-Reply-To: <20260120144408.606911-2-t-pratham@ti.com>
On Tue, Jan 20, 2026 at 08:14:06PM +0530, T Pratham wrote:
>
> + /*
> + * CTR mode can operate on any input length, but the hardware
> + * requires input length to be a multiple of the block size.
> + * We need to handle the padding in the driver.
> + */
> + if (ctx->aes_mode == DTHE_AES_CTR && req->cryptlen % AES_BLOCK_SIZE) {
> + struct scatterlist *sg;
> + int i = 0;
> + unsigned int curr_len = 0;
> +
> + len -= req->cryptlen % AES_BLOCK_SIZE;
> + src_nents = sg_nents_for_len(req->src, len);
> + dst_nents = sg_nents_for_len(req->dst, len);
> +
> + /*
> + * Need to truncate the src and dst to len, else DMA complains.
> + * Lengths restored at end
> + */
> + for_each_sg(req->src, sg, src_nents - 1, i) {
> + curr_len += sg->length;
> + }
> + curr_len += sg->length;
> + src_bkup_len = sg->length;
> + sg->length -= curr_len % AES_BLOCK_SIZE;
Please don't modify the SG lists since they may be used elsewhere.
There is no harm in mapping a bit more data than what you will
end up using.
Just truncate the length written to the hardware instead.
Thanks,
--
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
next prev parent reply other threads:[~2026-02-06 9:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-20 14:44 [PATCH v8 0/3] Add support for more AES modes in TI DTHEv2 T Pratham
2026-01-20 14:44 ` [PATCH v8 1/3] crypto: ti - Add support for AES-CTR in DTHEv2 driver T Pratham
2026-02-06 8:53 ` Herbert Xu [this message]
2026-02-06 11:37 ` T Pratham
2026-02-28 8:40 ` Herbert Xu
2026-03-02 14:08 ` T Pratham
2026-01-20 14:44 ` [PATCH v8 2/3] crypto: ti - Add support for AES-GCM " T Pratham
2026-01-20 14:44 ` [PATCH v8 3/3] crypto: ti - Add support for AES-CCM " T Pratham
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=aYWsJAmf05EdotTX@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=davem@davemloft.net \
--cc=k-malarvizhi@ti.com \
--cc=kamlesh@ti.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m-chawdhry@ti.com \
--cc=praneeth@ti.com \
--cc=s-tripathi1@ti.com \
--cc=t-pratham@ti.com \
--cc=vishalm@ti.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
all inboxes | Powered by JetHome®