Skip to content

Commit 6caf7ad

Browse files
Ard Biesheuvelherbertx
authored andcommitted
crypto: arm64/sha512-ce - yield NEON after every block of input
Avoid excessive scheduling delays under a preemptible kernel by conditionally yielding the NEON after every block of input. Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 7edc86c commit 6caf7ad

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

arch/arm64/crypto/sha512-ce-core.S

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,23 @@
107107
*/
108108
.text
109109
ENTRY(sha512_ce_transform)
110+
frame_push 3
111+
112+
mov x19, x0
113+
mov x20, x1
114+
mov x21, x2
115+
110116
/* load state */
111-
ld1 {v8.2d-v11.2d}, [x0]
117+
0: ld1 {v8.2d-v11.2d}, [x19]
112118

113119
/* load first 4 round constants */
114120
adr_l x3, .Lsha512_rcon
115121
ld1 {v20.2d-v23.2d}, [x3], #64
116122

117123
/* load input */
118-
0: ld1 {v12.2d-v15.2d}, [x1], #64
119-
ld1 {v16.2d-v19.2d}, [x1], #64
120-
sub w2, w2, #1
124+
1: ld1 {v12.2d-v15.2d}, [x20], #64
125+
ld1 {v16.2d-v19.2d}, [x20], #64
126+
sub w21, w21, #1
121127

122128
CPU_LE( rev64 v12.16b, v12.16b )
123129
CPU_LE( rev64 v13.16b, v13.16b )
@@ -196,9 +202,18 @@ CPU_LE( rev64 v19.16b, v19.16b )
196202
add v11.2d, v11.2d, v3.2d
197203

198204
/* handled all input blocks? */
199-
cbnz w2, 0b
205+
cbz w21, 3f
206+
207+
if_will_cond_yield_neon
208+
st1 {v8.2d-v11.2d}, [x19]
209+
do_cond_yield_neon
210+
b 0b
211+
endif_yield_neon
212+
213+
b 1b
200214

201215
/* store new state */
202-
3: st1 {v8.2d-v11.2d}, [x0]
216+
3: st1 {v8.2d-v11.2d}, [x19]
217+
frame_pop
203218
ret
204219
ENDPROC(sha512_ce_transform)

0 commit comments

Comments
 (0)