diff options
author | fabient <fabient@FreeBSD.org> | 2011-12-12 13:12:55 +0000 |
---|---|---|
committer | fabient <fabient@FreeBSD.org> | 2011-12-12 13:12:55 +0000 |
commit | a7b842db79e6f18933fb8b0436f92f66ab983c6e (patch) | |
tree | 034c62b43e6a5e53685919d2cb3afe8147a0fc55 | |
parent | 27797657ef00519d2b84b248c4d4fda10926b316 (diff) | |
download | FreeBSD-src-a7b842db79e6f18933fb8b0436f92f66ab983c6e.zip FreeBSD-src-a7b842db79e6f18933fb8b0436f92f66ab983c6e.tar.gz |
There's a small set of events on Nehalem, that are not supported in
processors with CPUID signature 06_1AH, 06_1EH, and 06_1FH.
Refuse to allocate them on unsupported model.
Submitted by: Davide Italiano <davide.italiano@gmail.com>
MFC after: 1 month
-rw-r--r-- | sys/dev/hwpmc/hwpmc_core.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/sys/dev/hwpmc/hwpmc_core.c b/sys/dev/hwpmc/hwpmc_core.c index 04f6e92..ce1db75 100644 --- a/sys/dev/hwpmc/hwpmc_core.c +++ b/sys/dev/hwpmc/hwpmc_core.c @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include <machine/apicvar.h> #include <machine/cpu.h> #include <machine/cpufunc.h> +#include <machine/md_var.h> #include <machine/specialreg.h> #define CORE_CPUID_REQUEST 0xA @@ -1553,7 +1554,7 @@ static int iap_allocate_pmc(int cpu, int ri, struct pmc *pm, const struct pmc_op_pmcallocate *a) { - int n; + int n, model; enum pmc_event ev; struct iap_event_descr *ie; uint32_t c, caps, config, cpuflag, evsel, mask; @@ -1573,6 +1574,16 @@ iap_allocate_pmc(int cpu, int ri, struct pmc *pm, if (iap_architectural_event_is_unsupported(ev)) return (EOPNOTSUPP); + /* + * A small number of events are not supported in all the + * processors based on a given microarchitecture. + */ + if (ev == PMC_EV_IAP_EVENT_0FH_01H || ev == PMC_EV_IAP_EVENT_0FH_80H) { + model = ((cpu_id & 0xF0000) >> 12) | ((cpu_id & 0xF0) >> 4); + if (core_cputype == PMC_CPU_INTEL_COREI7 && model != 0x2E) + return (EINVAL); + } + switch (core_cputype) { case PMC_CPU_INTEL_COREI7: if (iap_event_corei7_ok_on_counter(ev, ri) == 0) |