git: 0d98b06ab1ce - stable/15 - amd64: move code to clear PSL_T on debug exception into a helper

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Fri, 27 Mar 2026 01:52:21 UTC
The branch stable/15 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=0d98b06ab1ce08d5b0b2d403a97d83410f2da425

commit 0d98b06ab1ce08d5b0b2d403a97d83410f2da425
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-03-12 09:40:44 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-03-26 23:42:56 +0000

    amd64: move code to clear PSL_T on debug exception into a helper
    
    (cherry picked from commit d92ebde76430e99f78156fb1d865a18916380aed)
---
 sys/amd64/amd64/trap.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
index 6393da186db5..3a9323936d2d 100644
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -249,6 +249,17 @@ trap_check_pcb_onfault(struct thread *td, struct trapframe *frame)
 	return (res);
 }
 
+static void
+trap_clear_step(struct thread *td, struct trapframe *frame)
+{
+	PROC_LOCK(td->td_proc);
+	if ((td->td_dbgflags & TDB_STEP) != 0) {
+		td->td_frame->tf_rflags &= ~PSL_T;
+		td->td_dbgflags &= ~TDB_STEP;
+	}
+	PROC_UNLOCK(td->td_proc);
+}
+
 /*
  * Table of handlers for various segment load faults.
  */
@@ -395,14 +406,8 @@ trap(struct trapframe *frame)
 			signo = SIGTRAP;
 			ucode = TRAP_TRACE;
 			dr6 = rdr6();
-			if ((dr6 & DBREG_DR6_BS) != 0) {
-				PROC_LOCK(td->td_proc);
-				if ((td->td_dbgflags & TDB_STEP) != 0) {
-					td->td_frame->tf_rflags &= ~PSL_T;
-					td->td_dbgflags &= ~TDB_STEP;
-				}
-				PROC_UNLOCK(td->td_proc);
-			}
+			if ((dr6 & DBREG_DR6_BS) != 0)
+				trap_clear_step(td, frame);
 			break;
 
 		case T_ARITHTRAP:	/* arithmetic trap */