-/* $OpenBSD: identcpu.c,v 1.90 2017/10/18 12:52:06 mikeb Exp $ */
+/* $OpenBSD: identcpu.c,v 1.91 2018/01/07 01:08:20 mlarkin Exp $ */
/* $NetBSD: identcpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */
/*
{ SEFF0ECX_AVX512VBMI, "AVX512VBMI" },
{ SEFF0ECX_UMIP, "UMIP" },
{ SEFF0ECX_PKU, "PKU" },
+}, cpu_seff0_edxfeatures[] = {
+ { SEFF0EDX_IBRS, "IBRS" },
+ { SEFF0EDX_STIBP, "STIBP" },
}, cpu_tpm_eaxfeatures[] = {
{ TPM_SENSOR, "SENSOR" },
{ TPM_ARAT, "ARAT" },
{ CPUIDEAX_VERID, "PERF" },
}, cpu_cpuid_apmi_edx[] = {
{ CPUIDEDX_ITSC, "ITSC" },
+}, cpu_amdspec_ebxfeatures[] = {
+ { CPUIDEBX_IBPB, "IBPB" },
};
int
if (cpuid_level >= 0x07) {
/* "Structured Extended Feature Flags" */
CPUID_LEAF(0x7, 0, dummy, ci->ci_feature_sefflags_ebx,
- ci->ci_feature_sefflags_ecx, dummy);
+ ci->ci_feature_sefflags_ecx, ci->ci_feature_sefflags_edx);
for (i = 0; i < nitems(cpu_seff0_ebxfeatures); i++)
if (ci->ci_feature_sefflags_ebx &
cpu_seff0_ebxfeatures[i].bit)
if (ci->ci_feature_sefflags_ecx &
cpu_seff0_ecxfeatures[i].bit)
printf(",%s", cpu_seff0_ecxfeatures[i].str);
+ for (i = 0; i < nitems(cpu_seff0_edxfeatures); i++)
+ if (ci->ci_feature_sefflags_edx &
+ cpu_seff0_edxfeatures[i].bit)
+ printf(",%s", cpu_seff0_edxfeatures[i].str);
}
if (!strcmp(cpu_vendor, "GenuineIntel") && cpuid_level >= 0x06) {
ci->ci_feature_tpmflags |= TPM_ARAT;
}
+ /* AMD speculation control features */
+ if (!strcmp(cpu_vendor, "AuthenticAMD")) {
+ if (ci->ci_pnfeatset >= 0x80000008) {
+ CPUID(0x80000008, dummy, ci->ci_feature_amdspec_ebx,
+ dummy, dummy);
+ for (i = 0; i < nitems(cpu_amdspec_ebxfeatures); i++)
+ if (ci->ci_feature_amdspec_ebx &
+ cpu_amdspec_ebxfeatures[i].bit)
+ printf(",%s",
+ cpu_amdspec_ebxfeatures[i].str);
+ }
+ }
+
printf("\n");
x86_print_cacheinfo(ci);
-/* $OpenBSD: cpu.h,v 1.117 2017/10/23 15:41:29 mikeb Exp $ */
+/* $OpenBSD: cpu.h,v 1.118 2018/01/07 01:08:20 mlarkin Exp $ */
/* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */
/*-
u_int32_t ci_feature_eflags;
u_int32_t ci_feature_sefflags_ebx;
u_int32_t ci_feature_sefflags_ecx;
+ u_int32_t ci_feature_sefflags_edx;
+ u_int32_t ci_feature_amdspec_ebx;
u_int32_t ci_feature_tpmflags;
u_int32_t ci_pnfeatset;
u_int32_t ci_efeature_eax;
-/* $OpenBSD: specialreg.h,v 1.62 2017/12/06 16:26:12 fcambus Exp $ */
+/* $OpenBSD: specialreg.h,v 1.63 2018/01/07 01:08:20 mlarkin 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 $ */
#define SEFF0ECX_AVX512VBMI 0x00000002 /* AVX-512 vector bit inst */
#define SEFF0ECX_UMIP 0x00000004 /* UMIP support */
#define SEFF0ECX_PKU 0x00000008 /* Page prot keys for user mode */
+/* SEFF EDX bits */
+#define SEFF0EDX_IBRS 0x04000000 /* IBRS / IBPB Speculation Control */
+#define SEFF0EDX_STIBP 0x08000000 /* STIBP Speculation Control */
/*
* Thermal and Power Management (CPUID function 0x6) EAX bits
* "Advanced Power Management Information" bits (CPUID function 0x80000007):
* EDX bits.
*/
-
#define CPUIDEDX_ITSC (1 << 8) /* Invariant TSC */
+/*
+ * AMD CPUID function 0x80000008 EBX bits
+ */
+#define CPUIDEBX_IBPB (1ULL << 12) /* Speculation Control IBPB */
+
#define CPUID2FAMILY(cpuid) (((cpuid) >> 8) & 15)
#define CPUID2MODEL(cpuid) (((cpuid) >> 4) & 15)
#define CPUID2STEPPING(cpuid) ((cpuid) & 15)
#define MSR_EBC_FREQUENCY_ID 0x02c /* Pentium 4 only */
#define MSR_TEST_CTL 0x033
#define MSR_IA32_FEATURE_CONTROL 0x03a
+#define MSR_SPEC_CTRL 0x048 /* Speculation Control IBRS / STIBP */
+#define SPEC_CTRL_IBRS (1ULL << 0)
+#define SPEC_CTRL_STIBP (1ULL << 1)
+#define MSR_PRED_CMD 0x049 /* Speculation Control IBPB */
+#define PRED_CMD_IBPB (1ULL << 0)
#define MSR_BIOS_UPDT_TRIG 0x079
#define MSR_BBL_CR_D0 0x088 /* PII+ only */
#define MSR_BBL_CR_D1 0x089 /* PII+ only */