Skip to content

Commit 31260b5

Browse files
committed
zstd: Disable intrinsics
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. This lets us remove the problematic workaround in the aarch64_compat.h header which undefines the __aarch64__ macro. Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
1 parent f93506d commit 31260b5

File tree

4 files changed

+10
-64
lines changed

4 files changed

+10
-64
lines changed

module/Kbuild.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,9 @@ ZSTD_UPSTREAM_OBJS := \
293293

294294
zfs-objs += $(addprefix zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS))
295295

296-
# Disable aarch64 neon SIMD instructions for kernel mode
297296
$(addprefix $(obj)/zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS)) : ccflags-y += -I$(zstd_include) $(ZFS_ZSTD_FLAGS)
298297
$(addprefix $(obj)/zstd/,$(ZSTD_OBJS) $(ZSTD_UPSTREAM_OBJS)) : asflags-y += -I$(zstd_include)
299-
$(addprefix $(obj)/zstd/,$(ZSTD_UPSTREAM_OBJS)) : ccflags-y += -include $(zstd_include)/aarch64_compat.h -include $(zstd_include)/zstd_compat_wrapper.h -Wp,-w
298+
$(addprefix $(obj)/zstd/,$(ZSTD_UPSTREAM_OBJS)) : ccflags-y += -include $(zstd_include)/zstd_compat_wrapper.h -Wp,-w
300299
$(obj)/zstd/zfs_zstd.o : ccflags-y += -include $(zstd_include)/zstd_compat_wrapper.h
301300

302301

module/Makefile.bsd

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -521,30 +521,6 @@ CFLAGS.zstd_ldm.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICA
521521
CFLAGS.zstd_opt.c= -U__BMI__ -fno-tree-vectorize ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
522522

523523
.if ${MACHINE_ARCH} == "aarch64"
524-
__ZFS_ZSTD_AARCH64_FLAGS= -include ${SRCDIR}/zstd/include/aarch64_compat.h
525-
CFLAGS.zstd.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
526-
CFLAGS.entropy_common.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
527-
CFLAGS.error_private.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
528-
CFLAGS.fse_compress.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
529-
CFLAGS.fse_decompress.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
530-
CFLAGS.hist.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
531-
CFLAGS.huf_compress.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
532-
CFLAGS.huf_decompress.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
533-
CFLAGS.pool.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
534-
CFLAGS.xxhash.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
535-
CFLAGS.zstd_common.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
536-
CFLAGS.zstd_compress.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
537-
CFLAGS.zstd_compress_literals.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
538-
CFLAGS.zstd_compress_sequences.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
539-
CFLAGS.zstd_compress_superblock.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
540-
CFLAGS.zstd_ddict.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
541-
CFLAGS.zstd_decompress.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
542-
CFLAGS.zstd_decompress_block.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
543-
CFLAGS.zstd_double_fast.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
544-
CFLAGS.zstd_fast.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
545-
CFLAGS.zstd_lazy.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
546-
CFLAGS.zstd_ldm.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
547-
CFLAGS.zstd_opt.c+= ${__ZFS_ZSTD_AARCH64_FLAGS}
548524

549525
sha256-armv8.o: sha256-armv8.S
550526
${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${.IMPSRC} \

module/zstd/include/aarch64_compat.h

Lines changed: 0 additions & 38 deletions
This file was deleted.

module/zstd/lib/common/zstd_internal.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@
1212
#ifndef ZSTD_CCOMMON_H_MODULE
1313
#define ZSTD_CCOMMON_H_MODULE
1414

15+
/*
16+
* Disable the aarch64 NEON SIMD intrinsics for kernel builds. Safely
17+
* using them in the kernel context requires saving/restoring the FPU
18+
* registers which is not currently done.
19+
*/
20+
#ifdef _KERNEL
21+
#define ZSTD_NO_INTRINSICS
22+
#endif
23+
1524
/* this module contains definitions which must be identical
1625
* across compression, decompression and dictBuilder.
1726
* It also contains a few functions useful to at least 2 of them

0 commit comments

Comments
 (0)