ARMV8CE_AES.patch 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. --- a/package/libs/mbedtls/Makefile
  2. +++ b/package/libs/mbedtls/Makefile
  3. @@ -23,6 +23,8 @@ PKG_CPE_ID:=cpe:/a:arm:mbed_tls
  4. PKG_CONFIG_DEPENDS := \
  5. CONFIG_LIBMBEDTLS_DEBUG_C \
  6. + CONFIG_LIBMBEDTLS_HAVE_ARMV8CE_AES \
  7. + CONFIG_LIBMBEDTLS_HAVE_SSE2 \
  8. CONFIG_LIBMBEDTLS_HKDF_C
  9. include $(INCLUDE_DIR)/package.mk
  10. @@ -60,6 +62,34 @@ config LIBMBEDTLS_DEBUG_C
  11. Usually, you don't need this, so don't select this if you're unsure.
  12. +config LIBMBEDTLS_HAVE_ARMV8CE_AES
  13. + depends on PACKAGE_libmbedtls
  14. + bool
  15. + default y
  16. + prompt "Enable use of the ARMv8 Crypto Extensions"
  17. + depends on aarch64 && !TARGET_bcm27xx && !TARGET_bcm4908
  18. + help
  19. + Use of the ARMv8 Crypto Extensions greatly increase performance
  20. + (up to 4x faster on AES-GCM while 10x faster on raw AES).
  21. +
  22. + Related instructions should be included in all modern Aarch64
  23. + devices, except some wastes like Broadcom.
  24. + If you don't sure, say Y here.
  25. +
  26. +config LIBMBEDTLS_HAVE_SSE2
  27. + depends on PACKAGE_libmbedtls
  28. + bool
  29. + default y if !TARGET_x86_legacy && !TARGET_x86_geode
  30. + prompt "Enable use of x86 SSE2 instructions"
  31. + depends on x86_64 || i386
  32. + help
  33. + Use of SSE2 instructions greatly increase performance (up to
  34. + 3x faster) with a minimum (~0.2%, or 23KB) increase in package
  35. + size, but it will bring no benefit if your hardware does not
  36. + support them, such as Geode GX and LX. In this case you may
  37. + save 23KB by saying yes here. AMD Geode NX, and Intel
  38. + Pentium 4 and above support SSE2.
  39. +
  40. config LIBMBEDTLS_HKDF_C
  41. depends on PACKAGE_libmbedtls
  42. bool "Enable the HKDF algorithm (RFC 5869)"
  43. @@ -92,6 +122,9 @@ PKG_INSTALL:=1
  44. TARGET_CFLAGS += -ffunction-sections -fdata-sections
  45. TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS))
  46. +ifneq ($(CONFIG_LIBMBEDTLS_HAVE_ARMV8CE_AES),)
  47. + TARGET_CFLAGS := $(filter-out -march=%,$(TARGET_CFLAGS)) -march=armv8-a+crypto
  48. +endif
  49. CMAKE_OPTIONS += \
  50. -DUSE_SHARED_MBEDTLS_LIBRARY:Bool=ON \
  51. @@ -103,6 +136,8 @@ define Build/Configure
  52. awk 'BEGIN { rc = 1 } \
  53. /#define MBEDTLS_DEBUG_C/ { $$$$0 = "$(if $(CONFIG_LIBMBEDTLS_DEBUG_C),,// )#define MBEDTLS_DEBUG_C"; rc = 0 } \
  54. + /#define MBEDTLS_ARMV8CE_AES_C/ { $$$$0 = "$(if $(CONFIG_LIBMBEDTLS_HAVE_ARMV8CE_AES),,// )#define MBEDTLS_ARMV8CE_AES_C"; rc = 0 } \
  55. + /#define MBEDTLS_HAVE_SSE2/ { $$$$0 = "$(if $(CONFIG_LIBMBEDTLS_HAVE_SSE2),,// )#define MBEDTLS_HAVE_SSE2"; rc = 0 } \
  56. { print } \
  57. END { exit(rc) }' $(PKG_BUILD_DIR)/include/mbedtls/config.h \
  58. >$(PKG_BUILD_DIR)/include/mbedtls/config.h.new && \