Kernel mode program, trace, breakpoint and machine check exceptions go
through dbtrap, which builds the trap frame on trapstk before calling
db_trap_glue() and, when KDB does not want the trap, restores every
register from that frame and re-enters the normal trap path. There
was a single trapstk for the whole machine. Two CPUs taking such a
trap at the same time built their frames on top of each other and one
of them continued with the other's registers and stack pointer.
DTrace fbt probes are exactly these traps, so enabling a probe on a
function that runs concurrently on several CPUs corrupted the kernel
within seconds: an fbt probe on pmap_nofault() during a parallel
compile on a POWER9 pseries guest panicked with "stack overflow
detected" from pmap_nofault() itself.
Give each CPU its own stack, kept in its pcpu. The boot CPU uses a
static one, since it is initialised before malloc works; the others
allocate theirs in cpu_pcpu_init(), as 564fe16c does for the booke
critical interrupt stack. dbtrap takes the stack from the pcpu.
MFC after: 1 week