Re: [PATCH] VT-d: fix PCI device detach from virtual machine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2009-02-26 at 17:31 +0800, Han, Weidong wrote:
> When assign a device behind conventional PCI bridge or PCIe to
> PCI/PCI-x bridge to a domain, it must assign its bridge and may
> also need to assign secondary interface to the same domain. 
> 
> Dependent assignment is already there, but dependent
> deassignment is missed when detach device from virtual machine.
> This results in conventional PCI device assignment failure after
> it has been assigned once. This patch addes dependent
> deassignment, and fixes the issue. 

Um, this code makes my head hurt.

Why are we doing this in the first place? Because the IOMMU works on the
source-id in PCIe transactions, the pci_find_upstream_pcie_bridge()
function effectively tells us which PCI device our own device will be
masquerading as, for the purposes of DMA.

So why do we bother setting up a context in the IOMMU for the device
itself, when no DMA will ever appear to come from this device? And
likewise why do we bother setting up a context for intermediate PCI
bridges?

Why not just jump straight to the 'DMA proxy' device, and use that
_only_?

We'll have to cope with multiple devices behind the same 'proxy', but it
looks like our handling of that is totally screwed already...  what
happens right now if you have two PCI devices behind the same PCIe-PCI
bridge, and try to attach both of them to different domains... or both
to the _same_ domain, in fact, and then detach just one of them. I think
the answer to the latter question is that your newly-added
iommu_detach_dependent_devices() routine will tear down the mapping on
the 'proxy' device and faults will start happening for the device which
is supposed to still be mapped?

Confused... and tempted to rip it all out and start over.

-- 
dwmw2

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux