Skip to content

Commit 1676629

Browse files
committed
Revert "crypto: powerpc/poly1305 - Add SIMD fallback"
This reverts commit c66d7eb. Link: https://lore.kernel.org/all/02c22854-eebf-4ad1-b89e-8c2b65ab8236@csgroup.eu/ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 72942d6 commit 1676629

File tree

3 files changed

+4
-40
lines changed

3 files changed

+4
-40
lines changed

arch/powerpc/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ config PPC
173173
select ARCH_STACKWALK
174174
select ARCH_SUPPORTS_ATOMIC_RMW
175175
select ARCH_SUPPORTS_DEBUG_PAGEALLOC if PPC_BOOK3S || PPC_8xx
176-
select ARCH_SUPPORTS_INT128 if PPC64 && CC_HAS_INT128
177176
select ARCH_USE_BUILTIN_BSWAP
178177
select ARCH_USE_CMPXCHG_LOCKREF if PPC64
179178
select ARCH_USE_MEMTEST

arch/powerpc/lib/crypto/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ config CRYPTO_CHACHA20_P10
99

1010
config CRYPTO_POLY1305_P10
1111
tristate
12-
depends on PPC64 && CPU_LITTLE_ENDIAN && VSX && ARCH_SUPPORTS_INT128
12+
depends on PPC64 && CPU_LITTLE_ENDIAN && VSX
1313
default CRYPTO_LIB_POLY1305
1414
select CRYPTO_ARCH_HAVE_LIB_POLY1305
1515
select CRYPTO_LIB_POLY1305_GENERIC

arch/powerpc/lib/crypto/poly1305-p10-glue.c

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77
#include <asm/switch_to.h>
88
#include <crypto/internal/poly1305.h>
9-
#include <crypto/internal/simd.h>
109
#include <linux/cpufeature.h>
1110
#include <linux/jump_label.h>
1211
#include <linux/kernel.h>
@@ -19,11 +18,6 @@ asmlinkage void poly1305_emit_64(const struct poly1305_state *state, const u32 n
1918

2019
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_p10);
2120

22-
static inline bool is_state_base64(struct poly1305_block_state *state)
23-
{
24-
return state->core_r.precomputed_s.r64[2];
25-
}
26-
2721
static void vsx_begin(void)
2822
{
2923
preempt_disable();
@@ -36,35 +30,12 @@ static void vsx_end(void)
3630
preempt_enable();
3731
}
3832

39-
static void convert_to_base2_44(struct poly1305_block_state *state)
40-
{
41-
u8 raw_key[POLY1305_BLOCK_SIZE];
42-
u64 h0, h1, h2;
43-
44-
if (!is_state_base64(state))
45-
return;
46-
47-
state->core_r.precomputed_s.r64[2] = 0;
48-
put_unaligned_le64(state->core_r.key.r64[0], raw_key + 0);
49-
put_unaligned_le64(state->core_r.key.r64[1], raw_key + 8);
50-
poly1305_core_setkey(&state->core_r, raw_key);
51-
52-
h0 = state->h.h64[0];
53-
h1 = state->h.h64[1];
54-
h2 = state->h.h64[2];
55-
state->h.h64[0] = h0 & 0xfffffffffffULL;
56-
state->h.h64[1] = h0 >> 44 | (h1 & 0xffffffULL) << 20;
57-
state->h.h64[2] = h1 >> 24 | h2 << 40;
58-
}
59-
6033
void poly1305_block_init_arch(struct poly1305_block_state *dctx,
6134
const u8 raw_key[POLY1305_BLOCK_SIZE])
6235
{
63-
dctx->core_r.precomputed_s.r64[2] = 0;
64-
if (!static_key_enabled(&have_p10) || !crypto_simd_usable())
36+
if (!static_key_enabled(&have_p10))
6537
return poly1305_block_init_generic(dctx, raw_key);
6638

67-
dctx->core_r.precomputed_s.r64[2] = 1;
6839
dctx->h = (struct poly1305_state){};
6940
dctx->core_r.key.r64[0] = get_unaligned_le64(raw_key + 0);
7041
dctx->core_r.key.r64[1] = get_unaligned_le64(raw_key + 8);
@@ -74,11 +45,8 @@ EXPORT_SYMBOL_GPL(poly1305_block_init_arch);
7445
void poly1305_blocks_arch(struct poly1305_block_state *state, const u8 *src,
7546
unsigned int len, u32 padbit)
7647
{
77-
if (!static_key_enabled(&have_p10) || !is_state_base64(state) ||
78-
!crypto_simd_usable()) {
79-
convert_to_base2_44(state);
48+
if (!static_key_enabled(&have_p10))
8049
return poly1305_blocks_generic(state, src, len, padbit);
81-
}
8250
vsx_begin();
8351
if (len >= POLY1305_BLOCK_SIZE * 4) {
8452
poly1305_p10le_4blocks(state, src, len);
@@ -98,10 +66,7 @@ void poly1305_emit_arch(const struct poly1305_state *state,
9866
u8 digest[POLY1305_DIGEST_SIZE],
9967
const u32 nonce[4])
10068
{
101-
struct poly1305_block_state *dctx =
102-
container_of(state, struct poly1305_block_state, h);
103-
104-
if (!static_key_enabled(&have_p10) || !is_state_base64(dctx))
69+
if (!static_key_enabled(&have_p10))
10570
return poly1305_emit_generic(state, digest, nonce);
10671
poly1305_emit_64(state, nonce, digest);
10772
}

0 commit comments

Comments
 (0)