git: 2efebd04b4be - stable/15 - amd64 FRED: handle in-kernel faults same as IDT

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

URL: https://cgit.FreeBSD.org/src/commit/?id=2efebd04b4bed3e75898d5d74830e119ea45244e

commit 2efebd04b4bed3e75898d5d74830e119ea45244e
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-10-28 13:58:49 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-11-03 09:01:15 +0000

    amd64 FRED: handle in-kernel faults same as IDT
    
    (cherry picked from commit efb0c54c7694798214a2c130ec8461a34444e1c4)
---
 sys/amd64/amd64/trap.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
index ba0b8a5a233e..9087d3754bca 100644
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -1762,8 +1762,17 @@ trap_fred_handle_k_exc(struct thread *td, struct trapframe_fred *frame,
 	 * there is no sense to enable interrupts.
 	 */
 
-	if (exc != IDT_PF && trap_check_pcb_onfault(td, &frame->tf_idt))
-		return;
+	if (exc != IDT_DF && exc != IDT_MC) {
+#ifdef KDB
+		if (kdb_active) {
+			kdb_reenter();
+			return;
+		}
+#endif
+		if (exc != IDT_PF && trap_check_pcb_onfault(td,
+		    &frame->tf_idt))
+			return;
+	}
 
 	switch (exc) {
 	case IDT_DE: