summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2015-05-28 20:10:59 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2015-05-28 20:10:59 +0000
commit9720dcf9b0f447cb8683388f03629410cd4b255a (patch)
treec9a4d56527132ba0a2a541b86cba5cb56dee2931
parent86241f3476e7a76d21eda4b22cb2da3381bab123 (diff)
Save the cpuid(6) eax bits in the cpu_info and report the SENSOR and ARAT
bits from it. ok krw@ kettenis@
-rw-r--r--sys/arch/amd64/amd64/identcpu.c31
-rw-r--r--sys/arch/amd64/include/cpu.h3
-rw-r--r--sys/arch/amd64/include/specialreg.h8
-rw-r--r--sys/arch/i386/i386/machdep.c30
-rw-r--r--sys/arch/i386/include/cpu.h3
-rw-r--r--sys/arch/i386/include/specialreg.h8
6 files changed, 58 insertions, 25 deletions
diff --git a/sys/arch/amd64/amd64/identcpu.c b/sys/arch/amd64/amd64/identcpu.c
index da9682a76bf..ed7dbd336d7 100644
--- a/sys/arch/amd64/amd64/identcpu.c
+++ b/sys/arch/amd64/amd64/identcpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: identcpu.c,v 1.61 2015/03/14 03:38:46 jsg Exp $ */
+/* $OpenBSD: identcpu.c,v 1.62 2015/05/28 20:10:58 guenther Exp $ */
/* $NetBSD: identcpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */
/*
@@ -161,6 +161,9 @@ const struct {
{ SEFF0EBX_RDSEED, "RDSEED" },
{ SEFF0EBX_ADX, "ADX" },
{ SEFF0EBX_SMAP, "SMAP" },
+}, cpu_tpm_eaxfeatures[] = {
+ { TPM_SENSOR, "SENSOR" },
+ { TPM_ARAT, "ARAT" },
}, cpu_cpuid_perf_eax[] = {
{ CPUIDEAX_VERID, "PERF" },
}, cpu_cpuid_apmi_edx[] = {
@@ -522,6 +525,14 @@ identifycpu(struct cpu_info *ci)
printf(",%s", cpu_seff0_ebxfeatures[i].str);
}
+ if (!strcmp(cpu_vendor, "GenuineIntel") && cpuid_level >= 0x06 ) {
+ CPUID(0x06, ci->ci_feature_tpmflags, dummy, dummy, dummy);
+ for (i = 0; i < nitems(cpu_tpm_eaxfeatures); i++)
+ if (ci->ci_feature_tpmflags &
+ cpu_tpm_eaxfeatures[i].bit)
+ printf(",%s", cpu_tpm_eaxfeatures[i].str);
+ }
+
printf("\n");
x86_print_cacheinfo(ci);
@@ -561,17 +572,13 @@ identifycpu(struct cpu_info *ci)
ci->ci_cflushsz = ((cflushsz >> 8) & 0xff) * 8;
}
- if (CPU_IS_PRIMARY(ci) && !strcmp(cpu_vendor, "GenuineIntel") &&
- cpuid_level >= 0x06 ) {
- CPUID(0x06, val, dummy, dummy, dummy);
- if (val & 0x1) {
- strlcpy(ci->ci_sensordev.xname, ci->ci_dev->dv_xname,
- sizeof(ci->ci_sensordev.xname));
- ci->ci_sensor.type = SENSOR_TEMP;
- sensor_task_register(ci, intelcore_update_sensor, 5);
- sensor_attach(&ci->ci_sensordev, &ci->ci_sensor);
- sensordev_install(&ci->ci_sensordev);
- }
+ if (CPU_IS_PRIMARY(ci) && (ci->ci_feature_tpmflags & TPM_SENSOR)) {
+ strlcpy(ci->ci_sensordev.xname, ci->ci_dev->dv_xname,
+ sizeof(ci->ci_sensordev.xname));
+ ci->ci_sensor.type = SENSOR_TEMP;
+ sensor_task_register(ci, intelcore_update_sensor, 5);
+ sensor_attach(&ci->ci_sensordev, &ci->ci_sensor);
+ sensordev_install(&ci->ci_sensordev);
}
#endif
diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h
index fb010dc87f4..a521fd6e773 100644
--- a/sys/arch/amd64/include/cpu.h
+++ b/sys/arch/amd64/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.92 2015/05/18 19:59:27 guenther Exp $ */
+/* $OpenBSD: cpu.h,v 1.93 2015/05/28 20:10:58 guenther Exp $ */
/* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */
/*-
@@ -92,6 +92,7 @@ struct cpu_info {
u_int32_t ci_feature_flags;
u_int32_t ci_feature_eflags;
u_int32_t ci_feature_sefflags;
+ u_int32_t ci_feature_tpmflags;
u_int32_t ci_signature;
u_int32_t ci_family;
u_int32_t ci_model;
diff --git a/sys/arch/amd64/include/specialreg.h b/sys/arch/amd64/include/specialreg.h
index 7cf92377f28..39ceef0cf30 100644
--- a/sys/arch/amd64/include/specialreg.h
+++ b/sys/arch/amd64/include/specialreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: specialreg.h,v 1.35 2015/04/19 19:45:21 sf Exp $ */
+/* $OpenBSD: specialreg.h,v 1.36 2015/05/28 20:10:58 guenther Exp $ */
/* $NetBSD: specialreg.h,v 1.1 2003/04/26 18:39:48 fvdl Exp $ */
/* $NetBSD: x86/specialreg.h,v 1.2 2003/04/25 21:54:30 fvdl Exp $ */
@@ -185,6 +185,12 @@
#define SEFF0EBX_ADX 0x00080000 /* ADCX/ADOX instructions */
#define SEFF0EBX_SMAP 0x00100000 /* Supervisor mode access prevent */
+/*
+ * Thermal and Power Management (CPUID function 0x6) EAX bits
+ */
+#define TPM_SENSOR 0x00000001 /* Digital temp sensor */
+#define TPM_ARAT 0x00000004 /* APIC Timer Always Running */
+
/*
* "Architectural Performance Monitoring" bits (CPUID function 0x0a):
* EAX bits, EBX bits, EDX bits.
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index 40f0a9bfac0..1aa2ba82fbd 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.569 2015/04/18 22:16:21 kettenis Exp $ */
+/* $OpenBSD: machdep.c,v 1.570 2015/05/28 20:10:58 guenther Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -1077,6 +1077,11 @@ const struct cpu_cpuid_feature cpu_seff0_ebxfeatures[] = {
{ SEFF0EBX_SMAP, "SMAP" },
};
+const struct cpu_cpuid_feature cpu_tpm_eaxfeatures[] = {
+ { TPM_SENSOR, "SENSOR" },
+ { TPM_ARAT, "ARAT" },
+};
+
const struct cpu_cpuid_feature i386_cpuid_eaxperf[] = {
{ CPUIDEAX_VERID, "PERF" },
};
@@ -1481,14 +1486,7 @@ intelcore_update_sensor(void *args)
void
intel686_cpusensors_setup(struct cpu_info *ci)
{
- u_int regs[4];
-
- if (!CPU_IS_PRIMARY(ci) || cpuid_level < 0x06)
- return;
-
- /* CPUID.06H.EAX[0] = 1 tells us if we have on-die sensor */
- cpuid(0x06, regs);
- if ((regs[0] & 0x01) != 1)
+ if (!CPU_IS_PRIMARY(ci) || (ci->ci_feature_tpmflags & TPM_SENSOR) == 0)
return;
/* Setup the sensors structures */
@@ -1988,6 +1986,20 @@ identifycpu(struct cpu_info *ci)
(numbits == 0 ? "" : ","),
cpu_seff0_ebxfeatures[i].feature_name);
}
+
+ if (!strcmp(cpu_vendor, "GenuineIntel") &&
+ cpuid_level >= 0x06 ) {
+ u_int dummy;
+
+ CPUID(0x06, ci->ci_feature_tpmflags, dummy,
+ dummy, dummy);
+ max = nitems(cpu_tpm_eaxfeatures);
+ for (i = 0; i < max; i++)
+ if (ci->ci_feature_tpmflags &
+ cpu_tpm_eaxfeatures[i].feature_bit)
+ printf(",%s", cpu_tpm_eaxfeatures[i].feature_name);
+ }
+
printf("\n");
}
}
diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h
index 14033d378d0..623154e993d 100644
--- a/sys/arch/i386/include/cpu.h
+++ b/sys/arch/i386/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.139 2015/04/18 22:16:21 kettenis Exp $ */
+/* $OpenBSD: cpu.h,v 1.140 2015/05/28 20:10:58 guenther Exp $ */
/* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */
/*-
@@ -118,6 +118,7 @@ struct cpu_info {
u_int32_t ci_model; /* extended cpuid model */
u_int32_t ci_feature_flags; /* X86 CPUID feature bits */
u_int32_t ci_feature_sefflags; /* more CPUID feature bits */
+ u_int32_t ci_feature_tpmflags; /* thermal & power bits */
u_int32_t cpu_class; /* CPU class */
u_int32_t ci_cflushsz; /* clflush cache-line size */
diff --git a/sys/arch/i386/include/specialreg.h b/sys/arch/i386/include/specialreg.h
index 3bb33b3f4ce..7f1f341dfdf 100644
--- a/sys/arch/i386/include/specialreg.h
+++ b/sys/arch/i386/include/specialreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: specialreg.h,v 1.50 2015/03/25 20:59:30 kettenis Exp $ */
+/* $OpenBSD: specialreg.h,v 1.51 2015/05/28 20:10:58 guenther Exp $ */
/* $NetBSD: specialreg.h,v 1.7 1994/10/27 04:16:26 cgd Exp $ */
/*-
@@ -178,6 +178,12 @@
#define SEFF0EBX_SMAP 0x00100000 /* Supervisor mode access prevent */
/*
+ * Thermal and Power Management (CPUID function 0x6) EAX bits
+ */
+#define TPM_SENSOR 0x00000001 /* Digital temp sensor */
+#define TPM_ARAT 0x00000004 /* APIC Timer Always Running */
+
+/*
* "Architectural Performance Monitoring" bits (CPUID function 0x0a):
* EAX bits
*/