improve aesni check for x86_64

`MBEDTLS_AESNI_C` does not depends on `MBEDTLS_HAVE_ASM`
when intrinsic is available.

And compiler relative checks only work on x86_64, it should
be only checked on x86_64.

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
This commit is contained in:
Jerry Yu 2023-08-10 13:53:41 +08:00
parent 13696bb07b
commit 8189f32945
2 changed files with 8 additions and 7 deletions

View file

@ -40,8 +40,7 @@
#endif #endif
#endif #endif
#if defined(MBEDTLS_HAVE_ASM) && \ #if defined(__amd64__) || defined(__x86_64__)
(defined(__amd64__) || defined(__x86_64__))
#if !defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_AES_USE_HARDWARE_ONLY) #if !defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_AES_USE_HARDWARE_ONLY)
#error "MBEDTLS_AES_USE_HARDWARE_ONLY defined, but not all prerequisites" #error "MBEDTLS_AES_USE_HARDWARE_ONLY defined, but not all prerequisites"
#endif #endif

View file

@ -35,13 +35,13 @@
/* Can we do AESNI with inline assembly? /* Can we do AESNI with inline assembly?
* (Only implemented with gas syntax, only for 64-bit.) * (Only implemented with gas syntax, only for 64-bit.)
*/ */
#if defined(MBEDTLS_HAVE_ASM) && defined(__GNUC__) && \ #if !defined(MBEDTLS_HAVE_X86_64) && \
(defined(__amd64__) || defined(__x86_64__)) && \ (defined(__amd64__) || defined(__x86_64__) || \
!defined(MBEDTLS_HAVE_X86_64) defined(_M_X64) || defined(_M_AMD64))
#define MBEDTLS_HAVE_X86_64 #define MBEDTLS_HAVE_X86_64
#endif #endif
#if defined(MBEDTLS_AESNI_C) #if defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_HAVE_X86_64)
/* Can we do AESNI with intrinsics? /* Can we do AESNI with intrinsics?
* (Only implemented with certain compilers, only for certain targets.) * (Only implemented with certain compilers, only for certain targets.)
@ -67,8 +67,10 @@
* In the long run, we will likely remove the assembly implementation. */ * In the long run, we will likely remove the assembly implementation. */
#if defined(MBEDTLS_AESNI_HAVE_INTRINSICS) #if defined(MBEDTLS_AESNI_HAVE_INTRINSICS)
#define MBEDTLS_AESNI_HAVE_CODE 2 // via intrinsics #define MBEDTLS_AESNI_HAVE_CODE 2 // via intrinsics
#elif defined(MBEDTLS_HAVE_X86_64) #elif defined(MBEDTLS_HAVE_ASM)
#define MBEDTLS_AESNI_HAVE_CODE 1 // via assembly #define MBEDTLS_AESNI_HAVE_CODE 1 // via assembly
#else
#error "MBEDTLS_AESNI_C defined, but neither intrinsics nor assembly available"
#endif #endif
#if defined(MBEDTLS_AESNI_HAVE_CODE) #if defined(MBEDTLS_AESNI_HAVE_CODE)