* [PATCH] amd iommu: Fix a xen crash after pci-attach
@ 2011-02-01 16:27 Wei Wang2
2011-02-09 15:24 ` [osrc-patches] [PATCH] amd iommu: Fix a xen crash after pci-attach (backport) Wei Wang2
0 siblings, 1 reply; 2+ messages in thread
From: Wei Wang2 @ 2011-02-01 16:27 UTC (permalink / raw)
To: Keir Fraser; +Cc: xen-devel@lists.xensource.com
[-- Attachment #1: Type: text/plain, Size: 474 bytes --]
Keir,
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.
Thanks,
Wei
Signed-off-by: Wei Wang <wei.wang2@amd.com>
--
Advanced Micro Devices GmbH
Sitz: Dornach, Gemeinde Aschheim,
Landkreis München Registergericht München,
HRB Nr. 43632
WEEE-Reg-Nr: DE 12919551
Geschäftsführer:
Alberto Bozzo, Andrew Bowd
[-- Attachment #2: fix_detach.patch --]
[-- Type: text/x-diff, Size: 809 bytes --]
diff -r a69965e61ae9 xen/drivers/passthrough/amd/pci_amd_iommu.c
--- a/xen/drivers/passthrough/amd/pci_amd_iommu.c Mon Jan 31 17:47:24 2011 +0000
+++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c Tue Feb 01 17:19:16 2011 +0100
@@ -301,6 +301,11 @@ static int reassign_device( struct domai
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),
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [osrc-patches] [PATCH] amd iommu: Fix a xen crash after pci-attach (backport)
2011-02-01 16:27 [PATCH] amd iommu: Fix a xen crash after pci-attach Wei Wang2
@ 2011-02-09 15:24 ` Wei Wang2
0 siblings, 0 replies; 2+ messages in thread
From: Wei Wang2 @ 2011-02-09 15:24 UTC (permalink / raw)
To: Keir Fraser; +Cc: xen-devel@lists.xensource.com
[-- Attachment #1: Type: text/plain, Size: 752 bytes --]
On Tuesday 01 February 2011 17:27:16 Wei Wang2 wrote:
> Keir,
> 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.
> Thanks,
> Wei
>
> Signed-off-by: Wei Wang <wei.wang2@amd.com>
> --
> Advanced Micro Devices GmbH
> Sitz: Dornach, Gemeinde Aschheim,
> Landkreis München Registergericht München,
> HRB Nr. 43632
> WEEE-Reg-Nr: DE 12919551
> Geschäftsführer:
> Alberto Bozzo, Andrew Bowd
Keir,
I think this should also be back ported to 4.0, I found the same issue with
xen-4.0.2-rc2-pre. Patch has been attached.
Thanks,
Wei
Signed-off-by: Wei Wang <wei.wang2@amd.com>
[-- Attachment #2: fix_detach_xen40.patch --]
[-- Type: text/x-diff, Size: 1021 bytes --]
diff -r a8bc981ce9c7 xen/drivers/passthrough/amd/pci_amd_iommu.c
--- a/xen/drivers/passthrough/amd/pci_amd_iommu.c Mon Feb 07 10:01:19 2011 +0000
+++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c Wed Feb 09 16:03:59 2011 +0100
@@ -277,6 +277,7 @@ static int reassign_device( struct domai
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);
@@ -297,6 +298,11 @@ static int reassign_device( struct domai
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",
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-02-09 15:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-01 16:27 [PATCH] amd iommu: Fix a xen crash after pci-attach Wei Wang2
2011-02-09 15:24 ` [osrc-patches] [PATCH] amd iommu: Fix a xen crash after pci-attach (backport) Wei Wang2
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.