diff --git a/sys/arm/arm/pmu_acpi.c b/sys/arm/arm/pmu_acpi.c --- a/sys/arm/arm/pmu_acpi.c +++ b/sys/arm/arm/pmu_acpi.c @@ -72,7 +72,7 @@ for (i = 0; i < MAXCPU; i++) { pcpu = pcpu_find(i); - if (pcpu != NULL && pcpu->pc_mpidr == intr->ArmMpidr) { + if (pcpu != NULL && PCPU_GET_MPIDR(pcpu) == intr->ArmMpidr) { cpuid = i; break; } diff --git a/sys/arm/arm/pmu_fdt.c b/sys/arm/arm/pmu_fdt.c --- a/sys/arm/arm/pmu_fdt.c +++ b/sys/arm/arm/pmu_fdt.c @@ -105,7 +105,7 @@ for (i = 0; i < MAXCPU; i++) { pcpu = pcpu_find(i); - if (pcpu != NULL && pcpu->pc_mpidr == mpidr) { + if (pcpu != NULL && PCPU_GET_MPIDR(pcpu) == mpidr) { irq->cpuid = i; return (0); } diff --git a/sys/arm/include/pcpu.h b/sys/arm/include/pcpu.h --- a/sys/arm/include/pcpu.h +++ b/sys/arm/include/pcpu.h @@ -139,6 +139,8 @@ #define PCPU_PTR(member) (&get_pcpu()->pc_ ## member) #define PCPU_SET(member,value) (get_pcpu()->pc_ ## member = (value)) +#define PCPU_GET_MPIDR(pc) ((pc)->pc_mpidr) + void pcpu0_init(void); #endif /* _KERNEL */ diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -300,7 +300,8 @@ { pcpu->pc_acpi_id = 0xffffffff; - pcpu->pc_mpidr = 0xffffffff; + pcpu->pc_mpidr_low = 0xffffffff; + pcpu->pc_mpidr_high = 0xffffffff; } void 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 @@ -153,7 +153,7 @@ is_boot_cpu(uint64_t target_cpu) { - return (cpuid_to_pcpu[0]->pc_mpidr == (target_cpu & CPU_AFF_MASK)); + return (PCPU_GET_MPIDR(cpuid_to_pcpu[0]) == (target_cpu & CPU_AFF_MASK)); } static void @@ -207,7 +207,7 @@ { struct pcpu *pcpup; pmap_t pmap0; - u_int mpidr; + uint64_t mpidr; ptrauth_mp_start(cpu); @@ -218,10 +218,10 @@ */ mpidr = READ_SPECIALREG(mpidr_el1) & CPU_AFF_MASK; if (cpu >= MAXCPU || cpuid_to_pcpu[cpu] == NULL || - cpuid_to_pcpu[cpu]->pc_mpidr != mpidr) { + PCPU_GET_MPIDR(cpuid_to_pcpu[cpu]) != mpidr) { for (cpu = 0; cpu < mp_maxid; cpu++) if (cpuid_to_pcpu[cpu] != NULL && - cpuid_to_pcpu[cpu]->pc_mpidr == mpidr) + PCPU_GET_MPIDR(cpuid_to_pcpu[cpu]) == mpidr) break; if ( cpu >= MAXCPU) panic("MPIDR for this CPU is not in pcpu table"); @@ -517,7 +517,8 @@ pcpup = (struct pcpu *)pcpu_mem; pcpu_init(pcpup, cpuid, sizeof(struct pcpu)); - pcpup->pc_mpidr = target_cpu & CPU_AFF_MASK; + pcpup->pc_mpidr_low = target_cpu & CPU_AFF_MASK; + pcpup->pc_mpidr_high = (target_cpu & CPU_AFF_MASK) >> 32; dpcpu[cpuid - 1] = (void *)(pcpup + 1); dpcpu_init(dpcpu[cpuid - 1], cpuid); @@ -688,11 +689,15 @@ void cpu_mp_start(void) { + uint64_t mpidr; + mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN); /* CPU 0 is always boot CPU. */ CPU_SET(0, &all_cpus); - cpuid_to_pcpu[0]->pc_mpidr = READ_SPECIALREG(mpidr_el1) & CPU_AFF_MASK; + mpidr = READ_SPECIALREG(mpidr_el1) & CPU_AFF_MASK; + cpuid_to_pcpu[0]->pc_mpidr_low = mpidr; + cpuid_to_pcpu[0]->pc_mpidr_high = mpidr >> 32; switch(arm64_bus_method) { #ifdef DEV_ACPI diff --git a/sys/arm64/include/pcpu.h b/sys/arm64/include/pcpu.h --- a/sys/arm64/include/pcpu.h +++ b/sys/arm64/include/pcpu.h @@ -48,8 +48,10 @@ struct pmap *pc_curpmap; \ struct pmap *pc_curvmpmap; \ u_int pc_bcast_tlbi_workaround; \ - u_int pc_mpidr; /* stored MPIDR value */ \ - char __pad[201] + /* Store as two u_int values to preserve KBI */ \ + u_int pc_mpidr_low; /* lower MPIDR 32 bits */ \ + u_int pc_mpidr_high; /* upper MPIDR 32 bits */ \ + char __pad[197] #ifdef _KERNEL @@ -83,6 +85,9 @@ #define PCPU_PTR(member) (&pcpup->pc_ ## member) #define PCPU_SET(member,value) (pcpup->pc_ ## member = (value)) +#define PCPU_GET_MPIDR(pc) \ + ((((uint64_t)((pc)->pc_mpidr_high)) << 32) | ((pc)->pc_mpidr_low)) + #endif /* _KERNEL */ #endif /* !_MACHINE_PCPU_H_ */