<div dir="ltr"><div>After more thoughts, I guess that </div><div>1) normally ppl don't enable vIOMMU unless they need to use a nested guest, as vIOMMU is slow and the memory accounting issue you just mentioned.</div><div>2) host IOMMU driver actually can do io page fault and on-demanding pinning/mapping for ATS/PRI-capable device, but currently qemu doesn't tell if a pass-through device and host IOMMU can do it or not. If this is true, maybe we can remove the pinning of all guest memory for this type of device??</div><div><br></div><div>Thanks.<br><div><br><div><div><div><br><div><div><br></div></div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jul 12, 2020 at 5:24 PM Alex Williamson <<a href="mailto:alex.l.williamson@gmail.com">alex.l.williamson@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Sun, Jul 12, 2020 at 6:16 PM Yv Lin <<a href="mailto:yvlamg@gmail.com" target="_blank">yvlamg@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><div class="gmail_quote"><div>Here are some summaries that I learned from what you told.</div><div>1) If a device is passed through to guestOS via vfio, and there is no IOMMU present in guestOS. all memory regions within the device address space will be pinned down. if IOMMU is presented in guestOS, qemu could only pin and map the needed pages (specified by dma_map_page() called in guestOS device driver), but as vIOMMU is emulated, the performance is not good. </div><div>2) Even if a pcie device can support ATS/PRI capability and it's passed through to guestOS, the above statement is still true, the IO page fault and demanding page won't be utilized anyway.</div></div></div></blockquote><div><br></div><div>Correct, also note that a vIOMMU is never enabled during early boot on x86/64, therefore all guest memory will be pinned initially.  Also a vIOMMU introduces locked memory accounting issues as each device address space makes use of a separate VFIO container, which does accounting separately.  And finally, ATS implies that we honor devices making use of "pre-translated" DMA, which implies a degree of trust that the user/device cannot make use of this as a vector to exploit the host.  Thanks,</div><div><br></div><div>Alex</div></div></div>
</blockquote></div>