From nobody Wed Sep 21 09:46:44 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MXYTc2w0Wz4ctc6; Wed, 21 Sep 2022 09:46:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MXYTc2RmQz3f5t; Wed, 21 Sep 2022 09:46:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663753604; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8KJk97FTjgW9wqp5ZH6WWhqfpECJAEiKErmi0x+Z940=; b=P5WcIxhRIQ1fd2pjMsOmk13o5bVogFSFyS+fiijA1ATf6g21t+KXb8RLvirHT13E/wZXMb BS+JQQk1nkBrI2FJpi1d1wkA3MDfSYVcTsUr8VsUoRrz8YLB4Wzy1q+VBDFkUEdlxq/Cfz 4WzfbxNuff8n3OptKQ2GnZ33Zfc9j3NK4gwc455xDQOoQTy7AgYRAerc5uRdmHCmDTXv5l h4c4QMU3I67qcKJjStIHJHOAEOrIpuPs/I1DSsees8mo6NcI8+1AQHUwT4zOhpPVCFUm9C 2JMYlEjimmc6BrI6RmgEd+9FOTbJr+rLtfuK7oKwhaiVuQQR4QtQwXtiRPt+2Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MXYTc0w4Xz11vq; Wed, 21 Sep 2022 09:46:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 28L9kiZw076097; Wed, 21 Sep 2022 09:46:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28L9ki9A076096; Wed, 21 Sep 2022 09:46:44 GMT (envelope-from git) Date: Wed, 21 Sep 2022 09:46:44 GMT Message-Id: <202209210946.28L9ki9A076096@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andrew Turner Subject: git: b3e05bc282b6 - stable/13 - Store mpidr as a 64-bit value on arm64 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b3e05bc282b65e08ad34d734cee8f1af087f38d8 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663753604; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8KJk97FTjgW9wqp5ZH6WWhqfpECJAEiKErmi0x+Z940=; b=MLVy19QHiEnsgRJpEjv2Dv/Ew+xL1tPBHgCfJN2E1BkkGOhO8GGg2TBgamZN7A2lv/jjSQ GAZAgLrfNSj6tVMyy4dzE6nok+cImL/Szwz7mgUJ90q9OuAKNYoPhPlieu7LpjhEDFruMC pc8tnKskO/F2Ut/+2WUtqc5Kw10INBTITVT50/EgAhSk3U4Q8pVrpdJJJ5BslERgQ5wk2k jFXz8bEUfLeDsq30Uu1daD7njAJQJWsbGqtgvH8vfdC6Fe6/mUMI5MLPzALInPacjmNSng Adz98rvpICh9e75Fb6gGAsAj9rYplLJMENQ6+9reRFrleHKT+i8NYS4bfR4Eng== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1663753604; a=rsa-sha256; cv=none; b=lAivjw2YDswSVwy3hjTAagP1hk5eQmL041GG4Zl/vHIG9OcbiurHQyptXCZHnAza8wCuLY bfPxyhKvFgjp3cCxkV5KEx1u1UWRR+i1mvY8Vx2RRGK1sGvkSNgYpO3l4jQxPPHvUB0Rv7 MKdwl5PpoqE7m3ENtbTOnoMhadaKeGBbq401VDvApcxUC9um3w1RsJI1ziJQyDwbB/L6Q5 VC8tUijeClizS540zSzu3iyWaOH4qB9+IEfVyTIGnb6VVwtK/tAv8DOjPNy5dztv3tuij3 iCbIHdzu0UD6jfGywm+qh0wCSmweZMNZlZRa1+wrNjcBwD1u0F3MoOQkfBEvEQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=b3e05bc282b65e08ad34d734cee8f1af087f38d8 commit b3e05bc282b65e08ad34d734cee8f1af087f38d8 Author: Andrew Turner AuthorDate: 2022-08-25 08:28:28 +0000 Commit: Andrew Turner CommitDate: 2022-09-21 09:45:52 +0000 Store mpidr as a 64-bit value on arm64 The mpidr register is 64 bit on arm64 and 32 bit on arm. Fix this by extending the arm64 definition to include the top 32 bits. To preserve KBI when MFCing split the value into two 32 bit values. This will be cleaned up later only on main. Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D36346 (cherry picked from commit 544f047f894046a68c373f55ddd072e91bcfbf38) --- sys/arm/arm/pmu_fdt.c | 2 +- sys/arm/include/pcpu.h | 2 ++ sys/arm64/arm64/machdep.c | 3 ++- sys/arm64/arm64/mp_machdep.c | 17 +++++++++++------ sys/arm64/include/pcpu.h | 9 +++++++-- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/sys/arm/arm/pmu_fdt.c b/sys/arm/arm/pmu_fdt.c index 2e03fc98bfe0..6590e0659d82 100644 --- a/sys/arm/arm/pmu_fdt.c +++ b/sys/arm/arm/pmu_fdt.c @@ -105,7 +105,7 @@ pmu_parse_affinity(device_t dev, struct pmu_softc *sc, struct pmu_intr *irq, 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 index 4d609b10bf73..a3a6900f692d 100644 --- a/sys/arm/include/pcpu.h +++ b/sys/arm/include/pcpu.h @@ -140,6 +140,8 @@ set_tls(void *tls) #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 index 14d0dcbf6c2f..6e2ec7d39ed2 100644 --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -300,7 +300,8 @@ cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t size) { 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 index 8443c766923b..4d3f9f4963f5 100644 --- a/sys/arm64/arm64/mp_machdep.c +++ b/sys/arm64/arm64/mp_machdep.c @@ -154,7 +154,7 @@ static bool 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 @@ -208,7 +208,7 @@ init_secondary(uint64_t cpu) { struct pcpu *pcpup; pmap_t pmap0; - u_int mpidr; + uint64_t mpidr; /* * Verify that the value passed in 'cpu' argument (aka context_id) is @@ -217,10 +217,10 @@ init_secondary(uint64_t cpu) */ 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 @@ start_cpu(u_int cpuid, uint64_t target_cpu, int domain) 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 @@ cpu_init_fdt(void) 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 index d83c9a656634..8ec4a33b0d67 100644 --- a/sys/arm64/include/pcpu.h +++ b/sys/arm64/include/pcpu.h @@ -48,8 +48,10 @@ struct debug_monitor_state; 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 @@ -84,6 +86,9 @@ 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)) + #endif /* _KERNEL */ #endif /* !_MACHINE_PCPU_H_ */