Skip to content

Commit 64e2cbc

Browse files
committed
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. Note that the build is broken both before and after this commit in the openzfs repo... there's a non-trivial conflict of AT_UID/AT_GID in sys/elf_common.h. In FreeBSD, we solved it with a quick hack in spl/sys/vnode.h to undef AT_UID/AT_GID before, but in the standalone build the conflict is in the other direction. It's not clear how to best handle that; presumably we don't want the elf_common.h definition of AT_UID/AT_GID in ZFS code, but to solve it we would need to undef these before including machine/elf.h in spl/sys/simd_aarch64.h. Punting on this for now. Signed-off-by: Kyle Evans <kevans@FreeBSD.org>
1 parent 6c3b357 commit 64e2cbc

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)