Re: Memory corruption with CONFIG_SWIOTLB_DYNAMIC=y

From: Christoph Hellwig
Date: Wed Nov 08 2023 - 02:30:57 EST


On Tue, Nov 07, 2023 at 06:24:37PM +0100, Halil Pasic wrote:
> Thanks Christoph! So for NVMe in certain contexts the low
> bits of addresses get discarded, but in other contexts the high bits
> of addresses get discarded and the low bits need to remain the same
> after the bounce (and that's why we need commits 36950f2da1ea ("driver
> core: add a min_align_mask) and 1f221a0d0dbf ("swiotlb: respect
> min_align_mask").

Nothing really gets discarded. NVMe basicaly requires all pages
(where the page is a device page, currently hard coded to 4k in
Linux) except for the first to not have an offset. This is what
the driver sets the virt boundary to in Linux. When bounce buffering
thus all segments (except possibly the first) need to keep their
alignment.