diff --git a/crypto/chacha/chacha.c b/crypto/chacha/chacha.c index 21274bc874..85693b2bed 100644 --- a/crypto/chacha/chacha.c +++ b/crypto/chacha/chacha.c @@ -92,7 +92,7 @@ static void ChaCha20_ctr32(uint8_t *out, const uint8_t *in, size_t in_len, return; } #endif -#if defined(CHACHA20_ASM_AVX2) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) +#if defined(CHACHA20_ASM_AVX2) if (ChaCha20_ctr32_avx2_capable(in_len)) { ChaCha20_ctr32_avx2(out, in, in_len, key, counter); return; @@ -245,3 +245,15 @@ void CRYPTO_chacha_20(uint8_t *out, const uint8_t *in, size_t in_len, } #endif + +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) + +#if defined(CHACHA20_ASM_AVX2) +void ChaCha20_ctr32_avx2(uint8_t *out, const uint8_t *in, size_t in_len, + const uint32_t key[8], const uint32_t counter[4]) { + perror("ChaCha20_ctr32_avx2"); + abort(); +} +#endif // defined(CHACHA20_ASM_AVX2) + +#endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) diff --git a/crypto/chacha/chacha_test.cc b/crypto/chacha/chacha_test.cc index 3a379a9e88..c1a45a6bb4 100644 --- a/crypto/chacha/chacha_test.cc +++ b/crypto/chacha/chacha_test.cc @@ -356,7 +356,7 @@ static void check_abi(uint8_t *out, const uint8_t *in, size_t in_len, CHECK_ABI(ChaCha20_ctr32_neon, out, in, in_len, key, counter); } #endif -#if defined(CHACHA20_ASM_AVX2) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) +#if defined(CHACHA20_ASM_AVX2) if (ChaCha20_ctr32_avx2_capable(in_len)) { CHECK_ABI(ChaCha20_ctr32_avx2, out, in, in_len, key, counter); } diff --git a/crypto/chacha/internal.h b/crypto/chacha/internal.h index bcdcf2f576..9f4fdfd288 100644 --- a/crypto/chacha/internal.h +++ b/crypto/chacha/internal.h @@ -59,6 +59,9 @@ void ChaCha20_ctr32_neon(uint8_t *out, const uint8_t *in, size_t in_len, #define CHACHA20_ASM_AVX2 OPENSSL_INLINE int ChaCha20_ctr32_avx2_capable(size_t len) { +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) + return 0; +#endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) return len > 128 && CRYPTO_is_AVX2_capable(); } void ChaCha20_ctr32_avx2(uint8_t *out, const uint8_t *in, size_t in_len, diff --git a/crypto/fipsmodule/sha/internal.h b/crypto/fipsmodule/sha/internal.h index 99afc11697..9c35db02a1 100644 --- a/crypto/fipsmodule/sha/internal.h +++ b/crypto/fipsmodule/sha/internal.h @@ -192,6 +192,9 @@ void sha1_block_data_order_ssse3(uint32_t state[5], const uint8_t *data, #define SHA1_ASM_AVX OPENSSL_INLINE int sha1_avx_capable(void) { +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) + return 0; +#endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) // Pre-Zen AMD CPUs had slow SHLD/SHRD; Zen added the SHA extension; see the // discussion in sha1-586.pl. // @@ -215,6 +218,9 @@ void sha256_block_data_order_ssse3(uint32_t state[8], const uint8_t *data, #define SHA256_ASM_AVX OPENSSL_INLINE int sha256_avx_capable(void) { +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) + return 0; +#endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) // Pre-Zen AMD CPUs had slow SHLD/SHRD; Zen added the SHA extension; see the // discussion in sha1-586.pl. // @@ -245,6 +251,9 @@ OPENSSL_INLINE int sha1_hw_capable(void) { #define SHA1_ASM_AVX2 OPENSSL_INLINE int sha1_avx2_capable(void) { +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) + return 0; +#endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) // TODO: Simplify this logic, which was extracted from the assembly: // * Does AVX2 imply SSSE3? // * sha1_block_data_order_avx2 does not seem to use SSSE3 instructions. @@ -256,6 +265,9 @@ void sha1_block_data_order_avx2(uint32_t state[5], const uint8_t *data, #define SHA1_ASM_AVX OPENSSL_INLINE int sha1_avx_capable(void) { +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) + return 0; +#endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) // TODO: Simplify this logic, which was extracted from the assembly: // * Does AVX imply SSSE3? // * sha1_block_data_order_avx does not seem to use SSSE3 instructions. @@ -281,6 +293,9 @@ OPENSSL_INLINE int sha256_hw_capable(void) { #define SHA256_ASM_AVX OPENSSL_INLINE int sha256_avx_capable(void) { +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) + return 0; +#endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) // TODO: Simplify this logic, which was extracted from the assembly: // * Does AVX imply SSSE3? // * sha256_block_data_order_avx does not seem to use SSSE3 instructions. @@ -301,6 +316,9 @@ void sha256_block_data_order_ssse3(uint32_t state[8], const uint8_t *data, #define SHA512_ASM_AVX OPENSSL_INLINE int sha512_avx_capable(void) { +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) + return 0; +#endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) // TODO: Simplify this logic, which was extracted from the assembly: // * Does AVX imply SSSE3? // * sha512_block_data_order_avx does not seem to use SSSE3 instructions. diff --git a/crypto/fipsmodule/sha/sha1.c b/crypto/fipsmodule/sha/sha1.c index c1b2dcb9a8..17a9d15e41 100644 --- a/crypto/fipsmodule/sha/sha1.c +++ b/crypto/fipsmodule/sha/sha1.c @@ -396,13 +396,13 @@ static void sha1_block_data_order(uint32_t state[5], const uint8_t *data, return; } #endif -#if defined(SHA1_ASM_AVX2) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) +#if defined(SHA1_ASM_AVX2) if (sha1_avx2_capable()) { sha1_block_data_order_avx2(state, data, num); return; } #endif -#if defined(SHA1_ASM_AVX) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) +#if defined(SHA1_ASM_AVX) if (sha1_avx_capable()) { sha1_block_data_order_avx(state, data, num); return; @@ -441,3 +441,23 @@ static void sha1_block_data_order(uint32_t state[5], const uint8_t *data, #undef BODY_40_59 #undef BODY_60_79 #undef X + +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) + +#if defined(ASH1_ASM_AVX2) +void sha1_block_data_order_avx2(uint32_t state[5], const uint8_t *data, + size_t num) { + perror("sha1_block_data_order_avx2"); + abort(); +} +#endif // defined(ASH1_ASM_AVX2) + +#if defined(SHA1_ASM_AVX) +void sha1_block_data_order_avx(uint32_t state[5], const uint8_t *data, + size_t num) { + perror("sha1_block_data_order_avx"); + abort(); +} +#endif // defined(SHA1_ASM_AVX) + +#endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) diff --git a/crypto/fipsmodule/sha/sha256.c b/crypto/fipsmodule/sha/sha256.c index f36fb8b716..ffe5d4b2a9 100644 --- a/crypto/fipsmodule/sha/sha256.c +++ b/crypto/fipsmodule/sha/sha256.c @@ -392,7 +392,7 @@ static void sha256_block_data_order(uint32_t state[8], const uint8_t *data, return; } #endif -#if defined(SHA256_ASM_AVX) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) +#if defined(SHA256_ASM_AVX) if (sha256_avx_capable()) { sha256_block_data_order_avx(state, data, num); return; @@ -429,3 +429,15 @@ void SHA256_TransformBlocks(uint32_t state[8], const uint8_t *data, #undef Maj #undef ROUND_00_15 #undef ROUND_16_63 + +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) + +#if defined(SHA256_ASM_AVX) +void sha256_block_data_order_avx(uint32_t state[8], const uint8_t *data, + size_t num) { + perror("sha256_block_data_order_avx"); + abort(); +} +#endif // defined(SHA256_ASM_AVX) + +#endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) diff --git a/crypto/fipsmodule/sha/sha512.c b/crypto/fipsmodule/sha/sha512.c index a5d0bab5c6..a5a124d01c 100644 --- a/crypto/fipsmodule/sha/sha512.c +++ b/crypto/fipsmodule/sha/sha512.c @@ -689,7 +689,7 @@ static void sha512_block_data_order(uint64_t state[8], const uint8_t *data, return; } #endif -#if defined(SHA512_ASM_AVX) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) +#if defined(SHA512_ASM_AVX) if (sha512_avx_capable()) { sha512_block_data_order_avx(state, data, num); return; @@ -714,3 +714,15 @@ static void sha512_block_data_order(uint64_t state[8], const uint8_t *data, #undef Maj #undef ROUND_00_15 #undef ROUND_16_80 + +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) + +#if defined(SHA512_ASM_AVX) +void sha512_block_data_order_avx(uint64_t state[8], const uint8_t *data, + size_t num) { + perror("sha512_block_data_order_avx"); + abort(); +} +#endif // defined(SHA512_ASM_AVX) + +#endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) diff --git a/crypto/fipsmodule/sha/sha_test.cc b/crypto/fipsmodule/sha/sha_test.cc index e8854fd8bf..14931c512c 100644 --- a/crypto/fipsmodule/sha/sha_test.cc +++ b/crypto/fipsmodule/sha/sha_test.cc @@ -36,12 +36,12 @@ TEST(SHATest, SHA1ABI) { CHECK_ABI(sha1_block_data_order_hw, ctx.h, kBuf, blocks); } #endif -#if defined(SHA1_ASM_AVX2) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) +#if defined(SHA1_ASM_AVX2) if (sha1_avx2_capable()) { CHECK_ABI(sha1_block_data_order_avx2, ctx.h, kBuf, blocks); } #endif -#if defined(SHA1_ASM_AVX) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) +#if defined(SHA1_ASM_AVX) if (sha1_avx_capable()) { CHECK_ABI(sha1_block_data_order_avx, ctx.h, kBuf, blocks); } @@ -76,7 +76,7 @@ TEST(SHATest, SHA256ABI) { CHECK_ABI(sha256_block_data_order_hw, ctx.h, kBuf, blocks); } #endif -#if defined(SHA256_ASM_AVX) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) +#if defined(SHA256_ASM_AVX) if (sha256_avx_capable()) { CHECK_ABI(sha256_block_data_order_avx, ctx.h, kBuf, blocks); } @@ -111,7 +111,7 @@ TEST(SHATest, SHA512ABI) { CHECK_ABI(sha512_block_data_order_hw, ctx.h, kBuf, blocks); } #endif -#if defined(SHA512_ASM_AVX) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) +#if defined(SHA512_ASM_AVX) if (sha512_avx_capable()) { CHECK_ABI(sha512_block_data_order_avx, ctx.h, kBuf, blocks); }