git: 880d2991661d - main - amd64 FRED: get out of NMI blocking mode unconditionally

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

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

commit 880d2991661de74e1f800db867dc9d0eda7b1bc9
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-10-30 12:43:44 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-10-30 13:47:12 +0000

    amd64 FRED: get out of NMI blocking mode unconditionally
    
    When NMI interrupted userspace (ring 3), unconditionally unblock NMI,
    not only for the pmc backtrace sampling. Return to userspace needs
    to deliver ASTs and do userret(), which should not be done with NMIs
    blocking.
    
    Note that NMI from ring 3 is always delivered at stack level 0, i.e. the
    thread's kernel stack.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
---
 sys/amd64/amd64/trap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c
index 9187d881c703..534768abcd59 100644
--- a/sys/amd64/amd64/trap.c
+++ b/sys/amd64/amd64/trap.c
@@ -1643,11 +1643,11 @@ trap_fred_u(struct trapframe_fred *frame)
 	case TF_FRED_EVINFO2_TYPE_NMI:
 		frame->tf_idt.tf_trapno = T_NMI;
 		nmi_handle_intr(&frame->tf_idt);
+		fred_out_of_nmi();
 #ifdef HWPMC_HOOKS
 		if ((td->td_pflags & TDP_CALLCHAIN) != 0) {
 			int (*ph)(struct thread *, int, void *);
 
-			fred_out_of_nmi();
 			ph = atomic_load_ptr(&pmc_hook);
 			if (ph != NULL) {
 				enable_intr();