On Tue, Nov 10, 2015 at 10:54:21AM -0800, Andy Lutomirski wrote: > On Nov 10, 2015 7:02 AM, "Michael S. Tsirkin" <m...@redhat.com> wrote: > > > > On Sun, Nov 08, 2015 at 12:49:46PM +0100, Joerg Roedel wrote: > > > On Sun, Nov 08, 2015 at 12:37:47PM +0200, Michael S. Tsirkin wrote: > > > > I have no problem with that. For example, can we teach > > > > the DMA API on intel x86 to use PT for virtio by default? > > > > That would allow merging Andy's patches with > > > > full compatibility with old guests and hosts. > > > > > > Well, the only incompatibility comes from an experimental qemu feature, > > > more explicitly from a bug in that features implementation. So why > > > should we work around that in the kernel? I think it is not too hard to > > > fix qemu to generate a correct DMAR table which excludes the virtio > > > devices from iommu translation. > > > > > > > > > Joerg > > > > It's not that easy - you'd have to dedicate some buses > > for iommu bypass, and teach management tools to only put > > virtio there - but it's possible. > > > > This will absolutely address guests that don't need to set up IOMMU for > > virtio devices, and virtio that bypasses the IOMMU. > > > > But the problem is that we do want to *allow* guests > > to set up IOMMU for virtio devices. > > In that case, these are two other usecases: > > > > A- monolitic virtio within QEMU: > > iommu only needed for VFIO -> > > guest should always use iommu=pt > > iommu=on works but is just useless overhead. > > > > B- modular out of process virtio outside QEMU: > > iommu needed for VFIO or kernel driver -> > > guest should use iommu=pt or iommu=on > > depending on security/performance requirements > > > > Note that there could easily be a mix of these in the same system. > > > > So for these cases we do need QEMU to specify to guest that IOMMU covers > > the virtio devices. Also, once one does this, the default on linux is > > iommu=on and not pt, which works but ATM is very slow. > > > > This poses three problems: > > > > 1. How do we address the different needs of A and B? > > One way would be for virtio to pass the information to guest > > using some virtio specific way, and have drivers > > specify what kind of DMA access they want. > > > > 2. (Kind of a subset of 1) once we do allow IOMMU, how do we make sure most > > guests > > use the more sensible iommu=pt. > > > > 3. Once we do allow IOMMU, how can we keep existing guests work in this > > configuration? > > Creating different hypervisor configurations depending on guest is very > > nasty. > > Again, one way would be some virtio specific interface. > > > > I'd rather we figured the answers to this before merging Andy's patches > > because I'm concerned that instead of 1 broken configuration > > (virtio always bypasses IOMMU) we'll get two bad configurations > > (in the second one, virtio uses the slow default with no > > gain in security). > > > > Suggestions wellcome. > > I think there's still no downside of using my patches, even on x86. > > Old kernels on new QEMU work unless IOMMU is enabled on the host. I > think that's the best we can possibly do. > New kernels work at full speed on old QEMU.
Only if IOMMU is disabled, right? > New kernels with new QEMU and iommu enabled work slower. Even newer > kernels with default passthrough work at full speed, and there's no > obvious downside to the existence of kernels with just my patches. > > --Andy > I tried to explain the possible downside. Let me try again. Imagine that guest kernel notifies hypervisor that it wants IOMMU to actually work. This will make old kernel on new QEMU work even with IOMMU enabled on host - better than "the best we can do" that you described above. Specifically, QEMU will assume that if it didn't get notification, it's an old kernel so it should ignore the IOMMU. But if we apply your patches this trick won't work. Without implementing it all, I think the easiest incremental step would be to teach linux to make passthrough the default when running as a guest on top of QEMU, put your patches on top. If someone specifies non passthrough on command line it'll still be broken, but not too bad. > > > > -- > > MST -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html