From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tim Deegan Subject: Re: [PATCH 11/38] arm: implement p2m lookup Date: Thu, 7 Jun 2012 10:03:34 +0100 Message-ID: <20120607090334.GC70339@ocelot.phlegethon.org> References: <1338565113.17466.141.camel@zakaz.uk.xensource.com> <1338565207-2888-1-git-send-email-ian.campbell@citrix.com> <1338565207-2888-11-git-send-email-ian.campbell@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1338565207-2888-11-git-send-email-ian.campbell@citrix.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: Ian Campbell Cc: xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org At 15:39 +0000 on 01 Jun (1338565180), Ian Campbell wrote: > +/* > + * Lookup the MFN corresponding to a domain's PFN. > + * > + * There are no processor functions to do a stage 2 only lookup therefore we > + * do a a software walk. > + */ > +paddr_t p2m_lookup(struct domain *d, paddr_t paddr) > +{ > + struct p2m_domain *p2m = &d->arch.p2m; > + lpae_t pte, *first = NULL, *second = NULL, *third = NULL; > + paddr_t maddr = INVALID_PADDR; > + > + spin_lock(&p2m->lock); > + > + first = __map_domain_page(p2m->first_level); > + if ( !first[first_table_offset(paddr)].p2m.valid ) > + goto done_err; > + if ( !first[first_table_offset(paddr)].p2m.table ) > + { > + pte = first[first_table_offset(paddr)]; > + goto done; > + } This would be neater as: pte = first[first_table_offset(paddr)]; if ( !pte.p2m.valid || !pte.p2m.table ) goto done; and test for pte.valid at 'done'. It would be nice to do the three levels in a loop as well, but the weird way the table bit behaves in third-level entries might make that more confusing than the straight-line version. Tim.