From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Wang2 Subject: [PATCH] amd iommu: Fix a xen crash after pci-attach Date: Tue, 1 Feb 2011 17:27:16 +0100 Message-ID: <201102011727.17297.wei.wang2@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary-00=_lRDSNkFOik/gBcQ" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org --Boundary-00=_lRDSNkFOik/gBcQ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Keir, pci-detach triggers IO page table deallocation if the last passthru device = has=20 been removed from pdev list, and this will result a BUG on amd systems for= =20 next pci-attach. This patch fixes this issue. Thanks, Wei Signed-off-by: Wei Wang =2D- Advanced Micro Devices GmbH Sitz: Dornach, Gemeinde Aschheim,=20 Landkreis M=FCnchen Registergericht M=FCnchen,=20 HRB Nr. 43632 WEEE-Reg-Nr: DE 12919551 Gesch=E4ftsf=FChrer: Alberto Bozzo, Andrew Bowd --Boundary-00=_lRDSNkFOik/gBcQ Content-Type: text/x-diff; charset="iso-8859-1"; name="fix_detach.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="fix_detach.patch" Content-Description: fix_detach.patch 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), --Boundary-00=_lRDSNkFOik/gBcQ Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --Boundary-00=_lRDSNkFOik/gBcQ--