From: "Jan Beulich" Subject: [PATCH 1/2] amd-iommu: obtain page_alloc_lock before traversing a domain's page list Date: Fri, 30 Jan 2009 10:50:57 +0000 Message-ID: <4982E9A1.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org >From all I can tell, this doesn't violate lock ordering as other places call heap allocation functions from inside hd->mapping_lock. Signed-off-by: Jan Beulich --- 2009-01-27.orig/xen/drivers/passthrough/amd/iommu_map.c 2009-01-29 = 11:33:26.000000000 +0100 +++ 2009-01-27/xen/drivers/passthrough/amd/iommu_map.c 2009-01-30 = 08:43:35.000000000 +0100 @@ -567,6 +567,8 @@ int amd_iommu_sync_p2m(struct domain *d) if ( hd->p2m_synchronized ) goto out; =20 + spin_lock(&d->page_alloc_lock); + page_list_for_each ( page, &d->page_list ) { mfn =3D page_to_mfn(page); @@ -579,6 +581,7 @@ int amd_iommu_sync_p2m(struct domain *d) =20 if ( iommu_l2e =3D=3D 0 ) { + spin_unlock(&d->page_alloc_lock); amd_iov_error("Invalid IO pagetable entry gfn =3D %lx\n", = gfn); spin_unlock_irqrestore(&hd->mapping_lock, flags); return -EFAULT; @@ -587,6 +590,8 @@ int amd_iommu_sync_p2m(struct domain *d) set_iommu_l1e_present(iommu_l2e, gfn, (u64)mfn << PAGE_SHIFT, iw, = ir); } =20 + spin_unlock(&d->page_alloc_lock); + hd->p2m_synchronized =3D 1; =20 out: