|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] arm: handy function to print a walk of a page table
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1340724224 -3600
# Node ID f84e8a0914b61c8ea2875a424e3cade37b8feaf6
# Parent d29a911cc8cf816934a462dad0a25462e6049c18
arm: handy function to print a walk of a page table
Include helpers for dumping hypervisor walks and guest p2m walks.
Useful for debug but not actually used in this patch.
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Acked-by: Tim Deegan <tim@xxxxxxx>
Committed-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
diff -r d29a911cc8cf -r f84e8a0914b6 xen/arch/arm/mm.c
--- a/xen/arch/arm/mm.c Tue Jun 26 16:23:43 2012 +0100
+++ b/xen/arch/arm/mm.c Tue Jun 26 16:23:44 2012 +0100
@@ -26,6 +26,7 @@
#include <xen/preempt.h>
#include <xen/errno.h>
#include <xen/guest_access.h>
+#include <xen/domain_page.h>
#include <asm/page.h>
#include <asm/current.h>
#include <public/memory.h>
@@ -42,6 +43,8 @@ static lpae_t xen_xenmap[LPAE_ENTRIES] _
/* Non-boot CPUs use this to find the correct pagetables. */
uint64_t boot_httbr;
+static paddr_t phys_offset;
+
/* Limits of the Xen heap */
unsigned long xenheap_mfn_start, xenheap_mfn_end;
unsigned long xenheap_virt_end;
@@ -53,6 +56,50 @@ unsigned long max_page;
extern char __init_begin[], __init_end[];
+void dump_pt_walk(lpae_t *first, paddr_t addr)
+{
+ lpae_t *second = NULL, *third = NULL;
+
+ if ( first_table_offset(addr) >= LPAE_ENTRIES )
+ return;
+
+ printk("1ST[0x%llx] = 0x%"PRIpaddr"\n",
+ first_table_offset(addr),
+ first[first_table_offset(addr)].bits);
+ if ( !first[first_table_offset(addr)].walk.valid ||
+ !first[first_table_offset(addr)].walk.table )
+ goto done;
+
+ second = map_domain_page(first[first_table_offset(addr)].walk.base);
+ printk("2ND[0x%llx] = 0x%"PRIpaddr"\n",
+ second_table_offset(addr),
+ second[second_table_offset(addr)].bits);
+ if ( !second[second_table_offset(addr)].walk.valid ||
+ !second[second_table_offset(addr)].walk.table )
+ goto done;
+
+ third = map_domain_page(second[second_table_offset(addr)].walk.base);
+ printk("3RD[0x%llx] = 0x%"PRIpaddr"\n",
+ third_table_offset(addr),
+ third[third_table_offset(addr)].bits);
+
+done:
+ if (third) unmap_domain_page(third);
+ if (second) unmap_domain_page(second);
+
+}
+
+void dump_hyp_walk(uint32_t addr)
+{
+ uint64_t httbr = READ_CP64(HTTBR);
+
+ printk("Walking Hypervisor VA 0x%08"PRIx32" via HTTBR 0x%016"PRIx64"\n",
+ addr, httbr);
+
+ BUG_ON( (lpae_t *)(unsigned long)(httbr - phys_offset) != xen_pgtable );
+ dump_pt_walk(xen_pgtable, addr);
+}
+
/* Map a 4k page in a fixmap entry */
void set_fixmap(unsigned map, unsigned long mfn, unsigned attributes)
{
@@ -159,7 +206,7 @@ void unmap_domain_page(const void *va)
* Changes here may need matching changes in head.S */
void __init setup_pagetables(unsigned long boot_phys_offset)
{
- paddr_t xen_paddr, phys_offset;
+ paddr_t xen_paddr;
unsigned long dest_va;
lpae_t pte, *p;
int i;
diff -r d29a911cc8cf -r f84e8a0914b6 xen/arch/arm/p2m.c
--- a/xen/arch/arm/p2m.c Tue Jun 26 16:23:43 2012 +0100
+++ b/xen/arch/arm/p2m.c Tue Jun 26 16:23:44 2012 +0100
@@ -5,6 +5,21 @@
#include <xen/domain_page.h>
#include <asm/flushtlb.h>
+void dump_p2m_lookup(struct domain *d, paddr_t addr)
+{
+ struct p2m_domain *p2m = &d->arch.p2m;
+ lpae_t *first;
+
+ printk("dom%d IPA 0x%"PRIpaddr"\n", d->domain_id, addr);
+
+ printk("P2M @ %p mfn:0x%lx\n",
+ p2m->first_level, page_to_mfn(p2m->first_level));
+
+ first = __map_domain_page(p2m->first_level);
+ dump_pt_walk(first, addr);
+ unmap_domain_page(first);
+}
+
void p2m_load_VTTBR(struct domain *d)
{
struct p2m_domain *p2m = &d->arch.p2m;
diff -r d29a911cc8cf -r f84e8a0914b6 xen/include/asm-arm/page.h
--- a/xen/include/asm-arm/page.h Tue Jun 26 16:23:43 2012 +0100
+++ b/xen/include/asm-arm/page.h Tue Jun 26 16:23:44 2012 +0100
@@ -132,10 +132,28 @@ typedef struct {
unsigned long sbz1:5;
} __attribute__((__packed__)) lpae_p2m_t;
+/*
+ * Walk is the common bits of p2m and pt entries which are needed to
+ * simply walk the table (e.g. for debug).
+ */
+typedef struct {
+ /* These are used in all kinds of entry. */
+ unsigned long valid:1; /* Valid mapping */
+ unsigned long table:1; /* == 1 in 4k map entries too */
+
+ unsigned long pad2:10;
+
+ /* The base address must be approprately aligned for Block entries */
+ unsigned long base:28; /* Base address of block or next table */
+
+ unsigned long pad1:24;
+} __attribute__((__packed__)) lpae_walk_t;
+
typedef union {
uint64_t bits;
lpae_pt_t pt;
lpae_p2m_t p2m;
+ lpae_walk_t walk;
} lpae_t;
/* Standard entry type that we'll use to build Xen's own pagetables.
@@ -252,6 +270,14 @@ static inline void flush_guest_tlb(void)
WRITE_CP32(r0 /* dummy */, TLBIALLNSNH);
}
+/* Print a walk of an arbitrary page table */
+void dump_pt_walk(lpae_t *table, paddr_t addr);
+
+/* Print a walk of the hypervisor's page tables for a virtual addr. */
+extern void dump_hyp_walk(uint32_t addr);
+/* Print a walk of the p2m for a domain for a physical address. */
+extern void dump_p2m_lookup(struct domain *d, paddr_t addr);
+
/* Ask the MMU to translate a VA for us */
static inline uint64_t __va_to_par(uint32_t va)
{
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |