From patchwork Fri Jul 10 11:33:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hidehiro Kawai X-Patchwork-Id: 6765471 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AC73D9F749 for ; Fri, 10 Jul 2015 12:18:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8DEA620515 for ; Fri, 10 Jul 2015 12:17:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 49F4B2053B for ; Fri, 10 Jul 2015 12:17:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754053AbbGJMR5 (ORCPT ); Fri, 10 Jul 2015 08:17:57 -0400 Received: from fallback.hitachi.co.jp ([133.145.228.49]:33109 "EHLO mailx.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753080AbbGJMRy (ORCPT ); Fri, 10 Jul 2015 08:17:54 -0400 Received: from mail7.hitachi.co.jp (mail7.hitachi.co.jp [133.145.228.42]) by mailx.hitachi.co.jp (Postfix) with ESMTP id C408B216808D; Fri, 10 Jul 2015 20:40:01 +0900 (JST) Received: from mlsv3.hitachi.co.jp (unknown [133.144.234.166]) by mail7.hitachi.co.jp (Postfix) with ESMTP id 361F3B1D382; Fri, 10 Jul 2015 20:39:55 +0900 (JST) Received: from mfilter06.hitachi.co.jp by mlsv3.hitachi.co.jp (8.13.1/8.13.1) id t6ABdtTi016987; Fri, 10 Jul 2015 20:39:55 +0900 Received: from vshuts04.hitachi.co.jp (vshuts04.hitachi.co.jp [10.201.6.86]) by mfilter06.hitachi.co.jp (Switch-3.3.4/Switch-3.3.4) with ESMTP id t6ABdrNL023940; Fri, 10 Jul 2015 20:39:54 +0900 Received: from hsdlmain.sdl.hitachi.co.jp (unknown [133.144.14.194]) by vshuts04.hitachi.co.jp (Postfix) with ESMTP id 5D26614003B; Fri, 10 Jul 2015 20:39:53 +0900 (JST) Received: from hsdlvgate2.sdl.hitachi.co.jp by hsdlmain.sdl.hitachi.co.jp (8.13.8/3.7W11021512) id t6ABdr5R008865; Fri, 10 Jul 2015 20:39:53 +0900 X-AuditID: 85900ec0-9c3c7b9000001a57-6c-559faef242f9 Received: from sdl99w.sdl.hitachi.co.jp (sdl99w.yrl.intra.hitachi.co.jp [133.144.14.250]) by hsdlvgate2.sdl.hitachi.co.jp (Symantec Mail Security) with ESMTP id 4C869236561; Fri, 10 Jul 2015 20:39:30 +0900 (JST) Received: from mailb.sdl.hitachi.co.jp (sdl99b.yrl.intra.hitachi.co.jp [133.144.14.197]) by sdl99w.sdl.hitachi.co.jp (Postfix) with ESMTP id C351C53C21A; Fri, 10 Jul 2015 20:39:52 +0900 (JST) Received: from [10.198.219.30] (unknown [10.198.219.30]) by mailb.sdl.hitachi.co.jp (Postfix) with ESMTP id 7C12D495B93; Fri, 10 Jul 2015 20:39:52 +0900 (JST) X-Mailbox-Line: From nobody Fri Jul 10 20:33:31 2015 Subject: [PATCH 2/3] kexec: Pass panic message to crash_kexec() To: Andrew Morton , "Eric W. Biederman" , Vivek Goyal From: Hidehiro Kawai Cc: linux-mips@linux-mips.org, Baoquan He , linux-sh@vger.kernel.org, linux-s390@vger.kernel.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Ingo Molnar , HATAYAMA Daisuke , Masami Hiramatsu , Daniel Walker , linuxppc-dev@lists.ozlabs.org, linux-metag@vger.kernel.org, linux-arm-kernel@lists.infradead.org Date: Fri, 10 Jul 2015 20:33:31 +0900 Message-ID: <20150710113331.4368.9926.stgit@softrs> In-Reply-To: <20150710113331.4368.10495.stgit@softrs> References: <20150710113331.4368.10495.stgit@softrs> User-Agent: StGit/0.16 MIME-Version: 1.0 X-Brightmail-Tracker: AAAAAA== Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add an argument to crash_kexec() to pass the panic message. This patch is a preparation for the next patch, and it doesn't change the current behavior. Signed-off-by: Hidehiro Kawai Cc: Andrew Morton Cc: Eric Biederman Cc: Vivek Goyal --- arch/arm/kernel/traps.c | 2 +- arch/arm64/kernel/traps.c | 2 +- arch/metag/kernel/traps.c | 2 +- arch/mips/kernel/traps.c | 2 +- arch/powerpc/kernel/traps.c | 2 +- arch/s390/kernel/ipl.c | 2 +- arch/sh/kernel/traps.c | 2 +- arch/x86/kernel/dumpstack.c | 2 +- arch/x86/platform/uv/uv_nmi.c | 2 +- include/linux/kexec.h | 7 +++++-- kernel/kexec.c | 23 ++++++++++++++++++++++- kernel/panic.c | 4 ++-- 12 files changed, 38 insertions(+), 14 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index d358226..abb7b86 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c @@ -293,7 +293,7 @@ static unsigned long oops_begin(void) static void oops_end(unsigned long flags, struct pt_regs *regs, int signr) { if (regs && kexec_should_crash(current)) - crash_kexec(regs); + crash_kexec_on_oops(regs, current); bust_spinlocks(0); die_owner = -1; diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index 566bc4c..17a6841 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -233,7 +233,7 @@ void die(const char *str, struct pt_regs *regs, int err) ret = __die(str, err, thread, regs); if (regs && kexec_should_crash(thread->task)) - crash_kexec(regs); + crash_kexec_on_oops(regs, thread->task); bust_spinlocks(0); add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE); diff --git a/arch/metag/kernel/traps.c b/arch/metag/kernel/traps.c index 17b2e2e..dca46c7 100644 --- a/arch/metag/kernel/traps.c +++ b/arch/metag/kernel/traps.c @@ -110,7 +110,7 @@ void __noreturn die(const char *str, struct pt_regs *regs, bust_spinlocks(0); add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE); if (kexec_should_crash(current)) - crash_kexec(regs); + crash_kexec_on_oops(regs, current); if (in_interrupt()) panic("Fatal exception in interrupt"); diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index 2a7b38e..46fc9a6 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -402,7 +402,7 @@ void __noreturn die(const char *str, struct pt_regs *regs) } if (regs && kexec_should_crash(current)) - crash_kexec(regs); + crash_kexec_on_oops(regs, current); do_exit(sig); } diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c index 6530f1b..4e1fe20 100644 --- a/arch/powerpc/kernel/traps.c +++ b/arch/powerpc/kernel/traps.c @@ -163,7 +163,7 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, * it through the crashdump code. */ if (kexec_should_crash(current) || (TRAP(regs) == 0x100)) { - crash_kexec(regs); + crash_kexec_on_oops(regs, current); /* * We aren't the primary crash CPU. We need to send it diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c index 52fbef91d..67c1f8b 100644 --- a/arch/s390/kernel/ipl.c +++ b/arch/s390/kernel/ipl.c @@ -1726,7 +1726,7 @@ static void __do_restart(void *ignore) __arch_local_irq_stosm(0x04); /* enable DAT */ smp_send_stop(); #ifdef CONFIG_CRASH_DUMP - crash_kexec(NULL); + crash_kexec(NULL, "restart"); #endif on_restart_trigger.action->fn(&on_restart_trigger); stop_run(&on_restart_trigger); diff --git a/arch/sh/kernel/traps.c b/arch/sh/kernel/traps.c index dfdad72..4bfb519 100644 --- a/arch/sh/kernel/traps.c +++ b/arch/sh/kernel/traps.c @@ -43,7 +43,7 @@ void die(const char *str, struct pt_regs *regs, long err) oops_exit(); if (kexec_should_crash(current)) - crash_kexec(regs); + crash_kexec_on_oops(regs, current); if (in_interrupt()) panic("Fatal exception in interrupt"); diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c index 9c30acf..e973a1d 100644 --- a/arch/x86/kernel/dumpstack.c +++ b/arch/x86/kernel/dumpstack.c @@ -229,7 +229,7 @@ unsigned long oops_begin(void) void oops_end(unsigned long flags, struct pt_regs *regs, int signr) { if (regs && kexec_should_crash(current)) - crash_kexec(regs); + crash_kexec_on_oops(regs, current); bust_spinlocks(0); die_owner = -1; diff --git a/arch/x86/platform/uv/uv_nmi.c b/arch/x86/platform/uv/uv_nmi.c index 020c101..8b67644 100644 --- a/arch/x86/platform/uv/uv_nmi.c +++ b/arch/x86/platform/uv/uv_nmi.c @@ -499,7 +499,7 @@ static void uv_nmi_kdump(int cpu, int master, struct pt_regs *regs) /* Call crash to dump system state */ if (master) { pr_emerg("UV: NMI executing crash_kexec on CPU%d\n", cpu); - crash_kexec(regs); + crash_kexec(regs, "UV: NMI executing crash_kexec"); pr_emerg("UV: crash_kexec unexpectedly returned, "); if (!kexec_crash_image) { diff --git a/include/linux/kexec.h b/include/linux/kexec.h index e804306..0a2744d 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -237,7 +237,8 @@ extern int kexec_purgatory_get_set_symbol(struct kimage *image, unsigned int size, bool get_value); extern void *kexec_purgatory_get_symbol_addr(struct kimage *image, const char *name); -extern void crash_kexec(struct pt_regs *); +extern void crash_kexec(struct pt_regs *, char *msg); +extern void crash_kexec_on_oops(struct pt_regs *, struct task_struct *p); int kexec_should_crash(struct task_struct *); void crash_save_cpu(struct pt_regs *regs, int cpu); void crash_save_vmcoreinfo(void); @@ -321,7 +322,9 @@ int parse_crashkernel_low(char *cmdline, unsigned long long system_ram, #else /* !CONFIG_KEXEC */ struct pt_regs; struct task_struct; -static inline void crash_kexec(struct pt_regs *regs) { } +static inline void crash_kexec(struct pt_regs *regs, char *msg) { } +static inline void crash_kexec_on_oops(struct pt_regs *regs, + struct task_struct *p) { } static inline int kexec_should_crash(struct task_struct *p) { return 0; } #endif /* CONFIG_KEXEC */ diff --git a/kernel/kexec.c b/kernel/kexec.c index a785c10..9c7894f 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c @@ -1470,7 +1470,7 @@ void __weak crash_unmap_reserved_pages(void) #endif /* CONFIG_KEXEC_FILE */ -void crash_kexec(struct pt_regs *regs) +void crash_kexec(struct pt_regs *regs, char *msg) { /* Take the kexec_mutex here to prevent sys_kexec_load * running on one cpu from replacing the crash kernel @@ -1493,6 +1493,27 @@ void crash_kexec(struct pt_regs *regs) } } +void crash_kexec_on_oops(struct pt_regs *regs, struct task_struct *p) +{ + static char buf[128]; + char *msg = "Die for unknown reason"; + + if (in_interrupt()) + msg = "Fatal exception in interrupt"; + else if (panic_on_oops) + msg = "Fatal exception"; + else if (!p->pid) + msg = "Attempted to kill the idle task!"; + else if (is_global_init(p)) { + snprintf(buf, sizeof(buf), + "Attempted to kill init! exitcode=0x%08x", + p->signal->group_exit_code ?: p->exit_code); + msg = buf; + } + + crash_kexec(regs, msg); +} + size_t crash_get_memory_size(void) { size_t size = 0; diff --git a/kernel/panic.c b/kernel/panic.c index 5252331..93008b6 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -118,7 +118,7 @@ void panic(const char *fmt, ...) * the "crash_kexec_post_notifiers" option to the kernel. */ if (!crash_kexec_post_notifiers) - crash_kexec(NULL); + crash_kexec(NULL, buf); /* * Note smp_send_stop is the usual smp shutdown function, which @@ -143,7 +143,7 @@ void panic(const char *fmt, ...) * more unstable, it can increase risks of the kdump failure too. */ if (crash_kexec_post_notifiers) - crash_kexec(NULL); + crash_kexec(NULL, buf); bust_spinlocks(0);