From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Wang2 Subject: Re: [osrc-patches] [PATCH] amd iommu: Fix a xen crash after pci-attach (backport) Date: Wed, 9 Feb 2011 16:24:59 +0100 Message-ID: <201102091625.00122.wei.wang2@amd.com> References: <201102011727.17297.wei.wang2@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary-00=_MHrUNrKUHczI31G" Return-path: In-Reply-To: <201102011727.17297.wei.wang2@amd.com> 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=_MHrUNrKUHczI31G Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 > -- > Advanced Micro Devices GmbH > Sitz: Dornach, Gemeinde Aschheim, > Landkreis M=C3=BCnchen Registergericht M=C3=BCnchen, > HRB Nr. 43632 > WEEE-Reg-Nr: DE 12919551 > Gesch=C3=A4ftsf=C3=BChrer: > Alberto Bozzo, Andrew Bowd Keir,=20 I think this should also be back ported to 4.0, I found the same issue with= =20 xen-4.0.2-rc2-pre. Patch has been attached. Thanks, Wei Signed-off-by: Wei Wang --Boundary-00=_MHrUNrKUHczI31G Content-Type: text/x-diff; charset="utf-8"; name="fix_detach_xen40.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="fix_detach_xen40.patch" Content-Description: fix_detach_xen40.patch 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", --Boundary-00=_MHrUNrKUHczI31G 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=_MHrUNrKUHczI31G--