[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aCrfNdnRzlQSr6sy@gondor.apana.org.au>
Date: Mon, 19 May 2025 15:35:17 +0800
From: Herbert Xu <herbert@...dor.apana.org.au>
To: Bharat Bhushan <bharatb.linux@...il.com>
Cc: Bharat Bhushan <bbhushan2@...vell.com>, bbrezillon@...nel.org,
arno@...isbad.org, schalla@...vell.com, davem@...emloft.net,
giovanni.cabiddu@...el.com, linux@...blig.org,
linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Subject: Re: [PATCH 3/4 RESEND] crypto: octeontx2: Fix address alignment on
CN10K A0/A1 and OcteonTX2
On Mon, May 19, 2025 at 11:47:18AM +0530, Bharat Bhushan wrote:
>
> > > + /* Allocate extra memory for SG and response address alignment */
> > > + total_mem_len = ALIGN(info_len, OTX2_CPT_DPTR_RPTR_ALIGN) + dlen;
>
> This add extra memory for 8-byte (OTX2_CPT_DPTR_RPTR_ALIGN) alignment
>
> > > + total_mem_len = ALIGN(total_mem_len, OTX2_CPT_RES_ADDR_ALIGN) +
> > > + sizeof(union otx2_cpt_res_s);
>
> This add extra memory for 32-byte (OTX2_CPT_RES_ADDR_ALIGN))
> In case not observed, OTX2_CPT_RES_ADDR_ALIGN is not the same as
> OTX2_CPT_DPTR_RPTR_ALIGN.
But it doesn't do that. Look, assume that total_mem_len is 64,
then ALIGN(64, 32) will still be 64. You're not adding any extra
space for the alignment padding.
OTOH, kmalloc can return something that has a page offset of 8,
and you will need 24 extra bytes in your structure to make it
align at 32.
Now of course if you're very lucky, and total_mem_len starts out
at 8, then it would work but that's purely by chance.
Cheers,
--
Email: Herbert Xu <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Powered by blists - more mailing lists