* [PATCH] powerpc: Print instruction when logging unhandled exceptions
@ 2013-06-07 5:42 Anton Blanchard
0 siblings, 0 replies; 2+ messages in thread
From: Anton Blanchard @ 2013-06-07 5:42 UTC (permalink / raw)
To: benh, paulus; +Cc: linuxppc-dev
It is often useful to see the instruction that caused an unhandled
exception.
Signed-off-by: Anton Blanchard <anton@samba.org>
---
We print all ones if the get_user fails, do we want to go to
the added effort of printing XXXXXXXX like we do in the oops
code?
Index: b/arch/powerpc/kernel/traps.c
===================================================================
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -242,9 +242,9 @@ void _exception(int signr, struct pt_reg
{
siginfo_t info;
const char fmt32[] = KERN_INFO "%s[%d]: unhandled signal %d " \
- "at %08lx nip %08lx lr %08lx code %x\n";
+ "at %08lx nip %08lx lr %08lx code %x insn %08x\n";
const char fmt64[] = KERN_INFO "%s[%d]: unhandled signal %d " \
- "at %016lx nip %016lx lr %016lx code %x\n";
+ "at %016lx nip %016lx lr %016lx code %x insn %08x\n";
if (!user_mode(regs)) {
die("Exception in kernel mode", regs, signr);
@@ -252,9 +252,14 @@ void _exception(int signr, struct pt_reg
}
if (show_unhandled_signals && unhandled_signal(current, signr)) {
+ u32 insn;
+
+ if (get_user(insn, (u32 __user *)(regs->nip)))
+ insn = 0xffffffff;
+
printk_ratelimited(regs->msr & MSR_64BIT ? fmt64 : fmt32,
current->comm, current->pid, signr,
- addr, regs->nip, regs->link, code);
+ addr, regs->nip, regs->link, code, insn);
}
if (arch_irqs_disabled() && !arch_irq_disabled_regs(regs))
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] powerpc: Print instruction when logging unhandled exceptions
@ 2014-09-25 5:05 Anton Blanchard
0 siblings, 0 replies; 2+ messages in thread
From: Anton Blanchard @ 2014-09-25 5:05 UTC (permalink / raw)
To: benh, paulus, mpe; +Cc: linuxppc-dev
It is often useful to see the instruction that caused an unhandled
exception.
Signed-off-by: Anton Blanchard <anton@samba.org>
---
arch/powerpc/kernel/traps.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 0dc43f9..27e30c8 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -36,10 +36,10 @@
#include <linux/debugfs.h>
#include <linux/ratelimit.h>
#include <linux/context_tracking.h>
+#include <linux/uaccess.h>
#include <asm/emulated_ops.h>
#include <asm/pgtable.h>
-#include <asm/uaccess.h>
#include <asm/io.h>
#include <asm/machdep.h>
#include <asm/rtas.h>
@@ -242,9 +242,9 @@ void _exception(int signr, struct pt_regs *regs, int code, unsigned long addr)
{
siginfo_t info;
const char fmt32[] = KERN_INFO "%s[%d]: unhandled signal %d " \
- "at %08lx nip %08lx lr %08lx code %x\n";
+ "at %08lx nip %08lx lr %08lx code %x insn %08x\n";
const char fmt64[] = KERN_INFO "%s[%d]: unhandled signal %d " \
- "at %016lx nip %016lx lr %016lx code %x\n";
+ "at %016lx nip %016lx lr %016lx code %x insn %08x\n";
if (!user_mode(regs)) {
die("Exception in kernel mode", regs, signr);
@@ -252,9 +252,18 @@ void _exception(int signr, struct pt_regs *regs, int code, unsigned long addr)
}
if (show_unhandled_signals && unhandled_signal(current, signr)) {
+ u32 __user *nia = (u32 __user *)regs->nip;
+ u32 insn = 0;
+
+ pagefault_disable();
+ if (!access_ok(VERIFY_READ, nia, sizeof(*nia)) ||
+ __get_user_inatomic(insn, nia))
+ insn = 0xffffffffUL;
+ pagefault_enable();
+
printk_ratelimited(regs->msr & MSR_64BIT ? fmt64 : fmt32,
current->comm, current->pid, signr,
- addr, regs->nip, regs->link, code);
+ addr, regs->nip, regs->link, code, insn);
}
if (arch_irqs_disabled() && !arch_irq_disabled_regs(regs))
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-09-25 5:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-07 5:42 [PATCH] powerpc: Print instruction when logging unhandled exceptions Anton Blanchard
-- strict thread matches above, loose matches on Subject: below --
2014-09-25 5:05 Anton Blanchard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).