File tree 1 file changed +20
-0
lines changed
crates/std_detect/src/detect/os
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -249,5 +249,25 @@ pub(crate) fn detect_features() -> cache::Initializer {
249
249
}
250
250
}
251
251
252
+ // Unfortunately, some Skylake chips erroneously report support for BMI1 and
253
+ // BMI2 without actual support. These chips don't support AVX, and it seems
254
+ // that all Intel chips with non-erroneous support BMI do (I didn't check
255
+ // other vendors), so we can disable these flags for chips that don't also
256
+ // report support for AVX.
257
+ //
258
+ // It's possible this will pessimize future chips that do support BMI and
259
+ // not AVX, but this seems minor compared to a hard crash you get when
260
+ // executing an unsupported instruction (to put it another way, it's safe
261
+ // for us to under-report CPU features, but not to over-report them). Still,
262
+ // to limit any impact this may have in the future, we only do this for
263
+ // Intel chips, as it's a bug only present in their chips.
264
+ //
265
+ // This bug is documented as `SKL052` in the errata section of this document:
266
+ // http://www.intel.com/content/dam/www/public/us/en/documents/specification-updates/desktop-6th-gen-core-family-spec-update.pdf
267
+ if vendor_id == * b"GenuineIntel" && !value. test ( Feature :: avx as u32 ) {
268
+ value. unset ( Feature :: bmi1 as u32 ) ;
269
+ value. unset ( Feature :: bmi2 as u32 ) ;
270
+ }
271
+
252
272
value
253
273
}
You can’t perform that action at this time.
0 commit comments