1dnl # 2dnl # Handle differences in kernel FPU code. 3dnl # 4dnl # Kernel 5dnl # 5.0: Wrappers have been introduced to save/restore the FPU state. 6dnl # This change was made to the 4.19.38 and 4.14.120 LTS kernels. 7dnl # HAVE_KERNEL_FPU_INTERNAL 8dnl # 9dnl # 4.2: Use __kernel_fpu_{begin,end}() 10dnl # HAVE_UNDERSCORE_KERNEL_FPU & KERNEL_EXPORTS_X86_FPU 11dnl # 12dnl # Pre-4.2: Use kernel_fpu_{begin,end}() 13dnl # HAVE_KERNEL_FPU & KERNEL_EXPORTS_X86_FPU 14dnl # 15dnl # N.B. The header check is performed before all other checks since it 16dnl # depends on HAVE_KERNEL_FPU_API_HEADER being set in confdefs.h. 17dnl # 18AC_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 33AC_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 = ¤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; 94 ]) 95]) 96 97AC_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]) 132