Index: sys/riscv/riscv/mp_machdep.c =================================================================== --- sys/riscv/riscv/mp_machdep.c +++ sys/riscv/riscv/mp_machdep.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -266,6 +267,9 @@ /* Enable external (PLIC) interrupts */ csr_set(sie, SIE_SEIE); + /* Activate this hart in the kernel pmap. */ + CPU_SET_ATOMIC(hart, &kernel_pmap->pm_active); + /* Activate process 0's pmap. */ pmap_activate_boot(vmspace_pmap(proc0.p_vmspace)); Index: sys/riscv/riscv/pmap.c =================================================================== --- sys/riscv/riscv/pmap.c +++ sys/riscv/riscv/pmap.c @@ -573,7 +573,11 @@ rw_init(&pvh_global_lock, "pmap pv global"); - CPU_FILL(&kernel_pmap->pm_active); + /* + * Set the current CPU as active. Secondary cores will add themselves + * later in init_secondary(). + */ + CPU_SET(PCPU_GET(hart), &kernel_pmap->pm_active); /* Assume the address we were loaded to is a valid physical address. */ min_pa = max_pa = kernstart;