From: "Jan Beulich" Subject: Re: [v3][PATCH 1/1] xen:vtd: missing RMRR mapping while share EPT Date: Fri, 25 Jul 2014 10:14:49 +0100 Message-ID: <53D23C290200007800025EC1@mail.emea.novell.com> References: <1406199618-21574-1-git-send-email-tiejun.chen@intel.com> <20140724111143.GF1817@deinos.phlegethon.org> <53D0ED1B.80107@intel.com> <20140724113528.GD1821@deinos.phlegethon.org> <53D1FD7E.9070204@intel.com> <53D22C700200007800025DAC@mail.emea.novell.com> <53D2192B.2010804@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <53D2192B.2010804@intel.com> 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: Tiejun Chen Cc: yang.z.zhang@intel.com, kevin.tian@intel.com, Tim Deegan , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org >>> On 25.07.14 at 10:45, wrote: > On 2014/7/25 16:07, Jan Beulich wrote: >>>>> On 25.07.14 at 08:47, wrote: >>>> So I think it would be prudent to at least try to detect a clash here >>>> and return an error. >>> >>> Could we check if this pte already present like this? >>> >>> @@ -1870,6 +1872,16 @@ static int rmrr_identity_mapping(struct domain *d, >>> if ( iommu_use_hap_pt(d) ) >>> { >>> ASSERT(!iommu_passthrough || !is_hardware_domain(d)); >>> + /* get last level pte */ >>> + pg_maddr = addr_to_dma_page_maddr(d, ((paddr_t)gfn << PAGE_SHIFT_4K), 0); >>> + page = (struct dma_pte *)map_vtd_domain_page(pg_maddr); >>> + pte = page + address_level_offset(addr, 1); >>> + if ( dma_pte_present(*pte) ) >>> + { >>> + printk(XENLOG_ERR VTDPREFIX >>> + "Overlapping RMRRs at %"PRIx64".\n", (paddr_t)base_gfn); >>> + return -1; >>> + } >>> if ( set_mmio_p2m_entry(d, base_pfn, _mfn(base_pfn)) ) >>> return -1; >>> } >> >> I think you'd be better off using P2M functions here, even more so >> considering that you're in an iommu_use_hap_pt() guarded code >> section. > > Are you pointing p2m->get_entry? Sort of. For the check to really be meaningful the get and set would need to be done without the respective lock dropped intermediately. Jan