Skip to content

Commit d0cbd9f

Browse files
kevans91behlendorf
authored andcommitted
module: freebsd: fix aarch64 fpu handling
Just like x86, aarch64 needs to use the fpu_kern(9) API around FPU usage, otherwise we panic promptly at boot as soon as ZFS attempts to do checksum benchmarking. Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de> Signed-off-by: Kyle Evans <kevans@FreeBSD.org> Closes #14715
1 parent dee77f4 commit d0cbd9f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

include/os/freebsd/spl/sys/simd_aarch64.h

+12-2
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,23 @@
4444
#define _FREEBSD_SIMD_AARCH64_H
4545

4646
#include <sys/types.h>
47+
#include <sys/ucontext.h>
4748
#include <machine/elf.h>
49+
#include <machine/fpu.h>
4850
#include <machine/md_var.h>
51+
#include <machine/pcb.h>
4952

5053
#define kfpu_allowed() 1
5154
#define kfpu_initialize(tsk) do {} while (0)
52-
#define kfpu_begin() do {} while (0)
53-
#define kfpu_end() do {} while (0)
55+
#define kfpu_begin() do { \
56+
if (__predict_false(!is_fpu_kern_thread(0))) \
57+
fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX); \
58+
} while (0)
59+
60+
#define kfpu_end() do { \
61+
if (__predict_false(curthread->td_pcb->pcb_fpflags & PCB_FP_NOSAVE)) \
62+
fpu_kern_leave(curthread, NULL); \
63+
} while (0)
5464
#define kfpu_init() (0)
5565
#define kfpu_fini() do {} while (0)
5666

0 commit comments

Comments
 (0)