aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-10-07 00:19:14 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-10-07 02:24:31 +0200
commitbddaca79f57aac71d63d2cb4713de5ee4320cc28 (patch)
tree7e3bdb638ccdbdcdaf8289acca2cc39bff49aed4 /src
parentcompat: account for ancient ARM assembler (diff)
downloadwireguard-monolithic-historical-bddaca79f57aac71d63d2cb4713de5ee4320cc28.tar.xz
wireguard-monolithic-historical-bddaca79f57aac71d63d2cb4713de5ee4320cc28.zip
compat: make asm/simd.h conditional on its existence
Android kernels backported it, complicating things.
Diffstat (limited to 'src')
-rw-r--r--src/compat/Kbuild.include4
-rw-r--r--src/compat/compat.h18
-rw-r--r--src/compat/simd-asm/include/asm/simd.h21
-rw-r--r--src/compat/simd-x86/include/asm/simd.h1
-rw-r--r--src/compat/simd/include/linux/simd.h3
5 files changed, 24 insertions, 23 deletions
diff --git a/src/compat/Kbuild.include b/src/compat/Kbuild.include
index 879aa84..0e70006 100644
--- a/src/compat/Kbuild.include
+++ b/src/compat/Kbuild.include
@@ -33,8 +33,8 @@ ifeq ($(wildcard $(srctree)/arch/x86/include/asm/fpu/api.h)$(CONFIG_X86),y)
ccflags-y += -I$(src)/compat/fpu-x86/include
endif
-ifeq ($(wildcard $(srctree)/arch/x86/include/asm/simd.h)$(CONFIG_X86),y)
-ccflags-y += -I$(src)/compat/simd-x86/include
+ifeq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/simd.h)$(shell grep -F "generic-y += simd.h" "$(srctree)/arch/$(SRCARCH)/Kbuild"),)
+ccflags-y += -I$(src)/compat/simd-asm/include
endif
ifeq ($(wildcard $(srctree)/include/linux/simd.h),)
diff --git a/src/compat/compat.h b/src/compat/compat.h
index 8c366f5..796736c 100644
--- a/src/compat/compat.h
+++ b/src/compat/compat.h
@@ -737,24 +737,6 @@ static inline void crypto_xor_cpy(u8 *dst, const u8 *src1, const u8 *src2,
#define read_cpuid_part() read_cpuid_part_number()
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0) || (!defined(CONFIG_X86_64) && !defined(CONFIG_ARM64) && !defined(CONFIG_ARM))
-#if defined(CONFIG_X86_64)
-#include <asm/fpu/api.h>
-#endif
-static __must_check inline bool may_use_simd(void)
-{
-#if defined(CONFIG_X86_64)
- return irq_fpu_usable();
-#elif defined(CONFIG_ARM64) && defined(CONFIG_KERNEL_MODE_NEON)
- return true;
-#elif defined(CONFIG_ARM) && defined(CONFIG_KERNEL_MODE_NEON)
- return !in_nmi() && !in_irq() && !in_serving_softirq();
-#else
- return false;
-#endif
-}
-#endif
-
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
#define hlist_add_behind(a, b) hlist_add_after(b, a)
#endif
diff --git a/src/compat/simd-asm/include/asm/simd.h b/src/compat/simd-asm/include/asm/simd.h
new file mode 100644
index 0000000..a975b38
--- /dev/null
+++ b/src/compat/simd-asm/include/asm/simd.h
@@ -0,0 +1,21 @@
+#ifndef _COMPAT_ASM_SIMD_H
+#define _COMPAT_ASM_SIMD_H
+
+#if defined(CONFIG_X86_64)
+#include <asm/fpu/api.h>
+#endif
+
+static __must_check inline bool may_use_simd(void)
+{
+#if defined(CONFIG_X86_64)
+ return irq_fpu_usable();
+#elif defined(CONFIG_ARM64) && defined(CONFIG_KERNEL_MODE_NEON)
+ return true;
+#elif defined(CONFIG_ARM) && defined(CONFIG_KERNEL_MODE_NEON)
+ return !in_nmi() && !in_irq() && !in_serving_softirq();
+#else
+ return false;
+#endif
+}
+
+#endif
diff --git a/src/compat/simd-x86/include/asm/simd.h b/src/compat/simd-x86/include/asm/simd.h
deleted file mode 100644
index f3f9117..0000000
--- a/src/compat/simd-x86/include/asm/simd.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <asm/i387.h>
diff --git a/src/compat/simd/include/linux/simd.h b/src/compat/simd/include/linux/simd.h
index a117afd..11ee98a 100644
--- a/src/compat/simd/include/linux/simd.h
+++ b/src/compat/simd/include/linux/simd.h
@@ -7,13 +7,12 @@
#define _WG_SIMD_H
#include <linux/sched.h>
+#include <asm/simd.h>
#if defined(CONFIG_X86_64)
#include <linux/version.h>
#include <asm/fpu/api.h>
-#include <asm/simd.h>
#elif defined(CONFIG_KERNEL_MODE_NEON)
#include <asm/neon.h>
-#include <asm/simd.h>
#endif
typedef enum {