From: "Jan Beulich" Subject: Re: [V12 PATCH 3/4] pvh dom0: Add and remove foreign pages Date: Mon, 12 May 2014 11:34:14 +0100 Message-ID: <5370BFC60200007800011554@mail.emea.novell.com> References: <1399683043-29112-1-git-send-email-mukesh.rathor@oracle.com> <1399683043-29112-4-git-send-email-mukesh.rathor@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WjnYp-0006J3-RT for xen-devel@lists.xenproject.org; Mon, 12 May 2014 10:34:20 +0000 In-Reply-To: <1399683043-29112-4-git-send-email-mukesh.rathor@oracle.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: Mukesh Rathor Cc: George.Dunlap@eu.citrix.com, tim@xen.org, eddie.dong@intel.com, keir.xen@gmail.com, jun.nakajima@intel.com, xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org >>> On 10.05.14 at 02:50, wrote: > +static int atomic_write_ept_entry(ept_entry_t *entryptr, ept_entry_t new, > + int level) > +{ > + unsigned long oldmfn = INVALID_MFN; > + bool_t skip_foreign = (new.mfn == entryptr->mfn && > + new.sa_p2mt == entryptr->sa_p2mt); This still seems too weak to me: Shouldn't you also consider whether the old and new entries respectively are present (also further down)? > + > + if ( level ) > + { > + ASSERT(!new.sp || !p2m_is_foreign(new.sa_p2mt)); Please use is_epte_superpage() here. > @@ -292,7 +332,7 @@ static bool_t ept_invalidate_emt(mfn_t mfn, bool_t recalc) > e.emt = MTRR_NUM_TYPES; > if ( recalc ) > e.recalc = 1; > - atomic_write_ept_entry(&epte[i], e); > + atomic_write_ept_entry(&epte[i], e, level); I'm afraid you mustn't ever ignore this function failing (i.e. unless you're in places where you know the non-leaf shortcut is always going to be taken, but even there I think you'd be better off documenting this via ASSERT()), for security reasons. And yes, I realize that this isn't going to be trivial in some cases, especially if you want to do better than domain_crash(). And a more general question: How is the insertion of p2m_foreign entries working together with the controlled domain (i.e. the one owning the page) being subject to paging/sharing? I only recall fixme-s having got added for the two features presently not being supported for PVH domains... Jan