]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - config/kernel-fpu.m4
Linux 5.12 update: bio_max_segs() replaces BIO_MAX_PAGES
[FreeBSD/FreeBSD.git] / config / kernel-fpu.m4
1 dnl # 
2 dnl # Handle differences in kernel FPU code.
3 dnl #
4 dnl # Kernel
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
8 dnl #
9 dnl # 4.2:      Use __kernel_fpu_{begin,end}()
10 dnl #           HAVE_UNDERSCORE_KERNEL_FPU & KERNEL_EXPORTS_X86_FPU
11 dnl #
12 dnl # Pre-4.2:  Use kernel_fpu_{begin,end}()
13 dnl #           HAVE_KERNEL_FPU & KERNEL_EXPORTS_X86_FPU
14 dnl #
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.
17 dnl #
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>
23         ],[
24         ],[
25                 AC_DEFINE(HAVE_KERNEL_FPU_API_HEADER, 1,
26                     [kernel has asm/fpu/api.h])
27                 AC_MSG_RESULT(asm/fpu/api.h)
28         ],[
29                 AC_MSG_RESULT(i387.h & xcr.h)
30         ])
31 ])
32
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>
38                 #else
39                 #include <asm/i387.h>
40                 #include <asm/xcr.h>
41                 #endif
42         ], [
43                 kernel_fpu_begin();
44                 kernel_fpu_end();
45         ], [], [ZFS_META_LICENSE])
46
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>
51                 #else
52                 #include <asm/i387.h>
53                 #include <asm/xcr.h>
54                 #endif
55         ], [
56                 __kernel_fpu_begin();
57                 __kernel_fpu_end();
58         ], [], [ZFS_META_LICENSE])
59
60         ZFS_LINUX_TEST_SRC([fpu_internal], [
61                 #if defined(__x86_64) || defined(__x86_64__) || \
62                     defined(__i386) || defined(__i386__)
63                 #if !defined(__x86)
64                 #define __x86
65                 #endif
66                 #endif
67
68                 #if !defined(__x86)
69                 #error Unsupported architecture
70                 #endif
71
72                 #include <linux/types.h>
73                 #ifdef HAVE_KERNEL_FPU_API_HEADER
74                 #include <asm/fpu/api.h>
75                 #include <asm/fpu/internal.h>
76                 #else
77                 #include <asm/i387.h>
78                 #include <asm/xcr.h>
79                 #endif
80
81                 #if !defined(XSTATE_XSAVE)
82                 #error XSTATE_XSAVE not defined
83                 #endif
84
85                 #if !defined(XSTATE_XRESTORE)
86                 #error XSTATE_XRESTORE not defined
87                 #endif
88         ],[
89                 struct fpu *fpu = &current->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;
94         ])
95 ])
96
97 AC_DEFUN([ZFS_AC_KERNEL_FPU], [
98         dnl #
99         dnl # Legacy kernel
100         dnl #
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])
109         ],[
110                 dnl #
111                 dnl # Linux 4.2 kernel
112                 dnl #
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])
121                 ],[
122                         ZFS_LINUX_TEST_RESULT([fpu_internal], [
123                                 AC_MSG_RESULT(internal)
124                                 AC_DEFINE(HAVE_KERNEL_FPU_INTERNAL, 1,
125                                     [kernel fpu internal])
126                         ],[
127                                 AC_MSG_RESULT(unavailable)
128                         ])
129                 ])
130         ])
131 ])