diff options
author | Keir Fraser <keir@xen.org> | 2011-02-10 09:04:05 +0000 |
---|---|---|
committer | Keir Fraser <keir@xen.org> | 2011-02-10 09:04:05 +0000 |
commit | 55354d089b85d279f0c68028961d6a7fad7f5b67 (patch) | |
tree | fec2fe6be2f8e0d881917f3a72128c1e737a1faf | |
parent | f4d78c889e4ff00aa0c36cefdabea3803931218d (diff) | |
download | xen-55354d089b85d279f0c68028961d6a7fad7f5b67.tar.gz xen-55354d089b85d279f0c68028961d6a7fad7f5b67.tar.bz2 xen-55354d089b85d279f0c68028961d6a7fad7f5b67.zip |
amd iommu: Fix a xen crash after pci-attach
pci-detach triggers IO page table deallocation if the last passthru
device has been removed from pdev list, and this will result a BUG on
amd systems for next pci-attach. This patch fixes this issue.
Signed-off-by: Wei Wang <wei.wang2@amd.com>
xen-unstable changeset: 22872:cba9a84d32fb
xen-unstable date: Sun Feb 06 16:54:01 2011 +0000
-rw-r--r-- | xen/drivers/passthrough/amd/pci_amd_iommu.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/xen/drivers/passthrough/amd/pci_amd_iommu.c b/xen/drivers/passthrough/amd/pci_amd_iommu.c index d4e06ffc86..fb29e209c6 100644 --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c @@ -277,6 +277,7 @@ static int reassign_device( struct domain *source, struct domain *target, struct pci_dev *pdev; struct amd_iommu *iommu; int bdf; + struct hvm_iommu *t = domain_hvm_iommu(target); ASSERT(spin_is_locked(&pcidevs_lock)); pdev = pci_get_pdev_by_domain(source, bus, devfn); @@ -298,6 +299,11 @@ static int reassign_device( struct domain *source, struct domain *target, list_move(&pdev->domain_list, &target->arch.pdev_list); pdev->domain = target; + /* IO page tables might be destroyed after pci-detach the last device + * In this case, we have to re-allocate root table for next pci-attach.*/ + if ( t->root_table == NULL ) + allocate_domain_resources(t); + amd_iommu_setup_domain_device(target, iommu, bdf); AMD_IOMMU_DEBUG("reassign %x:%x.%x domain %d -> domain %d\n", bus, PCI_SLOT(devfn), PCI_FUNC(devfn), |