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

Configure Feed

Select the types of activity you want to include in your feed.

lib/crypto: riscv/chacha: Avoid s0/fp register

In chacha_zvkb, avoid using the s0 register, which is the frame pointer,
by reallocating KEY0 to t5. This makes stack traces available if e.g. a
crash happens in chacha_zvkb.

No frame pointer maintenance is otherwise required since this is a leaf
function.

Signed-off-by: Vivian Wang <wangruikang@iscas.ac.cn>
Fixes: bb54668837a0 ("crypto: riscv - add vector crypto accelerated ChaCha20")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20251202-riscv-chacha_zvkb-fp-v2-1-7bd00098c9dc@iscas.ac.cn
Signed-off-by: Eric Biggers <ebiggers@kernel.org>

authored by

Vivian Wang and committed by
Eric Biggers
43169328 7a3984bb

+2 -3
+2 -3
lib/crypto/riscv/chacha-riscv64-zvkb.S
··· 60 60 #define VL t2 61 61 #define STRIDE t3 62 62 #define ROUND_CTR t4 63 - #define KEY0 s0 63 + #define KEY0 t5 64 + // Avoid s0/fp to allow for unwinding 64 65 #define KEY1 s1 65 66 #define KEY2 s2 66 67 #define KEY3 s3 ··· 144 143 // The updated 32-bit counter is written back to state->x[12] before returning. 145 144 SYM_FUNC_START(chacha_zvkb) 146 145 addi sp, sp, -96 147 - sd s0, 0(sp) 148 146 sd s1, 8(sp) 149 147 sd s2, 16(sp) 150 148 sd s3, 24(sp) ··· 280 280 bnez NBLOCKS, .Lblock_loop 281 281 282 282 sw COUNTER, 48(STATEP) 283 - ld s0, 0(sp) 284 283 ld s1, 8(sp) 285 284 ld s2, 16(sp) 286 285 ld s3, 24(sp)