From e658e3e48413ffad80c0908fbead5d125f84ad1f Mon Sep 17 00:00:00 2001 From: zonyitoo Date: Tue, 6 May 2025 15:32:38 +0800 Subject: [PATCH 1/3] cpufeatures: x86 support of sha512, sm3, sm4 --- cpufeatures/README.md | 3 +++ cpufeatures/src/x86.rs | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cpufeatures/README.md b/cpufeatures/README.md index cca0fa36..74d178e9 100644 --- a/cpufeatures/README.md +++ b/cpufeatures/README.md @@ -87,6 +87,9 @@ Target features: - `sse4.1` - `sse4.2` - `ssse3` +- `sha512` +- `sm3` +- `sm4` If you would like detection support for a target feature which is not on this list, please [open a GitHub issue]. diff --git a/cpufeatures/src/x86.rs b/cpufeatures/src/x86.rs index b26ef9b3..d0b88c43 100644 --- a/cpufeatures/src/x86.rs +++ b/cpufeatures/src/x86.rs @@ -47,7 +47,7 @@ macro_rules! __detect_target_features { } let cr = unsafe { - [cpuid(1), cpuid_count(7, 0)] + [cpuid(1), cpuid_count(7, 0), cpuid_count(7, 1)] }; $($crate::check!(cr, $tf) & )+ true @@ -142,4 +142,8 @@ __expand_check_macro! { ("vpclmulqdq", "zmm", 1, ecx, 10), ("avx512bitalg", "zmm", 1, ecx, 12), ("avx512vpopcntdq", "zmm", 1, ecx, 14), + + ("sha512", "ymm", 2, eax, 0), + ("sm3", "xmm", 2, eax, 1), + ("sm4", "xmm", 2, eax, 2), } From 693f083a6123394c02c331a79b9613c4f161e2f1 Mon Sep 17 00:00:00 2001 From: zonyitoo Date: Tue, 6 May 2025 15:50:39 +0800 Subject: [PATCH 2/3] cpufeatures: sm4 has ymm support --- cpufeatures/src/x86.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpufeatures/src/x86.rs b/cpufeatures/src/x86.rs index d0b88c43..dc83f2fd 100644 --- a/cpufeatures/src/x86.rs +++ b/cpufeatures/src/x86.rs @@ -145,5 +145,5 @@ __expand_check_macro! { ("sha512", "ymm", 2, eax, 0), ("sm3", "xmm", 2, eax, 1), - ("sm4", "xmm", 2, eax, 2), + ("sm4", "ymm", 2, eax, 2), } From 98547d278a196ec09e7e095025f94df3850c339d Mon Sep 17 00:00:00 2001 From: zonyitoo Date: Tue, 6 May 2025 21:59:29 +0800 Subject: [PATCH 3/3] cpufeatures: sha512, sm3, sm4 marked unstable --- cpufeatures/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cpufeatures/README.md b/cpufeatures/README.md index 74d178e9..a59eef5f 100644 --- a/cpufeatures/README.md +++ b/cpufeatures/README.md @@ -87,9 +87,9 @@ Target features: - `sse4.1` - `sse4.2` - `ssse3` -- `sha512` -- `sm3` -- `sm4` +- `sha512`* +- `sm3`* +- `sm4`* If you would like detection support for a target feature which is not on this list, please [open a GitHub issue].