From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 832CE21B06E67 for ; Sat, 15 Jul 2017 05:07:15 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP; 15 Jul 2017 05:09:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,363,1496127600"; d="scan'208";a="993309130" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga003.jf.intel.com with ESMTP; 15 Jul 2017 05:09:05 -0700 Received: from fmsmsx113.amr.corp.intel.com (10.18.116.7) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 15 Jul 2017 05:09:05 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX113.amr.corp.intel.com (10.18.116.7) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 15 Jul 2017 05:09:04 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.116]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.197]) with mapi id 14.03.0319.002; Sat, 15 Jul 2017 20:09:02 +0800 From: "Long, Qin" To: Ard Biesheuvel , "edk2-devel@lists.01.org" CC: "Ye, Ting" , "leif.lindholm@linaro.org" , "lersek@redhat.com" Thread-Topic: [PATCH] CryptoPkg/OpensslLib AARCH64: clear XIP CC flags Thread-Index: AQHS/MVaqboK8QHQEUCShPbsY2e6jaJUzI+w Date: Sat, 15 Jul 2017 12:09:02 +0000 Message-ID: References: <20170714171913.28524-1-ard.biesheuvel@linaro.org> In-Reply-To: <20170714171913.28524-1-ard.biesheuvel@linaro.org> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: Sat, 15 Jul 2017 12:07:15 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Long Qin Best Regards & Thanks, LONG, Qin -----Original Message----- From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]=20 Sent: Saturday, July 15, 2017 1:19 AM To: edk2-devel@lists.01.org; Long, Qin Cc: Ye, Ting ; leif.lindholm@linaro.org; lersek@redhat.c= om; Ard Biesheuvel Subject: [PATCH] CryptoPkg/OpensslLib AARCH64: clear XIP CC flags 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 regis= ter file is shared with the FPU, and since OpenSSL contains some references= to float/double types (which are mostly unused for UEFI btw), disabling fl= oating point prevents the compiler from building OpenSSL at all. When introducing the support for XIP CC flags, we were aware that this woul= d affect BASE libraries as well, but were not expecting this to have any pe= rformance impact. However, in the case of software crypto, it makes sense n= ot 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 M= MU 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 t= hat 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/Librar= y/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 =3D $(OPENSSL_FLAGS) --library_interface=3Daea= bi_clib99 --diag_suppress=3D1296,1295,550,1293,111,68,177,223,144,513,188,1= 28,546,1,3017 -JCryptoPkg/Include XCODE:*_*_IA32_CC_FLAGS =3D -mmmx -msse -U_WIN32 -U_WIN64 $(OPENSSL_FL= AGS) -w XCODE:*_*_X64_CC_FLAGS =3D -mmmx -msse -U_WIN32 -U_WIN64 $(OPENSSL_FL= AGS) -w + + # + # AARCH64 uses strict alignment and avoids SIMD registers for code=20 + that may execute # with the MMU off. This involves SEC, PEI_CORE and=20 + PEIM modules as well as BASE # libraries, given that they may be include= d into such modules. + # This library, even though of the BASE type, is never used in such=20 + cases, and # avoiding the SIMD register file (which is shared with=20 + the FPU) prevents the # compiler from successfully building some of=20 + the OpenSSL source files that # use floating point types, so clear the f= lags here. + # + GCC:*_*_AARCH64_CC_XIPFLAGS =3D=3D 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 =3D $(OPENSSL_FLAGS) --library_interface=3Daea= bi_clib99 --diag_suppress=3D1296,1295,550,1293,111,68,177,223,144,513,188,1= 28,546,1,3017 -JCryptoPkg/Include XCODE:*_*_IA32_CC_FLAGS =3D -mmmx -msse -U_WIN32 -U_WIN64 $(OPENSSL_FL= AGS) -w XCODE:*_*_X64_CC_FLAGS =3D -mmmx -msse -U_WIN32 -U_WIN64 $(OPENSSL_FL= AGS) -w + + # + # AARCH64 uses strict alignment and avoids SIMD registers for code=20 + that may execute # with the MMU off. This involves SEC, PEI_CORE and=20 + PEIM modules as well as BASE # libraries, given that they may be include= d into such modules. + # This library, even though of the BASE type, is never used in such=20 + cases, and # avoiding the SIMD register file (which is shared with=20 + the FPU) prevents the # compiler from successfully building some of=20 + the OpenSSL source files that # use floating point types, so clear the f= lags here. + # + GCC:*_*_AARCH64_CC_XIPFLAGS =3D=3D -- 2.9.3