From c8cb9c119b635d85ed6cdf95cf9006c4d2d3558f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 22 Mar 2018 16:46:11 -0700 Subject: [PATCH] lib: crypto: Assume bit 25 being set means AESNI is available. See: https://en.wikipedia.org/wiki/CPUID for details on this assumption. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13302 Based on an idea by Eric Vannier Signed-off-by: Jeremy Allison --- lib/crypto/aes.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/lib/crypto/aes.c b/lib/crypto/aes.c index c226ac1b3df..f4fe2c9815e 100644 --- a/lib/crypto/aes.c +++ b/lib/crypto/aes.c @@ -66,22 +66,7 @@ static bool has_intel_aes_instructions(void) return (bool)has_aes_instructions; } - __cpuid(cpuid_results, 0); - /* - * MSB LSB - * EBX = 'u' 'n' 'e' 'G' - * EDX = 'I' 'e' 'n' 'i' - * ECX = 'l' 'e' 't' 'n' - */ - if (memcmp((unsigned char *)&cpuid_results[1], "Genu", 4) != 0 || - memcmp((unsigned char *)&cpuid_results[3], - "ineI", 4) != 0 || - memcmp((unsigned char *)&cpuid_results[2], - "ntel", 4) != 0) { - has_aes_instructions = 0; - return (bool)has_aes_instructions; - } - + memset(cpuid_results, '\0', sizeof(cpuid_results)); __cpuid(cpuid_results, 1); has_aes_instructions = !!(cpuid_results[2] & (1 << 25)); return (bool)has_aes_instructions; -- 2.14.1