aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2021-02-08 19:42:54 +0000
committerMark Johnston <markj@FreeBSD.org>2021-02-08 19:42:54 +0000
commitb5770470276268acef21368b3e77a325df883500 (patch)
treec00698e80457d573ca42809f834b78d8bd78bc62 /sys
parent7da3bfc20ca8aca8177b677cba37c9f52714605c (diff)
downloadsrc-b5770470276268acef21368b3e77a325df883500.tar.gz
src-b5770470276268acef21368b3e77a325df883500.zip
mca: Handle inconsistent CMCI capability reporting
A BIOS bug may apparently cause the BSP to report that it does not implement CMCI, with some APs reporting that they do. In this scenario, avoid a NULL pointer dereference that occurs in cmci_monitor() because cmc_state was not allocated by the BSP. PR: 253272 Reported by: asomers, mmacy Reviewed by: kib (previous version) MFC after: 1 week
Diffstat (limited to 'sys')
-rw-r--r--sys/x86/x86/mca.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/sys/x86/x86/mca.c b/sys/x86/x86/mca.c
index 03100e77d455..801e18073a52 100644
--- a/sys/x86/x86/mca.c
+++ b/sys/x86/x86/mca.c
@@ -1070,6 +1070,20 @@ cmci_monitor(int i)
KASSERT(i < mca_banks, ("CPU %d has more MC banks", PCPU_GET(cpuid)));
+ /*
+ * It is possible for some APs to report CMCI support even if the BSP
+ * does not, apparently due to a BIOS bug.
+ */
+ if (cmc_state == NULL) {
+ if (bootverbose) {
+ printf(
+ "AP %d (%d,%d) reports CMCI support but the BSP does not\n",
+ PCPU_GET(cpuid), PCPU_GET(apic_id),
+ PCPU_GET(acpi_id));
+ }
+ return;
+ }
+
ctl = rdmsr(MSR_MC_CTL2(i));
if (ctl & MC_CTL2_CMCI_EN)
/* Already monitored by another CPU. */
@@ -1114,6 +1128,10 @@ cmci_resume(int i)
KASSERT(i < mca_banks, ("CPU %d has more MC banks", PCPU_GET(cpuid)));
+ /* See cmci_monitor(). */
+ if (cmc_state == NULL)
+ return;
+
/* Ignore banks not monitored by this CPU. */
if (!(PCPU_GET(cmci_mask) & 1 << i))
return;