crypto: arm64/sha256 - fix build when CONFIG_PREEMPT_VOLUNTARY=y
Subsystems (2)
PATCH 1/1 crypto: arm64/sha256 - fix build when CONFIG_PREEMPT_VOLUNTARY=y
From: Eric Biggers <[email protected]>
Fix the build of sha256-ce.S when CONFIG_PREEMPT_VOLUNTARY=y by passing the correct label to the cond_yield macro. Also adjust the code to execute only one branch instruction when CONFIG_PREEMPT_VOLUNTARY=n.
--- arch/arm64/lib/crypto/sha256-ce.S | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/arm64/lib/crypto/sha256-ce.S +4 -3
@@ -121,14 +121,15 @@ CPU_LE( rev32 v19.16b, v19.16b ) /* update state */ add dgav.4s, dgav.4s, dg0v.4s add dgbv.4s, dgbv.4s, dg1v.4s + /* return early if voluntary preemption is needed */ + cond_yield 1f, x5, x6 + /* handled all input blocks? */ - cbz x2, 1f - cond_yield 3f, x5, x6 - b 0b + cbnz x2, 0b /* store new state */ 1: st1 {dgav.4s, dgbv.4s}, [x0] mov x0, x2 ret
base-commit: 20e9579f11b6cbdf0556d9cd85a0aa7653caf341
Signature · 1 line
2.49.0
Herbert Xu
maintainerQuoted 6 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Fix the build of
sha256-ce.SwhenCONFIG_PREEMPT_VOLUNTARY=yby passing the correct label to thecond_yieldmacro. Also adjust the code to execute only one branch instruction whenCONFIG_PREEMPT_VOLUNTARY=n.
Quoted 7 lines
Fixes 6e36be511d28 ("crypto: arm64/sha256 - implement library instead of shash")Reported-by kernel test robot <[email protected]>Signed-off-by Eric Biggers <[email protected]>---
arch/arm64/lib/crypto/sha256-ce.S| 7 ++++---1 file changed, 4 insertions(+), 3 deletions(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Quoted 20 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Fix the build of
sha256-ce.SwhenCONFIG_PREEMPT_VOLUNTARY=yby passing the correct label to thecond_yieldmacro. Also adjust the code to execute only one branch instruction whenCONFIG_PREEMPT_VOLUNTARY=n.Fixes 6e36be511d28 ("crypto: arm64/sha256 - implement library instead of shash")Reported-by kernel test robot <[email protected]>Signed-off-by Eric Biggers <[email protected]>--- arch/arm64/lib/crypto/sha256-ce.S | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)arch/arm64/lib/crypto/sha256-ce.S +0
-0
arch/arm64/lib/crypto/sha256-ce.S CPU_LE( rev32 v19.16b, v19.16b ) · line 128
Quoted 8 lines
arch/arm64/lib/crypto/sha256-ce.S +3
-0@@ -121,14 +121,15 @@ CPU_LE( rev32 v19.16b, v19.16b ) /* update state */ add dgav.4s, dgav.4s, dg0v.4s add dgbv.4s, dgbv.4s, dg1v.4s + /* return early if voluntary preemption is needed */ + cond_yield 1f, x5, x6 +
This will yield needlessly when the condition hits during the final iteration.
Quoted 15 lines
arch/arm64/lib/crypto/sha256-ce.S +1
-3/* handled all input blocks? */ - cbz x2, 1f - cond_yield 3f, x5, x6 - b 0b + cbnz x2, 0b /* store new state */ 1: st1 {dgav.4s, dgbv.4s}, [x0] mov x0, x2 retbase-commit:
20e9579f11b6cbdf0556d9cd85a0aa7653caf341--
2.49.0
Quoted 26 lines · Ard Biesheuvel
Quoted 25 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Fix the build of
sha256-ce.SwhenCONFIG_PREEMPT_VOLUNTARY=yby passing the correct label to thecond_yieldmacro. Also adjust the code to execute only one branch instruction whenCONFIG_PREEMPT_VOLUNTARY=n.Fixes 6e36be511d28 ("crypto: arm64/sha256 - implement library instead of shash")Reported-by kernel test robot <[email protected]>Signed-off-by Eric Biggers <[email protected]>--- arch/arm64/lib/crypto/sha256-ce.S | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)arch/arm64/lib/crypto/sha256-ce.S +0
-0@@ -121,14 +121,15 @@ CPU_LE( rev32 v19.16b, v19.16b ) /* update state */ add dgav.4s, dgav.4s, dg0v.4s add dgbv.4s, dgbv.4s, dg1v.4s
Quoted 11 lines
arch/arm64/lib/crypto/sha256-ce.S CPU_LE( rev32 v19.16b, v19.16b ) · line 128
Quoted 3 lines
arch/arm64/lib/crypto/sha256-ce.S +3
-0+ /* return early if voluntary preemption is needed */ + cond_yield 1f, x5, x6 +This will yield needlessly when the condition hits during the final iteration.
Quoted 5 lines
arch/arm64/lib/crypto/sha256-ce.S +1
-3/* handled all input blocks? */ - cbz x2, 1f - cond_yield 3f, x5, x6 - b 0b + cbnz x2, 0b
cond_yield doesn't actually yield, though. It just checks whether yielding is needed. So the behavior is the same: on the last iteration this function returns 0 (i.e. 0 blocks remaining), regardless of whether it gets to the end by jumping there due to TSK_TI_PREEMPT being set or by falling through after seeing nblocks==0. We could keep the nblocks==0 check first, but the cond_yield check is lightweight and it's probably better to avoid the extra branch instruction on every other iteration.
- Eric
Quoted 40 lines · Eric Biggers
Quoted 26 lines · Ard Biesheuvel
Quoted 25 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Fix the build of
sha256-ce.SwhenCONFIG_PREEMPT_VOLUNTARY=yby passing the correct label to thecond_yieldmacro. Also adjust the code to execute only one branch instruction whenCONFIG_PREEMPT_VOLUNTARY=n.Fixes 6e36be511d28 ("crypto: arm64/sha256 - implement library instead of shash")Reported-by kernel test robot <[email protected]>Signed-off-by Eric Biggers <[email protected]>--- arch/arm64/lib/crypto/sha256-ce.S | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)arch/arm64/lib/crypto/sha256-ce.S +0
-0@@ -121,14 +121,15 @@ CPU_LE( rev32 v19.16b, v19.16b ) /* update state */ add dgav.4s, dgav.4s, dg0v.4s add dgbv.4s, dgbv.4s, dg1v.4sQuoted 11 lines
arch/arm64/lib/crypto/sha256-ce.S CPU_LE( rev32 v19.16b, v19.16b ) · line 128
Quoted 3 lines
arch/arm64/lib/crypto/sha256-ce.S +3
-0+ /* return early if voluntary preemption is needed */ + cond_yield 1f, x5, x6 +This will yield needlessly when the condition hits during the final iteration.
Quoted 5 lines
arch/arm64/lib/crypto/sha256-ce.S +1
-3/* handled all input blocks? */ - cbz x2, 1f - cond_yield 3f, x5, x6 - b 0b + cbnz x2, 0b
Quoted 8 lines
cond_yielddoesn't actually yield, though. It just checks whether yielding is needed. So the behavior is the same: on the last iteration this function returns 0 (i.e. 0 blocks remaining), regardless of whether it gets to the end by jumping there due toTSK_TI_PREEMPTbeing set or by falling through after seeing nblocks==0. We could keep the nblocks==0 check first, but thecond_yieldcheck is lightweight and it's probably better to avoid the extra branch instruction on every other iteration.
Ah yes, you're right.
Hopefully we'll soon be able to get rid of it entirely.