linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Anton Blanchard <anton@samba.org>
To: benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au
Cc: linuxppc-dev@lists.ozlabs.org
Subject: [PATCH] powerpc: Print instruction when logging unhandled exceptions
Date: Thu, 25 Sep 2014 15:05:45 +1000	[thread overview]
Message-ID: <1411621545-19310-1-git-send-email-anton@samba.org> (raw)

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

             reply	other threads:[~2014-09-25  5:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-25  5:05 Anton Blanchard [this message]
2014-10-02  7:14 ` powerpc: Print instruction when logging unhandled exceptions Michael Ellerman
  -- strict thread matches above, loose matches on Subject: below --
2013-06-07  5:42 [PATCH] " Anton Blanchard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1411621545-19310-1-git-send-email-anton@samba.org \
    --to=anton@samba.org \
    --cc=benh@kernel.crashing.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).