Re: [RFC Patch 1/2][slimdump] Append CRASH_REASON to VMCOREINFOelf-note

From: Vivek Goyal
Date: Mon Nov 21 2011 - 10:12:27 EST


On Mon, Nov 21, 2011 at 03:41:57PM +0530, K.Prasad wrote:
> Allow various crash paths to append the reason of crash into the
> VMCOREINFO elf-note through the field CRASH_REASON. We also make the
> fatal machine check exceptions append "PANIC_MCE" as the crash reason.
> This string will be recognised by upstream tools like makedumpfile and
> crash to generate slimdump.
>
> With increased usage of the CRASH_REASON field, the crash strings can be
> encoded for better usage.
>
> Signed-off-by: K.Prasad <prasad@xxxxxxxxxxxxxxxxxx>
> ---
> arch/x86/kernel/cpu/mcheck/mce.c | 8 ++++++++
> kernel/kexec.c | 6 ++++++
> 2 files changed, 14 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
> index 362056a..5b2cb6a 100644
> --- a/arch/x86/kernel/cpu/mcheck/mce.c
> +++ b/arch/x86/kernel/cpu/mcheck/mce.c
> @@ -38,6 +38,7 @@
> #include <linux/debugfs.h>
> #include <linux/irq_work.h>
> #include <linux/export.h>
> +#include <linux/kexec.h>
>
> #include <asm/processor.h>
> #include <asm/mce.h>
> @@ -240,6 +241,13 @@ static atomic_t mce_paniced;
> static int fake_panic;
> static atomic_t mce_fake_paniced;
>
> +char *arch_add_crash_reason(void)
> +{
> + static char crash_reason[] = "PANIC_MCE";
> +
> + return crash_reason;
> +}
> +
> /* Panic in progress. Enable interrupts and wait for final IPI */
> static void wait_for_panic(void)
> {
> diff --git a/kernel/kexec.c b/kernel/kexec.c
> index dc7bc08..a731693 100644
> --- a/kernel/kexec.c
> +++ b/kernel/kexec.c
> @@ -1080,6 +1080,11 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
> }
> #endif
>
> +__weak char *arch_add_crash_reason(void)
> +{
> + return (char *)NULL;
> +}
> +
> void crash_kexec(struct pt_regs *regs)
> {
> /* Take the kexec_mutex here to prevent sys_kexec_load
> @@ -1411,6 +1416,7 @@ static void update_vmcoreinfo_note(void)
> void crash_save_vmcoreinfo(void)
> {
> vmcoreinfo_append_str("CRASHTIME=%ld", get_seconds());
> + vmcoreinfo_append_str("\nCRASH_REASON=%s\n", arch_add_crash_reason());

I think don't even create a CRASH_REASON= entry if arch returns a NULL
string.

Vivek
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/