Skip to content

Commit 4316932

Browse files
dramforeverEric Biggers
authored andcommitted
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: bb54668 ("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>
1 parent 7a3984b commit 4316932

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

lib/crypto/riscv/chacha-riscv64-zvkb.S

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060
#define VL t2
6161
#define STRIDE t3
6262
#define ROUND_CTR t4
63-
#define KEY0 s0
63+
#define KEY0 t5
64+
// Avoid s0/fp to allow for unwinding
6465
#define KEY1 s1
6566
#define KEY2 s2
6667
#define KEY3 s3
@@ -143,7 +144,6 @@
143144
// The updated 32-bit counter is written back to state->x[12] before returning.
144145
SYM_FUNC_START(chacha_zvkb)
145146
addi sp, sp, -96
146-
sd s0, 0(sp)
147147
sd s1, 8(sp)
148148
sd s2, 16(sp)
149149
sd s3, 24(sp)
@@ -280,7 +280,6 @@ SYM_FUNC_START(chacha_zvkb)
280280
bnez NBLOCKS, .Lblock_loop
281281

282282
sw COUNTER, 48(STATEP)
283-
ld s0, 0(sp)
284283
ld s1, 8(sp)
285284
ld s2, 16(sp)
286285
ld s3, 24(sp)

0 commit comments

Comments
 (0)