crypto: aesni - release FPU during skcipher walk API calls
authorArd Biesheuvel <ardb@kernel.org>
Sat, 16 Jan 2021 16:48:10 +0000 (17:48 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 22 Jan 2021 03:58:04 +0000 (14:58 +1100)
commit65d1e3c415f6e380f6168faf333a59ec235eac5d
tree6e8542ceb9c4bb9ab31c5c4948ed10cc1d63f4a3
parent64a49b85953cafeaba2b4c2c13d089b3ed41cca6
crypto: aesni - release FPU during skcipher walk API calls

Taking ownership of the FPU in kernel mode disables preemption, and
this may result in excessive scheduling blackouts if the size of the
data being processed on the FPU is unbounded.

Given that taking and releasing the FPU is cheap these days on x86, we
can limit the impact of this issue easily for skcipher implementations,
by moving the FPU begin/end calls inside the skcipher walk processing
loop. Considering that skcipher walks operate on at most one page at a
time, doing so fully mitigates this issue.

This also permits the skcipher walk logic to use non-atomic kmalloc()
calls etc so we can change the 'atomic' bool argument in the calls to
skcipher_walk_virt() to false as well.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
arch/x86/crypto/aesni-intel_glue.c