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
This commit is contained in:
Mitchell Horne 2021-08-04 14:37:05 -03:00
parent 4f35e8cba2
commit 8399d923a5

View File

@ -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: