From patchwork Fri Jul 14 17:19:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 107816 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1174608qge; Fri, 14 Jul 2017 10:19:26 -0700 (PDT) X-Received: by 10.84.193.36 with SMTP id e33mr17293110pld.122.1500052766453; Fri, 14 Jul 2017 10:19:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500052766; cv=none; d=google.com; s=arc-20160816; b=zK2IryB4Jq375SqUGHGKzZVttSvZWHhczjzYL14XbvvOHj0PtNp6oIaFy6WF1gkggd 64UrocLszaG3gUQRW2Heceihbl762SjhOGgwJZxs7XAvmQzWOkESeOaO3/cU5v/ERBpf QvSSuR7wJd0IWuMtsV5sjrZdmRzJHvG5pqg9dMedXO4rQlkvJN95P7ai1ikVdfsLFzc1 BkCAL6C9IROs07eoC25ehFF3Q2qlpo/83AlqYJoXpws+gw4oGGcoCAM8Lx0X1xtEXmcN jMaJmWFoZpw8FYxkgJGJ0libynLh4wkteuJNgnz1xkmyLft2gJPc/i7qvW7i/MmcIoky JQ+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=b9gtsSD6V/jAp4OlZhq63tjrFneLxjXaAOtJXTLAZkw=; b=zN+L1kuKranzcpIclKlQYg5pUBgpW07K9Dm7Y+lBnCmCw4L1B4Ju521P8vNXaqop9Y kYSCmrAqEEzQCxNtrcU/JeLyL1KoWy7dL+nlgLZo6ejigRMmAnJULj/+OuAYphLZNOxC F6lmQ1CO9W+etNzB9S5hgJOBxaoxGYj+34ECMIJJUIeTRMwFMm/ECoamfmMl1jNRNhrM mUD6pCC0ku4L2E6Hnc2JJAlDAvdFhFB9MHxvIQRD1reiPdgH0qQeSlads6daYJebahzR ivdmevUEtAgcjw+H3vI1ux1uMZV4ozTNSseWX5skWLygPTEG9WaKYYaqxc0raS88HGKR xfLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=d1dx0IZJ; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id 64si7227487plk.177.2017.07.14.10.19.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jul 2017 10:19:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=d1dx0IZJ; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C85DD2095D8D6; Fri, 14 Jul 2017 10:17:35 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org 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 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: [edk2] [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: , Cc: ting.ye@intel.com, lersek@redhat.com, leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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(+) -- 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Leif Lindholm Acked-by: Laszlo Ersek Reviewed-by: Long Qin Signed-off-by: Ard Biesheuvel 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 ==