Re: [PATCH 1/2] x86/crash: Disable virt in core NMI crash handler to avoid double list_add

From: Sean Christopherson
Date: Thu May 12 2022 - 10:35:30 EST


On Thu, May 12, 2022, Sean Christopherson wrote:
> On Thu, May 12, 2022, Thomas Gleixner wrote:
> > Sean,
> >
> > On Wed, May 11 2022 at 23:43, Sean Christopherson wrote:
> > > @@ -840,6 +858,20 @@ void nmi_shootdown_cpus(nmi_shootdown_cb callback)
> > > unsigned long msecs;
> > > local_irq_disable();
> > >
> > > + /*
> > > + * Invoking multiple callbacks is not currently supported, registering
> > > + * the NMI handler twice will cause a list_add() double add BUG().
> > > + * The exception is the "nop" handler in the emergency reboot path,
> > > + * which can run after e.g. kdump's shootdown. Do nothing if the crash
> > > + * handler has already run, i.e. has already prepared other CPUs, the
> > > + * reboot path doesn't have any work of its to do, it just needs to
> > > + * ensure all CPUs have prepared for reboot.
> >
> > This is confusing at best. The double list add is just one part of the
> > problem, which would be trivial enough to fix.
> >
> > The real point is that after the first shoot down all other CPUs are
> > stuck in crash_nmi_callback() and won't respond to the second NMI.
>
> Well that's embarrasingly obvious in hindsight.
>
> >
> > So trying to run this twice is completely pointless and guaranteed to
> > run into the timeout.
> >
> > > + */
> > > + if (shootdown_callback) {
> > > + WARN_ON_ONCE(callback != nmi_shootdown_nop);
> > > + return;
> >
> > Instead of playing games with the callback pointer, I prefer to make
> > this all explicit. Delta patch below.
>
> Much better. If you're planning on doing fixup, can you also include a comment
> tweak about why the callback is left set? If not, I'll do it in v2. A bit
> overkill, but it's another thing that for me was obvious only once I realized "why".

Actually, I'll send a v2, there's some more cleanup that can be done if patch 2
uses cpu_crash_disable_virtualization().