From nobody Mon Feb 19 16:45:02 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 4TdpL70Flnz5C9Mk; Mon, 19 Feb 2024 16:45:03 +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 4TdpL63ZRwz4bKp; Mon, 19 Feb 2024 16:45:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708361102; 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=AeFqNIJND9OxWaD7TtAbvNws2RCRphvahP0xkwRHFdg=; b=tInWsyDCDkRwur+DFY9w2U+t21Hx+t3RCErs3dbAYpUMvUmTBGgXDVqc7MPTM51Z8/XjiK 4ZuzWFEaR77qKQwzKzg0bfAVqtqV8K0e9cqygN4nBPY3ZhRzY4j+6xcneSel+LZQXrzxMe KFvL9N+2kic+cYtyoG/oH2AR0KpCw0MzjOmFIBVItdFCjQZN+VCXaxsijtUm9qb/cm2G9N FioZ73dw+8Tg5pPUpAw7XA8Fo/NtxLKS5j1HvFolWzLvArbQ2Wz3mLwU4eY+osOHzb6cjQ pXT5fvwK1Gj8FN+kC+3UnbgD9bC34Vaj4BrAUSMVQWRAV5nX1qbWqzwFZxDrug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708361102; 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=AeFqNIJND9OxWaD7TtAbvNws2RCRphvahP0xkwRHFdg=; b=dWWu5rYrcvFw5NURBlm3DjwXEsZcRZNP/Eorg9rlg/jbeF0yYz9Ys0ixSj6RtvzXEVnA0Y zTwT4EFyv3JFUAWI+QB+uJKRjZmQESza0Xzkefhzu/QLkGrzVnCfJpRjHuh2Cc16AO6/8n DZpF2U8Sr91TXIAM9uJTE8nFZCRB5VRttuD5kldDXqZYsVk8V6kyCxi/f0fv3Ar1momtzq YyvcycmPvj8k/GAzW2KnTEkykQEEquy52T95MC9OuX+w8//SrVsutMtWAoFMGnHYFTeDVT 5P881Abnvz3vQea6kY5tCYczuRJw1dxsCon6+BJN0NrGMB7tCiX9qvSxW6Wapg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708361102; a=rsa-sha256; cv=none; b=uiimR48PnmuyCqr08+UnzBynPWLFMkfTuCo/fIWr3IJm9c+JIWxOhSvK4b5NgFk/TCgt14 Xr7eUfocBrmObHohu0GCV8gUUw1JdbAI2D/Sat1HSMg8zPbM5JdCk3KbQff1FpGNMS7o7q HmCJIwOX7H6K5hBVAntuvF7tny3U/+43HsrC4M8lOlb5B5EIJnVxrhGVNqbSsZShaw5kXj a8jbEBmyTLULkbkodiYEEIziVfKyea/CskrsYl7IA1NQjWp7+sA9rkR1WIjOYkwtyDpa2z kMZS8H69bYlmq9VPrBQ6QVIHNBL/MgCC6jr2aRWBgegqpxWrR+COBCyctO/ueA== 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 4TdpL62hXSzjVW; Mon, 19 Feb 2024 16:45:02 +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 41JGj2N4094960; Mon, 19 Feb 2024 16:45:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41JGj2lV094957; Mon, 19 Feb 2024 16:45:02 GMT (envelope-from git) Date: Mon, 19 Feb 2024 16:45:02 GMT Message-Id: <202402191645.41JGj2lV094957@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: 3e3e2ce55be3 - stable/14 - Add BTI exceptions 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: 3e3e2ce55be3c8c9d1f2f83523a403332e747e16 Auto-Submitted: auto-generated The branch stable/14 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=3e3e2ce55be3c8c9d1f2f83523a403332e747e16 commit 3e3e2ce55be3c8c9d1f2f83523a403332e747e16 Author: Andrew Turner AuthorDate: 2023-04-05 12:28:46 +0000 Commit: Andrew Turner CommitDate: 2024-02-19 13:08:50 +0000 Add BTI exceptions We could hit these when executing code marked as using BTI but jumps to a non-branch target instruction. Sponsored by: Arm Ltd Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39450 (cherry picked from commit 450f731b7f2351d475b43bbc6234eea28adfd2b0) --- sys/arm64/arm64/locore.S | 2 +- sys/arm64/arm64/trap.c | 10 ++++++++++ sys/arm64/include/armreg.h | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sys/arm64/arm64/locore.S b/sys/arm64/arm64/locore.S index ac925f13f069..0c3a512cf671 100644 --- a/sys/arm64/arm64/locore.S +++ b/sys/arm64/arm64/locore.S @@ -879,7 +879,7 @@ sctlr_set: .quad (SCTLR_LSMAOE | SCTLR_nTLSMD | SCTLR_UCI | SCTLR_SPAN | \ SCTLR_nTWE | SCTLR_nTWI | SCTLR_UCT | SCTLR_DZE | \ SCTLR_I | SCTLR_SED | SCTLR_SA0 | SCTLR_SA | SCTLR_C | \ - SCTLR_M | SCTLR_CP15BEN) + SCTLR_M | SCTLR_CP15BEN | SCTLR_BT1 | SCTLR_BT0) sctlr_clear: /* Bits to clear */ .quad (SCTLR_EE | SCTLR_E0E | SCTLR_IESB | SCTLR_WXN | SCTLR_UMA | \ diff --git a/sys/arm64/arm64/trap.c b/sys/arm64/arm64/trap.c index 12f43e01630a..2dda8cfc4c20 100644 --- a/sys/arm64/arm64/trap.c +++ b/sys/arm64/arm64/trap.c @@ -559,6 +559,11 @@ do_el1h_sync(struct thread *td, struct trapframe *frame) panic("Undefined instruction: %08x", *(uint32_t *)frame->tf_elr); break; + case EXCP_BTI: + print_registers(frame); + print_gp_register("far", far); + panic("Branch Target exception"); + break; default: print_registers(frame); print_gp_register("far", far); @@ -699,6 +704,11 @@ do_el0_sync(struct thread *td, struct trapframe *frame) (void *)frame->tf_elr, exception); userret(td, frame); break; + case EXCP_BTI: + call_trapsignal(td, SIGILL, ILL_ILLOPC, (void *)frame->tf_elr, + exception); + userret(td, frame); + break; default: call_trapsignal(td, SIGBUS, BUS_OBJERR, (void *)frame->tf_elr, exception); diff --git a/sys/arm64/include/armreg.h b/sys/arm64/include/armreg.h index 8251a687a5d1..953c9af220b9 100644 --- a/sys/arm64/include/armreg.h +++ b/sys/arm64/include/armreg.h @@ -408,6 +408,7 @@ #define EXCP_UNKNOWN 0x00 /* Unkwn exception */ #define EXCP_TRAP_WFI_WFE 0x01 /* Trapped WFI or WFE */ #define EXCP_FP_SIMD 0x07 /* VFP/SIMD trap */ +#define EXCP_BTI 0x0d /* Branch Target Exception */ #define EXCP_ILL_STATE 0x0e /* Illegal execution state */ #define EXCP_SVC32 0x11 /* SVC trap for AArch32 */ #define EXCP_SVC64 0x15 /* SVC trap for AArch64 */