From bddaca79f57aac71d63d2cb4713de5ee4320cc28 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 7 Oct 2018 00:19:14 +0200 Subject: compat: make asm/simd.h conditional on its existence Android kernels backported it, complicating things. --- src/compat/Kbuild.include | 4 ++-- src/compat/compat.h | 18 ------------------ src/compat/simd-asm/include/asm/simd.h | 21 +++++++++++++++++++++ src/compat/simd-x86/include/asm/simd.h | 1 - src/compat/simd/include/linux/simd.h | 3 +-- 5 files changed, 24 insertions(+), 23 deletions(-) create mode 100644 src/compat/simd-asm/include/asm/simd.h delete mode 100644 src/compat/simd-x86/include/asm/simd.h (limited to 'src/compat') 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 -#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 +#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 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 +#include #if defined(CONFIG_X86_64) #include #include -#include #elif defined(CONFIG_KERNEL_MODE_NEON) #include -#include #endif typedef enum { -- cgit v1.2.3-59-g8ed1b