From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x232.google.com (mail-wm0-x232.google.com [IPv6:2a00:1450:400c:c09::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3F06C2095D8CF for ; Fri, 14 Jul 2017 10:17:34 -0700 (PDT) Received: by mail-wm0-x232.google.com with SMTP id i127so28952665wma.0 for ; Fri, 14 Jul 2017 10:19:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=q9culi+A05MDRkXxKDcQEQUzXVuWlLpq/hBHkvKY9ho=; b=d1dx0IZJlYj+qzKucMRABMdt0FlF8K42ESqaNlM/sTXqCmTy5mEmqjrYpkr/praaG4 rS1MEicIZ2a2LmMel0xE2DcHKWszou5NXZiHzcVsdMmusm5WGWH1gzAVWTjb8T7S33Ol rLc2AecywGENJFZOD6mx6opSiiEZODj7u37YI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=q9culi+A05MDRkXxKDcQEQUzXVuWlLpq/hBHkvKY9ho=; b=qpTL59069e0/SpxzKOwC9Z83IP7TuqqvXnOVX3upAAJwuDblxWsq5Ir/n9R1b1XxDX gs00FoP8l4Z7TouSn/HthKY7X3key6zOrKouYrFyLAI5/zt3t3hQjFKCR/GmAaYzJDsT KwT0J72B7q/voJtu4t+e8BFPwudfLHYgyGxP4rBBD6ndySVgFfdNiJAgSmyczb0ElSQI iwUf4M/LncibeAJvR5bm8iM+pLoXgiJYrKq6bEnglzzPhUgdwGDloi/umHf1Kqtvx4C7 Sis+Etkdaejb2RRnXc6KQhYRbIxCRJr721T3jbhoqrBmofxiwpnW7mO3wKselQEOeoZz eNPQ== X-Gm-Message-State: AIVw113Ry9GMiF0e7jykLhYa2ee49Z+dNzeZuzscXLxAICV+J1jETEc8 owbOnFwjfhF2kfDc3OZx0Q== X-Received: by 10.28.154.19 with SMTP id c19mr3272853wme.87.1500052761955; Fri, 14 Jul 2017 10:19:21 -0700 (PDT) Received: from localhost.localdomain ([154.145.198.181]) by smtp.gmail.com with ESMTPSA id l73sm5593927wma.27.2017.07.14.10.19.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jul 2017 10:19:21 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, qin.long@intel.com Cc: ting.ye@intel.com, leif.lindholm@linaro.org, lersek@redhat.com, Ard Biesheuvel Date: Fri, 14 Jul 2017 18:19:13 +0100 Message-Id: <20170714171913.28524-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 Subject: [PATCH] CryptoPkg/OpensslLib AARCH64: clear XIP CC flags X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Jul 2017 17:17:34 -0000 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. 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 we can create a local exception, and clear its XIP CC flags for AARCH64. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- Note that this un-breaks the currently broken AARCH64 build for platforms that have secure boot enabled CryptoPkg/Library/OpensslLib/OpensslLib.inf | 11 +++++++++++ CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/CryptoPkg/Library/OpensslLib/OpensslLib.inf b/CryptoPkg/Library/OpensslLib/OpensslLib.inf index cbabb34bdd7c..1d15da6660b2 100644 --- a/CryptoPkg/Library/OpensslLib/OpensslLib.inf +++ b/CryptoPkg/Library/OpensslLib/OpensslLib.inf @@ -580,3 +580,14 @@ [BuildOptions] 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 XCODE:*_*_IA32_CC_FLAGS = -mmmx -msse -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) -w XCODE:*_*_X64_CC_FLAGS = -mmmx -msse -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) -w + + # + # AARCH64 uses strict alignment and avoids SIMD registers for code that may execute + # with the MMU off. This involves SEC, PEI_CORE and PEIM modules as well as BASE + # libraries, given that they may be included into such modules. + # This library, even though of the BASE type, is never used in such cases, and + # avoiding the SIMD register file (which is shared with the FPU) prevents the + # compiler from successfully building some of the OpenSSL source files that + # use floating point types, so clear the flags here. + # + GCC:*_*_AARCH64_CC_XIPFLAGS == diff --git a/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf b/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf index 026b551bcafa..6fc8884da492 100644 --- a/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf +++ b/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf @@ -541,3 +541,14 @@ [BuildOptions] 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 XCODE:*_*_IA32_CC_FLAGS = -mmmx -msse -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) -w XCODE:*_*_X64_CC_FLAGS = -mmmx -msse -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) -w + + # + # AARCH64 uses strict alignment and avoids SIMD registers for code that may execute + # with the MMU off. This involves SEC, PEI_CORE and PEIM modules as well as BASE + # libraries, given that they may be included into such modules. + # This library, even though of the BASE type, is never used in such cases, and + # avoiding the SIMD register file (which is shared with the FPU) prevents the + # compiler from successfully building some of the OpenSSL source files that + # use floating point types, so clear the flags here. + # + GCC:*_*_AARCH64_CC_XIPFLAGS == -- 2.9.3