On 25/01/2017 18:36, Alex Williamson wrote: >> You probably should also put a comment about why VFIO does *not* need to >> keep a reference between vfio_dma_map and vfio_dma_unmap (which doesn't >> sound easy to do either). Would any well-behaved guest invalidate the >> IOMMU page tables before a memory hot-unplug? > > Hmm, we do take a reference in vfio_listener_region_add(), but this is > of course to the iommu region not to the RAM region we're translating. > In the non-vIOMMU case we would be holding a reference to the memory > region backing a DMA mapping. I would expect a well behaved guest to > evacuate DMA mappings targeting a hotplug memory region before it gets > ejected, but how much do we want to rely on well behaved guests.
It depends of what happens if they aren't. I think it's fine (see other message), but taking a reference for each mapping entry isn't so easy because the unmap case doesn't know the old memory region. Paolo > Perhaps we should be taking a reference for each mapping entry, though > this makes Peter's plans to invalidate the entire address space much > more difficult. Thanks,