aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/amd64/amd64/trap.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
index 480728e9749f..d59b689c56b6 100644
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -1785,6 +1785,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 */