From nobody Mon Feb 19 16:44:57 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 4TdpL21n9Lz5C8vn; Mon, 19 Feb 2024 16:44:58 +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 4TdpL16swlz4bGS; Mon, 19 Feb 2024 16:44:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708361098; 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=8EGtVDLuZDypdZL5SKf7o8705877Rn3jOz+QwOLQQ6o=; b=HaNmVbs/2MdYUlqBw4/EbViDSWQmftGn0JXxcgP4ePV4I+nV4L0/SmqVAFLjlocn7y30dO mPplRNddKmhMVpkm6Cps9nulBaS4SU4eQyZhBEL/l+/1SSt6pODFswAQpUHYnhySuJZZsE sAW7pinci+MggcSPHHOLPe5bbMhsM52cpAc6Zn2e84uGG08Co+gyfV16pCouBGoAWhnVpV j7VigH7yLjACLFjOIgkod6epLB4lNycNg9M5HdVDmh1saPWdIW9CxJ2DHvmc8QA3j/5oYv VpjPeUEzWHEF6p1FnX8+wnWgaFjJzKED+nbSTofWTl1V8mxYzkCGlRCJF+xITg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708361098; 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=8EGtVDLuZDypdZL5SKf7o8705877Rn3jOz+QwOLQQ6o=; b=bjbHSM64Oyo+RFjnngiUIs4VjauAeDW+i4PFJjdk9q6TxHOFhH21UInTxGtJ3Y/p7Ioqdt eEr5z/Y4cdBXZD8KxFlIW83vQD80fXwOHYsOhqF9hUa8n0KuW/1jo/E5lCKdXukzd91n/f IbmYJRahCeKc1O4x2T6pj1zrH5/elgyaYxD8VPjMfuRZcPIqLUAFzjeSacBS/Zo3lN5zH8 +GzCUZYD4DOm+WrN1hljIR7qzskki4ezXzwIK3E68V9AcxCfH4qp9sxjQJSLCo1+5+xVdw p2gKgtDEcdBgxIb9kA8Q2SNfR/6Dk4iUBa/lA0gxOiclZWjsKyve8vZmHkQ1Gw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708361098; a=rsa-sha256; cv=none; b=HCBhKkeQRUzcbwRg95Y1k6oOuYDUR0vBSMy3BO5d/ogY7iY1AJZenQM+Mqejhom+S2pPcz GreuU64x4s/ZBVoAuXKdwjqCjQROONSDsx/TuWikUX0rlJWEGkU9m+urJD4cv/acK+zz5x 5CtRlTxITmWGtBta4LmxkkxBDUEvW18eA/oaplWOeat3ox+Fphd1PwLCezc9laHUhQeJ0H A+sQHG2eEGh3bPtgT7Y2ZCfGWhglMHDcNi7+TcVCH40IpK4PHD6TNqrA80grSv5JiW1y2O bMaxFif3RUx4dJzBIsQdBFCghFZj9PBDUZQA1dORt/D6GS4nJqxq5/HYxadc7w== 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 4TdpL15zNdzjfX; Mon, 19 Feb 2024 16:44:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41JGivNA094563; Mon, 19 Feb 2024 16:44:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41JGivA4094560; Mon, 19 Feb 2024 16:44:57 GMT (envelope-from git) Date: Mon, 19 Feb 2024 16:44:57 GMT Message-Id: <202402191644.41JGivA4094560@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: 628fd849f55e - stable/14 - arm64: Enable FEAT_E0PD when supported 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/14 X-Git-Reftype: branch X-Git-Commit: 628fd849f55e9804331caf63584573dea7a36547 Auto-Submitted: auto-generated The branch stable/14 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=628fd849f55e9804331caf63584573dea7a36547 commit 628fd849f55e9804331caf63584573dea7a36547 Author: Andrew Turner AuthorDate: 2023-09-06 11:07:41 +0000 Commit: Andrew Turner CommitDate: 2024-02-19 13:07:56 +0000 arm64: Enable FEAT_E0PD when supported FEAT_E0PD adds two fields to the tcr_el1 special register that, when set, cause userspace access to either the top or bottom half of the address spaces without a page walk. This can be used to stop userspace probing the kernel address space as the CPU will raise an exception in the same time if the probed address is in the TLB or not. Reviewed by: kevans Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D41760 (cherry picked from commit 9e2cafe4fb901214903484998adf51a6cc5e4ebb) --- sys/arm64/arm64/identcpu.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/sys/arm64/arm64/identcpu.c b/sys/arm64/arm64/identcpu.c index 698a98e3da1d..1e9ff32754f0 100644 --- a/sys/arm64/arm64/identcpu.c +++ b/sys/arm64/arm64/identcpu.c @@ -2259,6 +2259,31 @@ cpu_features_sysinit(void *dummy __unused) /* Log features before APs are released and start printing to the dmesg. */ SYSINIT(cpu_features, SI_SUB_SMP - 1, SI_ORDER_ANY, cpu_features_sysinit, NULL); +static void +tcr_set_e0pd1(void *arg __unused) +{ + uint64_t tcr; + + tcr = READ_SPECIALREG(tcr_el1); + tcr |= TCR_E0PD1; + WRITE_SPECIALREG(tcr_el1, tcr); + isb(); +} + +/* Enable support for more recent architecture features */ +static void +cpu_feat_support(void *arg __unused) +{ + /* + * If FEAT_E0PD is supported use it to cause faults without a page + * table walk if userspace tries to access kernel memory. + */ + if (ID_AA64MMFR2_E0PD_VAL(kern_cpu_desc.id_aa64mmfr2) != + ID_AA64MMFR2_E0PD_NONE) + smp_rendezvous(NULL, tcr_set_e0pd1, NULL, NULL); +} +SYSINIT(cpu_feat_support, SI_SUB_SMP, SI_ORDER_ANY, cpu_feat_support, NULL); + #ifdef COMPAT_FREEBSD32 static u_long parse_cpu_features_hwcap32(void)