From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tim Deegan Subject: Re: [RFC][PATCH 06/13] xen:vtd: create RMRR mapping Date: Thu, 16 Apr 2015 16:16:12 +0100 Message-ID: <20150416151612.GH13441@deinos.phlegethon.org> References: <1428657724-3498-1-git-send-email-tiejun.chen@intel.com> <1428657724-3498-7-git-send-email-tiejun.chen@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1428657724-3498-7-git-send-email-tiejun.chen@intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Tiejun Chen Cc: kevin.tian@intel.com, wei.liu2@citrix.com, ian.campbell@citrix.com, andrew.cooper3@citrix.com, Ian.Jackson@eu.citrix.com, xen-devel@lists.xen.org, stefano.stabellini@citrix.com, JBeulich@suse.com, yang.z.zhang@intel.com List-Id: xen-devel@lists.xenproject.org Hi, At 17:21 +0800 on 10 Apr (1428686517), Tiejun Chen wrote: > RMRR reserved regions must be setup in the pfn space with an identity > mapping to reported mfn. However existing code has problem to setup > correct mapping when VT-d shares EPT page table, so lead to problem > when assigning devices (e.g GPU) with RMRR reported. This patch > aims to setup identity mapping in p2m layer, regardless of whether EPT > is shared or not. This leaves the IOMMU mapping in place even if the p2m mapping fails. I think it would be better to keep the p2m as the canonical mapping and make the iommu tables match the p2m. So, this function should not call intel_iommu_map_page() itself; rather, set_identity_p2m_entry() should call intel_iommu_map_page() if it adds the p2m entry. Likewise for the unmap code just above this: we should be calling a p2m function here (guest_physmap_remove_page(), I think), which will then call iommu_unmap_page() for us. Cheers, Tim. > Signed-off-by: Tiejun Chen > --- > xen/drivers/passthrough/vtd/iommu.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c > index 4e789d1..f8fc6c3 100644 > --- a/xen/drivers/passthrough/vtd/iommu.c > +++ b/xen/drivers/passthrough/vtd/iommu.c > @@ -1847,6 +1847,12 @@ static int rmrr_identity_mapping(struct domain *d, bool_t map, > > if ( err ) > return err; > + > + if ( !is_hardware_domain(d) ) > + { > + if ( (err = set_identity_p2m_entry(d, base_pfn, p2m_access_rw)) ) > + return err; > + } > base_pfn++; > } > > -- > 1.9.1 >