From: jbeulich@novell.com
Subject: dump the correct page tables for user mode faults
Patch-mainline: obsolete
--- head.orig/arch/x86/mm/fault-xen.c 2014-06-27 10:54:54.000000000 +0200
+++ head/arch/x86/mm/fault-xen.c 2013-12-11 11:58:20.000000000 +0100
@@ -353,6 +353,7 @@ static void dump_pagetable(unsigned long
out:
printk(KERN_CONT "\n");
}
+#define dump_pagetable(addr, krnl) dump_pagetable(addr)
#else /* CONFIG_X86_64: */
@@ -462,7 +463,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);
@@ -470,6 +471,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;
@@ -618,7 +622,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
@@ -635,7 +639,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_nr = X86_TRAP_PF;