From patchwork Fri Jun 7 05:42:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Blanchard X-Patchwork-Id: 249598 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id E9F772C032D for ; Fri, 7 Jun 2013 15:43:22 +1000 (EST) Received: from kryten (ppp121-44-134-28.lns20.syd7.internode.on.net [121.44.134.28]) (using SSLv3 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPSA id 9163F2C009F; Fri, 7 Jun 2013 15:42:53 +1000 (EST) Date: Fri, 7 Jun 2013 15:42:54 +1000 From: Anton Blanchard To: benh@kernel.crashing.org, paulus@samba.org Subject: [PATCH] powerpc: Print instruction when logging unhandled exceptions Message-ID: <20130607154254.4b001093@kryten> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.17; x86_64-pc-linux-gnu) Mime-Version: 1.0 Cc: linuxppc-dev@lists.ozlabs.org X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" It is often useful to see the instruction that caused an unhandled exception. Signed-off-by: Anton Blanchard --- 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))