Skip to content

Commit

Permalink
module: freebsd: fix aarch64 fpu handling
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
kevans91 committed Apr 4, 2023
1 parent c1b7fed commit 919844e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions include/os/freebsd/spl/sys/simd_aarch64.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,23 @@
#define _FREEBSD_SIMD_AARCH64_H

#include <sys/types.h>
#include <sys/ucontext.h>
#include <machine/elf.h>
#include <machine/fpu.h>
#include <machine/md_var.h>
#include <machine/pcb.h>

#define kfpu_allowed() 1
#define kfpu_initialize(tsk) do {} while (0)
#define kfpu_begin() do {} while (0)
#define kfpu_end() do {} while (0)
#define kfpu_begin() do { \
if (__predict_false(!is_fpu_kern_thread(0))) \
fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX); \
} while(0)

#define kfpu_end() do { \
if (__predict_false(curthread->td_pcb->pcb_fpflags & PCB_FP_NOSAVE)) \
fpu_kern_leave(curthread, NULL); \
} while(0)
#define kfpu_init() (0)
#define kfpu_fini() do {} while (0)

Expand Down

0 comments on commit 919844e

Please sign in to comment.