diff --git a/sys/arm64/arm64/mp_machdep.c b/sys/arm64/arm64/mp_machdep.c --- a/sys/arm64/arm64/mp_machdep.c +++ b/sys/arm64/arm64/mp_machdep.c @@ -82,6 +82,8 @@ #include "pic_if.h" +#define MP_BOOTSTACK_SIZE (kstack_pages * PAGE_SIZE) + #define MP_QUIRK_CPULIST 0x01 /* The list of cpus may be wrong, */ /* don't panic if one fails to start */ static uint32_t mp_quirks; @@ -317,7 +319,8 @@ for (cpu = 1; cpu < mp_ncpus; cpu++) { if (bootstacks[cpu] != NULL) - kmem_free((vm_offset_t)bootstacks[cpu], PAGE_SIZE); + kmem_free((vm_offset_t)bootstacks[cpu], + MP_BOOTSTACK_SIZE); } } SYSINIT(smp_after_idle_runnable, SI_SUB_SMP, SI_ORDER_ANY, @@ -524,10 +527,10 @@ dpcpu_init(dpcpu[cpuid - 1], cpuid); bootstacks[cpuid] = (void *)kmem_malloc_domainset( - DOMAINSET_PREF(domain), PAGE_SIZE, M_WAITOK | M_ZERO); + DOMAINSET_PREF(domain), MP_BOOTSTACK_SIZE, M_WAITOK | M_ZERO); naps = atomic_load_int(&aps_started); - bootstack = (char *)bootstacks[cpuid] + PAGE_SIZE; + bootstack = (char *)bootstacks[cpuid] + MP_BOOTSTACK_SIZE; printf("Starting CPU %u (%lx)\n", cpuid, target_cpu); pa = pmap_extract(kernel_pmap, (vm_offset_t)mpentry); @@ -545,7 +548,7 @@ pcpu_destroy(pcpup); dpcpu[cpuid - 1] = NULL; - kmem_free((vm_offset_t)bootstacks[cpuid], PAGE_SIZE); + kmem_free((vm_offset_t)bootstacks[cpuid], MP_BOOTSTACK_SIZE); kmem_free(pcpu_mem, size); bootstacks[cpuid] = NULL; mp_ncpus--; diff --git a/sys/riscv/riscv/mp_machdep.c b/sys/riscv/riscv/mp_machdep.c --- a/sys/riscv/riscv/mp_machdep.c +++ b/sys/riscv/riscv/mp_machdep.c @@ -71,6 +71,8 @@ #include #endif +#define MP_BOOTSTACK_SIZE (kstack_pages * PAGE_SIZE) + boolean_t ofw_cpu_reg(phandle_t node, u_int, cell_t *); uint32_t __riscv_boot_ap[MAXCPU]; @@ -311,7 +313,8 @@ for (cpu = 1; cpu <= mp_maxid; cpu++) { if (bootstacks[cpu] != NULL) - kmem_free((vm_offset_t)bootstacks[cpu], PAGE_SIZE); + kmem_free((vm_offset_t)bootstacks[cpu], + MP_BOOTSTACK_SIZE); } } SYSINIT(smp_after_idle_runnable, SI_SUB_SMP, SI_ORDER_ANY, @@ -475,10 +478,11 @@ dpcpu[cpuid - 1] = (void *)kmem_malloc(DPCPU_SIZE, M_WAITOK | M_ZERO); dpcpu_init(dpcpu[cpuid - 1], cpuid); - bootstacks[cpuid] = (void *)kmem_malloc(PAGE_SIZE, M_WAITOK | M_ZERO); + bootstacks[cpuid] = (void *)kmem_malloc(MP_BOOTSTACK_SIZE, + M_WAITOK | M_ZERO); naps = atomic_load_int(&aps_started); - bootstack = (char *)bootstacks[cpuid] + PAGE_SIZE; + bootstack = (char *)bootstacks[cpuid] + MP_BOOTSTACK_SIZE; printf("Starting CPU %u (hart %lx)\n", cpuid, hart); atomic_store_32(&__riscv_boot_ap[hart], 1);