From: jbeulich@novell.com Subject: dump the correct page tables for user mode faults Patch-mainline: obsolete Index: head-2008-11-10/arch/x86/mm/fault-xen.c =================================================================== --- head-2008-11-10.orig/arch/x86/mm/fault-xen.c 2008-11-17 11:33:51.000000000 +0100 +++ head-2008-11-10/arch/x86/mm/fault-xen.c 2008-11-17 11:38:21.000000000 +0100 @@ -189,9 +189,11 @@ static int bad_address(void *p) unsigned long dummy; return probe_kernel_address((unsigned long *)p, dummy); } +#else +#define dump_pagetable(addr, krnl) dump_pagetable(addr) #endif -static void dump_pagetable(unsigned long address) +static void dump_pagetable(unsigned long address, bool kernel) { #ifdef CONFIG_X86_32 __typeof__(pte_val(__pte(0))) page; @@ -239,6 +241,8 @@ static void dump_pagetable(unsigned long pgd = (pgd_t *)read_cr3(); pgd = __va((unsigned long)pgd & PHYSICAL_PAGE_MASK); + if (!kernel) + pgd = __user_pgd(pgd); pgd += pgd_index(address); if (bad_address(pgd)) goto bad; printk("PGD %lx ", pgd_val(*pgd)); @@ -419,7 +423,7 @@ static void show_fault_oops(struct pt_re printk(KERN_CONT " at %p\n", (void *) address); printk(KERN_ALERT "IP:"); printk_address(regs->ip, 1); - dump_pagetable(address); + dump_pagetable(address, !(error_code & PF_USER)); } #ifdef CONFIG_X86_64 @@ -431,7 +435,7 @@ static noinline void pgtable_bad(unsigne printk(KERN_ALERT "%s: Corrupted page table at address %lx\n", current->comm, address); - dump_pagetable(address); + dump_pagetable(address, !(error_code & PF_USER)); tsk = current; tsk->thread.cr2 = address; tsk->thread.trap_no = 14;