[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <875y45ag6o.fsf@jogness.linutronix.de>
Date: Wed, 20 Sep 2023 01:42:47 +0206
From: John Ogness <john.ogness@...utronix.de>
To: Petr Mladek <pmladek@...e.com>
Cc: Sergey Senozhatsky <senozhatsky@...omium.org>,
Steven Rostedt <rostedt@...dmis.org>,
Thomas Gleixner <tglx@...utronix.de>,
linux-kernel@...r.kernel.org, Kees Cook <keescook@...omium.org>,
Luis Chamberlain <mcgrof@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Peter Zijlstra <peterz@...radead.org>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Arnd Bergmann <arnd@...db.de>,
"Guilherme G. Piccoli" <gpiccoli@...lia.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: Re: [PATCH printk v2 09/11] panic: Add atomic write enforcement to
oops
On 2023-09-20, John Ogness <john.ogness@...utronix.de> wrote:
> diff --git a/kernel/panic.c b/kernel/panic.c
> index 86ed71ba8c4d..e2879098645d 100644
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -630,6 +634,36 @@ bool oops_may_print(void)
> */
> void oops_enter(void)
> {
> + enum nbcon_prio prev_prio;
> + int cpu = -1;
oops_exit() calls put_cpu(). Here used to be the corresponding
get_cpu(). Somehow I managed to drop it. Here are the inline fixups.
int cur_cpu = get_cpu();
int old_cpu = -1;
> +
> + /*
> + * If this turns out to be the first CPU in oops, this is the
> + * beginning of the outermost atomic section. Otherwise it is
> + * the beginning of an inner atomic section.
> + */
> + prev_prio = nbcon_atomic_enter(NBCON_PRIO_EMERGENCY);
> +
> + if (atomic_try_cmpxchg_relaxed(&oops_cpu, &cpu, smp_processor_id())) {
if (atomic_try_cmpxchg_relaxed(&oops_cpu, &old_cpu, cur_cpu)) {
> + /*
> + * This is the first CPU in oops. Save the outermost
> + * @prev_prio in order to restore it on the outermost
> + * matching oops_exit(), when @oops_nesting == 0.
> + */
> + oops_prev_prio = prev_prio;
> +
> + /*
> + * Enter an inner atomic section that ends at the end of this
> + * function. In this case, the nbcon_atomic_enter() above
> + * began the outermost atomic section.
> + */
> + prev_prio = nbcon_atomic_enter(NBCON_PRIO_EMERGENCY);
> + }
> +
> + /* Track nesting when this CPU is the owner. */
> + if (cpu == -1 || cpu == smp_processor_id())
if (old_cpu == -1 || old_cpu == cur_cpu)
> + oops_nesting++;
> +
> tracing_off();
> /* can't trust the integrity of the kernel anymore: */
> debug_locks_off();
Powered by blists - more mailing lists