From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 45A049412FC for ; Tue, 21 Nov 2023 08:48:59 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=EzAeA8p+w9g2nzi/j3Iu2xnX18TUwLLoH4UP+rNYdhw=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1700556538; v=1; b=wwxCyYcThRiOjRaQU6d4W4gLPrXnAsOqRRb35zfK9t7joiQZpB4SF97OzR70/85mTRERzfuN y8N1Dxrz5AZLzHVpcmGdWSSRU6yeIQ8RQz+b7EGL9tnMNnwlzdyBlhZAerZWE0pr3nXQv4uifgu ZPiwlR+t/6iDAKrbmp0RPdgQ= X-Received: by 127.0.0.2 with SMTP id MbHNYY7687511xbpZjoHcoyt; Tue, 21 Nov 2023 00:48:58 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.34449.1700556537435951528 for ; Tue, 21 Nov 2023 00:48:57 -0800 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2C18E1684; Tue, 21 Nov 2023 00:49:43 -0800 (PST) X-Received: from cam-smtp0.cambridge.arm.com (e126645.nice.arm.com [10.34.100.114]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 322023F73F; Tue, 21 Nov 2023 00:48:55 -0800 (PST) From: "PierreGondois" To: devel@edk2.groups.io Cc: Jiewen Yao , Yi Li , Xiaoyu Lu , Guomin Jiang , Leif Lindholm , Ard Biesheuvel , Sami Mujawar , Gerd Hoffmann Subject: [edk2-devel] [PATCH v5 5/6] CryptoPkg/OpensslLib: Add AArch64Cap for arch specific hooks Date: Tue, 21 Nov 2023 09:47:14 +0100 Message-Id: <20231121084715.1393672-6-pierre.gondois@arm.com> In-Reply-To: <20231121084715.1393672-1-pierre.gondois@arm.com> References: <20231121084715.1393672-1-pierre.gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 4oxBY7eHW1SmAoh6lEMY67pwx7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=wwxCyYcT; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Add AARCH64 specific implementations of: - OPENSSL_cpuid_setup(), probing hardware capabilitie (presence of FEAT_AES, etc.) - OPENSSL_rdtsc(), returning non-trusted entropy by accessing system counter. Acked-by: Gerd Hoffmann Acked-by: Leif Lindholm Signed-off-by: Pierre Gondois --- .../Library/OpensslLib/OpensslLibAccel.inf | 7 ++ .../OpensslLib/OpensslLibFullAccel.inf | 7 ++ .../OpensslLib/OpensslStub/AArch64Cap.c | 66 +++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 CryptoPkg/Library/OpensslLib/OpensslStub/AArch64Cap.c diff --git a/CryptoPkg/Library/OpensslLib/OpensslLibAccel.inf b/CryptoPkg/L= ibrary/OpensslLib/OpensslLibAccel.inf index 3d1a9638b1c1..08e8be6ea9e1 100644 --- a/CryptoPkg/Library/OpensslLib/OpensslLibAccel.inf +++ b/CryptoPkg/Library/OpensslLib/OpensslLibAccel.inf @@ -1329,6 +1329,7 @@ [Sources.X64] # Autogenerated files list ends here=0D =0D [Sources.AARCH64]=0D + OpensslStub/AArch64Cap.c=0D # Autogenerated files list starts here=0D $(OPENSSL_PATH)/crypto/aes/aes_cbc.c=0D $(OPENSSL_PATH)/crypto/aes/aes_cfb.c=0D @@ -1955,11 +1956,17 @@ [Packages] MdePkg/MdePkg.dec=0D CryptoPkg/CryptoPkg.dec=0D =0D +[Packages.AARCH64]=0D + ArmPkg/ArmPkg.dec=0D +=0D [LibraryClasses]=0D BaseLib=0D DebugLib=0D RngLib=0D =0D +[LibraryClasses.AARCH64]=0D + ArmLib=0D +=0D [BuildOptions]=0D #=0D # Disables the following Visual Studio compiler warnings brought by open= ssl source,=0D diff --git a/CryptoPkg/Library/OpensslLib/OpensslLibFullAccel.inf b/CryptoP= kg/Library/OpensslLib/OpensslLibFullAccel.inf index e7e83d419f4b..2a01ffe06bd7 100644 --- a/CryptoPkg/Library/OpensslLib/OpensslLibFullAccel.inf +++ b/CryptoPkg/Library/OpensslLib/OpensslLibFullAccel.inf @@ -1432,6 +1432,7 @@ [Sources.X64] # Autogenerated files list ends here=0D =0D [Sources.AARCH64]=0D + OpensslStub/AArch64Cap.c=0D # Autogenerated files list starts here=0D $(OPENSSL_PATH)/crypto/aes/aes_cbc.c=0D $(OPENSSL_PATH)/crypto/aes/aes_cfb.c=0D @@ -2107,11 +2108,17 @@ [Packages] MdePkg/MdePkg.dec=0D CryptoPkg/CryptoPkg.dec=0D =0D +[Packages.AARCH64]=0D + ArmPkg/ArmPkg.dec=0D +=0D [LibraryClasses]=0D BaseLib=0D DebugLib=0D RngLib=0D =0D +[LibraryClasses.AARCH64]=0D + ArmLib=0D +=0D [BuildOptions]=0D #=0D # Disables the following Visual Studio compiler warnings brought by open= ssl source,=0D diff --git a/CryptoPkg/Library/OpensslLib/OpensslStub/AArch64Cap.c b/Crypto= Pkg/Library/OpensslLib/OpensslStub/AArch64Cap.c new file mode 100644 index 000000000000..846b004a4dd3 --- /dev/null +++ b/CryptoPkg/Library/OpensslLib/OpensslStub/AArch64Cap.c @@ -0,0 +1,66 @@ +/** @file=0D + Arm capabilities probing.=0D +=0D + Copyright (c) 2023, Arm Limited. All rights reserved.
=0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +**/=0D +=0D +#include =0D +#include "crypto/arm_arch.h"=0D +=0D +#include =0D +=0D +UINT32 OPENSSL_armcap_P =3D 0;=0D +=0D +void=0D +OPENSSL_cpuid_setup (=0D + void=0D + )=0D +{=0D + OPENSSL_armcap_P =3D 0;=0D +=0D + /* Access to EL0 registers is possible from higher ELx. */=0D + OPENSSL_armcap_P |=3D ARMV8_CPUID;=0D + /* Access to Physical timer is possible. */=0D + OPENSSL_armcap_P |=3D ARMV7_TICK;=0D +=0D + /* Neon support is not guaranteed, but it is assumed to be present.=0D + Arm ARM for Armv8, sA1.5 Advanced SIMD and floating-point support=0D + */=0D + OPENSSL_armcap_P |=3D ARMV7_NEON;=0D +=0D + if (ArmHasAes ()) {=0D + OPENSSL_armcap_P |=3D ARMV8_AES;=0D + }=0D +=0D + if (ArmHasSha1 ()) {=0D + OPENSSL_armcap_P |=3D ARMV8_SHA1;=0D + }=0D +=0D + if (ArmHasSha256 ()) {=0D + OPENSSL_armcap_P |=3D ARMV8_SHA256;=0D + }=0D +=0D + if (ArmHasPmull ()) {=0D + OPENSSL_armcap_P |=3D ARMV8_PMULL;=0D + }=0D +=0D + if (ArmHasSha512 ()) {=0D + OPENSSL_armcap_P |=3D ARMV8_SHA512;=0D + }=0D +}=0D +=0D +/** Read system counter value.=0D +=0D + Used to get some non-trusted entropy.=0D +=0D + @return Lower bits of the physical counter.=0D +**/=0D +uint32_t=0D +OPENSSL_rdtsc (=0D + void=0D + )=0D +{=0D + return (UINT32)ArmReadCntPct ();=0D +}=0D --=20 2.25.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111538): https://edk2.groups.io/g/devel/message/111538 Mute This Topic: https://groups.io/mt/102725181/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-