From 1d0bbfdae9ecd6b3ad6b08bddb57439bb12dac5e Mon Sep 17 00:00:00 2001 From: Peter Michael Green Date: Thu, 29 Oct 2020 03:19:17 +0000 Subject: [PATCH] Patch out neon in freebl --- debian/changelog | 1 + security/nss/lib/freebl/Makefile | 6 +- security/nss/lib/freebl/freebl.gyp | 188 ++++++++++++++--------------- security/nss/lib/freebl/gcm.c | 2 +- security/nss/lib/freebl/rijndael.c | 4 +- 5 files changed, 101 insertions(+), 100 deletions(-) diff --git a/debian/changelog b/debian/changelog index d9cffc59ca..129b964556 100644 --- a/debian/changelog +++ b/debian/changelog @@ -22,6 +22,7 @@ thunderbird (1:78.4.0-1~deb10u1+rpi1) buster-staging; urgency=medium [changes introduced in 1:78.4.0-1~deb10u1+rpi1 by Peter Michael Green] * Add export NSS_DISABLE_ARM32_NEON=1 to hopefully disable neon in nss. + * Adding the define in debian/rules didn't seem to work, try to patch out neon in nss instead -- Raspbian forward porter Mon, 26 Oct 2020 12:12:48 +0000 diff --git a/security/nss/lib/freebl/Makefile b/security/nss/lib/freebl/Makefile index 5f7384429a..202409d5b4 100644 --- a/security/nss/lib/freebl/Makefile +++ b/security/nss/lib/freebl/Makefile @@ -124,9 +124,9 @@ ifeq ($(CPU_ARCH),aarch64) EXTRA_SRCS += aes-armv8.c gcm-aarch64.c endif ifeq ($(CPU_ARCH),arm) -ifndef NSS_DISABLE_ARM32_NEON - EXTRA_SRCS += gcm-arm32-neon.c -endif +#ifndef NSS_DISABLE_ARM32_NEON +# EXTRA_SRCS += gcm-arm32-neon.c +#endif ifdef CC_IS_CLANG DEFINES += -DUSE_HW_AES EXTRA_SRCS += aes-armv8.c diff --git a/security/nss/lib/freebl/freebl.gyp b/security/nss/lib/freebl/freebl.gyp index f3bb8a71a6..7fa2339e2c 100644 --- a/security/nss/lib/freebl/freebl.gyp +++ b/security/nss/lib/freebl/freebl.gyp @@ -103,13 +103,13 @@ ], }, }], - [ 'target_arch=="arm"', { - # Gecko doesn't support non-NEON platform on Android, but tier-3 - # platform such as Linux/arm will need it - 'cflags_mozilla': [ - '-mfpu=neon' - ], - }], + #[ 'target_arch=="arm"', { + # # Gecko doesn't support non-NEON platform on Android, but tier-3 + # # platform such as Linux/arm will need it + # 'cflags_mozilla': [ + # '-mfpu=neon' + # ], + #}], [ 'target_arch=="x64"', { 'sources': [ 'verified/Hacl_Poly1305_128.c', @@ -172,13 +172,13 @@ ], }, }], - [ 'target_arch=="arm"', { - # Gecko doesn't support non-NEON platform on Android, but tier-3 - # platform such as Linux/arm will need it - 'cflags_mozilla': [ - '-mfpu=neon' - ], - }], + #[ 'target_arch=="arm"', { + # # Gecko doesn't support non-NEON platform on Android, but tier-3 + # # platform such as Linux/arm will need it + # 'cflags_mozilla': [ + # '-mfpu=neon' + # ], + #}], [ 'target_arch=="x64"', { 'sources': [ 'verified/Hacl_Poly1305_256.c', @@ -219,25 +219,25 @@ }] ] }, - { - 'target_name': 'gcm-aes-arm32-neon_c_lib', - 'type': 'static_library', - 'sources': [ - 'gcm-arm32-neon.c' - ], - 'dependencies': [ - '<(DEPTH)/exports.gyp:nss_exports' - ], - 'cflags': [ - '-march=armv7', - '-mfpu=neon', - '<@(softfp_cflags)', - ], - 'cflags_mozilla': [ - '-mfpu=neon', - '<@(softfp_cflags)', - ] - }, + #{ + # 'target_name': 'gcm-aes-arm32-neon_c_lib', + # 'type': 'static_library', + # 'sources': [ + # 'gcm-arm32-neon.c' + # ], + # 'dependencies': [ + # '<(DEPTH)/exports.gyp:nss_exports' + # ], + # 'cflags': [ + # '-march=armv7', + # '-mfpu=neon', + # '<@(softfp_cflags)', + # ], + # 'cflags_mozilla': [ + # '-mfpu=neon', + # '<@(softfp_cflags)', + # ] + #}, { 'target_name': 'gcm-aes-aarch64_c_lib', 'type': 'static_library', @@ -324,37 +324,37 @@ 'FREEBL_NO_DEPEND', ], }, - { - 'target_name': 'armv8_c_lib', - 'type': 'static_library', - 'sources': [ - 'aes-armv8.c', - ], - 'dependencies': [ - '<(DEPTH)/exports.gyp:nss_exports' - ], - 'conditions': [ - [ 'target_arch=="arm"', { - 'cflags': [ - '-march=armv8-a', - '-mfpu=crypto-neon-fp-armv8', - '<@(softfp_cflags)', - ], - 'cflags_mozilla': [ - '-march=armv8-a', - '-mfpu=crypto-neon-fp-armv8', - '<@(softfp_cflags)', - ], - }, 'target_arch=="arm64" or target_arch=="aarch64"', { - 'cflags': [ - '-march=armv8-a+crypto' - ], - 'cflags_mozilla': [ - '-march=armv8-a+crypto' - ], - }] - ] - }, + #{ + # 'target_name': 'armv8_c_lib', + # 'type': 'static_library', + # 'sources': [ + # 'aes-armv8.c', + # ], + # 'dependencies': [ + # '<(DEPTH)/exports.gyp:nss_exports' + # ], + # 'conditions': [ + # [ 'target_arch=="arm"', { + # 'cflags': [ + # '-march=armv8-a', + # '-mfpu=crypto-neon-fp-armv8', + # '<@(softfp_cflags)', + # ], + # 'cflags_mozilla': [ + # '-march=armv8-a', + # '-mfpu=crypto-neon-fp-armv8', + # '<@(softfp_cflags)', + # ], + # }, 'target_arch=="arm64" or target_arch=="aarch64"', { + # 'cflags': [ + # '-march=armv8-a+crypto' + # ], + # 'cflags_mozilla': [ + # '-march=armv8-a+crypto' + # ], + # }] + # ] + #}, { 'target_name': 'freebl', 'type': 'static_library', @@ -380,21 +380,21 @@ 'hw-acc-crypto-avx2', ], 'conditions': [ - [ 'target_arch=="ia32" or target_arch=="x64"', { - 'dependencies': [ - 'gcm-aes-x86_c_lib', - ], - }, 'disable_arm_hw_aes==0 and (target_arch=="arm" or target_arch=="arm64" or target_arch=="aarch64")', { - 'dependencies': [ - 'armv8_c_lib' - ], - }], - [ 'disable_arm32_neon==0 and target_arch=="arm"', { - 'dependencies': [ - 'gcm-aes-arm32-neon_c_lib', - ], - }], - [ 'disable_arm32_neon==1 and target_arch=="arm"', { + #[ 'target_arch=="ia32" or target_arch=="x64"', { + # 'dependencies': [ + # 'gcm-aes-x86_c_lib', + # ], + #}, 'disable_arm_hw_aes==0 and (target_arch=="arm" or target_arch=="arm64" or target_arch=="aarch64")', { + # 'dependencies': [ + # 'armv8_c_lib' + # ], + #}], + #[ 'disable_arm32_neon==0 and target_arch=="arm"', { + # 'dependencies': [ + # 'gcm-aes-arm32-neon_c_lib', + # ], + #}], + [ 'target_arch=="arm"', { 'defines!': [ 'NSS_DISABLE_ARM32_NEON', ], @@ -448,21 +448,21 @@ 'hw-acc-crypto-avx2', ], 'conditions': [ - [ 'target_arch=="ia32" or target_arch=="x64"', { - 'dependencies': [ - 'gcm-aes-x86_c_lib', - ] - }, 'target_arch=="arm" or target_arch=="arm64" or target_arch=="aarch64"', { - 'dependencies': [ - 'armv8_c_lib', - ], - }], - [ 'disable_arm32_neon==0 and target_arch=="arm"', { - 'dependencies': [ - 'gcm-aes-arm32-neon_c_lib', - ], - }], - [ 'disable_arm32_neon==1 and target_arch=="arm"', { + #[ 'target_arch=="ia32" or target_arch=="x64"', { + # 'dependencies': [ + # 'gcm-aes-x86_c_lib', + # ] + #}, 'target_arch=="arm" or target_arch=="arm64" or target_arch=="aarch64"', { + # 'dependencies': [ + # 'armv8_c_lib', + # ], + #}], + #[ 'disable_arm32_neon==0 and target_arch=="arm"', { + # 'dependencies': [ + # 'gcm-aes-arm32-neon_c_lib', + # ], + #}], + [ 'target_arch=="arm"', { 'defines!': [ 'NSS_DISABLE_ARM32_NEON', ], diff --git a/security/nss/lib/freebl/gcm.c b/security/nss/lib/freebl/gcm.c index c2cc18d91a..6c6a6c9286 100644 --- a/security/nss/lib/freebl/gcm.c +++ b/security/nss/lib/freebl/gcm.c @@ -25,7 +25,7 @@ #elif defined(__arm__) && defined(IS_LITTLE_ENDIAN) && \ !defined(NSS_DISABLE_ARM32_NEON) /* We don't test on big endian platform, so disable this on big endian. */ -#define USE_ARM_GCM +//#define USE_ARM_GCM #endif /* Forward declarations */ diff --git a/security/nss/lib/freebl/rijndael.c b/security/nss/lib/freebl/rijndael.c index 449557cbe5..bc989c7739 100644 --- a/security/nss/lib/freebl/rijndael.c +++ b/security/nss/lib/freebl/rijndael.c @@ -20,10 +20,10 @@ #include "gcm.h" #include "mpi.h" -#if !defined(IS_LITTLE_ENDIAN) && !defined(NSS_X86_OR_X64) +//#if !defined(IS_LITTLE_ENDIAN) && !defined(NSS_X86_OR_X64) // not test yet on big endian platform of arm #undef USE_HW_AES -#endif +//#endif #ifdef USE_HW_AES #ifdef NSS_X86_OR_X64 -- 2.30.2