summaryrefslogtreecommitdiff
path: root/virt/kvm/vtd.c
diff options
context:
space:
mode:
authorWeidong Han <weidong.han@intel.com>2008-12-02 21:24:23 +0800
committerJoerg Roedel <joerg.roedel@amd.com>2009-01-03 14:02:19 +0100
commit0a920356748df4fb06e86c21c23d2ed6d31d37ad (patch)
tree545bf8591b48b8f33af3f03f50a536424853a259 /virt/kvm/vtd.c
parent260782bcfdaaa7850f29d6bb2ec6603019168c57 (diff)
downloadlwn-0a920356748df4fb06e86c21c23d2ed6d31d37ad.tar.gz
lwn-0a920356748df4fb06e86c21c23d2ed6d31d37ad.zip
KVM: support device deassignment
Support device deassignment, it can be used in device hotplug. Signed-off-by: Weidong Han <weidong.han@intel.com> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'virt/kvm/vtd.c')
-rw-r--r--virt/kvm/vtd.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/virt/kvm/vtd.c b/virt/kvm/vtd.c
index 44bb58a395a5..174ea1f8cee5 100644
--- a/virt/kvm/vtd.c
+++ b/virt/kvm/vtd.c
@@ -116,6 +116,30 @@ int kvm_assign_device(struct kvm *kvm,
return 0;
}
+int kvm_deassign_device(struct kvm *kvm,
+ struct kvm_assigned_dev_kernel *assigned_dev)
+{
+ struct dmar_domain *domain = kvm->arch.intel_iommu_domain;
+ struct pci_dev *pdev = NULL;
+
+ /* check if iommu exists and in use */
+ if (!domain)
+ return 0;
+
+ pdev = assigned_dev->dev;
+ if (pdev == NULL)
+ return -ENODEV;
+
+ intel_iommu_detach_device(domain, pdev);
+
+ printk(KERN_DEBUG "deassign device: host bdf = %x:%x:%x\n",
+ assigned_dev->host_busnr,
+ PCI_SLOT(assigned_dev->host_devfn),
+ PCI_FUNC(assigned_dev->host_devfn));
+
+ return 0;
+}
+
int kvm_iommu_map_guest(struct kvm *kvm)
{
int r;