mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

kmsg_dump doesn't forward the panic reason string to the kmsg_dumper callback. This patch adds a new struct kmsg_dump_detail, that will hold the reason and description, and pass it to the dump() callback. To avoid updating all kmsg_dump() call, it adds a kmsg_dump_desc() function and a macro for backward compatibility. I've written this for drm_panic, but it can be useful for other kmsg_dumper. It allows to see the panic reason, like "sysrq triggered crash" or "VFS: Unable to mount root fs on xxxx" on the drm panic screen. v2: * Use a struct kmsg_dump_detail to hold the reason and description pointer, for more flexibility if we want to add other parameters. (Kees Cook) * Fix powerpc/nvram_64 build, as I didn't update the forward declaration of oops_to_nvram() Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com> Acked-by: Petr Mladek <pmladek@suse.com> Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc) Acked-by: Kees Cook <kees@kernel.org> Link: https://patchwork.freedesktop.org/patch/msgid/20240702122639.248110-1-jfalempe@redhat.com
47 lines
1.3 KiB
C
47 lines
1.3 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* kmsg dumper that ensures the OPAL console fully flushes panic messages
|
|
*
|
|
* Author: Russell Currey <ruscur@russell.cc>
|
|
*
|
|
* Copyright 2015 IBM Corporation.
|
|
*/
|
|
|
|
#include <linux/kmsg_dump.h>
|
|
|
|
#include <asm/opal.h>
|
|
#include <asm/opal-api.h>
|
|
|
|
/*
|
|
* Console output is controlled by OPAL firmware. The kernel regularly calls
|
|
* OPAL_POLL_EVENTS, which flushes some console output. In a panic state,
|
|
* however, the kernel no longer calls OPAL_POLL_EVENTS and the panic message
|
|
* may not be completely printed. This function does not actually dump the
|
|
* message, it just ensures that OPAL completely flushes the console buffer.
|
|
*/
|
|
static void kmsg_dump_opal_console_flush(struct kmsg_dumper *dumper,
|
|
struct kmsg_dump_detail *detail)
|
|
{
|
|
/*
|
|
* Outside of a panic context the pollers will continue to run,
|
|
* so we don't need to do any special flushing.
|
|
*/
|
|
if (detail->reason != KMSG_DUMP_PANIC)
|
|
return;
|
|
|
|
opal_flush_console(0);
|
|
}
|
|
|
|
static struct kmsg_dumper opal_kmsg_dumper = {
|
|
.dump = kmsg_dump_opal_console_flush
|
|
};
|
|
|
|
void __init opal_kmsg_init(void)
|
|
{
|
|
int rc;
|
|
|
|
/* Add our dumper to the list */
|
|
rc = kmsg_dump_register(&opal_kmsg_dumper);
|
|
if (rc != 0)
|
|
pr_err("opal: kmsg_dump_register failed; returned %d\n", rc);
|
|
}
|