Index: sys/arm64/arm64/machdep.c =================================================================== --- sys/arm64/arm64/machdep.c +++ sys/arm64/arm64/machdep.c @@ -105,7 +105,8 @@ enum arm64_bus arm64_bus_method = ARM64_BUS_NONE; -struct pcpu __pcpu[MAXCPU]; +struct pcpu pcpu0; +struct pcpu *__pcpu[MAXCPU]; static struct trapframe proc0_tf; @@ -925,7 +926,10 @@ static void init_proc0(vm_offset_t kstack) { - struct pcpu *pcpup = &__pcpu[0]; + struct pcpu *pcpup; + + pcpup = __pcpu[0]; + MPASS(pcpup != NULL); proc_linkup0(&proc0, &thread0); thread0.td_kstack = kstack; @@ -1357,7 +1361,7 @@ physmem_exclude_region(0x80000000, 0x10000, EXFLAG_NOALLOC); /* Set the pcpu data, this is needed by pmap_bootstrap */ - pcpup = &__pcpu[0]; + pcpup = __pcpu[0] = &pcpu0; pcpu_init(pcpup, 0, sizeof(struct pcpu)); /* Index: sys/arm64/arm64/mp_machdep.c =================================================================== --- sys/arm64/arm64/mp_machdep.c +++ sys/arm64/arm64/mp_machdep.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -152,7 +153,7 @@ is_boot_cpu(uint64_t target_cpu) { - return (__pcpu[0].pc_mpidr == (target_cpu & CPU_AFF_MASK)); + return (__pcpu[0]->pc_mpidr == (target_cpu & CPU_AFF_MASK)); } static void @@ -216,15 +217,17 @@ * they can pass random value in it. */ mpidr = READ_SPECIALREG(mpidr_el1) & CPU_AFF_MASK; - if (cpu >= MAXCPU || __pcpu[cpu].pc_mpidr != mpidr) { + if (cpu >= MAXCPU || __pcpu[cpu] == NULL || + __pcpu[cpu]->pc_mpidr != mpidr) { for (cpu = 0; cpu < mp_maxid; cpu++) - if (__pcpu[cpu].pc_mpidr == mpidr) + if (__pcpu[cpu] != NULL && + __pcpu[cpu]->pc_mpidr == mpidr) break; if ( cpu >= MAXCPU) panic("MPIDR for this CPU is not in pcpu table"); } - pcpup = &__pcpu[cpu]; + pcpup = __pcpu[cpu]; /* * Set the pcpu pointer with a backup in tpidr_el1 to be * loaded when entering the kernel from userland. @@ -485,7 +488,7 @@ * do nothing. Returns true if the CPU is present and running. */ static bool -start_cpu(u_int cpuid, uint64_t target_cpu) +start_cpu(u_int cpuid, uint64_t target_cpu, int domain) { struct pcpu *pcpup; vm_paddr_t pa; @@ -502,14 +505,17 @@ KASSERT(cpuid < MAXCPU, ("Too many CPUs")); - pcpup = &__pcpu[cpuid]; + pcpup = __pcpu[cpuid] = (void *)kmem_malloc_domainset( + DOMAINSET_PREF(domain), sizeof(*pcpup), M_WAITOK | M_ZERO);; pcpu_init(pcpup, cpuid, sizeof(struct pcpu)); pcpup->pc_mpidr = target_cpu & CPU_AFF_MASK; - dpcpu[cpuid - 1] = (void *)kmem_malloc(DPCPU_SIZE, M_WAITOK | M_ZERO); + dpcpu[cpuid - 1] = (void *)kmem_malloc_domainset( + DOMAINSET_PREF(domain), 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_domainset( + DOMAINSET_PREF(domain), PAGE_SIZE, M_WAITOK | M_ZERO); naps = atomic_load_int(&aps_started); bootstack = (char *)bootstacks[cpuid] + PAGE_SIZE; @@ -552,6 +558,7 @@ ACPI_MADT_GENERIC_INTERRUPT *intr; u_int *cpuid; u_int id; + int domain; switch(entry->Type) { case ACPI_MADT_TYPE_GENERIC_INTERRUPT: @@ -563,8 +570,14 @@ else id = *cpuid; - if (start_cpu(id, intr->ArmMpidr)) { - __pcpu[id].pc_acpi_id = intr->Uid; +#ifdef NUMA + domain = acpi_pxm_get_cpu_locality(*cpuid); +#else + domain = 0; +#endif + if (start_cpu(id, intr->ArmMpidr, domain)) { + MPASS(__pcpu[id] != NULL); + __pcpu[id]->pc_acpi_id = intr->Uid; /* * Don't increment for the boot CPU, its CPU ID is * reserved. @@ -627,7 +640,7 @@ else cpuid = fdt_cpuid; - if (!start_cpu(cpuid, target_cpu)) + if (!start_cpu(cpuid, target_cpu, 0)) return (FALSE); /* @@ -640,7 +653,7 @@ if (vm_ndomains == 1 || OF_getencprop(node, "numa-node-id", &domain, sizeof(domain)) <= 0) domain = 0; - __pcpu[cpuid].pc_domain = domain; + __pcpu[cpuid]->pc_domain = domain; if (domain < MAXMEMDOM) CPU_SET(cpuid, &cpuset_domain[domain]); return (TRUE); @@ -671,7 +684,7 @@ /* CPU 0 is always boot CPU. */ CPU_SET(0, &all_cpus); - __pcpu[0].pc_mpidr = READ_SPECIALREG(mpidr_el1) & CPU_AFF_MASK; + __pcpu[0]->pc_mpidr = READ_SPECIALREG(mpidr_el1) & CPU_AFF_MASK; switch(arm64_bus_method) { #ifdef DEV_ACPI Index: sys/arm64/include/counter.h =================================================================== --- sys/arm64/include/counter.h +++ sys/arm64/include/counter.h @@ -32,7 +32,7 @@ #include #include -#define EARLY_COUNTER &__pcpu[0].pc_early_dummy_counter +#define EARLY_COUNTER &pcpu0.pc_early_dummy_counter #define counter_enter() do {} while (0) #define counter_exit() do {} while (0) Index: sys/arm64/include/pcpu_aux.h =================================================================== --- sys/arm64/include/pcpu_aux.h +++ sys/arm64/include/pcpu_aux.h @@ -47,6 +47,7 @@ */ _Static_assert(PAGE_SIZE % sizeof(struct pcpu) == 0, "fix pcpu size"); -extern struct pcpu __pcpu[]; +extern struct pcpu pcpu0; +extern struct pcpu *__pcpu[]; #endif /* _MACHINE_PCPU_AUX_H_ */