aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/crypto/zinc/blake2s/blake2s-x86_64-glue.h
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-10-03 18:42:37 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-10-03 18:42:37 +0200
commit15e8156f8719f1caf3cd5cbd2f77e44993995431 (patch)
treeb6e9b7062c317063c0277c7d9c3f8f13a74ae41d /src/crypto/zinc/blake2s/blake2s-x86_64-glue.h
parentsimd: introduce useful disabling macro (diff)
downloadwireguard-monolithic-historical-15e8156f8719f1caf3cd5cbd2f77e44993995431.tar.xz
wireguard-monolithic-historical-15e8156f8719f1caf3cd5cbd2f77e44993995431.zip
blake2s: always put a simd, even if not use()'d
Diffstat (limited to '')
-rw-r--r--src/crypto/zinc/blake2s/blake2s-x86_64-glue.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/crypto/zinc/blake2s/blake2s-x86_64-glue.h b/src/crypto/zinc/blake2s/blake2s-x86_64-glue.h
index 1f331cb..2191e3f 100644
--- a/src/crypto/zinc/blake2s/blake2s-x86_64-glue.h
+++ b/src/crypto/zinc/blake2s/blake2s-x86_64-glue.h
@@ -39,6 +39,7 @@ static inline bool blake2s_compress_arch(struct blake2s_state *state,
const u32 inc)
{
simd_context_t simd_context;
+ bool used_arch = false;
/* SIMD disables preemption, so relax after processing each page. */
BUILD_BUG_ON(PAGE_SIZE / BLAKE2S_BLOCK_SIZE < 8);
@@ -47,7 +48,8 @@ static inline bool blake2s_compress_arch(struct blake2s_state *state,
if (!IS_ENABLED(CONFIG_AS_AVX) || !blake2s_use_avx ||
!simd_use(&simd_context))
- return false;
+ goto out;
+ used_arch = true;
for (;;) {
const size_t blocks = min_t(size_t, nblocks,
@@ -64,6 +66,7 @@ static inline bool blake2s_compress_arch(struct blake2s_state *state,
block += blocks * BLAKE2S_BLOCK_SIZE;
simd_relax(&simd_context);
}
+out:
simd_put(&simd_context);
- return true;
+ return used_arch;
}