summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@iki.fi>2022-04-14 20:39:33 +0300
committerJussi Kivilinna <jussi.kivilinna@iki.fi>2022-04-24 01:44:16 +0300
commit3410d40996d8f7377935192ebecf4cad66688b25 (patch)
tree4ee350100dfc0847ef139e3ba7a0ae20e033ec57 /src
parentf736f3c70182d9c948f9105eb769c47c5578df35 (diff)
downloadlibgcrypt-3410d40996d8f7377935192ebecf4cad66688b25.tar.gz
Add detection for HW feature "intel-gfni"
* configure.ac (gfnisupport, gcry_cv_gcc_inline_asm_gfni) (ENABLE_GFNI_SUPPORT): New. * src/g10lib.h (HWF_INTEL_GFNI): New. * src/hwf-x86.c (detect_x86_gnuc): Add GFNI detection. * src/hwfeatures.c (hwflist): Add "intel-gfni". * doc/gcrypt.texi: Add "intel-gfni" to HW features list. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'src')
-rw-r--r--src/g10lib.h1
-rw-r--r--src/hwf-x86.c7
-rw-r--r--src/hwfeatures.c1
3 files changed, 8 insertions, 1 deletions
diff --git a/src/g10lib.h b/src/g10lib.h
index c07ed788..a5bed002 100644
--- a/src/g10lib.h
+++ b/src/g10lib.h
@@ -238,6 +238,7 @@ char **_gcry_strtokenize (const char *string, const char *delim);
#define HWF_INTEL_SHAEXT (1 << 16)
#define HWF_INTEL_VAES_VPCLMUL (1 << 17)
#define HWF_INTEL_AVX512 (1 << 18)
+#define HWF_INTEL_GFNI (1 << 19)
#elif defined(HAVE_CPU_ARCH_ARM)
diff --git a/src/hwf-x86.c b/src/hwf-x86.c
index 33386070..20420798 100644
--- a/src/hwf-x86.c
+++ b/src/hwf-x86.c
@@ -403,7 +403,7 @@ detect_x86_gnuc (void)
#if defined(ENABLE_AVX2_SUPPORT) && defined(ENABLE_AESNI_SUPPORT) && \
defined(ENABLE_PCLMUL_SUPPORT)
- /* Test bit 9 for VAES and bit 10 for VPCLMULDQD */
+ /* Test features2 bit 9 for VAES and features2 bit 10 for VPCLMULDQD */
if ((features2 & 0x00000200) && (features2 & 0x00000400))
result |= HWF_INTEL_VAES_VPCLMUL;
#endif
@@ -439,6 +439,11 @@ detect_x86_gnuc (void)
&& (features2 & (1 << 14)))
result |= HWF_INTEL_AVX512;
#endif
+
+ /* Test features2 bit 6 for GFNI (Galois field new instructions).
+ * These instructions are available for SSE/AVX/AVX2/AVX512. */
+ if (features2 & (1 << 6))
+ result |= HWF_INTEL_GFNI;
}
return result;
diff --git a/src/hwfeatures.c b/src/hwfeatures.c
index 8e92cbdd..af5daf62 100644
--- a/src/hwfeatures.c
+++ b/src/hwfeatures.c
@@ -63,6 +63,7 @@ static struct
{ HWF_INTEL_SHAEXT, "intel-shaext" },
{ HWF_INTEL_VAES_VPCLMUL, "intel-vaes-vpclmul" },
{ HWF_INTEL_AVX512, "intel-avx512" },
+ { HWF_INTEL_GFNI, "intel-gfni" },
#elif defined(HAVE_CPU_ARCH_ARM)
{ HWF_ARM_NEON, "arm-neon" },
{ HWF_ARM_AES, "arm-aes" },