Skip to content

Commit

Permalink
VPCLMULQDQ should also be gated on whether or not AVX is usable
Browse files Browse the repository at this point in the history
  • Loading branch information
graebm committed Jan 24, 2025
1 parent 2710281 commit c298d12
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions source/arch/intel/cpuid.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ static void s_cache_cpu_features(void) {
return;
}
aws_run_cpuid(0x7, 0x0, abcd);
s_cpu_features[AWS_CPU_FEATURE_BMI2] = abcd[1] & (1 << 8); /* bmi2 = EBX[bit 8] */
s_cpu_features[AWS_CPU_FEATURE_VPCLMULQDQ] = abcd[2] & (1 << 10); /* vpclmulqdq = ECX[bit 10] */
s_cpu_features[AWS_CPU_FEATURE_BMI2] = abcd[1] & (1 << 8); /* bmi2 = EBX[bit 8] */

/* NOTE: It SHOULD be impossible for a CPU to support AVX2 without supporting AVX.
* But we've received crash reports where the AVX2 feature check passed
Expand All @@ -91,7 +90,8 @@ static void s_cache_cpu_features(void) {
* check should stop them from running our AVX/AVX2 code paths. */
if (feature_avx) {
if (avx_usable) {
s_cpu_features[AWS_CPU_FEATURE_AVX2] = abcd[1] & (1 << 5); /* AVX2 = EBX[bit 5] */
s_cpu_features[AWS_CPU_FEATURE_AVX2] = abcd[1] & (1 << 5); /* AVX2 = EBX[bit 5] */
s_cpu_features[AWS_CPU_FEATURE_VPCLMULQDQ] = abcd[2] & (1 << 10); /* vpclmulqdq = ECX[bit 10] */
}
if (avx512_usable) {
s_cpu_features[AWS_CPU_FEATURE_AVX512] = abcd[1] & (1 << 16); /* AVX-512 Foundation = EBX[bit 16] */
Expand Down

0 comments on commit c298d12

Please sign in to comment.