diff options
Diffstat (limited to 'usr/src/uts/i86pc/os/cpuid.c')
| -rw-r--r-- | usr/src/uts/i86pc/os/cpuid.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/usr/src/uts/i86pc/os/cpuid.c b/usr/src/uts/i86pc/os/cpuid.c index 586ec0656b..9b55ba9553 100644 --- a/usr/src/uts/i86pc/os/cpuid.c +++ b/usr/src/uts/i86pc/os/cpuid.c @@ -170,7 +170,10 @@ static char *x86_feature_names[NUM_X86_FEATURES] = { "bmi1", "bmi2", "fma", - "smep" + "smep", + "smap", + "adx", + "rdseed" }; boolean_t @@ -223,6 +226,7 @@ print_x86_featureset(void *featureset) static size_t xsave_state_size = 0; uint64_t xsave_bv_all = (XFEATURE_LEGACY_FP | XFEATURE_SSE); boolean_t xsave_force_disable = B_FALSE; +extern int disable_smap; /* * This is set to platform type we are running on. @@ -1249,6 +1253,24 @@ cpuid_pass1(cpu_t *cpu, uchar_t *featureset) if (ecp->cp_ebx & CPUID_INTC_EBX_7_0_SMEP) add_x86_feature(featureset, X86FSET_SMEP); + + /* + * We check disable_smap here in addition to in startup_smap() + * to ensure CPUs that aren't the boot CPU don't accidentally + * include it in the feature set and thus generate a mismatched + * x86 feature set across CPUs. Note that at this time we only + * enable SMAP for the 64-bit kernel. + */ +#if defined(__amd64) + if (ecp->cp_ebx & CPUID_INTC_EBX_7_0_SMAP && + disable_smap == 0) + add_x86_feature(featureset, X86FSET_SMAP); +#endif + if (ecp->cp_ebx & CPUID_INTC_EBX_7_0_RDSEED) + add_x86_feature(featureset, X86FSET_RDSEED); + + if (ecp->cp_ebx & CPUID_INTC_EBX_7_0_ADX) + add_x86_feature(featureset, X86FSET_ADX); } /* @@ -2724,6 +2746,10 @@ cpuid_pass4(cpu_t *cpu, uint_t *hwcap_out) *ebx &= ~CPUID_INTC_EBX_7_0_BMI2; if (!is_x86_feature(x86_featureset, X86FSET_AVX2)) *ebx &= ~CPUID_INTC_EBX_7_0_AVX2; + if (!is_x86_feature(x86_featureset, X86FSET_RDSEED)) + *ebx &= ~CPUID_INTC_EBX_7_0_RDSEED; + if (!is_x86_feature(x86_featureset, X86FSET_ADX)) + *ebx &= ~CPUID_INTC_EBX_7_0_ADX; /* * [no explicit support required beyond x87 fp context] @@ -2793,8 +2819,20 @@ cpuid_pass4(cpu_t *cpu, uint_t *hwcap_out) if (*ecx & CPUID_INTC_ECX_RDRAND) hwcap_flags_2 |= AV_386_2_RDRAND; + if (*ebx & CPUID_INTC_EBX_7_0_ADX) + hwcap_flags_2 |= AV_386_2_ADX; + if (*ebx & CPUID_INTC_EBX_7_0_RDSEED) + hwcap_flags_2 |= AV_386_2_RDSEED; + } + /* Detect systems with a potential CPUID limit */ + if (cpi->cpi_vendor == X86_VENDOR_Intel && cpi->cpi_maxeax < 4) { + cmn_err(CE_NOTE, "CPUID limit detected, " + "see the CPUID(7D) man page for details\n"); + } + + if (cpi->cpi_xmaxeax < 0x80000001) goto pass4_done; |
