From nobody Wed Sep 6 17:43:40 2023 X-Original-To: dev-commits-src-main@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 4RgqVN4wP7z4sTWy; Wed, 6 Sep 2023 17:43:40 +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 4RgqVN4QmMz4D9L; Wed, 6 Sep 2023 17:43:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694022220; 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=jQ1aVJ3XkHN2iugkqk7FH3R/SkLHVJM9yh3yafn1Sgw=; b=xdQX7aTiK+il2SgnWoAtM2OGDl12VC13x7mRQXeXCCWB2iQO4QUe+60pLcglMiD4RkzKRs Q1KRUGUys2H9zKAqYnhnt0AUrNPhKJPnadumyCJ4gU8n1nJR7+z7f3EIyI1J6vL/fwi1X7 GaUZZ/b9lA123BH3MZi8G50oZEgK8KNIvVu/jUCrXPv28UbCOqJpkDczF6lzqLiZ9QXg81 uCa6QPCfBgG4TfUBSJlaBS6VAIhBa9ZAPCxGg61mHC9MveN/W6b9KsT5HUAXnZ6IymnRj1 O2sUi531/UIiCBC359/Y0GnrI/Q/C44Y+78olpJ+XM0l5ca4S8nuYSlN4MxM/g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694022220; a=rsa-sha256; cv=none; b=dVw2QfBIJjy7p4hjeOufycrxwMpbeik4dp50OtAU8futbJmY+DQ/Ks3kZCo6CcrXLBRUMz RYGL4nHo6jystBveLpCzry1PWnstB8bpItMvY3fBRnQxApgJAuSVl5ySEbCdJr/90fMkrw 3QVAvCXowI1UWFqUxl///c/EAaH04nGILsP5R1HgGHdEQyzWeTlSHZZUjTRHa8T4F3A+tG QrGLcRSIvaI96Mr3Km8fo+iHklZ1bg0nJXXu/ICdBkhKyVHCWNBk5aXydMtRCSkcxYhFok xbvMonRmO5eDow35wut15OlIXwWfmRIHcqCmU8pm3V6FPR/6g+KXFXk+EoGUFA== 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=1694022220; 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=jQ1aVJ3XkHN2iugkqk7FH3R/SkLHVJM9yh3yafn1Sgw=; b=pYm0nAtoqnlCml+yHbkwYGQeScAQyMEzseBKnoI5/17OqPD1WwUwxsOH6XlG63kqP3rcoT wjuF8SduMOkL/NdqQoIp46byCzHfUQnbNWW15tt1/8E/oHRFv56vm+TF64hEBlzUj9dvWk z/LQ2XDUsc84v+gAvaFfRE7/CK0/ZbN9eAr4cSExO18i6eoBSTbhBNWH4bFkrIBxItuiUr pEsxLyeLE92IwmOhOmHq3B9KRy+ZvR2OJ/Rknt9icYPINfGaQlJufePn/6f/3mZi3X5Wci Ftj9Ry0CV7MmiaxJUMYYq82KSS4urkUL2FlHVrfVGXeJG9g1g7+Dexfl9qU1ww== 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 4RgqVN3Vw8zBYk; Wed, 6 Sep 2023 17:43:40 +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 386Hheqb002796; Wed, 6 Sep 2023 17:43:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 386HheW5002793; Wed, 6 Sep 2023 17:43:40 GMT (envelope-from git) Date: Wed, 6 Sep 2023 17:43:40 GMT Message-Id: <202309061743.386HheW5002793@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: 9e2cafe4fb90 - main - arm64: Enable FEAT_E0PD when supported List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: 9e2cafe4fb901214903484998adf51a6cc5e4ebb Auto-Submitted: auto-generated The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=9e2cafe4fb901214903484998adf51a6cc5e4ebb commit 9e2cafe4fb901214903484998adf51a6cc5e4ebb Author: Andrew Turner AuthorDate: 2023-09-06 11:07:41 +0000 Commit: Andrew Turner CommitDate: 2023-09-06 17:32:49 +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 --- 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 fced2ffab258..e84ac338497b 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)