From: jbeulich@novell.com
Subject: dump the correct page tables for user mode faults
Patch-mainline: obsolete

--- a/arch/x86/mm/fault-xen.c
+++ b/arch/x86/mm/fault-xen.c
@@ -347,6 +347,7 @@ static void dump_pagetable(unsigned long
 out:
 	printk(KERN_CONT "\n");
 }
+#define dump_pagetable(addr, krnl) dump_pagetable(addr)
 
 #else /* CONFIG_X86_64: */
 
@@ -455,7 +456,7 @@ static int bad_address(void *p)
 	return probe_kernel_address((unsigned long *)p, dummy);
 }
 
-static void dump_pagetable(unsigned long address)
+static void dump_pagetable(unsigned long address, bool kernel)
 {
 	pgd_t *base = __va(read_cr3() & PHYSICAL_PAGE_MASK);
 	pgd_t *pgd = base + pgd_index(address);
@@ -463,6 +464,9 @@ static void dump_pagetable(unsigned long
 	pmd_t *pmd;
 	pte_t *pte;
 
+	if (!kernel)
+		pgd = __user_pgd(base) + pgd_index(address);
+
 	if (bad_address(pgd))
 		goto bad;
 
@@ -606,7 +610,7 @@ show_fault_oops(struct pt_regs *regs, un
 	printk(KERN_ALERT "IP:");
 	printk_address(regs->ip);
 
-	dump_pagetable(address);
+	dump_pagetable(address, !(error_code & PF_USER));
 }
 
 static noinline void
@@ -623,7 +627,7 @@ pgtable_bad(struct pt_regs *regs, unsign
 
 	printk(KERN_ALERT "%s: Corrupted page table at address %lx\n",
 	       tsk->comm, address);
-	dump_pagetable(address);
+	dump_pagetable(address, !(error_code & PF_USER));
 
 	tsk->thread.cr2		= address;
 	tsk->thread.trap_no	= 14;
