CryptoPkg/OpensslLib AARCH64: clear XIP CC flags
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Fri, 14 Jul 2017 17:09:03 +0000 (18:09 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Sat, 15 Jul 2017 12:36:58 +0000 (13:36 +0100)
Commit 0df6c8c157af ("BaseTools/tools_def AARCH64: avoid SIMD registers
in XIP code") updated the compiler flags used by AARCH64 when building
modules (including BASE libraries) that may execute before the MMU is
enabled.

This broke the build for OpensslLib/OpensslLibCrypto because the SIMD
register file is shared with the FPU, and since OpenSSL contains some
references to float/double types (which are mostly unused for UEFI btw),
disabling floating point prevents the compiler from building OpenSSL
at all. So for OpensslLib[Crypto], we need to override the XIP CC flags,
to remove the -mgeneral-regs-only compiler flag again.

When introducing the support for XIP CC flags, we were aware that this
would affect BASE libraries as well, but were not expecting this to
have any performance impact. However, in the case of software crypto,
it makes sense not to needlessly inhibit the compiler's ability to
generate fast code, and even if OpenssLib is a BASE library, it is
guaranteed not to run with the MMU off. So omit -mstrict-align from the
local XIP CC flags override as well.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Long Qin <qin.long@intel.com>
CryptoPkg/Library/OpensslLib/OpensslLib.inf
CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf

index cbabb34bdd7cb1e6fe64a4d55ed8b0171e06612c..1d15da6660b247a2a29b408784a005dfda07c776 100644 (file)
   RVCT:*_*_ARM_CC_FLAGS     = $(OPENSSL_FLAGS) --library_interface=aeabi_clib99 --diag_suppress=1296,1295,550,1293,111,68,177,223,144,513,188,128,546,1,3017 -JCryptoPkg/Include\r
   XCODE:*_*_IA32_CC_FLAGS   = -mmmx -msse -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) -w\r
   XCODE:*_*_X64_CC_FLAGS    = -mmmx -msse -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) -w\r
+\r
+  #\r
+  # AARCH64 uses strict alignment and avoids SIMD registers for code that may execute\r
+  # with the MMU off. This involves SEC, PEI_CORE and PEIM modules as well as BASE\r
+  # libraries, given that they may be included into such modules.\r
+  # This library, even though of the BASE type, is never used in such cases, and\r
+  # avoiding the SIMD register file (which is shared with the FPU) prevents the\r
+  # compiler from successfully building some of the OpenSSL source files that\r
+  # use floating point types, so clear the flags here.\r
+  #\r
+  GCC:*_*_AARCH64_CC_XIPFLAGS ==\r
index 026b551bcafa188db647fd2ba8560e1598455c35..6fc8884da492e84f8c9b3a6ac46ef73c5b9923e9 100644 (file)
   RVCT:*_*_ARM_CC_FLAGS     = $(OPENSSL_FLAGS) --library_interface=aeabi_clib99 --diag_suppress=1296,1295,550,1293,111,68,177,223,144,513,188,128,546,1,3017 -JCryptoPkg/Include\r
   XCODE:*_*_IA32_CC_FLAGS   = -mmmx -msse -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) -w\r
   XCODE:*_*_X64_CC_FLAGS    = -mmmx -msse -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) -w\r
+\r
+  #\r
+  # AARCH64 uses strict alignment and avoids SIMD registers for code that may execute\r
+  # with the MMU off. This involves SEC, PEI_CORE and PEIM modules as well as BASE\r
+  # libraries, given that they may be included into such modules.\r
+  # This library, even though of the BASE type, is never used in such cases, and\r
+  # avoiding the SIMD register file (which is shared with the FPU) prevents the\r
+  # compiler from successfully building some of the OpenSSL source files that\r
+  # use floating point types, so clear the flags here.\r
+  #\r
+  GCC:*_*_AARCH64_CC_XIPFLAGS ==\r