From 6ba2e72b7899771f588dc4557624c186be2c2176 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Tue, 13 Oct 2020 22:01:40 -0600 Subject: [PATCH] aarch64: Use proper guards for NEON instructions The zstd code assumes that if you are on aarch64, you have NEON instructions. This is not necessarily true. In a boot loader, where you might not have the VFP properly initialized, these instructions may not be available. It's also an error to include arm_neon.h when the NEON insturctions aren't enabled. Change the guards for using the NEON instructions from __aarch64__ to __ARM_NEON which is the standard symbol for knowing if they are available. __ARM_NEON is the proper symbol, defined in ARM C Language Extensions Release 2.1 (https://developer.arm.com/documentation/ihi0053/d/). Some sources suggest __ARM_NEON__, but that's the obsolete spelling from prior versions of the standard. Updated based on zstd pull request https://github.com/facebook/zstd/pull/2356 Reviewed-by: Brian Behlendorf Signed-off-by: Warner Losh Closes #11055 --- module/zstd/lib/zstd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/module/zstd/lib/zstd.c b/module/zstd/lib/zstd.c index 949b8e47e..acdd4d9da 100644 --- a/module/zstd/lib/zstd.c +++ b/module/zstd/lib/zstd.c @@ -3074,7 +3074,7 @@ size_t FSE_decompress(void* dst, size_t dstCapacity, const void* cSrc, size_t cS /*-************************************* * Dependencies ***************************************/ -#ifdef __aarch64__ +#if !defined(ZSTD_NO_INTRINSICS) && defined(__ARM_NEON) #include #endif /**** skipping file: compiler.h ****/ @@ -6525,7 +6525,7 @@ static const U32 OF_defaultNormLog = OF_DEFAULTNORMLOG; * Shared functions to include for inlining *********************************************/ static void ZSTD_copy8(void* dst, const void* src) { -#ifdef __aarch64__ +#if !defined(ZSTD_NO_INTRINSICS) && defined(__ARM_NEON) vst1_u8((uint8_t*)dst, vld1_u8((const uint8_t*)src)); #else memcpy(dst, src, 8); @@ -6534,7 +6534,7 @@ static void ZSTD_copy8(void* dst, const void* src) { #define COPY8(d,s) { ZSTD_copy8(d,s); d+=8; s+=8; } static void ZSTD_copy16(void* dst, const void* src) { -#ifdef __aarch64__ +#if !defined(ZSTD_NO_INTRINSICS) && defined(__ARM_NEON) vst1q_u8((uint8_t*)dst, vld1q_u8((const uint8_t*)src)); #else memcpy(dst, src, 16);