@@ -1898,7 +1898,8 @@ const StringMap<bool> sys::getHostCPUFeatures() {
1898
1898
}
1899
1899
1900
1900
#if defined(__aarch64__)
1901
- // Keep track of which crypto features we have seen
1901
+ // All of these are "crypto" features, but we must sift out actual features
1902
+ // as the former meaning of "crypto" as a single feature is no more.
1902
1903
enum { CAP_AES = 0x1 , CAP_PMULL = 0x2 , CAP_SHA1 = 0x4 , CAP_SHA2 = 0x8 };
1903
1904
uint32_t crypto = 0 ;
1904
1905
#endif
@@ -1944,7 +1945,10 @@ const StringMap<bool> sys::getHostCPUFeatures() {
1944
1945
// LLVM has decided some AArch64 CPUs have all the instructions they _may_
1945
1946
// have, as opposed to all the instructions they _must_ have, so allow runtime
1946
1947
// information to correct us on that.
1947
- Features[" crypto" ] = (crypto == (CAP_AES | CAP_PMULL | CAP_SHA1 | CAP_SHA2));
1948
+ uint32_t Aes = CAP_AES | CAP_PMULL;
1949
+ uint32_t Sha2 = CAP_SHA1 | CAP_SHA2;
1950
+ Features[" aes" ] = (crypto & Aes) == Aes;
1951
+ Features[" sha2" ] = (crypto & Sha2) == Sha2;
1948
1952
#endif
1949
1953
1950
1954
return Features;
@@ -1958,8 +1962,12 @@ const StringMap<bool> sys::getHostCPUFeatures() {
1958
1962
IsProcessorFeaturePresent (PF_ARM_NEON_INSTRUCTIONS_AVAILABLE);
1959
1963
Features[" crc" ] =
1960
1964
IsProcessorFeaturePresent (PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE);
1961
- Features[" crypto" ] =
1965
+
1966
+ // Avoid inferring "crypto" means more than the traditional AES + SHA2
1967
+ bool TradCrypto =
1962
1968
IsProcessorFeaturePresent (PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE);
1969
+ Features[" aes" ] = TradCrypto;
1970
+ Features[" sha2" ] = TradCrypto;
1963
1971
1964
1972
return Features;
1965
1973
}
0 commit comments