From 3410d40996d8f7377935192ebecf4cad66688b25 Mon Sep 17 00:00:00 2001 From: Jussi Kivilinna Date: Thu, 14 Apr 2022 20:39:33 +0300 Subject: 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 --- src/g10lib.h | 1 + src/hwf-x86.c | 7 ++++++- src/hwfeatures.c | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src') 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" }, -- cgit v1.2.1