[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220910222302.052398226@linutronix.de>
Date: Sun, 11 Sep 2022 00:28:17 +0200 (CEST)
From: Thomas Gleixner <tglx@...utronix.de>
To: LKML <linux-kernel@...r.kernel.org>
Cc: John Ogness <john.ogness@...utronix.de>,
Petr Mladek <pmladek@...e.com>,
Sergey Senozhatsky <senozhatsky@...omium.org>,
Steven Rostedt <rostedt@...dmis.org>,
Linus Torvalds <torvalds@...uxfoundation.org>,
Peter Zijlstra <peterz@...radead.org>,
"Paul E. McKenney" <paulmck@...nel.org>,
Daniel Vetter <daniel@...ll.ch>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Helge Deller <deller@....de>,
Jason Wessel <jason.wessel@...driver.com>,
Daniel Thompson <daniel.thompson@...aro.org>,
John Ogness <jogness@...utronix.de>
Subject: [patch RFC 29/29] printk: Add atomic write enforcement to warn/panic...
Signed-off-by: John Ogness <jogness@...utronix.de>
Invoke the atomic write enforcement functions for warn/panic to ensure that
the information gets out to the consoles.
This is not yet a final solution as this still unlocks consoles and depends
on the "reliablity" of legacy consoles which are invoked during printk().
Once the legacy is converted over this can be changed to lock consoles on
entry, print undisturbed and release them on exit.
Signed-off-by: John Ogness <jogness@...utronix.de>
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
---
kernel/panic.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -256,6 +256,12 @@ void panic(const char *fmt, ...)
if (old_cpu != PANIC_CPU_INVALID && old_cpu != this_cpu)
panic_smp_self_stop();
+ /*
+ * No point in saving the previous printk severity level
+ * here. Panic won't come back
+ */
+ cons_atomic_enter(CONS_PRIO_PANIC);
+
console_verbose();
bust_spinlocks(1);
va_start(args, fmt);
@@ -602,6 +608,10 @@ struct warn_args {
void __warn(const char *file, int line, void *caller, unsigned taint,
struct pt_regs *regs, struct warn_args *args)
{
+ enum cons_prio prev_prio;
+
+ prev_prio = cons_atomic_enter(CONS_PRIO_EMERGENCY);
+
disable_trace_on_warning();
if (file)
@@ -633,6 +643,8 @@ void __warn(const char *file, int line,
/* Just a warning, don't kill lockdep. */
add_taint(taint, LOCKDEP_STILL_OK);
+
+ cons_atomic_exit(CONS_PRIO_EMERGENCY, prev_prio);
}
#ifndef __WARN_FLAGS
Powered by blists - more mailing lists