Skip to content

Commit

Permalink
armv8_crypto: fix recursive fpu_kern_enter call
Browse files Browse the repository at this point in the history
Now armv8_crypto is using FPU_KERN_NOCTX, this results in a kernel panic
in armv8_crypto.c:armv8_crypto_cipher_setup:

    panic: recursive fpu_kern_enter while in PCB_FP_NOSAVE state

This is because in armv8_crypto.c:armv8_crypto_cipher_process,
directly after calling fpu_kern_enter() a call is made to
armv8_crypto_cipher_setup(), resulting in nested calls to
fpu_kern_enter() without the required fpu_kern_leave() in between.

Move fpu_kern_enter() in armv8_crypto_cipher_process() after the
call to armv8_crypto_cipher_setup() to resolve this.

Reviewed by:	markj, andrew
Fixes: 6485286 ("armv8_crypto: Switch to using FPU_KERN_NOCTX")
Sponsored by: Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D41671
  • Loading branch information
zdleaf authored and zxombie committed Sep 1, 2023
1 parent 5429e19 commit 565c887
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sys/crypto/armv8/armv8_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,15 +336,15 @@ armv8_crypto_cipher_process(struct armv8_crypto_session *ses,
crypto_cursor_copy(&fromc, &toc);
}

fpu_kern_enter(curthread, NULL, FPU_KERN_NORMAL | FPU_KERN_NOCTX);

if (crp->crp_cipher_key != NULL) {
armv8_crypto_cipher_setup(ses, csp, crp->crp_cipher_key,
csp->csp_cipher_klen);
}

crypto_read_iv(crp, iv);

fpu_kern_enter(curthread, NULL, FPU_KERN_NORMAL | FPU_KERN_NOCTX);

error = 0;
switch (csp->csp_cipher_alg) {
case CRYPTO_AES_CBC:
Expand Down

0 comments on commit 565c887

Please sign in to comment.