Re: [PATCH v1 2/2] dma-mapping-common: add DMA attribute - DMA_ATTR_IOMMU_BYPASS

Shamir Rabinovitch
2015-10-29T07:32:32Z

On Thu, Oct 29, 2015 at 09:42:12AM +0900, David Woodhouse wrote:

> Aside from the lack of security, the other disadvantage of that is that
> you have to pin *all* pages of a guest in case DMA happens; you don't
> get to pin *only* those pages which are referenced by that guest's
> IOMMU page tables...

We do bypass the IOMMU but not the DMA API and given that before we call
the DMA API we pin the page then we do not need to pin all the pages.
Just the ones we use for the DMA.

For me this flag looks orthogonal to the page pinning issue you brought. It
is just a hint to the DMA API that we want to use simple & fast mapping while
knowing we loose IOMMU protection for this memory.

For the IB case, setting and tearing DMA mappings for the drivers data buffers
is expensive. But we could for example consider to map all the HW control objects
that validate the HW access to the drivers data buffers as IOMMU protected and so
have IOMMU protection on those critical objects while having fast set-up/tear-down
of driver data buffers. The HW control objects have stable mapping for the lifetime
of the system. So the case of using both types of DMA mappings is still valid.

>
> --
> dwmw2
>
>