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 @@ -138,7 +138,7 @@ /* Stacks for AP initialization, discarded once idle threads are started. */ void *bootstack; -static void *bootstacks[MAXCPU - 1]; +static void **bootstacks; /* Count of started APs, used to synchronize access to bootstack. */ static volatile int aps_started; @@ -319,6 +319,7 @@ if (bootstacks[cpu - 1] != NULL) kmem_free(bootstacks[cpu - 1], MP_BOOTSTACK_SIZE); } + kmem_free(bootstacks, mp_maxid * sizeof(*bootstacks)); } SYSINIT(smp_after_idle_runnable, SI_SUB_SMP, SI_ORDER_ANY, smp_after_idle_runnable, NULL); @@ -774,6 +775,13 @@ mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN); + /* + * Allocate pointers for the noot stacks. We have already allocated + * the stack for CPU0. As we need a pointer for stacks 1 to mp_maxid + * we need an array suze of mp_maxid. + */ + bootstacks = kmem_malloc(mp_maxid * sizeof(*bootstacks), M_WAITOK); + /* CPU 0 is always boot CPU. */ CPU_SET(0, &all_cpus); mpidr = READ_SPECIALREG(mpidr_el1) & CPU_AFF_MASK;