Skip to content

Commit

Permalink
printk: Add atomic write enforcement to warn/panic...
Browse files Browse the repository at this point in the history
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@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
John Ogness authored and Thomas Gleixner committed Sep 10, 2022
1 parent e9d70c7 commit f6339cd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions kernel/panic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -633,6 +643,8 @@ void __warn(const char *file, int line, void *caller, unsigned taint,

/* Just a warning, don't kill lockdep. */
add_taint(taint, LOCKDEP_STILL_OK);

cons_atomic_exit(CONS_PRIO_EMERGENCY, prev_prio);
}

#ifndef __WARN_FLAGS
Expand Down

0 comments on commit f6339cd

Please sign in to comment.