Skip to content

Commit

Permalink
std_detect: Remove support for arm crypto target feature
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e authored and Amanieu committed Apr 1, 2023
1 parent 7b5d269 commit c0244ce
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 24 deletions.
2 changes: 0 additions & 2 deletions crates/std_detect/src/detect/arch/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ features! {
/// Polynomial Multiply
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] crc: "crc";
/// CRC32 (Cyclic Redundancy Check)
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] crypto: "crypto";
/// Crypto: AES + PMULL + SHA1 + SHA256. Prefer using the individual features where possible.
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] aes: "aes";
/// FEAT_AES (AES instructions)
@FEATURE: #[unstable(feature = "stdsimd", issue = "27731")] sha2: "sha2";
Expand Down
7 changes: 2 additions & 5 deletions crates/std_detect/src/detect/os/freebsd/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@ pub(crate) fn detect_features() -> cache::Initializer {

if let Ok(auxv) = auxvec::auxv() {
enable_feature(&mut value, Feature::neon, auxv.hwcap & HWCAP_NEON != 0);
let pmull = auxv.hwcap2 & HWCAP2_PMULL != 0;
enable_feature(&mut value, Feature::pmull, pmull);
enable_feature(&mut value, Feature::pmull, auxv.hwcap2 & HWCAP2_PMULL != 0);
enable_feature(&mut value, Feature::crc, auxv.hwcap2 & HWCAP2_CRC32 != 0);
let aes = auxv.hwcap2 & HWCAP2_AES != 0;
enable_feature(&mut value, Feature::aes, aes);
enable_feature(&mut value, Feature::aes, auxv.hwcap2 & HWCAP2_AES != 0);
// SHA2 requires SHA1 & SHA2 features
let sha1 = auxv.hwcap2 & HWCAP2_SHA1 != 0;
let sha2 = auxv.hwcap2 & HWCAP2_SHA2 != 0;
enable_feature(&mut value, Feature::sha2, sha1 && sha2);
enable_feature(&mut value, Feature::crypto, aes && pmull && sha1 && sha2);
return value;
}
value
Expand Down
16 changes: 0 additions & 16 deletions crates/std_detect/src/detect/os/linux/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ pub(crate) fn detect_features() -> cache::Initializer {
enable_feature(&mut value, Feature::neon, bit::test(auxv.hwcap, 12));
enable_feature(&mut value, Feature::pmull, bit::test(auxv.hwcap2, 1));
enable_feature(&mut value, Feature::crc, bit::test(auxv.hwcap2, 4));
enable_feature(
&mut value,
Feature::crypto,
bit::test(auxv.hwcap2, 0)
&& bit::test(auxv.hwcap2, 1)
&& bit::test(auxv.hwcap2, 2)
&& bit::test(auxv.hwcap2, 3),
);
enable_feature(&mut value, Feature::aes, bit::test(auxv.hwcap2, 0));
// SHA2 requires SHA1 & SHA2 features
enable_feature(
Expand All @@ -47,14 +39,6 @@ pub(crate) fn detect_features() -> cache::Initializer {
);
enable_feature(&mut value, Feature::pmull, c.field("Features").has("pmull"));
enable_feature(&mut value, Feature::crc, c.field("Features").has("crc32"));
enable_feature(
&mut value,
Feature::crypto,
c.field("Features").has("aes")
&& c.field("Features").has("pmull")
&& c.field("Features").has("sha1")
&& c.field("Features").has("sha2"),
);
enable_feature(&mut value, Feature::aes, c.field("Features").has("aes"));
enable_feature(
&mut value,
Expand Down
1 change: 0 additions & 1 deletion crates/std_detect/tests/cpu-detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ fn arm_linux_or_freebsd() {
println!("neon: {}", is_arm_feature_detected!("neon"));
println!("pmull: {}", is_arm_feature_detected!("pmull"));
println!("crc: {}", is_arm_feature_detected!("crc"));
println!("crypto: {}", is_arm_feature_detected!("crypto"));
println!("aes: {}", is_arm_feature_detected!("aes"));
println!("sha2: {}", is_arm_feature_detected!("sha2"));
}
Expand Down

0 comments on commit c0244ce

Please sign in to comment.