From: Jason Gunthorpe <jgg@nvidia.com>
To: Kashyap Desai <kashyap.desai@broadcom.com>
Cc: linux-rdma@vger.kernel.org, leonro@nvidia.com,
Selvin Xavier <selvin.xavier@broadcom.com>,
Andrew Gospodarek <andrew.gospodarek@broadcom.com>
Subject: Re: [PATCH rdma-rc v1] RDMA/core: fix sg_to_page mapping for boundary condition
Date: Tue, 6 Sep 2022 14:33:19 -0300 [thread overview]
Message-ID: <YxeEX7XcwYpnbP3M@nvidia.com> (raw)
In-Reply-To: <85a37f42a08f4163cb5440d8825b7e7a@mail.gmail.com>
On Thu, Sep 01, 2022 at 05:36:57PM +0530, Kashyap Desai wrote:
> > -----Original Message-----
> > From: Jason Gunthorpe [mailto:jgg@nvidia.com]
> > Sent: Friday, August 26, 2022 6:45 PM
> > To: Kashyap Desai <kashyap.desai@broadcom.com>
> > Cc: linux-rdma@vger.kernel.org; leonro@nvidia.com; Selvin Xavier
> > <selvin.xavier@broadcom.com>; Andrew Gospodarek
> > <andrew.gospodarek@broadcom.com>
> > Subject: Re: [PATCH rdma-rc v1] RDMA/core: fix sg_to_page mapping for
> > boundary condition
> >
> > On Mon, Aug 22, 2022 at 07:51:22PM +0530, Kashyap Desai wrote:
> >
> > > Now, we will enter into below loop with dma_addr = page_addr =
> > > 0xffffffffffffe000 and "end_dma_addr = dma_addr + dma_len" is ZERO.
> > > eval 0xffffffffffffe000 + 8192
> > > hexadecimal: 0
> >
> > This is called overflow.
>
> Is this not DMAable for 64bit DMA mask device ? It is DMAable. So not sure
> why you call it as overflow. ?
Beacuse the normal math overflowed.
Should it work? Yes. Is it a special edge case that might have bugs?
Certainly.
So the IOMMU layer shouldn't be stressing this edge case at all. It is
crazy, there is no reason to do this.
> I agree that such mapping is obviously dangerous, but it is not illegal as
> well.
> Same sgl mapping works if it is direct attached Storage, so there will be
> a logical question why IB stack is not handling this.
Oh that is probably very driver dependent.
> > You need to write the code so you never create the situation where
> > A+B=0 - don't try to fix things up after that happens.
>
> In proposed patch, A + B = 0 is possible, but it will be considered as end
> of the loop.
Like I said, don't do that. End of the loop is -1 which requires a
different loop logic design, so send a patch like that.
But I would still send a patch for iommu to not create this in the
first place.
Jason
next prev parent reply other threads:[~2022-09-06 17:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-16 8:11 [PATCH rdma-rc v1] RDMA/core: fix sg_to_page mapping for boundary condition Kashyap Desai
2022-08-18 23:52 ` Jason Gunthorpe
2022-08-19 9:43 ` Kashyap Desai
2022-08-19 11:48 ` Jason Gunthorpe
2022-08-22 14:21 ` Kashyap Desai
2022-08-26 13:14 ` Jason Gunthorpe
2022-09-01 12:06 ` Kashyap Desai
2022-09-06 17:33 ` Jason Gunthorpe [this message]
2022-09-12 11:02 ` Kashyap Desai
2022-09-20 19:14 ` Jason Gunthorpe
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=YxeEX7XcwYpnbP3M@nvidia.com \
--to=jgg@nvidia.com \
--cc=andrew.gospodarek@broadcom.com \
--cc=kashyap.desai@broadcom.com \
--cc=leonro@nvidia.com \
--cc=linux-rdma@vger.kernel.org \
--cc=selvin.xavier@broadcom.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;
as well as URLs for NNTP newsgroup(s).