CVSROOT: /cvs Module name: src Changes by: chel...@cvs.openbsd.org 2021/06/01 18:39:27
Modified files: sys/kern : subr_prf.c sys/ddb : db_command.c sys/sys : systm.h sys/arch/amd64/amd64: trap.c sys/arch/alpha/include: cpu.h sys/arch/amd64/include: cpu.h sys/arch/arm/include: cpu.h sys/arch/arm64/include: cpu.h sys/arch/hppa/include: cpu.h sys/arch/i386/include: cpu.h sys/arch/m88k/include: cpu.h sys/arch/mips64/include: cpu.h sys/arch/powerpc/include: cpu.h sys/arch/powerpc64/include: cpu.h sys/arch/riscv64/include: cpu.h sys/arch/sh/include: cpu.h sys/arch/sparc64/include: cpu.h Log message: kernel: introduce per-CPU panic(9) message buffers Add a 512-byte buffer (ci_panicbuf) to each cpu_info struct on each platform for use by panic(9). The first panic on a given CPU writes its message to this buffer. Subsequent panics on a given CPU print the panic message to the console but do not modify the buffer. This aids debugging in two cases: - If 2+ CPUs panic simultaneously there is no risk of garbled messages in the panic buffer. - If a CPU panics and then the operator causes a second panic while using ddb(4), the operator can still recall the first failure on a particular CPU. Misc. changes to support this bigger change: - Set panicstr atomically to identify the first CPU to reach panic(). - Tweak db_show_panic_cmd() to print all panic messages across all CPUs. Prefix the first panic with an asterisk ('*'). - Prefer db_printf() to printf() during a panic if we have it. Apparently it disturbs less global state. - On amd64, tweak fault() to write the local panic buffer. This needs more work. Prompted by bluhm@ and deraadt@. Mostly written by deraadt@. Discussed with bluhm@, deraadt@ and kettenis@. Borne from a discussion on tech@ about making panic(9) more MP-safe: https://marc.info/?l=openbsd-tech&m=162086462316143&w=2 ok kettenis@, visa@, bluhm@, deraadt@