summaryrefslogtreecommitdiffstatshomepage
path: root/src/compat
diff options
context:
space:
mode:
authorSamuel Neves <sneves@dei.uc.pt>2017-11-17 12:07:52 +0000
committerJason A. Donenfeld <Jason@zx2c4.com>2017-11-22 18:32:48 +0100
commitabad6eebd9a94f50645062882755fbeaac354873 (patch)
tree5e3d066bc3784eb1e7423a24191741e008a129e8 /src/compat
parentchacha20poly1305: add more test vectors, some of which are weird (diff)
downloadwireguard-monolithic-historical-abad6eebd9a94f50645062882755fbeaac354873.tar.xz
wireguard-monolithic-historical-abad6eebd9a94f50645062882755fbeaac354873.zip
chacha20poly1305: import x86_64 primitives from OpenSSL
x86_64 only at the moment. SSSE3, AVX, AVX2, AVX512. Signed-off-by: Samuel Neves <sneves@dei.uc.pt>
Diffstat (limited to 'src/compat')
-rw-r--r--src/compat/Kbuild.include23
-rw-r--r--src/compat/compat.h11
2 files changed, 30 insertions, 4 deletions
diff --git a/src/compat/Kbuild.include b/src/compat/Kbuild.include
index bee91ed..f952f6b 100644
--- a/src/compat/Kbuild.include
+++ b/src/compat/Kbuild.include
@@ -35,3 +35,26 @@ ifeq ($(shell grep -F "int crypto_memneq" "$(srctree)/include/crypto/algapi.h"),
ccflags-y += -include $(src)/compat/memneq/include.h
wireguard-y += compat/memneq/memneq.o
endif
+
+ifeq ($(CONFIG_X86_64),y)
+ ifeq ($(ssse3_instr),)
+ ssse3_instr := $(call as-instr,pshufb %xmm0$(comma)%xmm0,-DCONFIG_AS_SSSE3=1)
+ ccflags-y += $(ssse3_instr)
+ asflags-y += $(ssse3_instr)
+ endif
+ ifeq ($(avx_instr),)
+ avx_instr := $(call as-instr,vxorps %ymm0$(comma)%ymm1$(comma)%ymm2,-DCONFIG_AS_AVX=1)
+ ccflags-y += $(avx_instr)
+ asflags-y += $(avx_instr)
+ endif
+ ifeq ($(avx2_instr),)
+ avx2_instr := $(call as-instr,vpbroadcastb %xmm0$(comma)%ymm1,-DCONFIG_AS_AVX2=1)
+ ccflags-y += $(avx2_instr)
+ asflags-y += $(avx2_instr)
+ endif
+ ifeq ($(avx512_instr),)
+ avx512_instr := $(call as-instr,vpmovm2b %k1$(comma)%zmm5,-DCONFIG_AS_AVX512=1)
+ ccflags-y += $(avx512_instr)
+ asflags-y += $(avx512_instr)
+ endif
+endif
diff --git a/src/compat/compat.h b/src/compat/compat.h
index 5f2a867..68590fa 100644
--- a/src/compat/compat.h
+++ b/src/compat/compat.h
@@ -28,10 +28,6 @@
#error "WireGuard requires Linux >= 3.10"
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0) && defined(CONFIG_X86_64)
-#define CONFIG_AS_SSSE3
-#endif
-
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0) && !defined(ISRHEL7)
#define headers_start data
#define headers_end data
@@ -507,6 +503,9 @@ static inline int cpu_has_xfeatures(u64 xfeatures_needed, const char **feature_n
#ifndef XFEATURE_MASK_SSE
#define XFEATURE_MASK_SSE XSTATE_SSE
#endif
+#ifndef XFEATURE_MASK_ZMM_Hi256
+#define XFEATURE_MASK_ZMM_Hi256 XSTATE_ZMM_Hi256
+#endif
#endif
#endif
@@ -520,6 +519,10 @@ struct _____dummy_container { char dev; };
#define from_timer(var, callback_timer, timer_fieldname) container_of(callback_timer, typeof(*var), timer_fieldname)
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 3)
+#define COMPAT_CANNOT_USE_AVX512
+#endif
+
/* https://lkml.org/lkml/2017/6/23/790 */
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
#include <linux/ip.h>