From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tim Deegan Subject: Re: [hybrid]: code review for function mapping pfn to foreign mfn Date: Tue, 24 Apr 2012 10:36:26 +0100 Message-ID: <20120424093626.GC34721@ocelot.phlegethon.org> References: <20120413182952.504e2775@mantra.us.oracle.com> <20120419141527.GB23663@ocelot.phlegethon.org> <20120423183709.5636656f@mantra.us.oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20120423183709.5636656f@mantra.us.oracle.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: Mukesh Rathor Cc: Keir Fraser , "Xen-devel@lists.xensource.com" , Ian Campbell , "stefano.stabellini@eu.citrix.com" List-Id: xen-devel@lists.xenproject.org At 18:37 -0700 on 23 Apr (1335206229), Mukesh Rathor wrote: > On Thu, 19 Apr 2012 15:15:27 +0100 > Tim Deegan wrote: > > > At 18:29 -0700 on 13 Apr (1334341792), Mukesh Rathor wrote: > > - AFAICT you're using set_mmio_p2m_entry and adding a new unmap > > operation just to avoid having the m2p updated. Since you can't > > rely on the unmap always happening through the new call (and you don't > > enforce it anywhere), it would be better to add a new p2m_type > > just for non-grant foreign mappings. Then you can gate the m2p > > updates in the existing code on the map being normal RAM, as is > > already done for p2m_is_grant(). > > Hi Tim, > > The variants of get_page* are confusing me, so wanna double check with > you. I should be able to do something like following, right? > [...] > if ( (rc=get_page_and_type_from_pagenr(mfn, PGT_writable_page,fdom,0,0)) ) { > put_pg_owner(fdom); > return rc; > } Yes, but: - You should use get_page_from_pagenr() if fdom is paging_mode_external() and reference/copy the comment in get_page_from_l1e() to explain why: /* Foreign mappings into guests in shadow external mode don't * contribute to writeable mapping refcounts. (This allows the * qemu-dm helper process in dom0 to map the domain's memory without * messing up the count of "real" writable mappings.) */ - You should drop the refcount (and typecount, if you took one) if the mapping fails. - You need to make sure that _any_ path that removes the mapping drops the ref/type (_after_ any TLB flushes have happened, please!) Maybe the best way to do that is in ept_set_entry() for EPT and paging_write_p2m_entry() for NPT/shadow. - You need to handle the p2m teardown path as well. I think the best way to do that is to hoist the relinquish_shared_pages() loop up into a new function in p2m.c, and add your put_page[_and_type] calls in there. Cheers, Tim.