[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 02/38] arm: handy function to print a walk of the hypervisor page tables



Useful for debug but not actually used in this patch.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
 xen/arch/arm/mm.c          |   53 ++++++++++++++++++++++++++++++++++++++++++-
 xen/include/asm-arm/page.h |    2 +
 2 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 10ff883..c332e4c 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -42,6 +42,8 @@ static lpae_t xen_xenmap[LPAE_ENTRIES] 
__attribute__((__aligned__(4096)));
 /* Non-boot CPUs use this to find the correct pagetables. */
 uint64_t boot_httbr;
 
+static paddr_t xen_phys_offset;
+
 /* Limits of the Xen heap */
 unsigned long xenheap_mfn_start, xenheap_mfn_end;
 unsigned long xenheap_virt_end;
@@ -53,6 +55,53 @@ unsigned long max_page;
 
 extern char __init_begin[], __init_end[];
 
+void dump_pt_walk(uint32_t addr)
+{
+    paddr_t second_ma, third_ma;
+    lpae_t *first = NULL, *second = NULL, *third = NULL;
+    uint64_t httbr = READ_CP64(HTTBR);
+
+    printk("Walking Hypervisor VA %#"PRIx32" via HTTBR %#"PRIx64"\n",
+           addr, httbr);
+
+    BUG_ON( (lpae_t *)(unsigned long)(httbr - xen_phys_offset) != xen_pgtable 
);
+    first = xen_pgtable;
+    printk("1ST[%#03"PRIx32"] = %p[%#03"PRIx32"] = %#llx = %#016llx\n",
+           first_table_offset(addr),
+           first, first_table_offset(addr),
+           virt_to_maddr(&first[first_table_offset(addr)]),
+           first[first_table_offset(addr)].bits);
+
+    if ( !first[first_table_offset(addr)].pt.valid ||
+         !first[first_table_offset(addr)].pt.table )
+        goto done;
+
+    second_ma = (paddr_t)first[first_table_offset(addr)].pt.base << PAGE_SHIFT;
+    second = (lpae_t *)(unsigned long)(second_ma - xen_phys_offset);
+    printk("2ND[%#03"PRIx32"] = %p[%#03"PRIx32"] = %#llx = %#016llx\n",
+           second_table_offset(addr),
+           second, second_table_offset(addr),
+           virt_to_maddr(&second[second_table_offset(addr)]),
+           second[second_table_offset(addr)].bits);
+    if ( !second[second_table_offset(addr)].pt.valid ||
+         !second[second_table_offset(addr)].pt.table )
+        goto done;
+
+    third_ma = (paddr_t)second[second_table_offset(addr)].pt.base << 
PAGE_SHIFT;
+    third = (lpae_t *)(unsigned long)(third_ma - xen_phys_offset);
+    printk("3RD[%#03"PRIx32"] = %p[%#03"PRIx32"] = %#llx = %#016llx\n",
+           third_table_offset(addr),
+           third, third_table_offset(addr),
+           virt_to_maddr(&third[third_table_offset(addr)]),
+           third[third_table_offset(addr)].bits);
+    if ( !third[third_table_offset(addr)].pt.valid ||
+         !third[third_table_offset(addr)].pt.table )
+        goto done;
+
+done:
+    return;
+}
+
 /* Map a 4k page in a fixmap entry */
 void set_fixmap(unsigned map, unsigned long mfn, unsigned attributes)
 {
@@ -173,8 +222,8 @@ void __init setup_pagetables(unsigned long boot_phys_offset)
     flush_xen_data_tlb_va(dest_va);
 
     /* Calculate virt-to-phys offset for the new location */
-    phys_offset = xen_paddr - (unsigned long) _start;
-
+    xen_phys_offset = phys_offset = xen_paddr - (unsigned long) _start;
+    
     /* Copy */
     memcpy((void *) dest_va, _start, _end - _start);
 
diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h
index b6df64e..22c56b5 100644
--- a/xen/include/asm-arm/page.h
+++ b/xen/include/asm-arm/page.h
@@ -312,6 +312,8 @@ static inline uint64_t gva_to_ipa(uint32_t va)
 /* Bits in the PAR returned by va_to_par */
 #define PAR_FAULT 0x1
 
+extern void dump_pt_walk(uint32_t addr);
+
 #endif /* __ASSEMBLY__ */
 
 /* These numbers add up to a 39-bit input address space.  The  ARMv7-A
-- 
1.7.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.