From: Halil Pasic <pasic@linux.ibm.com>
To: Petr Tesarik <petr.tesarik1@huawei-partners.com>
Cc: "Petr Tesařík" <petr@tesarici.cz>,
"Niklas Schnelle" <schnelle@linux.ibm.com>,
"Christoph Hellwig" <hch@lst.de>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Marek Szyprowski" <m.szyprowski@samsung.com>,
"Robin Murphy" <robin.murphy@arm.com>,
"Ross Lagerwall" <ross.lagerwall@citrix.com>,
linux-pci <linux-pci@vger.kernel.org>,
linux-kernel@vger.kernel.org, iommu@lists.linux.dev,
"Matthew Rosato" <mjrosato@linux.ibm.com>,
"Halil Pasic" <pasic@linux.ibm.com>
Subject: Re: Memory corruption with CONFIG_SWIOTLB_DYNAMIC=y
Date: Fri, 10 Nov 2023 10:22:45 +0100 [thread overview]
Message-ID: <20231110102245.6ac971b9.pasic@linux.ibm.com> (raw)
In-Reply-To: <7a4f87c3-b3c6-42c5-9200-8eb56d1c8530@huawei-partners.com>
On Wed, 8 Nov 2023 15:45:49 +0100
Petr Tesarik <petr.tesarik1@huawei-partners.com> wrote:
> On 11/8/2023 3:32 PM, Halil Pasic wrote:
> > On Wed, 8 Nov 2023 12:04:12 +0100
> > Petr Tesarik <petr.tesarik1@huawei-partners.com> wrote:
> > [..]
> >>>
> >>> For the sake of simplicity let us assume we only have the min_align_mask
> >>> requirement. Then I believe the worst case is that we need
> >>> (orig_addr & min_align_mask & PAGE_MASK) + (min_align_mask & ~PAGE_MASK)
> >>> extra space to fit.
> >>>
> >>> Depending on how the semantics pan out one may be able to replace
> >>> min_align_mask with combined_mask.
> >>>
> >>> Is your point that for large combined_mask values
> >>> _get_free_pages(GFP_NOWAIT | __GFP_NOWARN, required_order) is not
> >>> likely to complete successfully?
> >>
> >> Yes, that's the reason. OTOH it's probably worth a try. The point is
> >> that mapping a DMA buffer is allowed to fail, so callers should be
> >> prepared anyway.
> >>
> >> And for the case you reported initially, I don't think there is any need
> >> to preserve bit 11 (0x800) from the original buffer's physical address,
> >> which is enough to fix it. See also my other email earlier today.
> >
> > Hm. Do you mean "[PATCH 1/1] swiotlb: fix out-of-bounds TLB allocations
> > with CONFIG_SWIOTLB_DYNAMIC" or a different one?
> >
> > I only see "[PATCH 1/1] swiotlb: fix out-of-bounds TLB allocations
> > with CONFIG_SWIOTLB_DYNAMIC" but I don't think that one takes
> > care of "I don't think there is any need to preserve bit 11 (0x800)
> > from the original buffer's physical address".
>
> Yes, I mean only this patch. I want to fix memory corruption fast, while
> waiting for more feedback on my understanding of the alignment masks.
> What I'm trying to say is that your specific use case may not even need
> a bigger allocation if the page alignment should be interpreted differently.
>
> Again, thank you for your in-depth inspection, because it's not totally
> clear how the various alignment parameters should be interpreted. It's
> difficult to write correct code then...
I fully understand. Thanks for tackling this. We decided to go with a bug
report and not with a fix because of the very same reasons: lack of
clarity on how certain things are supposed to work. Let us see how
the discussion develops. :)
Regards,
Halil
>
> Petr T
prev parent reply other threads:[~2023-11-10 18:27 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-03 15:13 Memory corruption with CONFIG_SWIOTLB_DYNAMIC=y Niklas Schnelle
2023-11-03 16:14 ` Halil Pasic
2023-11-03 20:50 ` Petr Tesařík
2023-11-06 7:42 ` Christoph Hellwig
2023-11-07 17:24 ` Halil Pasic
2023-11-08 7:30 ` Christoph Hellwig
2023-11-06 10:08 ` Halil Pasic
2023-11-07 17:24 ` Halil Pasic
2023-11-08 9:13 ` Petr Tesařík
2023-11-23 10:16 ` Petr Tesařík
2023-11-27 15:59 ` Christoph Hellwig
2023-11-28 7:16 ` Petr Tesařík
2023-11-03 18:59 ` Petr Tesařík
2023-11-06 7:44 ` Christoph Hellwig
2023-11-06 12:46 ` Petr Tesarik
2023-11-08 10:52 ` Halil Pasic
2023-11-08 11:04 ` Petr Tesarik
2023-11-08 14:32 ` Halil Pasic
2023-11-08 14:45 ` Petr Tesarik
2023-11-10 9:22 ` Halil Pasic [this message]
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=20231110102245.6ac971b9.pasic@linux.ibm.com \
--to=pasic@linux.ibm.com \
--cc=bhelgaas@google.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=mjrosato@linux.ibm.com \
--cc=petr.tesarik1@huawei-partners.com \
--cc=petr@tesarici.cz \
--cc=robin.murphy@arm.com \
--cc=ross.lagerwall@citrix.com \
--cc=schnelle@linux.ibm.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).