* [PATCH 2/3] x86: Introduce show_fault_oops helper to fault_32|64.c
@ 2008-01-21 22:58 Harvey Harrison
2008-01-22 11:29 ` Ingo Molnar
0 siblings, 1 reply; 2+ messages in thread
From: Harvey Harrison @ 2008-01-21 22:58 UTC (permalink / raw)
To: Ingo Molnar; +Cc: Thomas Gleixner, H. Peter Anvin, LKML, Arjan van de Ven
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>
---
arch/x86/mm/fault_32.c | 54 ++++++++++++++++++++++++++---------------------
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 0bd2417..fda3997 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)
return 0;
}
+static void show_fault_oops(struct pt_regs *regs, unsigned long error_code,
+ unsigned long address)
+{
+ if (!oops_may_print())
+ return;
+
+#ifdef CONFIG_X86_PAE
+ if (error_code & PF_INSTR) {
+ int level;
+ pte_t *pte = lookup_address(address, &level);
+
+ if (pte && pte_present(*pte) && !pte_exec(*pte))
+ printk(KERN_CRIT "kernel tried to execute "
+ "NX-protected page - exploit attempt? "
+ "(uid: %d)\n", current->uid);
+ }
+#endif
+ if (address < PAGE_SIZE)
+ printk(KERN_ALERT "BUG: unable to handle kernel NULL "
+ "pointer dereference");
+ else
+ printk(KERN_ALERT "BUG: unable to handle kernel paging"
+ " request");
+ printk(" at virtual address %08lx\n", address);
+ printk(KERN_ALERT "printing ip: %08lx ", regs->ip);
+
+ dump_pagetable(address);
+}
+
/*
* Handle a fault on the vmalloc or module mapping area
*
@@ -633,30 +662,7 @@ no_context:
bust_spinlocks(1);
- if (oops_may_print()) {
-
-#ifdef CONFIG_X86_PAE
- if (error_code & PF_INSTR) {
- int level;
- pte_t *pte = lookup_address(address, &level);
-
- if (pte && pte_present(*pte) && !pte_exec(*pte))
- printk(KERN_CRIT "kernel tried to execute "
- "NX-protected page - exploit attempt? "
- "(uid: %d)\n", current->uid);
- }
-#endif
- if (address < PAGE_SIZE)
- printk(KERN_ALERT "BUG: unable to handle kernel NULL "
- "pointer dereference");
- else
- printk(KERN_ALERT "BUG: unable to handle kernel paging"
- " request");
- printk(" at virtual address %08lx\n", address);
- printk(KERN_ALERT "printing ip: %08lx ", regs->ip);
-
- dump_pagetable(address);
- }
+ show_fault_oops(regs, error_code, address);
tsk->thread.cr2 = address;
tsk->thread.trap_no = 14;
diff --git a/arch/x86/mm/fault_64.c b/arch/x86/mm/fault_64.c
index ccbb8e3..1897704 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)
return 0;
}
+static void show_fault_oops(struct pt_regs *regs, unsigned long error_code,
+ unsigned long address)
+{
+ if (address < PAGE_SIZE)
+ printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference");
+ else
+ printk(KERN_ALERT "Unable to handle kernel paging request");
+ printk(" at %016lx RIP: \n" KERN_ALERT, address);
+ printk_address(regs->ip, 1);
+ dump_pagetable(address);
+}
+
static noinline void pgtable_bad(unsigned long address, struct pt_regs *regs,
unsigned long error_code)
{
@@ -636,13 +648,8 @@ no_context:
flags = oops_begin();
- if (address < PAGE_SIZE)
- printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference");
- else
- printk(KERN_ALERT "Unable to handle kernel paging request");
- printk(" at %016lx RIP: \n" KERN_ALERT, address);
- printk_address(regs->ip, 1);
- dump_pagetable(address);
+ show_fault_oops(regs, error_code, address);
+
tsk->thread.cr2 = address;
tsk->thread.trap_no = 14;
tsk->thread.error_code = error_code;
--
1.5.4.rc3.1118.gf6754c
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 2/3] x86: Introduce show_fault_oops helper to fault_32|64.c
2008-01-21 22:58 [PATCH 2/3] x86: Introduce show_fault_oops helper to fault_32|64.c Harvey Harrison
@ 2008-01-22 11:29 ` Ingo Molnar
0 siblings, 0 replies; 2+ messages in thread
From: Ingo Molnar @ 2008-01-22 11:29 UTC (permalink / raw)
To: Harvey Harrison; +Cc: Thomas Gleixner, H. Peter Anvin, LKML, Arjan van de Ven
* Harvey Harrison <harvey.harrison@gmail.com> wrote:
> This will help when unifying the oops dumping code on 32/64 bit. No
> functional changes.
thanks, applied.
Ingo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-01-22 11:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-21 22:58 [PATCH 2/3] x86: Introduce show_fault_oops helper to fault_32|64.c Harvey Harrison
2008-01-22 11:29 ` Ingo Molnar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox