]> git.baikalelectronics.ru Git - kernel.git/commit
crypto: arm64/chacha20 - move kernel mode neon en/disable into loop
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Sat, 10 Mar 2018 15:21:50 +0000 (15:21 +0000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 16 Mar 2018 15:35:55 +0000 (23:35 +0800)
commit0b65cf067751a6c0c3c25042accccc23d65eab62
treea8d0702d69f509f967b4fdfd57f91cef9a0cfdde
parent11bf817927087074ab92eb51731483cbd7c8d621
crypto: arm64/chacha20 - move kernel mode neon en/disable into loop

When kernel mode NEON was first introduced on arm64, the preserve and
restore of the userland NEON state was completely unoptimized, and
involved saving all registers on each call to kernel_neon_begin(),
and restoring them on each call to kernel_neon_end(). For this reason,
the NEON crypto code that was introduced at the time keeps the NEON
enabled throughout the execution of the crypto API methods, which may
include calls back into the crypto API that could result in memory
allocation or other actions that we should avoid when running with
preemption disabled.

Since then, we have optimized the kernel mode NEON handling, which now
restores lazily (upon return to userland), and so the preserve action
is only costly the first time it is called after entering the kernel.

So let's put the kernel_neon_begin() and kernel_neon_end() calls around
the actual invocations of the NEON crypto code, and run the remainder of
the code with kernel mode NEON disabled (and preemption enabled)

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
arch/arm64/crypto/chacha20-neon-glue.c