81 lines
2.9 KiB
Diff
81 lines
2.9 KiB
Diff
From f8d9ecea60d99c6143dcb9e2f8fe41c8e17e4d0f Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
|
|
<congdanhqx@gmail.com>
|
|
Date: Sun, 31 May 2020 12:13:08 +0700
|
|
Subject: [PATCH] enable AVX2 if applicable on x86_64
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
There's a runtime check for AVX2 before using, see:
|
|
|
|
lib/freebl/chacha20poly1305.c:140
|
|
lib/freebl/blinit.c:117
|
|
|
|
Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
|
|
---
|
|
nss/coreconf/arch.mk | 1 +
|
|
nss/coreconf/config.mk | 2 ++
|
|
nss/lib/freebl/Makefile | 9 +++++++--
|
|
3 files changed, 10 insertions(+), 2 deletions(-)
|
|
|
|
diff --git nss/coreconf/arch.mk nss/coreconf/arch.mk
|
|
index 790372d..cc13ced 100644
|
|
--- nss/coreconf/arch.mk
|
|
+++ nss/coreconf/arch.mk
|
|
@@ -116,6 +116,7 @@ ifeq ($(OS_ARCH),Linux)
|
|
OS_RELEASE := $(word 1,$(OS_RELEASE)).$(word 2,$(OS_RELEASE))
|
|
endif
|
|
KERNEL = Linux
|
|
+ include $(CORE_DEPTH)/coreconf/Linux.mk
|
|
endif
|
|
|
|
# Since all uses of OS_ARCH that follow affect only userland, we can
|
|
diff --git nss/coreconf/config.mk nss/coreconf/config.mk
|
|
index 39f755d..b65e684 100644
|
|
--- nss/coreconf/config.mk
|
|
+++ nss/coreconf/config.mk
|
|
@@ -149,8 +149,10 @@ DEFINES += -DNSS_DISABLE_DBM
|
|
endif
|
|
|
|
ifdef NSS_DISABLE_AVX2
|
|
+ifneq ($(NSS_DISABLE_AVX2),0)
|
|
DEFINES += -DNSS_DISABLE_AVX2
|
|
endif
|
|
+endif
|
|
|
|
ifdef NSS_DISABLE_CHACHAPOLY
|
|
DEFINES += -DNSS_DISABLE_CHACHAPOLY
|
|
diff --git nss/lib/freebl/Makefile nss/lib/freebl/Makefile
|
|
index 5f73844..8b98370 100644
|
|
--- nss/lib/freebl/Makefile
|
|
+++ nss/lib/freebl/Makefile
|
|
@@ -552,10 +552,12 @@ endif
|
|
ifndef NSS_DISABLE_CHACHAPOLY
|
|
ifeq ($(CPU_ARCH),x86_64)
|
|
ifndef NSS_DISABLE_AVX2
|
|
+ NSS_DISABLE_AVX2 = 0
|
|
+ endif
|
|
+ ifeq ($(NSS_DISABLE_AVX2),0)
|
|
EXTRA_SRCS += Hacl_Poly1305_256.c Hacl_Chacha20_Vec256.c Hacl_Chacha20Poly1305_256.c
|
|
- else
|
|
- EXTRA_SRCS += Hacl_Poly1305_128.c Hacl_Chacha20_Vec128.c Hacl_Chacha20Poly1305_128.c
|
|
endif # NSS_DISABLE_AVX2
|
|
+ EXTRA_SRCS += Hacl_Poly1305_128.c Hacl_Chacha20_Vec128.c Hacl_Chacha20Poly1305_128.c
|
|
endif # x86_64
|
|
|
|
VERIFIED_SRCS += Hacl_Poly1305_32.c Hacl_Chacha20.c Hacl_Chacha20Poly1305_32.c
|
|
@@ -737,6 +739,9 @@ $(OBJDIR)/$(PROG_PREFIX)Hacl_Chacha20Poly1305_128$(OBJ_SUFFIX): CFLAGS += -mssse
|
|
$(OBJDIR)/$(PROG_PREFIX)Hacl_Poly1305_128$(OBJ_SUFFIX): CFLAGS += -mssse3 -msse4.1 -msse4.2 -mavx -maes -mpclmul
|
|
|
|
ifndef NSS_DISABLE_AVX2
|
|
+ NSS_DISABLE_AVX2 = 0
|
|
+endif
|
|
+ifeq ($(NSS_DISABLE_AVX2),0)
|
|
$(OBJDIR)/$(PROG_PREFIX)Hacl_Chacha20Poly1305_256$(OBJ_SUFFIX): CFLAGS += -mssse3 -msse4.1 -msse4.2 -mavx2 -maes
|
|
$(OBJDIR)/$(PROG_PREFIX)Hacl_Chacha20_Vec256$(OBJ_SUFFIX): CFLAGS += -mssse3 -msse4.1 -msse4.2 -mavx -mavx2 -maes
|
|
$(OBJDIR)/$(PROG_PREFIX)Hacl_Poly1305_256$(OBJ_SUFFIX): CFLAGS += -mssse3 -msse4.1 -msse4.2 -mavx -mavx2 -maes -mpclmul
|
|
--
|
|
2.26.2.672.g232c24e857
|
|
|