Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux...
[pandora-kernel.git] / virt / kvm / iommu.c
index 78c80f6..a195c07 100644 (file)
@@ -25,7 +25,9 @@
 
 #include <linux/list.h>
 #include <linux/kvm_host.h>
+#include <linux/module.h>
 #include <linux/pci.h>
+#include <linux/stat.h>
 #include <linux/dmar.h>
 #include <linux/iommu.h>
 #include <linux/intel-iommu.h>
@@ -187,6 +189,8 @@ int kvm_assign_device(struct kvm *kvm,
                        goto out_unmap;
        }
 
+       pdev->dev_flags |= PCI_DEV_FLAGS_ASSIGNED;
+
        printk(KERN_DEBUG "assign device %x:%x:%x.%x\n",
                assigned_dev->host_segnr,
                assigned_dev->host_busnr,
@@ -215,6 +219,8 @@ int kvm_deassign_device(struct kvm *kvm,
 
        iommu_detach_device(domain, &pdev->dev);
 
+       pdev->dev_flags &= ~PCI_DEV_FLAGS_ASSIGNED;
+
        printk(KERN_DEBUG "deassign device %x:%x:%x.%x\n",
                assigned_dev->host_segnr,
                assigned_dev->host_busnr,
@@ -228,12 +234,12 @@ int kvm_iommu_map_guest(struct kvm *kvm)
 {
        int r;
 
-       if (!iommu_found()) {
+       if (!iommu_present(&pci_bus_type)) {
                printk(KERN_ERR "%s: iommu not found\n", __func__);
                return -ENODEV;
        }
 
-       kvm->arch.iommu_domain = iommu_domain_alloc();
+       kvm->arch.iommu_domain = iommu_domain_alloc(&pci_bus_type);
        if (!kvm->arch.iommu_domain)
                return -ENOMEM;