diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-10-03 18:38:22 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-10-03 18:38:22 +0200 |
commit | bcee2a1b842d022187c3422f4ccc150048b15166 (patch) | |
tree | d159f17d3ac5ae5b69ff2439af5076f7eb3ebfb6 | |
parent | 0769875840b9941fd9929d75e7cc276d6ce96cd3 (diff) |
simd: introduce useful disabling macro
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r-- | src/compat/simd/include/linux/simd.h | 2 | ||||
-rw-r--r-- | src/crypto/zinc/selftest/chacha20.h | 3 | ||||
-rw-r--r-- | src/crypto/zinc/selftest/poly1305.h | 2 |
3 files changed, 4 insertions, 3 deletions
diff --git a/src/compat/simd/include/linux/simd.h b/src/compat/simd/include/linux/simd.h index f45aa1f..a117afd 100644 --- a/src/compat/simd/include/linux/simd.h +++ b/src/compat/simd/include/linux/simd.h @@ -22,6 +22,8 @@ typedef enum { HAVE_SIMD_IN_USE = 1 << 31 } simd_context_t; +#define DONT_USE_SIMD ((simd_context_t []){ HAVE_NO_SIMD }) + static inline void simd_get(simd_context_t *ctx) { *ctx = !IS_ENABLED(CONFIG_PREEMPT_RT_BASE) && may_use_simd() ? HAVE_FULL_SIMD : HAVE_NO_SIMD; diff --git a/src/crypto/zinc/selftest/chacha20.h b/src/crypto/zinc/selftest/chacha20.h index 8622aef..82aec32 100644 --- a/src/crypto/zinc/selftest/chacha20.h +++ b/src/crypto/zinc/selftest/chacha20.h @@ -2680,8 +2680,7 @@ next_test: chacha20_init(&state, chacha20_testvecs[0].key, chacha20_testvecs[0].nonce); chacha20(&state, massive_input, massive_input, - OUTRAGEOUSLY_HUGE_BUFFER_LEN, - (simd_context_t []){ HAVE_NO_SIMD }); + OUTRAGEOUSLY_HUGE_BUFFER_LEN, DONT_USE_SIMD); for (k = 0; k < OUTRAGEOUSLY_HUGE_BUFFER_LEN; ++k) { if (massive_input[k]) { pr_err("chacha20 self-test massive: FAIL\n"); diff --git a/src/crypto/zinc/selftest/poly1305.h b/src/crypto/zinc/selftest/poly1305.h index 9c12feb..3acee63 100644 --- a/src/crypto/zinc/selftest/poly1305.h +++ b/src/crypto/zinc/selftest/poly1305.h @@ -1091,7 +1091,7 @@ static bool __init poly1305_selftest(void) poly1305_update(&poly1305, poly1305_testvecs[i].input + j, poly1305_testvecs[i].ilen - j, - (simd_context_t []){ HAVE_NO_SIMD }); + DONT_USE_SIMD); poly1305_final(&poly1305, out, &simd_context); if (memcmp(out, poly1305_testvecs[i].output, POLY1305_MAC_SIZE)) { |