From nobody Fri Jan 24 12:11:52 2025 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 4YfcB13cGPz5lJs3; Fri, 24 Jan 2025 12:11:53 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YfcB101fbz481K; Fri, 24 Jan 2025 12:11:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737720713; 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=dyV3Qqw5CTvlmIGTd6l3+NL7I33od69sHMOwcO72DMM=; b=y4Luu/IMDz8TI3Rd3F8pJCIoyFl+G5Ct5F6D4OV49Zn8RkHZk8vc3/2HSprPyS1hodnIcb AqoHWHpNvFbdXH2U91pSd3nA13cpvC83XvznH97OU5K3tSX8VGLw1VXmdZDMCqiPgO59oR wymDMtOoocYVoU9CnjV7O2Oy9OOlrwruuq655IFjI0l7Gj6EeMiGRNe6nMB62z4wHBt496 lPM23UpBNp2+qzh67B/Ninur/kT0kPsuVwPhT0L1/MLTzC2N6mZUsPkjyPw4jW21b7myf9 zdKY5VARAGq0EO61tgYeKhAumyqd2Wq+mLRcFEYR38n00QxfjPtecccA2EU52g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737720713; 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=dyV3Qqw5CTvlmIGTd6l3+NL7I33od69sHMOwcO72DMM=; b=eh/q1NkV8MyinGrRShCtowYXNerYdoVIpIVKeYPVp7PzrNHpZHj207DBWwnste3Gn9C7R+ pKno6n/2wxmOExKhMj2ER6BI+Inyz0uo98uh00U2y/JAdG3PFCs7Zxgp/fiAXtCpz7fiSs 8bogXPWZSNrWD5pr8CvGgJbWOzwa2VtGAxPqBIKd1yGZkunLuhkg3b5vNnxDE0J3s7kPyZ Lp6hpBac0A8n2R8+XqMYw092mHpB+XV/iLh0Zr6t85BbvGDtReUEVg817McmlqwJJ8D9FD 8a8lN0gro7McKPP3KPSPRomr2sy1SXlmC1btL1S61Vlvs9rO4FZylt5bbzOirA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1737720713; a=rsa-sha256; cv=none; b=VzKfBGhvoqmlNFlICECqg5XJoctFw4Hsj3xm/QJG/hJe4/hVyMcQWj7Y/oa7uZqLtPWMLy fA42D1Wy9MiicER6ed+jGPTUq+5JWVHABF7kR5iT/gKAurLSj/Hq7Ii+kI6OmDtUMU+Tvy necnwBJGDrmEzskyux5e/8otwKA/wVQaiDECbQkj5Mz3xrz5587EXrDMDeb/suTr7hqnMy j33vtvVUoOFhUE/L1SE4eOd/tGCtCcILZMOjgzeZEnpqf3Upwfh0heMzRwr/C3beDsERNV 4u/B+92PruTQVSSpmLKbOiH7EVLbwyGWdSiIYrromvN1no/IDxvh4c5aKtwPEw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4YfcB06CwNz8x7; Fri, 24 Jan 2025 12:11:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50OCBqwG040447; Fri, 24 Jan 2025 12:11:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50OCBqX8040444; Fri, 24 Jan 2025 12:11:52 GMT (envelope-from git) Date: Fri, 24 Jan 2025 12:11:52 GMT Message-Id: <202501241211.50OCBqX8040444@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 62f8d65ee4d0 - main - arm64: Move FEAT_PAN to the cpu feat framework 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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/main X-Git-Reftype: branch X-Git-Commit: 62f8d65ee4d0178f670a0930736d3628d06746fb Auto-Submitted: auto-generated The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=62f8d65ee4d0178f670a0930736d3628d06746fb commit 62f8d65ee4d0178f670a0930736d3628d06746fb Author: Andrew Turner AuthorDate: 2025-01-24 11:42:48 +0000 Commit: Andrew Turner CommitDate: 2025-01-24 12:09:28 +0000 arm64: Move FEAT_PAN to the cpu feat framework Use the common framework rather than custom functions called on each CPU. Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D47816 --- sys/arm64/arm64/machdep.c | 38 ++++++++++++++++++++++---------------- sys/arm64/arm64/mp_machdep.c | 1 - sys/arm64/include/cpufunc.h | 2 -- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c index db223e011c67..0a925842dba4 100644 --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -173,35 +173,43 @@ SYSINIT(ssp_warn, SI_SUB_COPYRIGHT, SI_ORDER_ANY, print_ssp_warning, NULL); SYSINIT(ssp_warn2, SI_SUB_LAST, SI_ORDER_ANY, print_ssp_warning, NULL); #endif -static void -pan_setup(void) +static bool +pan_check(const struct cpu_feat *feat __unused, u_int midr __unused) { uint64_t id_aa64mfr1; id_aa64mfr1 = READ_SPECIALREG(id_aa64mmfr1_el1); - if (ID_AA64MMFR1_PAN_VAL(id_aa64mfr1) != ID_AA64MMFR1_PAN_NONE) - has_pan = 1; + return (ID_AA64MMFR1_PAN_VAL(id_aa64mfr1) != ID_AA64MMFR1_PAN_NONE); } -void -pan_enable(void) +static void +pan_enable(const struct cpu_feat *feat __unused, + cpu_feat_errata errata_status __unused, u_int *errata_list __unused, + u_int errata_count __unused) { + has_pan = 1; /* * This sets the PAN bit, stopping the kernel from accessing * memory when userspace can also access it unless the kernel * uses the userspace load/store instructions. */ - if (has_pan) { - WRITE_SPECIALREG(sctlr_el1, - READ_SPECIALREG(sctlr_el1) & ~SCTLR_SPAN); - __asm __volatile( - ".arch_extension pan \n" - "msr pan, #1 \n" - ".arch_extension nopan \n"); - } + WRITE_SPECIALREG(sctlr_el1, + READ_SPECIALREG(sctlr_el1) & ~SCTLR_SPAN); + __asm __volatile( + ".arch_extension pan \n" + "msr pan, #1 \n" + ".arch_extension nopan \n"); } +static struct cpu_feat feat_pan = { + .feat_name = "FEAT_PAN", + .feat_check = pan_check, + .feat_enable = pan_enable, + .feat_flags = CPU_FEAT_EARLY_BOOT | CPU_FEAT_PER_CPU, +}; +DATA_SET(cpu_feat_set, feat_pan); + bool has_hyp(void) { @@ -964,7 +972,6 @@ initarm(struct arm64_bootparams *abp) init_param1(); cache_setup(); - pan_setup(); /* Bootstrap enough of pmap to enter the kernel proper */ pmap_bootstrap(lastaddr - KERNBASE); @@ -1029,7 +1036,6 @@ initarm(struct arm64_bootparams *abp) if ((boothowto & RB_KDB) != 0) kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger"); #endif - pan_enable(); kcsan_cpu_init(0); kasan_init(); diff --git a/sys/arm64/arm64/mp_machdep.c b/sys/arm64/arm64/mp_machdep.c index 987ff9ac1ceb..d052033d9575 100644 --- a/sys/arm64/arm64/mp_machdep.c +++ b/sys/arm64/arm64/mp_machdep.c @@ -256,7 +256,6 @@ init_secondary(uint64_t cpu) #endif dbg_init(); - pan_enable(); mtx_lock_spin(&ap_boot_mtx); atomic_add_rel_32(&smp_cpus, 1); diff --git a/sys/arm64/include/cpufunc.h b/sys/arm64/include/cpufunc.h index c948799eb7b9..e6e1f682794e 100644 --- a/sys/arm64/include/cpufunc.h +++ b/sys/arm64/include/cpufunc.h @@ -41,8 +41,6 @@ breakpoint(void) #ifdef _KERNEL #include -void pan_enable(void); - static __inline register_t dbg_disable(void) {