aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/compat/compat.h
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-10-20 19:00:50 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-10-31 17:22:49 +0100
commitd467551e7983673472d3f8b6fbddb467104d4422 (patch)
tree0c6755c1b031ec4dcd41702568efb62527dca404 /src/compat/compat.h
parentblake2: include headers for macros (diff)
downloadwireguard-monolithic-historical-d467551e7983673472d3f8b6fbddb467104d4422.tar.xz
wireguard-monolithic-historical-d467551e7983673472d3f8b6fbddb467104d4422.zip
crypto/avx: make sure we can actually use ymm registers
Diffstat (limited to 'src/compat/compat.h')
-rw-r--r--src/compat/compat.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/compat/compat.h b/src/compat/compat.h
index 1f490c5..419710d 100644
--- a/src/compat/compat.h
+++ b/src/compat/compat.h
@@ -476,6 +476,26 @@ static int get_device_dump_real(a, b)
#define COMPAT_CANNOT_USE_IFF_NO_QUEUE
#endif
+#if defined(CONFIG_X86_64)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
+#include <asm/user.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0)
+#include <asm/xsave.h>
+#include <asm/xcr.h>
+static inline int cpu_has_xfeatures(u64 xfeatures_needed, const char **feature_name)
+{
+ return xgetbv(XCR_XFEATURE_ENABLED_MASK) & xfeatures_needed;
+}
+#endif
+#ifndef XFEATURE_MASK_YMM
+#define XFEATURE_MASK_YMM XSTATE_YMM
+#endif
+#ifndef XFEATURE_MASK_SSE
+#define XFEATURE_MASK_SSE XSTATE_SSE
+#endif
+#endif
+#endif
+
/* https://lkml.org/lkml/2017/6/23/790 */
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
#include <linux/ip.h>