From nobody Mon Feb 19 16:44:50 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 4TdpKv0Cslz5C93T; Mon, 19 Feb 2024 16:44:51 +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 4TdpKt5j2zz4b79; Mon, 19 Feb 2024 16:44:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708361090; 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=etUdzcF0KYBf/KENeizcBzZx5lR9MW/hvC3MBVWDYrQ=; b=sgEi+u555LjWaHk+AdS3/JfEQtAKdcXa9/9m0JRuiaCRCiNTD4Gz/zl/8Jx5JRVWW34nB2 Ju6JwFbMs4bQY0XKmSYxOWOUYAuKpAQx8ggWYGXAa+6NI8IMo2eTH9eltL4juDDlaGRSbN eHYvwEcCqGwc9SoYVOWZoTkE/8bO0sIWYtt5IuAwElnDED1EEDLFAVTajUWFVMNFarpmak hJJZ9aFLjZ4AdB6FxFniw8BbNFil7/+sAWXkPtVGy2WmQuD/x51vMJ8/X8Y7CI08e0OC1+ KEZjWM0e732Jcavqr2Tj9DWnSk34E6mWNXGdRP2panQiRNBHyrg2GyoB4aQFaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708361090; 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=etUdzcF0KYBf/KENeizcBzZx5lR9MW/hvC3MBVWDYrQ=; b=PwS8DoTP0KhAMURkjOe8jt66jQJ5aWbaijhG0AoxRBnc+Z9vV/+vG8MRumeCv9Dk0GcQYV K/wkuTsOi8S2YlTP6YEQCfGSxloWXPK543Zcxuctl/smPLj7LPCHv65QZ72s8g7tBb0tWc GmHDQzQAyvj0szDRY9XyTsA158fdyrbJRg1415exQQ2qqA5zwGnbmFQseo8kkrlHsGKmK6 7OuRksrLdtROEdVYANfZ7CIQBaorgw2wvcDnyvLq8whbGhh5oWdKYdJxaR4QyEJgMahkTn j5HzfHRqHg4pObHKhKQTOZp7ZRzbfMHF6dF60HoArwgZAWg0H1d5y0hok1PWMQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708361090; a=rsa-sha256; cv=none; b=eeCspeEjUjvh+M5QUMIHU3ol0/vdmuECSq4uCSF9AyLVIR9KS+i8AMWIoSBtqHiK8YHEzz c9XL8Q0PV7vibKoSOn9RNAUi3TRKd3L/1V65JSu2DtFadnXh0vmclH2PfKNsdbDZY5M86H W99KR02LY+Z/l4qG2ZHoYEHNBmMahLUl5WnuM8aHjfXWxfz66DM80DtlqgDM6WScRJCJxl zd2Ddb+fGeOl/uFSCFYoNfHzJXp3cVg6To9JxF/r60dA9cf+J/MQCX8y3VFoFDsnUayTqG hqjN2atCGrr52lZG+V37NACCztnng81mFdKECNP/A+G5X16TH3a9TB2pvnKvyQ== 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 4TdpKt4WZ2zjSM; Mon, 19 Feb 2024 16:44:50 +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 41JGioJo093989; Mon, 19 Feb 2024 16:44:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41JGioRd093986; Mon, 19 Feb 2024 16:44:50 GMT (envelope-from git) Date: Mon, 19 Feb 2024 16:44:50 GMT Message-Id: <202402191644.41JGioRd093986@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: ed304b0be0df - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: ed304b0be0df1e89e50f8463f0a46989b66acc1f Auto-Submitted: auto-generated The branch stable/13 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=ed304b0be0df1e89e50f8463f0a46989b66acc1f commit ed304b0be0df1e89e50f8463f0a46989b66acc1f Author: Andrew Turner AuthorDate: 2023-04-05 12:28:46 +0000 Commit: Andrew Turner CommitDate: 2024-02-19 12:39:49 +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 | 11 +++++++++++ sys/arm64/include/armreg.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sys/arm64/arm64/locore.S b/sys/arm64/arm64/locore.S index 4712f8591b8b..d48984e39a59 100644 --- a/sys/arm64/arm64/locore.S +++ b/sys/arm64/arm64/locore.S @@ -737,7 +737,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 d62ebba3debd..d6f847d6b88c 100644 --- a/sys/arm64/arm64/trap.c +++ b/sys/arm64/arm64/trap.c @@ -526,6 +526,12 @@ do_el1h_sync(struct thread *td, struct trapframe *frame) panic("Undefined instruction: %08x", *(uint32_t *)frame->tf_elr); break; + case EXCP_BTI: + far = READ_SPECIALREG(far_el1); + print_registers(frame); + print_gp_register("far", far); + panic("Branch Target exception"); + break; default: print_registers(frame); print_gp_register("far", READ_SPECIALREG(far_el1)); @@ -660,6 +666,11 @@ do_el0_sync(struct thread *td, struct trapframe *frame, uint64_t far) (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 e2395951f524..098c55361913 100644 --- a/sys/arm64/include/armreg.h +++ b/sys/arm64/include/armreg.h @@ -411,6 +411,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 */