|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH RFC] xen/swiotlb: avoid arch_sync_dma_* on per-device DMA memory
On Fri, Apr 24, 2026 at 02:57:19PM +0800, Peng Fan wrote:
> Hi Jason,
>
> On Mon, Apr 20, 2026 at 08:01:37PM -0300, Jason Gunthorpe wrote:
> >On Wed, Apr 15, 2026 at 11:08:36PM +0800, Peng Fan (OSS) wrote:
> >> From: Peng Fan <peng.fan@xxxxxxx>
> >>
> >> On ARM64, arch_sync_dma_for_{cpu,device}() assumes that the
> >> physical address passed in refers to normal RAM that is part of the
> >> kernel linear(direct) mapping, as it unconditionally derives a CPU
> >> virtual address via phys_to_virt().
> >>
> >> With Xen swiotlb, devices may use per-device coherent DMA memory,
> >> such as reserved-memory regions described by 'shared-dma-pool',
> >> which are assigned to dev->dma_mem. These regions may be marked
> >> no-map in DT and therefore are not part of the kernel linear map.
> >> In such cases, pfn_valid() still returns true, but phys_to_virt()
> >> is not valid and cache maintenance via arch_sync_dma_* will fault.
> >>
> >> Prevent this by excluding devices with a private DMA memory pool
> >> (dev->dma_mem) from the arch_sync_dma_* fast path, and always
> >> fall back to xen_dma_sync_* for those devices to avoid invalid
> >> phys_to_virt() conversions for no-map DMA memory while preserving the
> >> existing fast path for normal, linear-mapped RAM.
> >
> >I think this is the same sort of weirdness the other two CC threads are
> >dealing with.. We already have two different flags indicating the
> >cache flush should be skipped, it would make more sense to have the
> >swiotlb mangle the flags, just like for cc.
> >
> >https://lore.kernel.org/r/20260420061415.3650870-1-aneesh.kumar@xxxxxxxxxx
> >
> >Then you know that the swiotlb was used and it should flow down to
> >here.
>
> Xen fully implements dev->dma_ops and does not leak hypervisor-specific
> semantics outside of it.
It may have its own re-implementation but the same remarks apply. The
flags in attrs should be correct and you should not be putting random
boolean checks all over the place to make up for incorrect flags.
Jason
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |