aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeir Fraser <keir@xen.org>2011-02-06 16:54:01 +0000
committerKeir Fraser <keir@xen.org>2011-02-06 16:54:01 +0000
commit77c01bba24c0896565834398a689896bcdd33ebe (patch)
tree00221f1855ed02f879d95741feccea8e561a4a94
parentb9a9873c2e97a765c5136b223bf8921f3bd40c66 (diff)
downloadxen-77c01bba24c0896565834398a689896bcdd33ebe.tar.gz
xen-77c01bba24c0896565834398a689896bcdd33ebe.tar.bz2
xen-77c01bba24c0896565834398a689896bcdd33ebe.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>
-rw-r--r--xen/drivers/passthrough/amd/pci_amd_iommu.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/xen/drivers/passthrough/amd/pci_amd_iommu.c b/xen/drivers/passthrough/amd/pci_amd_iommu.c
index 6a79efedb8..200ee2ea27 100644
--- a/xen/drivers/passthrough/amd/pci_amd_iommu.c
+++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c
@@ -301,6 +301,11 @@ static int reassign_device( struct domain *source, struct domain *target,
if ( target->max_pages > 0 )
t->paging_mode = get_paging_mode(target->max_pages);
+ /* 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("Re-assign %02x:%02x.%x from domain %d to domain %d\n",
bus, PCI_SLOT(devfn), PCI_FUNC(devfn),