From: Tim Deegan Subject: Re: [PATCH 03/38] arm: handy function to print a walk of a domain's p2m. Date: Thu, 7 Jun 2012 13:40:33 +0100 Message-ID: <20120607124033.GS70339@ocelot.phlegethon.org> References: <1338565113.17466.141.camel@zakaz.uk.xensource.com> <1338565207-2888-1-git-send-email-ian.campbell@citrix.com> <1338565207-2888-3-git-send-email-ian.campbell@citrix.com> <20120607084917.GB70339@ocelot.phlegethon.org> <1339072005.18523.18.camel@zakaz.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1339072005.18523.18.camel@zakaz.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: Ian Campbell Cc: "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org At 13:26 +0100 on 07 Jun (1339075605), Ian Campbell wrote: > On Thu, 2012-06-07 at 09:49 +0100, Tim Deegan wrote: > > At 15:39 +0000 on 01 Jun (1338565172), Ian Campbell wrote: > > > Useful for debug but not actually used in this patch. > > > > > > Signed-off-by: Ian Campbell > > > --- > > > xen/arch/arm/p2m.c | 34 ++++++++++++++++++++++++++++++++++ > > > xen/include/asm-arm/page.h | 1 + > > > 2 files changed, 35 insertions(+), 0 deletions(-) > > > > > > diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c > > > index 4f624d8..fdbecbc 100644 > > > --- a/xen/arch/arm/p2m.c > > > +++ b/xen/arch/arm/p2m.c > > > @@ -5,6 +5,40 @@ > > > #include > > > #include > > > > > > +void dump_p2m_lookup(struct domain *d, paddr_t addr) > > > +{ > > > + struct p2m_domain *p2m = &d->arch.p2m; > > > + lpae_t *first = NULL, *second = NULL, *third = NULL; > > > + > > > + printk("dom%d IPA %#016llx\n", d->domain_id, addr); > > > + > > > + first = __map_domain_page(p2m->first_level); > > > + printk("1ST[%#03llx] = %#016llx\n", > > > + first_table_offset(addr), > > > + first[first_table_offset(addr)].bits); > > > + if ( !first[first_table_offset(addr)].p2m.valid || > > > + !first[first_table_offset(addr)].p2m.table ) > > > + goto done; > > > + > > > + second = map_domain_page(first[first_table_offset(addr)].p2m.base); > > > + printk("2ND[%#03llx] = %#016llx\n", > > > + second_table_offset(addr), > > > + second[second_table_offset(addr)].bits); > > > + if ( !second[second_table_offset(addr)].p2m.valid || > > > + !second[second_table_offset(addr)].p2m.table ) > > > + goto done; > > > + > > > + third = map_domain_page(second[second_table_offset(addr)].p2m.base); > > > + printk("3RD[%#03llx] = %#016llx\n", > > > + third_table_offset(addr), > > > + third[third_table_offset(addr)].bits); > > > + > > > +done: > > > + if (third) unmap_domain_page(third); > > > + if (second) unmap_domain_page(second); > > > + if (first) unmap_domain_page(first); > > > +} > > > > Can this be unified with dump_pt_walk? > > Not all that easily, mainly because dump_pt_walk walks xenheap pages > (which don't need mapping) while dump_p2m_walk dumps domheap pages > (which need mapping as we go). I probably could write something generic > enough but I fear that it would be a mass of if's. Is there any harm in mapping xenheap pages? Since this is only invoked on error paths, we don't particularly need it to be fast. Tim.