Skip to content

Commit

Permalink
Fixed issue #76: Skylake Core i5 badly recognized
Browse files Browse the repository at this point in the history
Add support for detecting RDSEED and ADX instructions.
Use RDSEED instead of RTM to ascertain that the CPU is
Broadwell or later in recog_intel.c. This fixes
detection discrepancies on Linux, where RTM is not
made available (I guess there's no kernel support for it).

The two new flags are also now detected in the Broadwell
and Skylake tests. Update them as well.
  • Loading branch information
anrieff committed Oct 25, 2016
1 parent ee88463 commit e36a08d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions libcpuid/cpuid_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,8 @@ const char* cpu_feature_str(cpu_feature_t feature)
{ CPU_FEATURE_AVX512BW, "avx512bw" },
{ CPU_FEATURE_AVX512VL, "avx512vl" },
{ CPU_FEATURE_SGX, "sgx" },
{ CPU_FEATURE_RDSEED, "rdseed" },
{ CPU_FEATURE_ADX, "adx" },
};
unsigned i, n = COUNT_OF(matchtable);
if (n != NUM_CPU_FEATURES) {
Expand Down
2 changes: 2 additions & 0 deletions libcpuid/libcpuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,8 @@ typedef enum {
CPU_FEATURE_AVX512BW, /*!< AVX-512 Byte/Word granular insns */
CPU_FEATURE_AVX512VL, /*!< AVX-512 128/256 vector length extensions */
CPU_FEATURE_SGX, /*!< SGX extensions. Non-autoritative, check cpu_id_t::sgx::present to verify presence */
CPU_FEATURE_RDSEED, /*!< RDSEED instruction */
CPU_FEATURE_ADX, /*!< ADX extensions (arbitrary precision) */
/* termination: */
NUM_CPU_FEATURES,
} cpu_feature_t;
Expand Down
4 changes: 3 additions & 1 deletion libcpuid/recog_intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ static void load_intel_features(struct cpu_raw_data_t* raw, struct cpu_id_t* dat
{ 11, CPU_FEATURE_RTM },
{ 16, CPU_FEATURE_AVX512F },
{ 17, CPU_FEATURE_AVX512DQ },
{ 18, CPU_FEATURE_RDSEED },
{ 19, CPU_FEATURE_ADX },
{ 26, CPU_FEATURE_AVX512PF },
{ 27, CPU_FEATURE_AVX512ER },
{ 28, CPU_FEATURE_AVX512CD },
Expand Down Expand Up @@ -648,7 +650,7 @@ static intel_code_t get_brand_code(struct cpu_id_t* data)
if (data->flags[CPU_FEATURE_FMA3])
core_ix_base = CORE_HASWELL3;
/* if it has RTM, then it is at least a Broadwell-E or Skylake */
if (data->flags[CPU_FEATURE_RTM])
if (data->flags[CPU_FEATURE_RDSEED])
core_ix_base = CORE_BROADWELL3;

switch (bs[i + 9]) {
Expand Down
2 changes: 1 addition & 1 deletion tests/intel/broadwell/broadwell-e-i7.test
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ intel_fn11[3]=00000000 00000000 00000003 00000004
-1
128 (non-authoritative)
Broadwell-E (Core i7)
fpu vme de pse tsc msr pae mce cx8 apic mtrr sep pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe pni pclmul dts64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 syscall xd movbe popcnt aes xsave osxsave avx rdtscp lm lahf_lm constant_tsc fma3 f16c rdrand x2apic avx2 bmi1 bmi2 hle rtm
fpu vme de pse tsc msr pae mce cx8 apic mtrr sep pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe pni pclmul dts64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 syscall xd movbe popcnt aes xsave osxsave avx rdtscp lm lahf_lm constant_tsc fma3 f16c rdrand x2apic avx2 bmi1 bmi2 hle rtm rdseed adx
2 changes: 1 addition & 1 deletion tests/intel/skylake/skylake-i5.test
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ intel_fn11[3]=00000000 00000000 00000003 00000000
-1
128 (non-authoritative)
Skylake (Core i5)
fpu vme de pse tsc msr pae mce cx8 apic mtrr sep pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe pni pclmul dts64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 xd movbe popcnt aes xsave osxsave avx rdtscp lm lahf_lm constant_tsc fma3 f16c rdrand x2apic avx2 bmi1 bmi2 hle rtm
fpu vme de pse tsc msr pae mce cx8 apic mtrr sep pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe pni pclmul dts64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 xd movbe popcnt aes xsave osxsave avx rdtscp lm lahf_lm constant_tsc fma3 f16c rdrand x2apic avx2 bmi1 bmi2 hle rtm rdseed adx

0 comments on commit e36a08d

Please sign in to comment.