diff --git a/module/Kbuild.in b/module/Kbuild.in index c537aced8..c43358863 100644 --- a/module/Kbuild.in +++ b/module/Kbuild.in @@ -293,10 +293,9 @@ ZSTD_UPSTREAM_OBJS := \ zfs-objs += $(addprefix zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS)) -# Disable aarch64 neon SIMD instructions for kernel mode $(addprefix $(obj)/zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS)) : ccflags-y += -I$(zstd_include) $(ZFS_ZSTD_FLAGS) $(addprefix $(obj)/zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS)) : asflags-y += -I$(zstd_include) -$(addprefix $(obj)/zstd/,$(ZSTD_UPSTREAM_OBJS)) : ccflags-y += -include $(zstd_include)/aarch64_compat.h -include $(zstd_include)/zstd_compat_wrapper.h -Wp,-w +$(addprefix $(obj)/zstd/,$(ZSTD_UPSTREAM_OBJS)) : ccflags-y += -include $(zstd_include)/zstd_compat_wrapper.h -Wp,-w $(obj)/zstd/zfs_zstd.o : ccflags-y += -include $(zstd_include)/zstd_compat_wrapper.h diff --git a/module/Makefile.bsd b/module/Makefile.bsd index ddff8e7fb..8801568d6 100644 --- a/module/Makefile.bsd +++ b/module/Makefile.bsd @@ -521,30 +521,6 @@ CFLAGS.zstd_ldm.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICA CFLAGS.zstd_opt.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL} .if ${MACHINE_ARCH} == "aarch64" -__ZFS_ZSTD_AARCH64_FLAGS= -include ${SRCDIR}/zstd/include/aarch64_compat.h -CFLAGS.zstd.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} -CFLAGS.entropy_common.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} -CFLAGS.error_private.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} -CFLAGS.fse_compress.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} -CFLAGS.fse_decompress.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} -CFLAGS.hist.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} -CFLAGS.huf_compress.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} -CFLAGS.huf_decompress.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} -CFLAGS.pool.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} -CFLAGS.xxhash.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} -CFLAGS.zstd_common.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} -CFLAGS.zstd_compress.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} -CFLAGS.zstd_compress_literals.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} -CFLAGS.zstd_compress_sequences.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} -CFLAGS.zstd_compress_superblock.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} -CFLAGS.zstd_ddict.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} -CFLAGS.zstd_decompress.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} -CFLAGS.zstd_decompress_block.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} -CFLAGS.zstd_double_fast.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} -CFLAGS.zstd_fast.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} -CFLAGS.zstd_lazy.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} -CFLAGS.zstd_ldm.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} -CFLAGS.zstd_opt.c+= ${__ZFS_ZSTD_AARCH64_FLAGS} sha256-armv8.o: sha256-armv8.S ${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${.IMPSRC} \ diff --git a/module/zstd/include/aarch64_compat.h b/module/zstd/include/aarch64_compat.h deleted file mode 100644 index 9500a832b..000000000 --- a/module/zstd/include/aarch64_compat.h +++ /dev/null @@ -1,38 +0,0 @@ -// SPDX-License-Identifier: BSD-3-Clause -/* - * BSD 3-Clause New License (https://spdx.org/licenses/BSD-3-Clause.html) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Copyright (c) 2018-2020, Sebastian Gottschall - */ - -#ifdef _KERNEL -#undef __aarch64__ -#endif diff --git a/module/zstd/lib/common/compiler.h b/module/zstd/lib/common/compiler.h index d0f588e2e..c8d65a201 100644 --- a/module/zstd/lib/common/compiler.h +++ b/module/zstd/lib/common/compiler.h @@ -115,9 +115,6 @@ # include /* https://msdn.microsoft.com/fr-fr/library/84szxsww(v=vs.90).aspx */ # define PREFETCH_L1(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T0) # define PREFETCH_L2(ptr) _mm_prefetch((const char*)(ptr), _MM_HINT_T1) -# elif defined(__aarch64__) -# define PREFETCH_L1(ptr) __asm__ __volatile__("prfm pldl1keep, %0" ::"Q"(*(ptr))) -# define PREFETCH_L2(ptr) __asm__ __volatile__("prfm pldl2keep, %0" ::"Q"(*(ptr))) # elif defined(__GNUC__) && ( (__GNUC__ >= 4) || ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) ) # define PREFETCH_L1(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 3 /* locality */) # define PREFETCH_L2(ptr) __builtin_prefetch((ptr), 0 /* rw==read */, 2 /* locality */) diff --git a/module/zstd/lib/common/zstd_internal.h b/module/zstd/lib/common/zstd_internal.h index 6b1fc44cf..9650af77b 100644 --- a/module/zstd/lib/common/zstd_internal.h +++ b/module/zstd/lib/common/zstd_internal.h @@ -12,6 +12,15 @@ #ifndef ZSTD_CCOMMON_H_MODULE #define ZSTD_CCOMMON_H_MODULE +/* + * Disable the aarch64 NEON SIMD intrinsics for kernel builds. Safely + * using them in the kernel context requires saving/restoring the FPU + * registers which is not currently done. + */ +#ifdef _KERNEL +#define ZSTD_NO_INTRINSICS +#endif + /* this module contains definitions which must be identical * across compression, decompression and dictBuilder. * It also contains a few functions useful to at least 2 of them