git: 91d9fbb6e153 - main - amd64 FRED: enable interrupts after user EXTINTs and NMIs

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Fri, 30 Oct 2026 13:47:47 UTC
The branch main has been updated by kib:

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

commit 91d9fbb6e1537009c35ec0c1c37ca09b28c0b31d
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-10-30 13:01:15 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-10-30 13:47:12 +0000

    amd64 FRED: enable interrupts after user EXTINTs and NMIs
    
    This is needed to run userret() with interrupts enabled.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
---
 sys/amd64/amd64/trap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
index 534768abcd59..ff426a8995e1 100644
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -1639,20 +1639,20 @@ trap_fred_u(struct trapframe_fred *frame)
 	switch (type) {
 	case TF_FRED_EVINFO2_TYPE_EXTINT:
 		trap_fred_extint(frame, vec);
+		enable_intr();
 		break;
 	case TF_FRED_EVINFO2_TYPE_NMI:
 		frame->tf_idt.tf_trapno = T_NMI;
 		nmi_handle_intr(&frame->tf_idt);
 		fred_out_of_nmi();
+		enable_intr();
 #ifdef HWPMC_HOOKS
 		if ((td->td_pflags & TDP_CALLCHAIN) != 0) {
 			int (*ph)(struct thread *, int, void *);
 
 			ph = atomic_load_ptr(&pmc_hook);
-			if (ph != NULL) {
-				enable_intr();
+			if (ph != NULL)
 				ph(td, PMC_FN_USER_CALLCHAIN, &frame->tf_idt);
-			}
 		}
 #endif
 		break;