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]; +static void *bootstacks[MAXCPU - 1]; /* Count of started APs, used to synchronize access to bootstack. */ static volatile int aps_started; @@ -316,8 +316,8 @@ smp_no_rendezvous_barrier, NULL); for (cpu = 1; cpu < mp_ncpus; cpu++) { - if (bootstacks[cpu] != NULL) - kmem_free(bootstacks[cpu], MP_BOOTSTACK_SIZE); + if (bootstacks[cpu - 1] != NULL) + kmem_free(bootstacks[cpu - 1], MP_BOOTSTACK_SIZE); } } SYSINIT(smp_after_idle_runnable, SI_SUB_SMP, SI_ORDER_ANY, @@ -561,11 +561,11 @@ dpcpu[cpuid - 1] = (void *)(pcpup + 1); dpcpu_init(dpcpu[cpuid - 1], cpuid); - bootstacks[cpuid] = kmem_malloc_domainset(DOMAINSET_PREF(domain), + bootstacks[cpuid - 1] = kmem_malloc_domainset(DOMAINSET_PREF(domain), MP_BOOTSTACK_SIZE, M_WAITOK | M_ZERO); naps = atomic_load_int(&aps_started); - bootstack = (char *)bootstacks[cpuid] + MP_BOOTSTACK_SIZE; + bootstack = (char *)bootstacks[cpuid - 1] + MP_BOOTSTACK_SIZE; printf("Starting CPU %u (%lx)\n", cpuid, target_cpu); pa = pmap_extract(kernel_pmap, (vm_offset_t)mpentry); @@ -584,9 +584,9 @@ if (err != 0) { pcpu_destroy(pcpup); dpcpu[cpuid - 1] = NULL; - kmem_free(bootstacks[cpuid], MP_BOOTSTACK_SIZE); + kmem_free(bootstacks[cpuid - 1], MP_BOOTSTACK_SIZE); kmem_free(pcpup, size); - bootstacks[cpuid] = NULL; + bootstacks[cpuid - 1] = NULL; mp_ncpus--; return (false); }