aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Horne <mhorne@FreeBSD.org>2021-08-04 17:37:05 +0000
committerMitchell Horne <mhorne@FreeBSD.org>2021-08-04 18:23:22 +0000
commit8399d923a5697b7c194dbd44c33018c94ec42c4e (patch)
treec8298253435809a6835d0bd6b266fb045df640c3
parent4f35e8cba232d9256ab1399b8adfb761988e5eff (diff)
hwpmc_intel: assert for correct nclasses value
This variable is set based on the exact CPU model detected. If this value is set too small, it could lead to a NULL-dereference from an improperly initialized pmc_rowindex_to_classdep array. Though it has been fixed, this was previously the case for Broadwell. Add two asserts to catch this in DEBUG kernels, as it represents a configuration error that may be hard to uncover otherwise. PR: 253687 Reported by: Zhenlei Huang <zlei.huang@gmail.com> Sponsored by: The FreeBSD Foundation
-rw-r--r--sys/dev/hwpmc/hwpmc_intel.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/sys/dev/hwpmc/hwpmc_intel.c b/sys/dev/hwpmc/hwpmc_intel.c
index 02b8fd9431d1..6cc6ae3b50d6 100644
--- a/sys/dev/hwpmc/hwpmc_intel.c
+++ b/sys/dev/hwpmc/hwpmc_intel.c
@@ -255,6 +255,7 @@ pmc_intel_initialize(void)
case PMC_CPU_INTEL_IVYBRIDGE_XEON:
case PMC_CPU_INTEL_HASWELL:
case PMC_CPU_INTEL_HASWELL_XEON:
+ MPASS(nclasses >= PMC_MDEP_CLASS_INDEX_IAF);
error = pmc_core_initialize(pmc_mdep, ncpus, verov);
break;
@@ -296,6 +297,7 @@ pmc_intel_initialize(void)
case PMC_CPU_INTEL_BROADWELL:
case PMC_CPU_INTEL_SANDYBRIDGE:
#endif
+ MPASS(nclasses >= PMC_MDEP_CLASS_INDEX_UCF);
error = pmc_uncore_initialize(pmc_mdep, ncpus);
break;
default: