git: 06a534c55900 - stable/15 - amd64 FRED: clear %dr6 on #DB from kernel

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 03 Nov 2026 09:02:14 UTC
The branch stable/15 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=06a534c55900c709d3dc6fe9a9d7ea7eac6016e8

commit 06a534c55900c709d3dc6fe9a9d7ea7eac6016e8
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-10-29 00:57:52 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-11-03 09:01:16 +0000

    amd64 FRED: clear %dr6 on #DB from kernel
    
    (cherry picked from commit 837bb27c93a58a2df2f5203393ffa245b93caf31)
---
 sys/amd64/amd64/trap.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
index 643f4debb0b5..74a1ffd633e1 100644
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -1781,6 +1781,14 @@ trap_fred_handle_k_exc(struct thread *td, struct trapframe_fred *frame,
 	case IDT_DE:
 		break;
 	case IDT_DB:
+		/*
+		 * Clear %dr6 when #DB trapped from kernel mode, so
+		 * that PT_GETDBREGS does not report stale value.  FRED updates
+		 * %dr6 despite providing the same information in the
+		 * tf_fred_evdata field.
+		 */
+		load_dr6(0);
+
 		if (user_dbreg_trap(frame->tf_fred_evdata))
 			return;
 		/* FALLTHROUGH */