diff --git a/sys/riscv/riscv/mp_machdep.c b/sys/riscv/riscv/mp_machdep.c index b453ef844c2..cdcc86e715d 100644 --- a/sys/riscv/riscv/mp_machdep.c +++ b/sys/riscv/riscv/mp_machdep.c @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -266,6 +267,9 @@ init_secondary(uint64_t hart) /* 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)); diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c index 1d37bcb0bd2..6cad0f68740 100644 --- a/sys/riscv/riscv/pmap.c +++ b/sys/riscv/riscv/pmap.c @@ -573,7 +573,12 @@ pmap_bootstrap(vm_offset_t l1pt, vm_paddr_t kernstart, vm_size_t kernlen) rw_init(&pvh_global_lock, "pmap pv global"); - CPU_FILL(&kernel_pmap->pm_active); + /* + * Set the current CPU as active in the kernel pmap. Secondary cores + * will add themselves later in init_secondary(). The SBI firmware + * may rely on this mask being precise, so CPU_FILL() is not used. + */ + 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;