changeset:   23576:e2235fe267eb
user:        Jan Beulich <jbeulich@novell.com>
date:        Thu Jun 23 11:35:55 2011 +0100
files:       xen/arch/x86/mm.c xen/arch/x86/traps.c xen/arch/x86/x86_32/mm.c xen/arch/x86/x86_32/traps.c xen/arch/x86/x86_64/mm.c xen/arch/x86/x86_64/traps.c
description:
x86: show page walk also for early page faults

At once, move the common (between 32- and 64-bit) definition of
machine_to_phys_mapping_valid to a common location.

Signed-off-by: Jan Beulich <jbeulich@novell.com>


---
 xen/arch/x86/mm.c           |    2 ++
 xen/arch/x86/traps.c        |    1 +
 xen/arch/x86/x86_32/mm.c    |    2 --
 xen/arch/x86/x86_32/traps.c |    9 ++++++---
 xen/arch/x86/x86_64/mm.c    |    2 --
 xen/arch/x86/x86_64/traps.c |   12 ++++++++----
 6 files changed, 17 insertions(+), 11 deletions(-)

Index: xen-4.1.5-testing/xen/arch/x86/mm.c
===================================================================
--- xen-4.1.5-testing.orig/xen/arch/x86/mm.c
+++ xen-4.1.5-testing/xen/arch/x86/mm.c
@@ -153,6 +153,8 @@ unsigned long __read_mostly pdx_group_va
     (FRAMETABLE_SIZE / sizeof(*frame_table) + PDX_GROUP_COUNT - 1)
     / PDX_GROUP_COUNT)] = { [0] = 1 };
 
+bool_t __read_mostly machine_to_phys_mapping_valid = 0;
+
 #define PAGE_CACHE_ATTRS (_PAGE_PAT|_PAGE_PCD|_PAGE_PWT)
 
 bool_t __read_mostly opt_allow_superpage;
