2 dnl # Handle differences in kernel FPU code.
5 dnl # 5.16: XCR code put into asm/fpu/xcr.h
6 dnl # HAVE_KERNEL_FPU_XCR_HEADER
8 dnl # XSTATE_XSAVE and XSTATE_XRESTORE aren't accessible any more
9 dnl # HAVE_KERNEL_FPU_XSAVE_INTERNAL
11 dnl # 5.11: kernel_fpu_begin() is an inlined function now, so don't check
12 dnl # for it inside the kernel symbols.
14 dnl # 5.0: Wrappers have been introduced to save/restore the FPU state.
15 dnl # This change was made to the 4.19.38 and 4.14.120 LTS kernels.
16 dnl # HAVE_KERNEL_FPU_INTERNAL
18 dnl # 4.2: Use __kernel_fpu_{begin,end}()
19 dnl # HAVE_UNDERSCORE_KERNEL_FPU & KERNEL_EXPORTS_X86_FPU
21 dnl # Pre-4.2: Use kernel_fpu_{begin,end}()
22 dnl # HAVE_KERNEL_FPU & KERNEL_EXPORTS_X86_FPU
24 dnl # N.B. The header check is performed before all other checks since it
25 dnl # depends on HAVE_KERNEL_FPU_API_HEADER being set in confdefs.h.
27 AC_DEFUN([ZFS_AC_KERNEL_FPU_HEADER], [
28 AC_MSG_CHECKING([whether fpu headers are available])
29 ZFS_LINUX_TRY_COMPILE([
30 #include <linux/module.h>
31 #include <asm/fpu/api.h>
34 AC_DEFINE(HAVE_KERNEL_FPU_API_HEADER, 1,
35 [kernel has asm/fpu/api.h])
36 AC_MSG_RESULT(asm/fpu/api.h)
37 AC_MSG_CHECKING([whether fpu/xcr header is available])
38 ZFS_LINUX_TRY_COMPILE([
39 #include <linux/module.h>
40 #include <asm/fpu/xcr.h>
43 AC_DEFINE(HAVE_KERNEL_FPU_XCR_HEADER, 1,
44 [kernel has asm/fpu/xcr.h])
45 AC_MSG_RESULT(asm/fpu/xcr.h)
47 AC_MSG_RESULT(no asm/fpu/xcr.h)
50 AC_MSG_RESULT(i387.h & xcr.h)
54 AC_DEFUN([ZFS_AC_KERNEL_SRC_FPU], [
55 ZFS_LINUX_TEST_SRC([kernel_fpu], [
56 #include <linux/types.h>
57 #ifdef HAVE_KERNEL_FPU_API_HEADER
58 #include <asm/fpu/api.h>
66 ], [], [ZFS_META_LICENSE])
68 ZFS_LINUX_TEST_SRC([__kernel_fpu], [
69 #include <linux/types.h>
70 #ifdef HAVE_KERNEL_FPU_API_HEADER
71 #include <asm/fpu/api.h>
79 ], [], [ZFS_META_LICENSE])
81 ZFS_LINUX_TEST_SRC([fpu_internal], [
82 #if defined(__x86_64) || defined(__x86_64__) || \
83 defined(__i386) || defined(__i386__)
90 #error Unsupported architecture
93 #include <linux/types.h>
94 #ifdef HAVE_KERNEL_FPU_API_HEADER
95 #include <asm/fpu/api.h>
96 #include <asm/fpu/internal.h>
102 #if !defined(XSTATE_XSAVE)
103 #error XSTATE_XSAVE not defined
106 #if !defined(XSTATE_XRESTORE)
107 #error XSTATE_XRESTORE not defined
110 struct fpu *fpu = ¤t->thread.fpu;
111 union fpregs_state *st = &fpu->state;
112 struct fregs_state *fr __attribute__ ((unused)) = &st->fsave;
113 struct fxregs_state *fxr __attribute__ ((unused)) = &st->fxsave;
114 struct xregs_state *xr __attribute__ ((unused)) = &st->xsave;
117 ZFS_LINUX_TEST_SRC([fpu_xsave_internal], [
118 #include <linux/sched.h>
119 #if defined(__x86_64) || defined(__x86_64__) || \
120 defined(__i386) || defined(__i386__)
127 #error Unsupported architecture
130 #include <linux/types.h>
131 #ifdef HAVE_KERNEL_FPU_API_HEADER
132 #include <asm/fpu/api.h>
133 #include <asm/fpu/internal.h>
135 #include <asm/i387.h>
140 struct fpu *fpu = ¤t->thread.fpu;
141 union fpregs_state *st = &fpu->fpstate->regs;
142 struct fregs_state *fr __attribute__ ((unused)) = &st->fsave;
143 struct fxregs_state *fxr __attribute__ ((unused)) = &st->fxsave;
144 struct xregs_state *xr __attribute__ ((unused)) = &st->xsave;
148 AC_DEFUN([ZFS_AC_KERNEL_FPU], [
152 AC_MSG_CHECKING([whether kernel fpu is available])
153 ZFS_LINUX_TEST_RESULT([kernel_fpu_license], [
154 AC_MSG_RESULT(kernel_fpu_*)
155 AC_DEFINE(HAVE_KERNEL_FPU, 1,
156 [kernel has kernel_fpu_* functions])
157 AC_DEFINE(KERNEL_EXPORTS_X86_FPU, 1,
158 [kernel exports FPU functions])
161 dnl # Linux 4.2 kernel
163 ZFS_LINUX_TEST_RESULT_SYMBOL([__kernel_fpu_license],
164 [__kernel_fpu_begin],
165 [arch/x86/kernel/fpu/core.c arch/x86/kernel/i387.c], [
166 AC_MSG_RESULT(__kernel_fpu_*)
167 AC_DEFINE(HAVE_UNDERSCORE_KERNEL_FPU, 1,
168 [kernel has __kernel_fpu_* functions])
169 AC_DEFINE(KERNEL_EXPORTS_X86_FPU, 1,
170 [kernel exports FPU functions])
172 ZFS_LINUX_TEST_RESULT([fpu_internal], [
173 AC_MSG_RESULT(internal)
174 AC_DEFINE(HAVE_KERNEL_FPU_INTERNAL, 1,
175 [kernel fpu internal])
177 ZFS_LINUX_TEST_RESULT([fpu_xsave_internal], [
178 AC_MSG_RESULT(internal with internal XSAVE)
179 AC_DEFINE(HAVE_KERNEL_FPU_XSAVE_INTERNAL, 1,
180 [kernel fpu and XSAVE internal])
182 AC_MSG_RESULT(unavailable)