2 dnl # Handle differences in kernel FPU code.
5 dnl # 5.0: Wrappers have been introduced to save/restore the FPU state.
6 dnl # This change was made to the 4.19.38 and 4.14.120 LTS kernels.
7 dnl # HAVE_KERNEL_FPU_INTERNAL
9 dnl # 4.2: Use __kernel_fpu_{begin,end}()
10 dnl # HAVE_UNDERSCORE_KERNEL_FPU & KERNEL_EXPORTS_X86_FPU
12 dnl # Pre-4.2: Use kernel_fpu_{begin,end}()
13 dnl # HAVE_KERNEL_FPU & KERNEL_EXPORTS_X86_FPU
15 dnl # N.B. The header check is performed before all other checks since it
16 dnl # depends on HAVE_KERNEL_FPU_API_HEADER being set in confdefs.h.
18 AC_DEFUN([ZFS_AC_KERNEL_FPU_HEADER], [
19 AC_MSG_CHECKING([whether fpu headers are available])
20 ZFS_LINUX_TRY_COMPILE([
21 #include <linux/module.h>
22 #include <asm/fpu/api.h>
25 AC_DEFINE(HAVE_KERNEL_FPU_API_HEADER, 1,
26 [kernel has asm/fpu/api.h])
27 AC_MSG_RESULT(asm/fpu/api.h)
29 AC_MSG_RESULT(i387.h & xcr.h)
33 AC_DEFUN([ZFS_AC_KERNEL_SRC_FPU], [
34 ZFS_LINUX_TEST_SRC([kernel_fpu], [
35 #include <linux/types.h>
36 #ifdef HAVE_KERNEL_FPU_API_HEADER
37 #include <asm/fpu/api.h>
45 ], [], [ZFS_META_LICENSE])
47 ZFS_LINUX_TEST_SRC([__kernel_fpu], [
48 #include <linux/types.h>
49 #ifdef HAVE_KERNEL_FPU_API_HEADER
50 #include <asm/fpu/api.h>
58 ], [], [ZFS_META_LICENSE])
60 ZFS_LINUX_TEST_SRC([fpu_internal], [
61 #if defined(__x86_64) || defined(__x86_64__) || \
62 defined(__i386) || defined(__i386__)
69 #error Unsupported architecture
72 #include <linux/types.h>
73 #ifdef HAVE_KERNEL_FPU_API_HEADER
74 #include <asm/fpu/api.h>
75 #include <asm/fpu/internal.h>
81 #if !defined(XSTATE_XSAVE)
82 #error XSTATE_XSAVE not defined
85 #if !defined(XSTATE_XRESTORE)
86 #error XSTATE_XRESTORE not defined
89 struct fpu *fpu = ¤t->thread.fpu;
90 union fpregs_state *st = &fpu->state;
91 struct fregs_state *fr __attribute__ ((unused)) = &st->fsave;
92 struct fxregs_state *fxr __attribute__ ((unused)) = &st->fxsave;
93 struct xregs_state *xr __attribute__ ((unused)) = &st->xsave;
97 AC_DEFUN([ZFS_AC_KERNEL_FPU], [
101 AC_MSG_CHECKING([whether kernel fpu is available])
102 ZFS_LINUX_TEST_RESULT_SYMBOL([kernel_fpu_license],
103 [kernel_fpu_begin], [arch/x86/kernel/fpu/core.c], [
104 AC_MSG_RESULT(kernel_fpu_*)
105 AC_DEFINE(HAVE_KERNEL_FPU, 1,
106 [kernel has kernel_fpu_* functions])
107 AC_DEFINE(KERNEL_EXPORTS_X86_FPU, 1,
108 [kernel exports FPU functions])
111 dnl # Linux 4.2 kernel
113 ZFS_LINUX_TEST_RESULT_SYMBOL([__kernel_fpu_license],
114 [__kernel_fpu_begin],
115 [arch/x86/kernel/fpu/core.c arch/x86/kernel/i387.c], [
116 AC_MSG_RESULT(__kernel_fpu_*)
117 AC_DEFINE(HAVE_UNDERSCORE_KERNEL_FPU, 1,
118 [kernel has __kernel_fpu_* functions])
119 AC_DEFINE(KERNEL_EXPORTS_X86_FPU, 1,
120 [kernel exports FPU functions])
122 ZFS_LINUX_TEST_RESULT([fpu_internal], [
123 AC_MSG_RESULT(internal)
124 AC_DEFINE(HAVE_KERNEL_FPU_INTERNAL, 1,
125 [kernel fpu internal])
127 AC_MSG_RESULT(unavailable)