Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: powerpc/poly1305 - Add poly1305_emit_arch wrapper

Add poly1305_emit_arch with fallback instead of calling assembly
directly. This is because the state format differs between p10
and that of the generic implementation.

Reported-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Reported-by: Eric Biggers <ebiggers@google.com>
Fixes: 14d31979145d ("crypto: powerpc/poly1305 - Add block-only interface")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Herbert Xu 7916eddc 4e0146a9

+13 -6
+11 -4
arch/powerpc/lib/crypto/poly1305-p10-glue.c
··· 14 14 15 15 asmlinkage void poly1305_p10le_4blocks(struct poly1305_block_state *state, const u8 *m, u32 mlen); 16 16 asmlinkage void poly1305_64s(struct poly1305_block_state *state, const u8 *m, u32 mlen, int highbit); 17 - asmlinkage void poly1305_emit_arch(const struct poly1305_state *state, 18 - u8 digest[POLY1305_DIGEST_SIZE], 19 - const u32 nonce[4]); 20 - EXPORT_SYMBOL_GPL(poly1305_emit_arch); 17 + asmlinkage void poly1305_emit_64(const struct poly1305_state *state, const u32 nonce[4], u8 digest[POLY1305_DIGEST_SIZE]); 21 18 22 19 static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_p10); 23 20 ··· 61 64 vsx_end(); 62 65 } 63 66 EXPORT_SYMBOL_GPL(poly1305_blocks_arch); 67 + 68 + void poly1305_emit_arch(const struct poly1305_state *state, 69 + u8 digest[POLY1305_DIGEST_SIZE], 70 + const u32 nonce[4]) 71 + { 72 + if (!static_key_enabled(&have_p10)) 73 + return poly1305_emit_generic(state, digest, nonce); 74 + poly1305_emit_64(state, nonce, digest); 75 + } 76 + EXPORT_SYMBOL_GPL(poly1305_emit_arch); 64 77 65 78 bool poly1305_is_arch_optimized(void) 66 79 {
+2 -2
arch/powerpc/lib/crypto/poly1305-p10le_64.S
··· 1030 1030 # Input: r3 = h, r4 = s, r5 = mac 1031 1031 # mac = h + s 1032 1032 # 1033 - SYM_FUNC_START(poly1305_emit_arch) 1033 + SYM_FUNC_START(poly1305_emit_64) 1034 1034 ld 10, 0(3) 1035 1035 ld 11, 8(3) 1036 1036 ld 12, 16(3) ··· 1060 1060 std 10, 0(5) 1061 1061 std 11, 8(5) 1062 1062 blr 1063 - SYM_FUNC_END(poly1305_emit_arch) 1063 + SYM_FUNC_END(poly1305_emit_64) 1064 1064 1065 1065 SYM_DATA_START_LOCAL(RMASK) 1066 1066 .align 5