garypang13 пре 4 година
родитељ
комит
27b48a4c86
1 измењених фајлова са 49 додато и 0 уклоњено
  1. 49 0
      devices/common/patches/ARMV8CE_AES.patch

+ 49 - 0
devices/common/patches/ARMV8CE_AES.patch

@@ -0,0 +1,49 @@
+--- a/package/libs/mbedtls/Makefile
++++ b/package/libs/mbedtls/Makefile
+@@ -23,6 +23,7 @@ PKG_CPE_ID:=cpe:/a:arm:mbed_tls
+ 
+ PKG_CONFIG_DEPENDS := \
+ 	CONFIG_LIBMBEDTLS_DEBUG_C \
++	CONFIG_LIBMBEDTLS_HAVE_ARMV8CE_AES \
+ 	CONFIG_LIBMBEDTLS_HAVE_SSE2 \
+ 	CONFIG_LIBMBEDTLS_HKDF_C
+ 
+@@ -61,6 +62,20 @@ config LIBMBEDTLS_DEBUG_C
+ 
+ 	 Usually, you don't need this, so don't select this if you're unsure.
+ 
++config LIBMBEDTLS_HAVE_ARMV8CE_AES
++	depends on PACKAGE_libmbedtls
++	bool
++	default y
++	prompt "Enable use of the ARMv8 Crypto Extensions"
++	depends on aarch64 && !TARGET_bcm27xx && !TARGET_bcm4908
++	help
++	 Use of the ARMv8 Crypto Extensions greatly increase performance
++	 (up to 4x faster on AES-GCM while 10x faster on raw AES).
++
++	 Related instructions should be included in all modern Aarch64
++	 devices, except some wastes like Broadcom.
++	 If you don't sure, say Y here.
++
+ config LIBMBEDTLS_HAVE_SSE2
+ 	depends on PACKAGE_libmbedtls
+ 	bool
+@@ -107,6 +122,9 @@ PKG_INSTALL:=1
+ 
+ TARGET_CFLAGS += -ffunction-sections -fdata-sections
+ TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS))
++ifneq ($(CONFIG_LIBMBEDTILS_HAVE_ARMV8CE_AES),)
++  TARGET_CFLAGS := $(filter-out -march=%,$(TARGET_CFLAGS)) -march=armv8-a+crypto
++endif
+ 
+ CMAKE_OPTIONS += \
+ 	-DUSE_SHARED_MBEDTLS_LIBRARY:Bool=ON \
+@@ -118,6 +136,7 @@ define Build/Configure
+ 
+ 	awk 'BEGIN { rc = 1 } \
+ 	     /#define MBEDTLS_DEBUG_C/ { $$$$0 = "$(if $(CONFIG_LIBMBEDTLS_DEBUG_C),,// )#define MBEDTLS_DEBUG_C"; rc = 0 } \
++	     /#define MBEDTLS_ARMV8CE_AES_C/ { $$$$0 = "$(if $(CONFIG_LIBMBEDTLS_HAVE_ARMV8CE_AES),,// )#define MBEDTLS_ARMV8CE_AES_C"; rc = 0 } \
+ 	     /#define MBEDTLS_HAVE_SSE2/ { $$$$0 = "$(if $(CONFIG_LIBMBEDTLS_HAVE_SSE2),,// )#define MBEDTLS_HAVE_SSE2"; rc = 0 } \
+ 	     { print } \
+ 	     END { exit(rc) }' $(PKG_BUILD_DIR)/include/mbedtls/config.h \