From: "Jan Beulich" Subject: Re: [v6][PATCH 1/2] xen:x86:mm:p2m: introduce set_identity_p2m_entry Date: Fri, 01 Aug 2014 07:43:12 +0100 Message-ID: <53DB5320020000780002844E@mail.emea.novell.com> References: <1406684186-12788-1-git-send-email-tiejun.chen@intel.com> <53DAFAA7.90801@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <53DAFAA7.90801@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 , Kevin Tian , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org >>> On 01.08.14 at 04:25, wrote: > On 2014/8/1 6:29, Tian, Kevin wrote: >> what about !mfn_valid but the GFN has been used for emulated MMIOs? w/o >> a guest e820 view you can't avoid overlapping by just looking at mfn... > > What about the follows based on this patch? > > @@ -865,14 +865,26 @@ int set_identity_p2m_entry(struct domain *d, unsigned long gfn) > mfn_t mfn; > struct p2m_domain *p2m = p2m_get_hostp2m(d); > int ret = -EBUSY; > + u64 base_addr, end_addr; > > gfn_lock(p2m, gfn, 0); > > mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, 0, NULL); > > if ( !mfn_valid(mfn) ) > + { > + base_addr = gfn << PAGE_ORDER_4K; > + end_addr = base_addr + PAGE_MASK; > + if ( (!page_is_ram_type(paddr_to_pfn(base_addr), RAM_TYPE_RESERVED)) || > + (!page_is_ram_type(paddr_to_pfn(end_add), RAM_TYPE_RESERVED)) ) > + { > + gfn_unlock(p2m, gfn, 0); > + return ret; > + } > + That you're looking at the host E820, whereas Kevin asked about the guest one. But see also my other reply just sent to him. Jan