On Thu, Jun 02, 2016 at 07:34:17AM -0600, Alex Williamson wrote: > On Thu, 02 Jun 2016 13:09:27 +0000 > "Aviv B.D." <bd.a...@gmail.com> wrote: > > > Hi, > > > > In case of hot plug vfio device there should not be any active mapping > > to this device prior the device addition. > > Counter example - a device is hot added to a guest booted with iommu=pt.
I got the same question with Aviv... For hot-plug devices, even if it is using iommu=pt, shouldn't it still follow the steps that first init vfio device, then configure device context entry? Let me list the steps for device addition in case I got any mistake: 1. user add new VFIO device A 2. vfio_listener_region_add() called for device A on the IOMMU mr, here we should create the iommu notifier. However since the context entry still does not exist, memory_region_iommu_replay() will got all invalid IOTLB (IOMMU_NONE entries) 3. guest kernel found the device, enabled the device, filled in context entry for device A with "pass-through" (so the SLPTPTR is invalid) 4. guest sent context invalidation to QEMU vIOMMU since we have CM=1 set for guest vIOMMU 5. QEMU vIOMMU handle the invalidation, trigger VFIO notify to do correct VFIO mapping for device A Though here step 5 should still be missing (IIUC Aviv's patch 3 still not handled context invalidation). Just want to know whether we can avoid the replay operation for Intel vIOMMUs (for Intel only, because Intel has context invalidation and cache mode support, not sure about other platform)? Thanks, -- peterx