diff options
author | Harvey Harrison <harvey.harrison@gmail.com> | 2008-01-30 07:34:10 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:34:10 -0500 |
commit | b3279c7fd7acf807ab8395d16658514e8c222a37 (patch) | |
tree | 2ce674dc4a99ca594c7e1a40da3db1545bc8731c /arch | |
parent | 35f3266ffbee7ff8ca0474dc8dfa3b73d5a1d1ef (diff) |
x86: introduce show_fault_oops helper to fault_32|64.c
This will help when unifying the oops dumping code on 32/64
bit. No functional changes.
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/mm/fault_32.c | 54 | ||||
-rw-r--r-- | arch/x86/mm/fault_64.c | 21 |
2 files changed, 44 insertions, 31 deletions
diff --git a/arch/x86/mm/fault_32.c b/arch/x86/mm/fault_32.c index 0bd241729aa3..fda399758820 100644 --- a/arch/x86/mm/fault_32.c +++ b/arch/x86/mm/fault_32.c | |||
@@ -323,6 +323,35 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address) | |||
323 | return 0; | 323 | return 0; |
324 | } | 324 | } |
325 | 325 | ||
326 | static void show_fault_oops(struct pt_regs *regs, unsigned long error_code, | ||
327 | unsigned long address) | ||
328 | { | ||
329 | if (!oops_may_print()) | ||
330 | return; | ||
331 | |||
332 | #ifdef CONFIG_X86_PAE | ||
333 | if (error_code & PF_INSTR) { | ||
334 | int level; | ||
335 | pte_t *pte = lookup_address(address, &level); | ||
336 | |||
337 | if (pte && pte_present(*pte) && !pte_exec(*pte)) | ||
338 | printk(KERN_CRIT "kernel tried to execute " | ||
339 | "NX-protected page - exploit attempt? " | ||
340 | "(uid: %d)\n", current->uid); | ||
341 | } | ||
342 | #endif | ||
343 | if (address < PAGE_SIZE) | ||
344 | printk(KERN_ALERT "BUG: unable to handle kernel NULL " | ||
345 | "pointer dereference"); | ||
346 | else | ||
347 | printk(KERN_ALERT "BUG: unable to handle kernel paging" | ||
348 | " request"); | ||
349 | printk(" at virtual address %08lx\n", address); | ||
350 | printk(KERN_ALERT "printing ip: %08lx ", regs->ip); | ||
351 | |||
352 | dump_pagetable(address); | ||
353 | } | ||
354 | |||
326 | /* | 355 | /* |
327 | * Handle a fault on the vmalloc or module mapping area | 356 | * Handle a fault on the vmalloc or module mapping area |
328 | * | 357 | * |
@@ -633,30 +662,7 @@ no_context: | |||
633 | 662 | ||
634 | bust_spinlocks(1); | 663 | bust_spinlocks(1); |
635 | 664 | ||
636 | if (oops_may_print()) { | 665 | show_fault_oops(regs, error_code, address); |
637 | |||
638 | #ifdef CONFIG_X86_PAE | ||
639 | if (error_code & PF_INSTR) { | ||
640 | int level; | ||
641 | pte_t *pte = lookup_address(address, &level); | ||
642 | |||
643 | if (pte && pte_present(*pte) && !pte_exec(*pte)) | ||
644 | printk(KERN_CRIT "kernel tried to execute " | ||
645 | "NX-protected page - exploit attempt? " | ||
646 | "(uid: %d)\n", current->uid); | ||
647 | } | ||
648 | #endif | ||
649 | if (address < PAGE_SIZE) | ||
650 | printk(KERN_ALERT "BUG: unable to handle kernel NULL " | ||
651 | "pointer dereference"); | ||
652 | else | ||
653 | printk(KERN_ALERT "BUG: unable to handle kernel paging" | ||
654 | " request"); | ||
655 | printk(" at virtual address %08lx\n", address); | ||
656 | printk(KERN_ALERT "printing ip: %08lx ", regs->ip); | ||
657 | |||
658 | dump_pagetable(address); | ||
659 | } | ||
660 | 666 | ||
661 | tsk->thread.cr2 = address; | 667 | tsk->thread.cr2 = address; |
662 | tsk->thread.trap_no = 14; | 668 | tsk->thread.trap_no = 14; |
diff --git a/arch/x86/mm/fault_64.c b/arch/x86/mm/fault_64.c index ccbb8e30d9f5..1897704dad46 100644 --- a/arch/x86/mm/fault_64.c +++ b/arch/x86/mm/fault_64.c | |||
@@ -293,6 +293,18 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address) | |||
293 | return 0; | 293 | return 0; |
294 | } | 294 | } |
295 | 295 | ||
296 | static void show_fault_oops(struct pt_regs *regs, unsigned long error_code, | ||
297 | unsigned long address) | ||
298 | { | ||
299 | if (address < PAGE_SIZE) | ||
300 | printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference"); | ||
301 | else | ||
302 | printk(KERN_ALERT "Unable to handle kernel paging request"); | ||
303 | printk(" at %016lx RIP: \n" KERN_ALERT, address); | ||
304 | printk_address(regs->ip, 1); | ||
305 | dump_pagetable(address); | ||
306 | } | ||
307 | |||
296 | static noinline void pgtable_bad(unsigned long address, struct pt_regs *regs, | 308 | static noinline void pgtable_bad(unsigned long address, struct pt_regs *regs, |
297 | unsigned long error_code) | 309 | unsigned long error_code) |
298 | { | 310 | { |
@@ -636,13 +648,8 @@ no_context: | |||
636 | 648 | ||
637 | flags = oops_begin(); | 649 | flags = oops_begin(); |
638 | 650 | ||
639 | if (address < PAGE_SIZE) | 651 | show_fault_oops(regs, error_code, address); |
640 | printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference"); | 652 | |
641 | else | ||
642 | printk(KERN_ALERT "Unable to handle kernel paging request"); | ||
643 | printk(" at %016lx RIP: \n" KERN_ALERT, address); | ||
644 | printk_address(regs->ip, 1); | ||
645 | dump_pagetable(address); | ||
646 | tsk->thread.cr2 = address; | 653 | tsk->thread.cr2 = address; |
647 | tsk->thread.trap_no = 14; | 654 | tsk->thread.trap_no = 14; |
648 | tsk->thread.error_code = error_code; | 655 | tsk->thread.error_code = error_code; |