Re: [PATCH] MIPS: SGI-IP27: print the NMI dump on an nbcon console

From: Maciej W. Rozycki

Date: Fri Oct 16 2026 - 17:46:06 EST


On Thu, 1 Oct 2026, John Ogness wrote:

> > nmi_dump() has no caller in Linux. install_cpu_nmi_handler() stores
> > its address in the per-CPU NMI vector the PROM keeps in low memory,
> > and the PROM jumps to it when the system controller asserts NMI on
> > the CPUs: the "nmi" command at the L1 (or the MMSC on an Origin
> > 2000), typically used to get a dump out of a hung machine.
> >
> > Every CPU that takes the NMI enters nmi_dump(). The first one to get
> > nmi_lock waits until all online CPUs have arrived, prints the saved
> > state of every CPU and ends with the NI_PORT_RESET write. The others
> > spin on nmi_lock, which is never released. No CPU goes back to the
> > interrupted context
>
> Thanks for the explanation. I guess it should have been obvious, also
> because @nmi_lock is locked and never unlocked.

Mind that NMI on MIPS is not recoverable in the general case, unlike with
say x86.

First the event takes the reset vector, which typically is handled by the
machine firmware and while it can be told apart by software from other
events causing execution to reach there, it requires a machine-specific
protocol.

The use of the error level for the exception handler switches off the MMU
for KUSEG and lets the register context be dumped for later restoration
using $zero register as the base pointer, but again it has to be there in
the firmware and then not to clash with OS use of memory. Alternatively
scratch GPRs could be put aside for NMI handling in the ABI such as with
the kernel $k0-$k1 registers, but that'd be an overkill wasting precious
resources.

Then nesting is not supported since obviously it would clobber the state
of the outer NMI handler, so that'd have to be prevented from triggering
by system circuitry until cleared by software. There's no internal latch
in the CPU such as with x86 that would prevent an NMI from retriggering.

All in all we do not strive to recover and only dump available state for
any post-mortem examination. Some platforms can't even do that.

Maciej