Index: xen-4.1.5-testing/xen/arch/x86/traps.c
===================================================================
--- xen-4.1.5-testing.orig/xen/arch/x86/traps.c
+++ xen-4.1.5-testing/xen/arch/x86/traps.c
@@ -1455,6 +1455,7 @@ void __init do_early_page_fault(struct c
         unsigned long *stk = (unsigned long *)regs;
         printk("Early fatal page fault at %04x:%p (cr2=%p, ec=%04x)\n", 
                regs->cs, _p(regs->eip), _p(cr2), regs->error_code);
+        show_page_walk(cr2);
         printk("Stack dump: ");
         while ( ((long)stk & ((PAGE_SIZE - 1) & ~(BYTES_PER_LONG - 1))) != 0 )
             printk("%p ", _p(*stk++));
Index: xen-4.1.5-testing/xen/arch/x86/x86_32/mm.c
===================================================================
--- xen-4.1.5-testing.orig/xen/arch/x86/x86_32/mm.c
+++ xen-4.1.5-testing/xen/arch/x86/x86_32/mm.c
@@ -39,8 +39,6 @@ extern l1_pgentry_t l1_identmap[L1_PAGET
 unsigned int __read_mostly PAGE_HYPERVISOR         = __PAGE_HYPERVISOR;
 unsigned int __read_mostly PAGE_HYPERVISOR_NOCACHE = __PAGE_HYPERVISOR_NOCACHE;
 
-bool_t __read_mostly machine_to_phys_mapping_valid = 0;
-
 static unsigned long __read_mostly mpt_size;
 
 void *alloc_xen_pagetable(void)
Index: xen-4.1.5-testing/xen/arch/x86/x86_32/traps.c
===================================================================
--- xen-4.1.5-testing.orig/xen/arch/x86/x86_32/traps.c
+++ xen-4.1.5-testing/xen/arch/x86/x86_32/traps.c
@@ -164,7 +164,8 @@ void show_page_walk(unsigned long addr)
     l3t += (cr3 & 0xFE0UL) >> 3;
     l3e = l3t[l3_table_offset(addr)];
     mfn = l3e_get_pfn(l3e);
-    pfn = mfn_valid(mfn) ? get_gpfn_from_mfn(mfn) : INVALID_M2P_ENTRY;
+    pfn = mfn_valid(mfn) && machine_to_phys_mapping_valid ?
+          get_gpfn_from_mfn(mfn) : INVALID_M2P_ENTRY;
     printk(" L3[0x%03lx] = %"PRIpte" %08lx\n",
            l3_table_offset(addr), l3e_get_intpte(l3e), pfn);
     unmap_domain_page(l3t);
@@ -175,7 +176,8 @@ void show_page_walk(unsigned long addr)
     l2t = map_domain_page(mfn);
     l2e = l2t[l2_table_offset(addr)];
     mfn = l2e_get_pfn(l2e);
-    pfn = mfn_valid(mfn) ? get_gpfn_from_mfn(mfn) : INVALID_M2P_ENTRY;
+    pfn = mfn_valid(mfn) && machine_to_phys_mapping_valid ?
+          get_gpfn_from_mfn(mfn) : INVALID_M2P_ENTRY;
     printk(" L2[0x%03lx] = %"PRIpte" %08lx %s\n",
            l2_table_offset(addr), l2e_get_intpte(l2e), pfn,
            (l2e_get_flags(l2e) & _PAGE_PSE) ? "(PSE)" : "");
@@ -188,7 +190,8 @@ void show_page_walk(unsigned long addr)
     l1t = map_domain_page(mfn);
     l1e = l1t[l1_table_offset(addr)];
     mfn = l1e_get_pfn(l1e);
-    pfn = mfn_valid(mfn) ? get_gpfn_from_mfn(mfn) : INVALID_M2P_ENTRY;
+    pfn = mfn_valid(mfn) && machine_to_phys_mapping_valid ?
+          get_gpfn_from_mfn(mfn) : INVALID_M2P_ENTRY;
     printk(" L1[0x%03lx] = %"PRIpte" %08lx\n",
            l1_table_offset(addr), l1e_get_intpte(l1e), pfn);
     unmap_domain_page(l1t);
Index: xen-4.1.5-testing/xen/arch/x86/x86_64/mm.c
===================================================================
--- xen-4.1.5-testing.orig/xen/arch/x86/x86_64/mm.c
+++ xen-4.1.5-testing/xen/arch/x86/x86_64/mm.c
@@ -47,8 +47,6 @@ unsigned int __read_mostly pfn_pdx_hole_
 
 unsigned int __read_mostly m2p_compat_vstart = __HYPERVISOR_COMPAT_VIRT_START;
 
-bool_t __read_mostly machine_to_phys_mapping_valid = 0;
-
 /* Top-level master (and idle-domain) page directory. */
 l4_pgentry_t __attribute__ ((__section__ (".bss.page_aligned")))
     idle_pg_table[L4_PAGETABLE_ENTRIES];
Index: xen-4.1.5-testing/xen/arch/x86/x86_64/traps.c
===================================================================
--- xen-4.1.5-testing.orig/xen/arch/x86/x86_64/traps.c
+++ xen-4.1.5-testing/xen/arch/x86/x86_64/traps.c
@@ -176,7 +176,8 @@ void show_page_walk(unsigned long addr)
     l4t = mfn_to_virt(mfn);
     l4e = l4t[l4_table_offset(addr)];
     mfn = l4e_get_pfn(l4e);
-    pfn = mfn_valid(mfn) ? get_gpfn_from_mfn(mfn) : INVALID_M2P_ENTRY;
+    pfn = mfn_valid(mfn) && machine_to_phys_mapping_valid ?
+          get_gpfn_from_mfn(mfn) : INVALID_M2P_ENTRY;
     printk(" L4[0x%03lx] = %"PRIpte" %016lx\n",
            l4_table_offset(addr), l4e_get_intpte(l4e), pfn);
     if ( !(l4e_get_flags(l4e) & _PAGE_PRESENT) ||
@@ -186,7 +187,8 @@ void show_page_walk(unsigned long addr)
     l3t = mfn_to_virt(mfn);
     l3e = l3t[l3_table_offset(addr)];
     mfn = l3e_get_pfn(l3e);
-    pfn = mfn_valid(mfn) ? get_gpfn_from_mfn(mfn) : INVALID_M2P_ENTRY;
+    pfn = mfn_valid(mfn) && machine_to_phys_mapping_valid ?
+          get_gpfn_from_mfn(mfn) : INVALID_M2P_ENTRY;
     printk(" L3[0x%03lx] = %"PRIpte" %016lx%s\n",
            l3_table_offset(addr), l3e_get_intpte(l3e), pfn,
            (l3e_get_flags(l3e) & _PAGE_PSE) ? " (PSE)" : "");
@@ -198,7 +200,8 @@ void show_page_walk(unsigned long addr)
     l2t = mfn_to_virt(mfn);
     l2e = l2t[l2_table_offset(addr)];
     mfn = l2e_get_pfn(l2e);
-    pfn = mfn_valid(mfn) ? get_gpfn_from_mfn(mfn) : INVALID_M2P_ENTRY;
+    pfn = mfn_valid(mfn) && machine_to_phys_mapping_valid ?
+          get_gpfn_from_mfn(mfn) : INVALID_M2P_ENTRY;
     printk(" L2[0x%03lx] = %"PRIpte" %016lx %s\n",
            l2_table_offset(addr), l2e_get_intpte(l2e), pfn,
            (l2e_get_flags(l2e) & _PAGE_PSE) ? "(PSE)" : "");
@@ -210,7 +213,8 @@ void show_page_walk(unsigned long addr)
     l1t = mfn_to_virt(mfn);
     l1e = l1t[l1_table_offset(addr)];
     mfn = l1e_get_pfn(l1e);
-    pfn = mfn_valid(mfn) ? get_gpfn_from_mfn(mfn) : INVALID_M2P_ENTRY;
+    pfn = mfn_valid(mfn) && machine_to_phys_mapping_valid ?
+          get_gpfn_from_mfn(mfn) : INVALID_M2P_ENTRY;
     printk(" L1[0x%03lx] = %"PRIpte" %016lx\n",
            l1_table_offset(addr), l1e_get_intpte(l1e), pfn);
 }
