RE: [RFC 06/20] iommu: Add iommu_device_init[exit]_user_dma interfaces

From: Tian, Kevin
Date: Thu Oct 14 2021 - 21:29:30 EST


Hi, Jason,

> From: Jason Gunthorpe <jgg@xxxxxxxxxx>
> Sent: Wednesday, September 29, 2021 8:59 PM
>
> On Wed, Sep 29, 2021 at 12:38:35AM +0000, Tian, Kevin wrote:
>
> > /* If set the driver must call iommu_XX as the first action in probe() or
> > * before it attempts to do DMA
> > */
> > bool suppress_dma_owner:1;
>
> It is not "attempts to do DMA" but more "operates the physical device
> in any away"
>
> Not having ownership means another entity could be using user space
> DMA to manipulate the device state and attack the integrity of the
> kernel's programming of the device.
>

Does suppress_kernel_dma sounds better than suppress_dma_owner?
We found the latter causing some confusion when doing internal
code review. Somehow this flag represents "don't claim the kernel dma
ownership during driver binding". suppress_dma_owner sounds the
entire ownership is disabled...

Another thing is about DMA_OWNER_SHARED, which is set to indicate
no dma at all. Thinking more we feel that this flag is meaningless. Its
sole purpose is to show compatibility to any USER/KERNEL ownership,
and essentially the same semantics as a device which is not bound to
any driver. So we plan to remove it then pci-stub just needs one line
change to set the suppress flag. But want to check with you first in case
any oversight.

Thanks
Kevin