From nobody Mon Feb 19 16:44:45 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 4TdpKr0kYnz5C984; Mon, 19 Feb 2024 16:44:48 +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 4TdpKp1XNdz4Zr8; Mon, 19 Feb 2024 16:44:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708361086; 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=InXX6hKhjhEGHZpBZgrVSpSNjBiHNdGZI2IGSs/RZN8=; b=vSHDuQSooR1mK7bbemayOkOlHzI/QLY5FTf2vctEYtaBgVRfNq9F1BFfwZT/ybp1Ghj3LK NGhnDgleCn0de1bPLNkkCmSxre6l17aI/CSXmcZ7gH+Q/WHH+lLM0GAQNmEdDS0k9z2k8b lldmaoED7wKB7JiQVeoi7n2+rDXHNt4paXfS7ZOrdhFP62E5tvhuAbvPShFSnQiD0DH8wo k5KWEpS6myf+10L/Ph6L7x11hp/o+b1fIMBJDoqMzGeivJWT8a9acIWBwmw0Beuj1u7t4F Ffcn872dTcpJKG3BPAFVPdrbAH/S4LEaDhhocVtXYcWul6wg4FvxmSCAHRJPYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708361086; 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=InXX6hKhjhEGHZpBZgrVSpSNjBiHNdGZI2IGSs/RZN8=; b=J91VMdmXk/HVpDamtmO6Qjawk4P1GAv99+tkthqpV8td26lYSsEd6TJEf3pMVJfsNrpvtO al/J0haFPiUydCbqlpw2VwpPJ/NdiXrRKCdoAacQkwKyWmDQ0ignI3LILtAObpRA6tkBoL jNEoB6ge90wrA2kS36yfDksRgwPYOpooCMVtpey39+fz/IsnzF739myJYJMvYX2MdbQsRM 0aBQA6QwsK+Nssrl86A1+Nk3lNRGDeAsH3TF7EMxN0JGV80guAotk56XqMHI/GZkGhVIoA QFrldgWprhuhz0B1hPNPUovP9L8fkyP2VRBmi9tGQO4KoFzV/Fr+9ksYRBuqlw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708361086; a=rsa-sha256; cv=none; b=FI0C5s7LA+CRVu+8HJnr9oDIObnTt5ltCyDOogKTy6jCTdsiYUe9GD0XL9FreQohu1/Is5 JB8OJU12MgtVaSx1YE1kpBMS7NOTAzaTvKiTW4YqdzgJuJhzbaeO7t8GxyysvzHgnT4t83 VgZ77tNOxdDZKGj9AZKAwoHoz/bA6zjiaf7f3Vbsmq4dgDz+ErDkxnXfTGCAsP+p3hOmai 8YdBVuz7d2QaEUhpfUoy5TwIuR7Yx9xhx3d2qaOuDOpItcWpKFzbP/3BbEpXRGaSq1HGcG xexJFhTcXnH3K1+XXLcUQC2NsSuCPH/q4mXfS7rkgfIrbnc2rdm6CsgEpdp2RQ== 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 4TdpKp0chQzjDH; Mon, 19 Feb 2024 16:44:46 +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 41JGijH0093812; Mon, 19 Feb 2024 16:44:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41JGijB8093809; Mon, 19 Feb 2024 16:44:45 GMT (envelope-from git) Date: Mon, 19 Feb 2024 16:44:45 GMT Message-Id: <202402191644.41JGijB8093809@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: 9fbac657f11b - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: 9fbac657f11b868186ea4ad52af203d9c94ebb51 Auto-Submitted: auto-generated The branch stable/13 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=9fbac657f11b868186ea4ad52af203d9c94ebb51 commit 9fbac657f11b868186ea4ad52af203d9c94ebb51 Author: Andrew Turner AuthorDate: 2023-09-06 11:07:41 +0000 Commit: Andrew Turner CommitDate: 2024-02-19 12:37:44 +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 200841782f03..cb7850c2aa2a 100644 --- a/sys/arm64/arm64/identcpu.c +++ b/sys/arm64/arm64/identcpu.c @@ -2090,6 +2090,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)