lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAAeCc_kxhT-JHn+U2BNeh2E+DNukMXWfypW+-D_x5f1OcZ9Hmw@mail.gmail.com>
Date: Thu, 22 May 2025 15:38:08 +0530
From: Bharat Bhushan <bharatb.linux@...il.com>
To: Herbert Xu <herbert@...dor.apana.org.au>
Cc: Bharat Bhushan <bbhushan2@...vell.com>, bbrezillon@...nel.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 v3] crypto: octeontx2: Fix address alignment on CN10K
 A0/A1 and OcteonTX2

On Wed, May 21, 2025 at 4:58 PM Herbert Xu <herbert@...dor.apana.org.au> wrote:
>
> On Wed, May 21, 2025 at 03:34:46PM +0530, Bharat Bhushan wrote:
> >
> > @@ -429,22 +431,51 @@ otx2_sg_info_create(struct pci_dev *pdev, struct otx2_cpt_req_info *req,
> >               return NULL;
> >       }
> >
> > -     g_sz_bytes = ((req->in_cnt + 3) / 4) *
> > -                   sizeof(struct otx2_cpt_sglist_component);
> > -     s_sz_bytes = ((req->out_cnt + 3) / 4) *
> > -                   sizeof(struct otx2_cpt_sglist_component);
> > +     /* Allocate memory to meet below alignment requirement:
> > +      *  ----------------------------------
> > +      * |    struct otx2_cpt_inst_info     |
> > +      * |    (No alignment required)       |
> > +      * |     -----------------------------|
> > +      * |    | padding for 8B alignment    |
> > +      * |----------------------------------|
>
> This should be updated to show that everything following this
> is on an 128-byte boundary.
>
> > +      * |    SG List Gather/Input memory   |
> > +      * |    Length = multiple of 32Bytes  |
> > +      * |    Alignment = 8Byte             |
> > +      * |----------------------------------|
> > +      * |    SG List Scatter/Output memory |
> > +      * |    Length = multiple of 32Bytes  |
> > +      * |    Alignment = 8Byte             |
> > +      * |    (padding for below alignment) |
> > +      * |     -----------------------------|
> > +      * |    | padding for 32B alignment   |
> > +      * |----------------------------------|
> > +      * |    Result response memory        |
> > +      *  ----------------------------------
> > +      */
> >
> > -     dlen = g_sz_bytes + s_sz_bytes + SG_LIST_HDR_SIZE;
> > -     align_dlen = ALIGN(dlen, align);
> > -     info_len = ALIGN(sizeof(*info), align);
> > -     total_mem_len = align_dlen + info_len + sizeof(union otx2_cpt_res_s);
> > +     info_len = sizeof(*info);
> > +
> > +     g_len = ((req->in_cnt + 3) / 4) *
> > +              sizeof(struct otx2_cpt_sglist_component);
> > +     s_len = ((req->out_cnt + 3) / 4) *
> > +              sizeof(struct otx2_cpt_sglist_component);
> > +
> > +     dlen = g_len + s_len + SG_LIST_HDR_SIZE;
> > +
> > +     /* Allocate extra memory for SG and response address alignment */
> > +     total_mem_len = ALIGN(info_len, ARCH_DMA_MINALIGN) + dlen;
> > +     total_mem_len = ALIGN(total_mem_len, OTX2_CPT_DPTR_RPTR_ALIGN);
> > +     total_mem_len += (OTX2_CPT_RES_ADDR_ALIGN - 1) &
> > +                       ~(OTX2_CPT_DPTR_RPTR_ALIGN - 1);
> > +     total_mem_len += sizeof(union otx2_cpt_res_s);
>
> This calculation is wrong again.  It should be:
>
>         total_mem_len = ALIGN(info_len, OTX2_CPT_DPTR_RPTR_ALIGN);
>         total_mem_len += (ARCH_DMA_MINALIGN - 1) &
>                          ~(OTX2_CPT_DPTR_RPTR_ALIGN - 1);
>         total_mem_len += ALIGN(dlen, OTX2_CPT_RES_ADDR_ALIGN);
>         total_mem_len += sizeof(union otx2_cpt_res_s);
>
> Remember ALIGN may not actually give you extra memory.  So if you
> need to add memory for alignment padding, you will need to do it
> by hand.

Will do changes as proposed above, Thanks for reviewing.

Thanks
-Bharat

>
> 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

Powered by Openwall GNU/*/Linux Powered by OpenVZ