Date: Mon, 15 Feb 2021 19:47:10 GMT From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: dadf603f0f7b - stable/12 - mca: Handle inconsistent CMCI capability reporting Message-ID: <202102151947.11FJlAv6012478@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=dadf603f0f7b54c65fa5f16f552ae6da12f8210b commit dadf603f0f7b54c65fa5f16f552ae6da12f8210b Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2021-02-08 19:42:54 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2021-02-15 19:47:04 +0000 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) (cherry picked from commit b5770470276268acef21368b3e77a325df883500) --- sys/x86/x86/mca.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sys/x86/x86/mca.c b/sys/x86/x86/mca.c index d1488ff0ff82..1d2cc56e117d 100644 --- a/sys/x86/x86/mca.c +++ b/sys/x86/x86/mca.c @@ -913,6 +913,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. */ @@ -957,6 +971,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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202102151947.11FJlAv6012478>