Michael S. Tsirkin
2016-Apr-18 13:12 UTC
[PATCH RFC] fixup! virtio: convert to use DMA api
On Mon, Apr 18, 2016 at 07:58:37AM -0400, David Woodhouse wrote:> On Mon, 2016-04-18 at 14:47 +0300, Michael S. Tsirkin wrote: > > This adds a flag to enable/disable bypassing the IOMMU by > > virtio devices. > > I'm still deeply unhappy with having this kind of hack in the virtio > code at all, as you know. Drivers should just use the DMA API and if > the *platform* wants to make it a no-op for a specific device, then it > can. > > Remember, this isn't just virtio either. Don't we have *precisely* the > same issue with assigned PCI devices on a system with an emulated Intel > IOMMU? The assigned PCI devices aren't covered by the emulated IOMMU, > and the platform needs to know to bypass *those* too. > > Now, we've had this conversation, and we accepted the hack in virtio > for now until the platforms (especially SPARC and Power IIRC) can get > their act together and make their DMA API implementations not broken. > > But now you're adding this hack to the public API where we have to > support it for ever. Please, can't we avoid that?I'm not sure I understand the issue. The public API is not about how the driver works. It doesn't say "don't use DMA API" anywhere, does it? It's about telling device whether to obey the IOMMU and about discovering whether a device is in fact under the IOMMU. Once DMA API allows bypassing IOMMU per device we'll be able to drop the ugly hack from virtio drivers, simply keying it off the given flag.> -- > dwmw2 > >
On Mon, 2016-04-18 at 16:12 +0300, Michael S. Tsirkin wrote:> I'm not sure I understand the issue.??The public API is not about how > the driver works.??It doesn't say "don't use DMA API" anywhere, does it? > It's about telling device whether to obey the IOMMU and > about discovering whether a device is in fact under the IOMMU.Apologies, I was wrongly reading this as a kernel patch. After a brief struggle with "telling device whether to obey the IOMMU", which is obviously completely impossible from the guest kernel, I realise my mistake :) So... on x86 how does this get reflected in the DMAR tables that the guest BIOS presents to the guest kernel, so that the guest kernel *knows* which devices are behind which IOMMU? (And are you fixing the case of assigned PCI devices, which aren't behind any IOMMU, at the same time as you answer that? :) -- dwmw2 -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 5691 bytes Desc: not available URL: <http://lists.linuxfoundation.org/pipermail/virtualization/attachments/20160418/4933dd9a/attachment.bin>
Michael S. Tsirkin
2016-Apr-18 14:23 UTC
[PATCH RFC] fixup! virtio: convert to use DMA api
On Mon, Apr 18, 2016 at 10:03:52AM -0400, David Woodhouse wrote:> On Mon, 2016-04-18 at 16:12 +0300, Michael S. Tsirkin wrote: > > I'm not sure I understand the issue.??The public API is not about how > > the driver works.??It doesn't say "don't use DMA API" anywhere, does it? > > It's about telling device whether to obey the IOMMU and > > about discovering whether a device is in fact under the IOMMU. > > Apologies, I was wrongly reading this as a kernel patch. > > After a brief struggle with "telling device whether to obey the IOMMU", > which is obviously completely impossible from the guest kernel, I > realise my mistake :) > > So... on x86 how does this get reflected in the DMAR tables that the > guest BIOS presents to the guest kernel, so that the guest kernel > *knows* which devices are behind which IOMMU?This patch doesn't change DMAR tables, it creates a way for virtio device to tell guest "I obey what DMAR tables tell you, you can stop doing hacks". And as PPC guys seem adamant that platform tools there are no good for that purpose, there's another bit that says "ignore what platform tells you, I'm not a real device - I'm part of hypervisor and I bypass the IOMMU".> (And are you fixing the case of assigned PCI devices, which aren't > behind any IOMMU, at the same time as you answer that? :)No - Aviv B.D. has patches on list to fix that. -- MST