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
2019static __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-
2721static 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-
6033void 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);
7445void 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