Skip to content

Commit 75b309a

Browse files
ckanebehlendorf
authored andcommitted
Linux 5.16 compat: asm/fpu/xcr.h is new location for xgetbv/xsetbv
Linux 5.16 moved these functions into this new header in commit 1b4fb8545f2b00f2844c4b7619d64d98440a477c. This change adds code to look for the presence of this header, and include it so that the code using xgetbv & xsetbv will compile again. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Coleman Kane <[email protected]> Closes #12800
1 parent c0fb44c commit 75b309a

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

config/kernel-fpu.m4

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ dnl #
22
dnl # Handle differences in kernel FPU code.
33
dnl #
44
dnl # Kernel
5+
dnl # 5.16: XCR code put into asm/fpu/xcr.h
6+
dnl # HAVE_KERNEL_FPU_XCR_HEADER
7+
dnl #
58
dnl # 5.0: Wrappers have been introduced to save/restore the FPU state.
69
dnl # This change was made to the 4.19.38 and 4.14.120 LTS kernels.
710
dnl # HAVE_KERNEL_FPU_INTERNAL
@@ -25,6 +28,18 @@ AC_DEFUN([ZFS_AC_KERNEL_FPU_HEADER], [
2528
AC_DEFINE(HAVE_KERNEL_FPU_API_HEADER, 1,
2629
[kernel has asm/fpu/api.h])
2730
AC_MSG_RESULT(asm/fpu/api.h)
31+
AC_MSG_CHECKING([whether fpu/xcr header is available])
32+
ZFS_LINUX_TRY_COMPILE([
33+
#include <linux/module.h>
34+
#include <asm/fpu/xcr.h>
35+
],[
36+
],[
37+
AC_DEFINE(HAVE_KERNEL_FPU_XCR_HEADER, 1,
38+
[kernel has asm/fpu/xcr.h])
39+
AC_MSG_RESULT(asm/fpu/xcr.h)
40+
],[
41+
AC_MSG_RESULT(no asm/fpu/xcr.h)
42+
])
2843
],[
2944
AC_MSG_RESULT(i387.h & xcr.h)
3045
])

include/os/linux/kernel/linux/simd_x86.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@
8888
#if defined(HAVE_KERNEL_FPU_API_HEADER)
8989
#include <asm/fpu/api.h>
9090
#include <asm/fpu/internal.h>
91+
#if defined(HAVE_KERNEL_FPU_XCR_HEADER)
92+
#include <asm/fpu/xcr.h>
93+
#endif
9194
#else
9295
#include <asm/i387.h>
9396
#include <asm/xcr.h>

0 commit comments

Comments
 (0)