From 078a69abcbb8795f0e91d06ebcaef09236a11ceb Mon Sep 17 00:00:00 2001 From: Andrew Turner Date: Mon, 24 Apr 2023 11:24:13 +0100 Subject: [PATCH] Use a uint64_t to store the arm64 mpidr Use a single uint64_t to hole the mpidr register as we can break the KBI on 14. Keep the macro so code can still be MFCd to 13. Sponsored by: Arm Ltd --- sys/arm64/arm64/machdep.c | 3 +-- sys/arm64/arm64/mp_machdep.c | 6 ++---- sys/arm64/include/pcpu.h | 8 +++----- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c index 4aac339b1a1b..8d2e2f81d1d8 100644 --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -315,8 +315,7 @@ cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t size) { pcpu->pc_acpi_id = 0xffffffff; - pcpu->pc_mpidr_low = 0xffffffff; - pcpu->pc_mpidr_high = 0xffffffff; + pcpu->pc_mpidr = UINT64_MAX; } void diff --git a/sys/arm64/arm64/mp_machdep.c b/sys/arm64/arm64/mp_machdep.c index 4276b6dcffd2..24dca3b21d54 100644 --- a/sys/arm64/arm64/mp_machdep.c +++ b/sys/arm64/arm64/mp_machdep.c @@ -558,8 +558,7 @@ start_cpu(u_int cpuid, uint64_t target_cpu, int domain, vm_paddr_t release_addr) M_WAITOK | M_ZERO); pmap_disable_promotion((vm_offset_t)pcpup, size); pcpu_init(pcpup, cpuid, sizeof(struct pcpu)); - pcpup->pc_mpidr_low = target_cpu & CPU_AFF_MASK; - pcpup->pc_mpidr_high = (target_cpu & CPU_AFF_MASK) >> 32; + pcpup->pc_mpidr = target_cpu & CPU_AFF_MASK; dpcpu[cpuid - 1] = (void *)(pcpup + 1); dpcpu_init(dpcpu[cpuid - 1], cpuid); @@ -780,8 +779,7 @@ cpu_mp_start(void) /* CPU 0 is always boot CPU. */ CPU_SET(0, &all_cpus); 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; + cpuid_to_pcpu[0]->pc_mpidr = mpidr; switch(arm64_bus_method) { #ifdef DEV_ACPI diff --git a/sys/arm64/include/pcpu.h b/sys/arm64/include/pcpu.h index 8d60b4ef6356..38a8cd3c3e56 100644 --- a/sys/arm64/include/pcpu.h +++ b/sys/arm64/include/pcpu.h @@ -47,10 +47,9 @@ struct debug_monitor_state; pcpu_ssbd pc_ssbd; \ struct pmap *pc_curpmap; \ struct pmap *pc_curvmpmap; \ - u_int pc_bcast_tlbi_workaround; \ /* 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 */ \ + uint64_t pc_mpidr; \ + u_int pc_bcast_tlbi_workaround; \ char __pad[197] #ifdef _KERNEL @@ -85,8 +84,7 @@ get_curthread(void) #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)) +#define PCPU_GET_MPIDR(pc) ((pc)->pc_mpidr) #endif /* _KERNEL */