Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Aug 2018 09:00:09 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r337118 - stable/11/sys/x86/x86
Message-ID:  <201808020900.w729094l062677@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Thu Aug  2 09:00:09 2018
New Revision: 337118
URL: https://svnweb.freebsd.org/changeset/base/337118

Log:
  MFC r334786: x86: reorganize code that deals with unexpected NMI-s

Modified:
  stable/11/sys/x86/x86/cpu_machdep.c
  stable/11/sys/x86/x86/mp_x86.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/x86/x86/cpu_machdep.c
==============================================================================
--- stable/11/sys/x86/x86/cpu_machdep.c	Thu Aug  2 08:58:33 2018	(r337117)
+++ stable/11/sys/x86/x86/cpu_machdep.c	Thu Aug  2 09:00:09 2018	(r337118)
@@ -768,33 +768,34 @@ SYSCTL_INT(_machdep, OID_AUTO, kdb_on_nmi, CTLFLAG_RWT
     "Go to KDB on NMI with unknown source");
 #endif
 
-#ifdef DEV_ISA
 void
 nmi_call_kdb(u_int cpu, u_int type, struct trapframe *frame)
 {
+	bool claimed = false;
 
+#ifdef DEV_ISA
 	/* machine/parity/power fail/"kitchen sink" faults */
-	if (isa_nmi(frame->tf_err) == 0) {
+	if (isa_nmi(frame->tf_err)) {
+		claimed = true;
+		if (panic_on_nmi)
+			panic("NMI indicates hardware failure");
+	}
+#endif /* DEV_ISA */
 #ifdef KDB
+	if (!claimed && kdb_on_nmi) {
 		/*
 		 * NMI can be hooked up to a pushbutton for debugging.
 		 */
-		if (kdb_on_nmi) {
-			printf("NMI/cpu%d ... going to debugger\n", cpu);
-			kdb_trap(type, 0, frame);
-		}
-#endif /* KDB */
-	} else if (panic_on_nmi) {
-		panic("NMI indicates hardware failure");
+		printf("NMI/cpu%d ... going to debugger\n", cpu);
+		kdb_trap(type, 0, frame);
 	}
+#endif /* KDB */
 }
-#endif
 
 void
 nmi_handle_intr(u_int type, struct trapframe *frame)
 {
 
-#ifdef DEV_ISA
 #ifdef SMP
 	if (nmi_is_broadcast) {
 		nmi_call_kdb_smp(type, frame);
@@ -802,7 +803,6 @@ nmi_handle_intr(u_int type, struct trapframe *frame)
 	}
 #endif
 	nmi_call_kdb(PCPU_GET(cpuid), type, frame);
-#endif
 }
 
 int hw_ibrs_active;

Modified: stable/11/sys/x86/x86/mp_x86.c
==============================================================================
--- stable/11/sys/x86/x86/mp_x86.c	Thu Aug  2 08:58:33 2018	(r337117)
+++ stable/11/sys/x86/x86/mp_x86.c	Thu Aug  2 09:00:09 2018	(r337118)
@@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$");
 #include "opt_apic.h"
 #endif
 #include "opt_cpu.h"
-#include "opt_isa.h"
 #include "opt_kstack_pages.h"
 #include "opt_pmap.h"
 #include "opt_sched.h"
@@ -1233,7 +1232,6 @@ ipi_nmi_handler(void)
 	return (0);
 }
 
-#ifdef DEV_ISA
 int nmi_kdb_lock;
 
 void
@@ -1257,7 +1255,6 @@ nmi_call_kdb_smp(u_int type, struct trapframe *frame)
 	if (call_post)
 		cpustop_handler_post(cpu);
 }
-#endif
 
 /*
  * Handle an IPI_STOP by saving our current context and spinning until we



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201808020900.w729094l062677>