From owner-svn-src-all@freebsd.org Thu Jun 7 14:46:54 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BDD04FF9C83; Thu, 7 Jun 2018 14:46:54 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6C04D6D271; Thu, 7 Jun 2018 14:46:54 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E1D9721897; Thu, 7 Jun 2018 14:46:53 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w57EkrFh071775; Thu, 7 Jun 2018 14:46:53 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w57EkqKO071774; Thu, 7 Jun 2018 14:46:52 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201806071446.w57EkqKO071774@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 7 Jun 2018 14:46:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334786 - head/sys/x86/x86 X-SVN-Group: head X-SVN-Commit-Author: avg X-SVN-Commit-Paths: head/sys/x86/x86 X-SVN-Commit-Revision: 334786 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jun 2018 14:46:55 -0000 Author: avg Date: Thu Jun 7 14:46:52 2018 New Revision: 334786 URL: https://svnweb.freebsd.org/changeset/base/334786 Log: x86: reorganize code that deals with unexpected NMI-s Expected NMI-s are those than are either generated by the software (such as a CPU sending NMI to other CPU) or generated by the hardware after the software configured it to do so (such as NMI-s on PMC events). Some unexpected NMI-s can be caused by hardware failures and it is possible to inquire the hardware about them (somewhat like MCA but much more primitive) using an EISA mechanism. In some cases the origin of the NMI can remain truly unknown. This commit should not change any functionality. It just reorganizes the code, so that it is easier to extend with new checks for the origin of the NMI. Also, it frees the code that has nothing to do with ISA from DEV_ISA. MFC after: 3 weeks Modified: head/sys/x86/x86/cpu_machdep.c head/sys/x86/x86/mp_x86.c Modified: head/sys/x86/x86/cpu_machdep.c ============================================================================== --- head/sys/x86/x86/cpu_machdep.c Thu Jun 7 14:23:31 2018 (r334785) +++ head/sys/x86/x86/cpu_machdep.c Thu Jun 7 14:46:52 2018 (r334786) @@ -735,33 +735,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); @@ -769,7 +770,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: head/sys/x86/x86/mp_x86.c ============================================================================== --- head/sys/x86/x86/mp_x86.c Thu Jun 7 14:23:31 2018 (r334785) +++ head/sys/x86/x86/mp_x86.c Thu Jun 7 14:46:52 2018 (r334786) @@ -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" @@ -1339,7 +1338,6 @@ ipi_nmi_handler(void) return (0); } -#ifdef DEV_ISA int nmi_kdb_lock; void @@ -1363,7 +1361,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