From nobody Thu Feb 29 17:17:56 2024 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 4TlybV12nWz5CYfd; Thu, 29 Feb 2024 17:17:58 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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 "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TlybV0bwfz47ZH; Thu, 29 Feb 2024 17:17:58 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709227078; 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: in-reply-to:in-reply-to:references:references; bh=/czxFDN/iKmF8SpMbiGaHo495Cr/hdvWoOHZM0d5xBs=; b=AVZRWiXDYygqotr7JNQeug/L8b/ZWfUd3dV5IFcQyj658V6L+VoSHbHjJYmxSi1Jny39Si zv+B3Y9JRk9rwsfJvAhmOAkQ+BtD/AaJzdNFW9Q3KroEmlAyqmKjd0k7OPxLpIDQ5mfv1/ XfLajdvOFl7at4YCErq2QZ4PK2DTaHVixH1osI8cDAhmika6gii6DH8atQE+s4E188KuFD cctKS/dksGFFQf6Ngn6dueP9yjZqYtttkY6kWftqncvUPCe/B9G1pkqREf1EpaalE6Z10h P+A4c4GwCFvmFsj2fZvpkjdmR3j8o2vmV02+xJTZlNAuex9K9OGY/tEFoVnIqg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709227078; a=rsa-sha256; cv=none; b=A3FYLs6H5U37Xey79YCD2v7IK+DFbX99aGW2Acg3JW9/AaPBRFOj4VqExNbgNlEZ/YqPB5 8bRw3gxvNnxHuJEymfKunwWIAdYDgM+nVbaVQoaRGJnS3p4ptOM5a5DHKBPQ6iCk+8sw20 w2p2gk5KjEQEv0B4VO1I+31Sqlpv5zmxeIt5NpicGwB5KoMIAewkHMa+M2mSHOrqUERv0i gelXZDc6J/Qr28wi5+6rqHfvxIfJdNhdyrWCXzU67MXi+tFwQaXpWlY+1yDWOhw91NXHWv 4k4s7hIt/7PP7/UYRnSEdRAy+7TvHC8YpyEMFqbkaGDHWQ3mhOug/ZVGAVHhjA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709227078; 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: in-reply-to:in-reply-to:references:references; bh=/czxFDN/iKmF8SpMbiGaHo495Cr/hdvWoOHZM0d5xBs=; b=PxTkbpPs7IS/Om776JXZGz8F2JOddtsQ0/OPW/Umm2Rklkogr/i/7lLmbBePQ/J+2NtWc0 lHGMdELAFckgx352tsz21sqcXy6KbpotNA4fN9zBEgzHxNjKTyk+XGKO4MVdn1+lDulsWn qmyD1nsDSW8PZfHlFEgh6uMSy869cBdNfDQV683T2xQm+u+Bq5tE1z6b9LayAMbo+ilLuP r66ID2eS16vpGGbMEy60Di5eJkBtKOe31BJOuUL+tBfBW+UYAhzloOtPoWYVjthMkMSzUA M7Q54Q8fgpzOR6olNC/2PjZvDHtY746xPrCKPKKzDPXJ2a8z2z0isNreS8xIjg== Received: from [IPV6:2601:644:937f:4c50:7491:6f2f:4ea1:e2fa] (unknown [IPv6:2601:644:937f:4c50:7491:6f2f:4ea1:e2fa]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4TlybT46XHzSj8; Thu, 29 Feb 2024 17:17:57 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: Date: Thu, 29 Feb 2024 09:17:56 -0800 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 User-Agent: Mozilla Thunderbird Subject: Re: git: b9c0003f0fa3 - main - arm64: Initialize x18 for APs earlier during boot Content-Language: en-US To: Mark Johnston , src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org References: <202311131551.3ADFpHhg004260@gitrepo.freebsd.org> From: John Baldwin In-Reply-To: <202311131551.3ADFpHhg004260@gitrepo.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/13/23 7:51 AM, Mark Johnston wrote: > The branch main has been updated by markj: > > URL: https://cgit.FreeBSD.org/src/commit/?id=b9c0003f0fa39ead4bb3953b9118ae6f08e560f8 > > commit b9c0003f0fa39ead4bb3953b9118ae6f08e560f8 > Author: Mark Johnston > AuthorDate: 2023-11-13 15:44:45 +0000 > Commit: Mark Johnston > CommitDate: 2023-11-13 15:44:45 +0000 > > arm64: Initialize x18 for APs earlier during boot > > When KMSAN is configured, the instrumentation inserts calls to > __msan_get_context_state() into all function prologues. The > implementation dereferences curthread and thus assumes that x18 points > to the PCPU area. This applies in particular to init_secondary(), which > currently is responsible for initializing x18 for APs. > > Move initialization into locore to avoid this problem. No functional > change intended. > > Reviewed by: kib, andrew > MFC after: 2 weeks > Sponsored by: Juniper Networks, Inc. > Sponsored by: Klara, Inc. > Differential Revision: https://reviews.freebsd.org/D42533 (Sorry for just now replying, I'm looking at this in more detail while merging to CheriBSD) I think we can remove a bunch of now-dead code from init_secondary after this, and probably don't even need to pass the cpu number to init_secondary either? That is: void init_secondary(uint64_t cpu) { struct pcpu *pcpup; pmap_t pmap0; uint64_t mpidr; ptrauth_mp_start(cpu); /* * Verify that the value passed in 'cpu' argument (aka context_id) is * valid. Some older U-Boot based PSCI implementations are buggy, * they can pass random value in it. */ mpidr = READ_SPECIALREG(mpidr_el1) & CPU_AFF_MASK; if (cpu >= MAXCPU || cpuid_to_pcpu[cpu] == NULL || PCPU_GET_MPIDR(cpuid_to_pcpu[cpu]) != mpidr) { for (cpu = 0; cpu < mp_maxid; cpu++) if (cpuid_to_pcpu[cpu] != NULL && PCPU_GET_MPIDR(cpuid_to_pcpu[cpu]) == mpidr) break; if ( cpu >= MAXCPU) panic("MPIDR for this CPU is not in pcpu table"); } /* * Identify current CPU. This is necessary to setup * affinity registers and to provide support for * runtime chip identification. * * We need this before signalling the CPU is ready to * let the boot CPU use the results. */ pcpup = cpuid_to_pcpu[cpu]; pcpup->pc_midr = get_midr(); identify_cpu(cpu); Can I think instead become something like: void init_secondary(void) { struct pcpu *pcpup; pmap_t pmap0; uint64_t cpu; cpu = PCPU_GET(cpuid); ptrauth_mp_start(cpu); /* * Identify current CPU. This is necessary to setup * affinity registers and to provide support for * runtime chip identification. * * We need this before signalling the CPU is ready to * let the boot CPU use the results. */ pcpup = get_pcpu(); pcpup->pc_midr = get_midr(); identify_cpu(cpu); Maybe we want to keep an explicit panic if PCPU_GET_MPIDR(pcpup) doesn't match the mpidr from the register? -- John Baldwin