RE: [RFC 16/20] vfio/type1: Export symbols for dma [un]map code sharing

Tian, Kevin
2021-09-22T03:58:07Z

> From: Jason Gunthorpe <jgg@nvidia.com>
> Sent: Wednesday, September 22, 2021 2:15 AM
>
> On Sun, Sep 19, 2021 at 02:38:44PM +0800, Liu Yi L wrote:
> > [HACK. will fix in v2]
> >
> > There are two options to impelement vfio type1v2 mapping semantics in
> > /dev/iommu.
> >
> > One is to duplicate the related code from vfio as the starting point,
> > and then merge with vfio type1 at a later time. However
> vfio_iommu_type1.c
> > has over 3000LOC with ~80% related to dma management logic, including:
>
> I can't really see a way forward like this. I think some scheme to
> move the vfio datastructure is going to be necessary.
>
> > - the dma map/unmap metadata management
> > - page pinning, and related accounting
> > - iova range reporting
> > - dirty bitmap retrieving
> > - dynamic vaddr update, etc.
>
> All of this needs to be part of the iommufd anyhow..

yes

>
> > The alternative is to consolidate type1v2 logic in /dev/iommu immediately,
> > which requires converting vfio_iommu_type1 to be a shim driver.
>
> Another choice is the the datastructure coulde move and the two
> drivers could share its code and continue to exist more independently
>

where to put the shared code?

btw this is one major open that I plan to discuss in LPC. 😊