git: c6d7235ac15d - main - amd64: handle #AC in kernel mode

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 22 Sep 2026 15:41:48 UTC
The branch main has been updated by kib:

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

commit c6d7235ac15d208435a839bf847dd898d9b1d9fe
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-09-20 16:40:15 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-09-22 15:40:40 +0000

    amd64: handle #AC in kernel mode
    
    Recover from it if PCB_ONFAULT handler is provided.
    
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D59815
---
 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 815d356217f9..f3b06a419d07 100644
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -532,6 +532,14 @@ trap(struct trapframe *frame)
 			return;
 
 		switch (type) {
+		case T_ALIGNFLT:
+			if (curpcb->pcb_onfault != NULL) {
+				frame->tf_rip = (long)curpcb->pcb_onfault;
+				return;
+			}
+			trap_fatal(frame, 0);
+			return;
+
 		case T_PAGEFLT:			/* page fault */
 			(void)trap_pfault(frame, false, NULL, NULL);
 			return;