aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Moeller <freqlabs@FreeBSD.org>2020-07-14 22:25:06 +0000
committerRyan Moeller <freqlabs@FreeBSD.org>2020-07-14 22:25:06 +0000
commitef013ceecd0d7269768a57727666410d314ae8e9 (patch)
tree01b023867dc90e1d0ad700b291e4c90597fd479f
parent34c2f79d835569e758b3d448e672a2ca81541f0a (diff)
downloadsrc-ef013ceecd0d7269768a57727666410d314ae8e9.tar.gz
src-ef013ceecd0d7269768a57727666410d314ae8e9.zip
hwpmc: Always set pmc_cpuid to something
pmc_cpuid was uninitialized for most AMD processor families. We can still populate this string for unimplemented families. Also added a CPUID_TO_STEPPING macro and converted existing code to use it. Reviewed by: mav MFC after: 2 weeks Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D25673
Notes
Notes: svn path=/head/; revision=363206
-rw-r--r--sys/dev/coretemp/coretemp.c2
-rw-r--r--sys/dev/hwpmc/hwpmc_amd.c18
-rw-r--r--sys/dev/hwpmc/hwpmc_intel.c10
-rw-r--r--sys/x86/include/specialreg.h1
4 files changed, 18 insertions, 13 deletions
diff --git a/sys/dev/coretemp/coretemp.c b/sys/dev/coretemp/coretemp.c
index bfbc49835c35..884ed6309f0e 100644
--- a/sys/dev/coretemp/coretemp.c
+++ b/sys/dev/coretemp/coretemp.c
@@ -166,7 +166,7 @@ coretemp_attach(device_t dev)
sc->sc_dev = dev;
pdev = device_get_parent(dev);
cpu_model = CPUID_TO_MODEL(cpu_id);
- cpu_stepping = cpu_id & CPUID_STEPPING;
+ cpu_stepping = CPUID_TO_STEPPING(cpu_id);
/*
* Some CPUs, namely the PIII, don't have thermal sensors, but
diff --git a/sys/dev/hwpmc/hwpmc_amd.c b/sys/dev/hwpmc/hwpmc_amd.c
index ca139b6fd8a6..d54cf52f1082 100644
--- a/sys/dev/hwpmc/hwpmc_amd.c
+++ b/sys/dev/hwpmc/hwpmc_amd.c
@@ -1073,7 +1073,7 @@ pmc_amd_initialize(void)
enum pmc_cputype cputype;
struct pmc_mdep *pmc_mdep;
enum pmc_class class;
- int model, stepping;
+ int family, model, stepping;
char *name;
/*
@@ -1085,14 +1085,16 @@ pmc_amd_initialize(void)
*/
name = NULL;
- model = ((cpu_id & 0xF0000) >> 12) | ((cpu_id & 0xF0) >> 4);
- stepping = cpu_id & 0xF;
- if (CPUID_TO_FAMILY(cpu_id) == 0x17)
- snprintf(pmc_cpuid, sizeof(pmc_cpuid), "AuthenticAMD-%d-%02X-%X",
- CPUID_TO_FAMILY(cpu_id), model, stepping);
- if (CPUID_TO_FAMILY(cpu_id) == 0x18)
+ family = CPUID_TO_FAMILY(cpu_id);
+ model = CPUID_TO_MODEL(cpu_id);
+ stepping = CPUID_TO_STEPPING(cpu_id);
+
+ if (family == 0x18)
snprintf(pmc_cpuid, sizeof(pmc_cpuid), "HygonGenuine-%d-%02X-%X",
- CPUID_TO_FAMILY(cpu_id), model, stepping);
+ family, model, stepping);
+ else
+ snprintf(pmc_cpuid, sizeof(pmc_cpuid), "AuthenticAMD-%d-%02X-%X",
+ family, model, stepping);
switch (cpu_id & 0xF00) {
#if defined(__i386__)
diff --git a/sys/dev/hwpmc/hwpmc_intel.c b/sys/dev/hwpmc/hwpmc_intel.c
index c16d6f949670..aec037b64938 100644
--- a/sys/dev/hwpmc/hwpmc_intel.c
+++ b/sys/dev/hwpmc/hwpmc_intel.c
@@ -80,7 +80,7 @@ pmc_intel_initialize(void)
{
struct pmc_mdep *pmc_mdep;
enum pmc_cputype cputype;
- int error, model, nclasses, ncpus, stepping, verov;
+ int error, family, model, nclasses, ncpus, stepping, verov;
KASSERT(cpu_vendor_id == CPU_VENDOR_INTEL,
("[intel,%d] Initializing non-intel processor", __LINE__));
@@ -91,11 +91,13 @@ pmc_intel_initialize(void)
nclasses = 2;
error = 0;
verov = 0;
- model = ((cpu_id & 0xF0000) >> 12) | ((cpu_id & 0xF0) >> 4);
- stepping = cpu_id & 0xF;
+ family = CPUID_TO_FAMILY(cpu_id);
+ model = CPUID_TO_MODEL(cpu_id);
+ stepping = CPUID_TO_STEPPING(cpu_id);
snprintf(pmc_cpuid, sizeof(pmc_cpuid), "GenuineIntel-%d-%02X-%X",
- (cpu_id & 0xF00) >> 8, model, stepping);
+ family, model, stepping);
+
switch (cpu_id & 0xF00) {
case 0x600: /* Pentium Pro, Celeron, Pentium II & III */
switch (model) {
diff --git a/sys/x86/include/specialreg.h b/sys/x86/include/specialreg.h
index 2c7f15e3b10c..16010bf76b46 100644
--- a/sys/x86/include/specialreg.h
+++ b/sys/x86/include/specialreg.h
@@ -280,6 +280,7 @@
((((id) & CPUID_FAMILY) >> 8) + \
(((id) & CPUID_EXT_FAMILY) >> 20))
#endif
+#define CPUID_TO_STEPPING(id) ((id) & CPUID_STEPPING)
/*
* CPUID instruction 1 ebx info