OSDN Git Service

crypto: arm64/sha512-ce - yield NEON after every block of input
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 30 Apr 2018 16:18:30 +0000 (18:18 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 11 May 2018 16:13:12 +0000 (00:13 +0800)
Avoid excessive scheduling delays under a preemptible kernel by
conditionally yielding the NEON after every block of input.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
arch/arm64/crypto/sha512-ce-core.S

index 7f3bca5..ce65e3a 100644 (file)
         */
        .text
 ENTRY(sha512_ce_transform)
+       frame_push      3
+
+       mov             x19, x0
+       mov             x20, x1
+       mov             x21, x2
+
        /* load state */
-       ld1             {v8.2d-v11.2d}, [x0]
+0:     ld1             {v8.2d-v11.2d}, [x19]
 
        /* load first 4 round constants */
        adr_l           x3, .Lsha512_rcon
        ld1             {v20.2d-v23.2d}, [x3], #64
 
        /* load input */
-0:     ld1             {v12.2d-v15.2d}, [x1], #64
-       ld1             {v16.2d-v19.2d}, [x1], #64
-       sub             w2, w2, #1
+1:     ld1             {v12.2d-v15.2d}, [x20], #64
+       ld1             {v16.2d-v19.2d}, [x20], #64
+       sub             w21, w21, #1
 
 CPU_LE(        rev64           v12.16b, v12.16b        )
 CPU_LE(        rev64           v13.16b, v13.16b        )
@@ -196,9 +202,18 @@ CPU_LE(    rev64           v19.16b, v19.16b        )
        add             v11.2d, v11.2d, v3.2d
 
        /* handled all input blocks? */
-       cbnz            w2, 0b
+       cbz             w21, 3f
+
+       if_will_cond_yield_neon
+       st1             {v8.2d-v11.2d}, [x19]
+       do_cond_yield_neon
+       b               0b
+       endif_yield_neon
+
+       b               1b
 
        /* store new state */
-3:     st1             {v8.2d-v11.2d}, [x0]
+3:     st1             {v8.2d-v11.2d}, [x19]
+       frame_pop
        ret
 ENDPROC(sha512_ce_transform)