Add runtime feature detection for keylocker
This commit is contained in:
parent
e977f72f70
commit
2a6953d38a
3 changed files with 17 additions and 1 deletions
|
|
@ -103,6 +103,8 @@ features! {
|
|||
/// * `"xsaves"`
|
||||
/// * `"xsavec"`
|
||||
/// * `"cmpxchg16b"`
|
||||
/// * `"kl"`
|
||||
/// * `"widekl"`
|
||||
/// * `"adx"`
|
||||
/// * `"rtm"`
|
||||
/// * `"movbe"`
|
||||
|
|
@ -241,6 +243,10 @@ features! {
|
|||
/// XSAVEC (Save Processor Extended States Compacted)
|
||||
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] cmpxchg16b: "cmpxchg16b";
|
||||
/// CMPXCH16B (16-byte compare-and-swap instruction)
|
||||
@FEATURE: #[unstable(feature = "keylocker_x86", issue = "134813")] kl: "kl";
|
||||
/// Intel Key Locker
|
||||
@FEATURE: #[unstable(feature = "keylocker_x86", issue = "134813")] widekl: "widekl";
|
||||
/// Intel Key Locker Wide
|
||||
@FEATURE: #[stable(feature = "simd_x86_adx", since = "1.33.0")] adx: "adx";
|
||||
/// ADX, Intel ADX (Multi-Precision Add-Carry Instruction Extensions)
|
||||
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] rtm: "rtm";
|
||||
|
|
|
|||
|
|
@ -141,6 +141,13 @@ pub(crate) fn detect_features() -> cache::Initializer {
|
|||
|
||||
enable(extended_features_ebx, 9, Feature::ermsb);
|
||||
|
||||
// Detect if CPUID.19h available
|
||||
if bit::test(extended_features_ecx as usize, 23) {
|
||||
let CpuidResult { ebx, .. } = unsafe { __cpuid(0x19) };
|
||||
enable(ebx, 0, Feature::kl);
|
||||
enable(ebx, 2, Feature::widekl);
|
||||
}
|
||||
|
||||
// `XSAVE` and `AVX` support:
|
||||
let cpu_xsave = bit::test(proc_info_ecx as usize, 26);
|
||||
if cpu_xsave {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@
|
|||
avx512_target_feature,
|
||||
sha512_sm_x86,
|
||||
x86_amx_intrinsics,
|
||||
xop_target_feature
|
||||
xop_target_feature,
|
||||
keylocker_x86
|
||||
)]
|
||||
|
||||
extern crate cupid;
|
||||
|
|
@ -94,6 +95,8 @@ fn dump() {
|
|||
println!("amx-fp16: {:?}", is_x86_feature_detected!("amx-fp16"));
|
||||
println!("amx-complex: {:?}", is_x86_feature_detected!("amx-complex"));
|
||||
println!("xop: {:?}", is_x86_feature_detected!("xop"));
|
||||
println!("kl: {:?}", is_x86_feature_detected!("kl"));
|
||||
println!("widekl: {:?}", is_x86_feature_detected!("widekl"));
|
||||
}
|
||||
|
||||
#[cfg(feature = "std_detect_env_override")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue