On Tue, 5 Jun 2018 18:52:43 -0700 Huaicheng Li <huaich...@cs.uchicago.edu> wrote:
> Hi Alex, > > VFIO does not setup > > mappings per DMA buffer, it maps all of guest physical memory through > > the IOMMU so that the device can DMA to any GPA and it's already > > mapped. We call this transparent assignment, the guest can perform DMA > > without any knowledge of or interaction with the host IOMMU. > > > Could you briefly explain how all of guest physical memory is mapped > through IOMMU. > I do see a ``vfio_dma_map`` call with `size` almost equal to my guest > memory size, is > this the place where IOMMU is instructed to enable such transparent > assignment you > mentioned? I don't know that I have a brief explanation for this, you'll need to look at the code. The entry point to vfio is the MemoryListener (which calls vfio_dma_map) attached to the device AddressSpace, which is the system memory address space when a guest IOMMU is not present. RAMBlocks are mapped through MemoryRegions and sections of those come in through the MemoryListner to be populated through the IOMMU. > Since the guest driver is issuing IOs with GPA, how does the > device do > DMA to the corresponding physical DMA address? This is why we have an IOMMU. The guest drivers and the device operate in the guest physical address space, the IOMMU handles the translation to the host physical address space. > Is the GPA->HPA a static > mapping > so the HPA can be calculated instead of walking the page tables (which > those DMA APIs > do)? Without a guest IOMMU, the translations are almost entirely static, for instance the RAM in your computer doesn't spontaneously decide to relocate itself in the physical address space of your system, neither does RAM in a VM. All of guest physical memory is pinned in the host and mapped through the IOMMU. Regardless of this, there is no page table walking to create these mappings. Each RAMBlock is just a range of memory with a start and end offset in the guest physical address space. Thanks, Alex _______________________________________________ vfio-users mailing list vfio-users@redhat.com https://www.redhat.com/mailman/listinfo/vfio-users