Skip to content

Commit 6d575f1

Browse files
author
Eric Biggers
committed
lib/crypto: arm64/sha3: Remove obsolete chunking logic
Since commit aefbab8 ("arm64: fpsimd: Preserve/restore kernel mode NEON at context switch"), kernel-mode NEON sections have been preemptible on arm64. And since commit 7dadeaa ("sched: Further restrict the preemption modes"), voluntary preemption is no longer supported on arm64 either. Therefore, there's no longer any need to limit the length of kernel-mode NEON sections on arm64. Simplify the SHA-3 code accordingly. Reviewed-by: Ard Biesheuvel <ardb@kernel.org> Link: https://lore.kernel.org/r/20260401000548.133151-9-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org>
1 parent 7116418 commit 6d575f1

2 files changed

Lines changed: 7 additions & 16 deletions

File tree

lib/crypto/arm64/sha3-ce-core.S

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
.endm
3838

3939
/*
40-
* size_t sha3_ce_transform(struct sha3_state *state, const u8 *data,
41-
* size_t nblocks, size_t block_size)
40+
* void sha3_ce_transform(struct sha3_state *state, const u8 *data,
41+
* size_t nblocks, size_t block_size)
4242
*
4343
* block_size is assumed to be one of 72 (SHA3-512), 104 (SHA3-384), 136
4444
* (SHA3-256 and SHAKE256), 144 (SHA3-224), or 168 (SHAKE128).
@@ -185,18 +185,16 @@ SYM_FUNC_START(sha3_ce_transform)
185185
eor v0.16b, v0.16b, v31.16b
186186

187187
cbnz w8, 3b
188-
cond_yield 4f, x8, x9
189188
cbnz x2, 0b
190189

191190
/* save state */
192-
4: st1 { v0.1d- v3.1d}, [x0], #32
191+
st1 { v0.1d- v3.1d}, [x0], #32
193192
st1 { v4.1d- v7.1d}, [x0], #32
194193
st1 { v8.1d-v11.1d}, [x0], #32
195194
st1 {v12.1d-v15.1d}, [x0], #32
196195
st1 {v16.1d-v19.1d}, [x0], #32
197196
st1 {v20.1d-v23.1d}, [x0], #32
198197
st1 {v24.1d}, [x0]
199-
mov x0, x2
200198
ret
201199
SYM_FUNC_END(sha3_ce_transform)
202200

lib/crypto/arm64/sha3.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,15 @@
1212

1313
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_sha3);
1414

15-
asmlinkage size_t sha3_ce_transform(struct sha3_state *state, const u8 *data,
16-
size_t nblocks, size_t block_size);
15+
asmlinkage void sha3_ce_transform(struct sha3_state *state, const u8 *data,
16+
size_t nblocks, size_t block_size);
1717

1818
static void sha3_absorb_blocks(struct sha3_state *state, const u8 *data,
1919
size_t nblocks, size_t block_size)
2020
{
2121
if (static_branch_likely(&have_sha3) && likely(may_use_simd())) {
22-
do {
23-
size_t rem;
24-
25-
scoped_ksimd()
26-
rem = sha3_ce_transform(state, data, nblocks,
27-
block_size);
28-
data += (nblocks - rem) * block_size;
29-
nblocks = rem;
30-
} while (nblocks);
22+
scoped_ksimd()
23+
sha3_ce_transform(state, data, nblocks, block_size);
3124
} else {
3225
sha3_absorb_blocks_generic(state, data, nblocks, block_size);
3326
}

0 commit comments

Comments
 (0)