From: "Jan Beulich" Subject: Re: [PATCH] IOMMU/x86: avoid pages without GFN in page table creation/updating Date: Mon, 11 May 2015 07:47:44 +0100 Message-ID: <55506CB00200007800078B38@mail.emea.novell.com> References: <554B7DEB020000780007793D@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Yrhp6-0002LP-2U for xen-devel@lists.xenproject.org; Mon, 11 May 2015 07:08:20 +0000 In-Reply-To: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Yang Z Zhang Cc: Kevin Tian , AndrewCooper , Tim Deegan , Sander Eikelenboom , Aravind Gopalakrishnan , "suravee.suthikulpanit@amd.com" , xen-devel List-Id: xen-devel@lists.xenproject.org >>> On 11.05.15 at 04:53, wrote: > Jan Beulich wrote on 2015-05-07: >> --- a/xen/drivers/passthrough/x86/iommu.c >> +++ b/xen/drivers/passthrough/x86/iommu.c >> @@ -59,10 +59,17 @@ int arch_iommu_populate_page_table(struc >> if ( has_hvm_container_domain(d) || >> (page->u.inuse.type_info & PGT_type_mask) == >> PGT_writable_page ) >> { >> - BUG_ON(SHARED_M2P(mfn_to_gmfn(d, >> page_to_mfn(page)))); >> - rc = hd->platform_ops->map_page( >> - d, mfn_to_gmfn(d, page_to_mfn(page)), >> page_to_mfn(page), >> - IOMMUF_readable|IOMMUF_writable); >> + unsigned long mfn = page_to_mfn(page); >> + unsigned long gfn = mfn_to_gmfn(d, mfn); >> + >> + if ( gfn != INVALID_MFN ) >> + { >> + ASSERT(!(gfn >> DEFAULT_DOMAIN_ADDRESS_WIDTH)); >> + BUG_ON(SHARED_M2P(gfn)); > > It seems ASSERT() is unnecessary. BUG_ON() is enough to cover it. The two check completely different things, so I don't see how the BUG_ON() would help with out of bounds, yet also not INVALID_MFN GFNs. Please clarify what you mean here. Jan