Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Apr 2018 20:29:41 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r332971 - head/sys/x86/x86
Message-ID:  <201804242029.w3OKTfLd029457@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Tue Apr 24 20:29:40 2018
New Revision: 332971
URL: https://svnweb.freebsd.org/changeset/base/332971

Log:
  Ensure that cmci_monitor() is not executed in parallel, since shared
  machine check banks must be only monitored by single CPU.
  
  Noted and reviewed by:	jhb
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week
  Differential revision:	https://reviews.freebsd.org/D15157

Modified:
  head/sys/x86/x86/mca.c

Modified: head/sys/x86/x86/mca.c
==============================================================================
--- head/sys/x86/x86/mca.c	Tue Apr 24 20:22:30 2018	(r332970)
+++ head/sys/x86/x86/mca.c	Tue Apr 24 20:29:40 2018	(r332971)
@@ -1119,6 +1119,14 @@ _mca_init(int boot)
 			if ((mask & (1UL << 5)) == 0)
 				wrmsr(MSR_MC0_CTL_MASK, mask | (1UL << 5));
 		}
+
+		/*
+		 * The cmci_monitor() must not be executed
+		 * simultaneously by several CPUs.
+		 */
+		if (boot)
+			mtx_lock_spin(&mca_lock);
+
 		for (i = 0; i < (mcg_cap & MCG_CAP_COUNT); i++) {
 			/* By default enable logging of all errors. */
 			ctl = 0xffffffffffffffffUL;
@@ -1158,6 +1166,8 @@ _mca_init(int boot)
 			/* Clear all errors. */
 			wrmsr(MSR_MC_STATUS(i), 0);
 		}
+		if (boot)
+			mtx_unlock_spin(&mca_lock);
 
 #ifdef DEV_APIC
 		if (!amd_thresholding_supported() &&



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