Re: AMD SME encrpytion and PCI BAR pages to user space

From: Jason Gunthorpe
Date: Tue Oct 27 2020 - 07:58:21 EST


On Tue, Oct 27, 2020 at 08:43:57AM +0000, Christoph Hellwig wrote:
> On Wed, Oct 21, 2020 at 01:03:22PM -0300, Jason Gunthorpe wrote:
> > Oh, interesting.. Yes the issue is no userspace DMA stuff uses the DMA
> > API correctly (because it is in userspace)
> >
> > So SWIOTLB tricks don't work, I wish the dma_map could fail for these
> > situations
>
> Userspace DMA by definition also does not use dma_map..

? Sure it does, ib_dma_map_sg_attrs() is what RDMA uses

What all the userspace users skip is the dma_sync*() - that would
require a kernel call which defeats the point.

So, my desire is some flag to dma_map_sg() that says
'user space mapping no dma_sync_*'

ie dma_sync_* is a NOP

Then things like SWIOTLB on the SEV system can fail with an error code
instead of malfunctioning

If FOLL_LONGERM is some estimate of this pattern then we have these users:
- drivers/infiniband
- v4l
- vdpa
- xdp
- rds
- habana labs

Jason