[panic] Have panics stop all cores

Kernel panics previously only stopped the calling core. This commit
re-implements the panic system to allow us to stop all cores on a panic.

Changes include:

- panic now sends an NMI to all cores. This means we can't control the
  contents of their registers, so panic information has been moved to a
  global struct, and the panicking cpu sets the pointer to that data in
  its cpu_data.
- the panic_handler is now set up with mutexes to print appropriately
  and only initialize objects once.
- copying _current_gsbase into the panic handler, and #including the
  cpprt.cpp file (so that we can define NDEBUG and not have it try to
  link the assert code back in)
- making the symbol data pointer in kargs an actual pointer again, not
  an address - and carrying that through to the panic handler
- the number of cpus is now saved globally in the kernel as g_num_cpus
This commit is contained in:
Justin C. Miller
2022-01-08 01:00:43 -08:00
parent a3fff889d1
commit eeef23c2b7
12 changed files with 134 additions and 30 deletions

View File

@@ -82,7 +82,7 @@ kernel_main(bootproto::args *args)
{
if (args->panic) {
IDT::set_nmi_handler(args->panic->entrypoint);
panic::symbol_table = args->symbol_table | mem::linear_offset;
panic::symbol_table = util::offset_pointer(args->symbol_table, mem::linear_offset);
}
init_console();
@@ -149,7 +149,7 @@ kernel_main(bootproto::args *args)
apic->calibrate_timer();
const auto &apic_ids = devices.get_apic_ids();
unsigned num_cpus = start_aps(*apic, apic_ids, args->pml4);
g_num_cpus = start_aps(*apic, apic_ids, args->pml4);
interrupts_enable();
g_com1.handle_interrupt();
@@ -178,7 +178,7 @@ kernel_main(bootproto::args *args)
}
*/
scheduler *sched = new scheduler {num_cpus};
scheduler *sched = new scheduler {g_num_cpus};
scheduler_ready = true;
// Load the init server