From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Chen, Tiejun" Subject: Re: [PATCH for 4.6] VT-d: Create IOMMU mappings for RMRR regions if shared EPT is not being used Date: Thu, 27 Aug 2015 17:05:01 +0800 Message-ID: <55DED2BD.4050605@intel.com> References: <1440604165-23738-1-git-send-email-malcolm.crossley@citrix.com> <55DE7D2F.90105@intel.com> <55DECD1A.8020704@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" 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 1ZUt7M-0004bx-J2 for xen-devel@lists.xenproject.org; Thu, 27 Aug 2015 09:05:08 +0000 In-Reply-To: <55DECD1A.8020704@citrix.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: Malcolm Crossley , xen-devel@lists.xenproject.org, kevin.tian@intel.com, JBeulich@suse.com Cc: yang.z.zhang@intel.com List-Id: xen-devel@lists.xenproject.org On 8/27/2015 4:40 PM, Malcolm Crossley wrote: > On 27/08/15 03:59, Chen, Tiejun wrote: >> This kind of issue is already gone. >> >> https://www.mail-archive.com/xen-devel@lists.xen.org/msg32464.html > > There is a bug in the code you refer to above which results in no IOMMU page table > mappings being created if the guest domain is not sharing it's EPT page tables with > the IOMMU. > > set_identity_p2m_entry only configures the EPT page tables and does not configure > the IOMMU page tables. Okay, I got what you mean. Instead, could you insert iommu_{map,unmap_page() into {set,clear}_identity_p2m_entry()? I think this can make {set,clear}_identity_p2m_entry approachable in all circumstances. Kevin and Jan, Is this fine? Thanks Tiejun > > We had a real world regression (with xen 4.6-rc1) on a Intel Haswell system with > integrated graphics. > > The patch below resolves the regression. > > Malcolm > >> >> Thanks >> Tiejun >> >> On 8/26/2015 11:49 PM, Malcolm Crossley wrote: >>> Add RMRR 1:1 IOMMU mappings to IOMMU page tables if EPT page table are not being >>> shared with the IOMMU. >>> >>> This is a regression in behaviour versus Xen 4.5. >>> >>> Signed-off-by: Malcolm Crossley >>> --- >>> xen/drivers/passthrough/vtd/iommu.c | 23 ++++++++++++++++++++--- >>> 1 file changed, 20 insertions(+), 3 deletions(-) >>> >>> diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c >>> index 836aed5..89de741 100644 >>> --- a/xen/drivers/passthrough/vtd/iommu.c >>> +++ b/xen/drivers/passthrough/vtd/iommu.c >>> @@ -1839,8 +1839,16 @@ static int rmrr_identity_mapping(struct domain *d, bool_t map, >>> >>> while ( base_pfn < end_pfn ) >>> { >>> - if ( (d, base_pfn) ) >>> - ret = -ENXIO; >>> + if ( iommu_use_hap_pt(d) ) >>> + { >>> + if ( clear_identity_p2m_entry(d, base_pfn) ) >>> + ret = -ENXIO; >>> + } >>> + else >>> + { >>> + if ( intel_iommu_unmap_page(d, base_pfn) ) >>> + ret = -ENXIO; >>> + } >>> base_pfn++; >>> } >>> >>> @@ -1855,7 +1863,16 @@ static int rmrr_identity_mapping(struct domain *d, bool_t map, >>> >>> while ( base_pfn < end_pfn ) >>> { >>> - int err = set_identity_p2m_entry(d, base_pfn, p2m_access_rw, flag); >>> + int err; >>> + if ( iommu_use_hap_pt(d) ) >>> + { >>> + err = set_identity_p2m_entry(d, base_pfn, p2m_access_rw, flag); >>> + } >>> + else >>> + { >>> + err = intel_iommu_map_page(d, base_pfn, base_pfn, >>> + IOMMUF_readable|IOMMUF_writable); >>> + } >>> >>> if ( err ) >>> return err; >>> > >