From: Ian Campbell Subject: Re: [PATCH 4/8] xen/arm: Store p2m type in each page of the guest Date: Thu, 5 Dec 2013 16:02:06 +0000 Message-ID: <1386259326.20047.92.camel@kazak.uk.xensource.com> References: <1386258131-755-1-git-send-email-julien.grall@linaro.org> <1386258131-755-5-git-send-email-julien.grall@linaro.org> <1386258928.20047.86.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" 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 1VobNj-0005m6-9T for xen-devel@lists.xenproject.org; Thu, 05 Dec 2013 16:02:27 +0000 In-Reply-To: <1386258928.20047.86.camel@kazak.uk.xensource.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: Julien Grall Cc: xen-devel@lists.xenproject.org, tim@xen.org, stefano.stabellini@citrix.com, patches@linaro.org List-Id: xen-devel@lists.xenproject.org On Thu, 2013-12-05 at 15:55 +0000, Ian Campbell wrote: [....] oops, hit send before I was done ;-) > > }; > > > > + switch (t) > > + { > > + case p2m_ram_rw: > > + case p2m_mmio_direct: > > + case p2m_map_foreign: > > + e.p2m.write = 1; > > + break; > > + case p2m_invalid: > > + case p2m_ram_ro: > > + default: > > + e.p2m.write = 0; > > + } > > + > > ASSERT(!(pa & ~PAGE_MASK)); > > ASSERT(!(pa & ~PADDR_MASK)); > > > > @@ -167,7 +181,7 @@ static int p2m_create_table(struct domain *d, > > clear_page(p); > > unmap_domain_page(p); > > > > - pte = mfn_to_p2m_entry(page_to_mfn(page), MATTR_MEM); > > + pte = mfn_to_p2m_entry(page_to_mfn(page), MATTR_MEM, p2m_invalid); Is invalid really the right type here? Are you using invalid for non-leaf pages? I think the table bit suffices to identify them, doesn't it? Really the type field is only valid for the leafs ptes (including superpage leafs). If it is useful to have "pseudo-types" which don't directly correspond to the 4 available bits perhaps make them >= 16, although then you would need a function to take a pte and extract its type taking that into account. > > > > -int guest_physmap_add_page(struct domain *d, > > - unsigned long gpfn, > > - unsigned long mfn, > > - unsigned int page_order) > > +int guest_physmap_add_entry(struct domain *d, > > + unsigned long gpfn, > > + unsigned long mfn, > > + unsigned long page_order, > > + p2m_type_t t) > > { > > return create_p2m_entries(d, INSERT, > > pfn_to_paddr(gpfn), > > - pfn_to_paddr(gpfn + (1< > - pfn_to_paddr(mfn), MATTR_MEM); > > + pfn_to_paddr(gpfn + (1 << page_order)), > > + pfn_to_paddr(mfn), MATTR_MEM, t); > > } > > > > void guest_physmap_remove_page(struct domain *d, > > @@ -331,7 +350,7 @@ void guest_physmap_remove_page(struct domain *d, > > create_p2m_entries(d, REMOVE, > > pfn_to_paddr(gpfn), > > pfn_to_paddr(gpfn + (1< > - pfn_to_paddr(mfn), MATTR_MEM); > > + pfn_to_paddr(mfn), MATTR_MEM, p2m_invalid); This looks odd to me, although I understand it is calling a common helper function which requires a type elsewhere. Perhpas p2m_invalid here really needs a placeholder. p2m_none == INT_MAX perhaps? Ian.