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 3CF45D8067E for ; Thu, 2 Nov 2023 13:54:42 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=ynocRXGLOrlWkNyRF0bP1JdPgaO6FwdAb7YwgwxFvgY=; 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=1698933280; v=1; b=NoQpLI9z6eJegpC40MVENSg9EkR3bQPDmbVSRTCrRmLMbORN8/XgRQl3nvzTIBhqDuWTx2xk Vm/t77JD2+dPQMmIKYigjENggUsvnsdzgp9RgnFYTBscuPfwXIqwXlMKBiLj/a4FDlWAT8hRIQZ IrznhnRmqt2JQyq0pbFkErBw= X-Received: by 127.0.0.2 with SMTP id DNJIYY7687511xCcZgvepiWB; Thu, 02 Nov 2023 06:54:40 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.31757.1698933280353058601 for ; Thu, 02 Nov 2023 06:54:40 -0700 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 00819152B; Thu, 2 Nov 2023 06:55:22 -0700 (PDT) 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 62B773F738; Thu, 2 Nov 2023 06:54:38 -0700 (PDT) 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 v1 4/7] CryptoPkg/OpensslLib: Add native instruction support for AARCH64 Date: Thu, 2 Nov 2023 14:54:14 +0100 Message-Id: <20231102135417.336334-5-pierre.gondois@arm.com> In-Reply-To: <20231102135417.336334-1-pierre.gondois@arm.com> References: <20231102135417.336334-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: yV0lmodxYTcZc80JrKYHGOvsx7686176AA= 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=NoQpLI9z; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none) Add native instruction support for AARCH64. Signed-off-by: Pierre Gondois --- .../Library/OpensslLib/OpensslLibAccel.inf | 21 ++++++++++++++++++- .../OpensslLib/OpensslLibFullAccel.inf | 21 ++++++++++++++++++- CryptoPkg/Library/OpensslLib/UefiAsm.conf | 6 ++++++ CryptoPkg/Library/OpensslLib/configure.py | 5 ++++- 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/CryptoPkg/Library/OpensslLib/OpensslLibAccel.inf b/CryptoPkg/L= ibrary/OpensslLib/OpensslLibAccel.inf index a37347fbbfd6..a47e9087133b 100644 --- a/CryptoPkg/Library/OpensslLib/OpensslLibAccel.inf +++ b/CryptoPkg/Library/OpensslLib/OpensslLibAccel.inf @@ -5,6 +5,7 @@ #=0D # Copyright (c) 2010 - 2020, Intel Corporation. All rights reserved.
= =0D # (C) Copyright 2020 Hewlett Packard Enterprise Development LP
=0D +# Copyright (c) 2023, Arm Limited. All rights reserved.
=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D ##=0D @@ -24,9 +25,10 @@ [Defines] DEFINE OPENSSL_FLAGS =3D -DL_ENDIAN -DOPENSSL_SMALL_FOOTPRINT = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DEDK2_OPENSSL_NOEC= =3D1=0D DEFINE OPENSSL_FLAGS_IA32 =3D -DAES_ASM -DGHASH_ASM -DMD5_ASM -DOPE= NSSL_CPUID_OBJ -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DVPAES_ASM=0D DEFINE OPENSSL_FLAGS_X64 =3D -DAES_ASM -DBSAES_ASM -DGHASH_ASM -DK= ECCAK1600_ASM -DMD5_ASM -DOPENSSL_CPUID_OBJ -DSHA1_ASM -DSHA256_ASM -DSHA51= 2_ASM -DVPAES_ASM=0D + DEFINE OPENSSL_FLAGS_AARCH64 =3D=0D =0D #=0D -# VALID_ARCHITECTURES =3D IA32 X64=0D +# VALID_ARCHITECTURES =3D IA32 X64 AARCH64=0D #=0D =0D [Sources]=0D @@ -1326,6 +1328,10 @@ [Sources.X64] $(OPENSSL_GEN_PATH)/X64-GCC/crypto/sha/sha512-x86_64.s | GCC=0D # Autogenerated files list ends here=0D =0D +[Sources.AARCH64]=0D +# Autogenerated files list starts here=0D +# Autogenerated files list ends here=0D +=0D [Packages]=0D MdePkg/MdePkg.dec=0D CryptoPkg/CryptoPkg.dec=0D @@ -1403,3 +1409,16 @@ [BuildOptions] # commit d9b8b89bec4480de3a10bdaf9425db371c19145b, and can be drop= ped then.)=0D XCODE:*_*_IA32_CC_FLAGS =3D -mmmx -msse -U_WIN32 -U_WIN64 $(OPENSSL_FL= AGS) $(OPENSSL_FLAGS_IA32) -w -std=3Dc99 -Wno-error=3Duninitialized=0D XCODE:*_*_X64_CC_FLAGS =3D -mmmx -msse -U_WIN32 -U_WIN64 $(OPENSSL_FL= AGS) $(OPENSSL_FLAGS_X64) -w -std=3Dc99 -Wno-error=3Duninitialized=0D +=0D + GCC:*_*_AARCH64_CC_FLAGS =3D $(OPENSSL_FLAGS) $(OPENSSL_FLAGS_AARCH64= ) -Wno-error=3Dformat -Wno-format -D_BITS_STDINT_UINTN_H -D_BITS_STDINT_INT= N_H=0D +=0D + #=0D + # AARCH64 uses strict alignment and avoids SIMD registers for code that = may execute=0D + # with the MMU off. This involves SEC, PEI_CORE and PEIM modules as well= as BASE=0D + # libraries, given that they may be included into such modules.=0D + # This library, even though of the BASE type, is never used in such case= s, and=0D + # avoiding the SIMD register file (which is shared with the FPU) prevent= s the=0D + # compiler from successfully building some of the OpenSSL source files t= hat=0D + # use floating point types, so clear the flags here.=0D + #=0D + GCC:*_*_AARCH64_CC_XIPFLAGS =3D=3D=0D diff --git a/CryptoPkg/Library/OpensslLib/OpensslLibFullAccel.inf b/CryptoP= kg/Library/OpensslLib/OpensslLibFullAccel.inf index 780d5febd72e..45a58c7d382e 100644 --- a/CryptoPkg/Library/OpensslLib/OpensslLibFullAccel.inf +++ b/CryptoPkg/Library/OpensslLib/OpensslLibFullAccel.inf @@ -10,6 +10,7 @@ #=0D # Copyright (c) 2010 - 2020, Intel Corporation. All rights reserved.
= =0D # (C) Copyright 2020 Hewlett Packard Enterprise Development LP
=0D +# Copyright (c) 2023, Arm Limited. All rights reserved.
=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D ##=0D @@ -29,9 +30,10 @@ [Defines] DEFINE OPENSSL_FLAGS =3D -DL_ENDIAN -DOPENSSL_SMALL_FOOTPRINT = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE=0D DEFINE OPENSSL_FLAGS_IA32 =3D -DAES_ASM -DGHASH_ASM -DMD5_ASM -DOPE= NSSL_CPUID_OBJ -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DVPAES_ASM=0D DEFINE OPENSSL_FLAGS_X64 =3D -DAES_ASM -DBSAES_ASM -DGHASH_ASM -DK= ECCAK1600_ASM -DMD5_ASM -DOPENSSL_CPUID_OBJ -DSHA1_ASM -DSHA256_ASM -DSHA51= 2_ASM -DVPAES_ASM=0D + DEFINE OPENSSL_FLAGS_AARCH64 =3D=0D =0D #=0D -# VALID_ARCHITECTURES =3D IA32 X64=0D +# VALID_ARCHITECTURES =3D IA32 X64 AARCH64=0D #=0D =0D [Sources]=0D @@ -1429,6 +1431,10 @@ [Sources.X64] $(OPENSSL_GEN_PATH)/X64-GCC/crypto/sha/sha512-x86_64.s | GCC=0D # Autogenerated files list ends here=0D =0D +[Sources.AARCH64]=0D +# Autogenerated files list starts here=0D +# Autogenerated files list ends here=0D +=0D [Packages]=0D MdePkg/MdePkg.dec=0D CryptoPkg/CryptoPkg.dec=0D @@ -1506,3 +1512,16 @@ [BuildOptions] # commit d9b8b89bec4480de3a10bdaf9425db371c19145b, and can be drop= ped then.)=0D XCODE:*_*_IA32_CC_FLAGS =3D -mmmx -msse -U_WIN32 -U_WIN64 $(OPENSSL_FL= AGS) $(OPENSSL_FLAGS_IA32) -w -std=3Dc99 -Wno-error=3Duninitialized=0D XCODE:*_*_X64_CC_FLAGS =3D -mmmx -msse -U_WIN32 -U_WIN64 $(OPENSSL_FL= AGS) $(OPENSSL_FLAGS_X64) -w -std=3Dc99 -Wno-error=3Duninitialized=0D +=0D + GCC:*_*_AARCH64_CC_FLAGS =3D $(OPENSSL_FLAGS) $(OPENSSL_FLAGS_AARCH64= ) -Wno-error=3Dformat -Wno-format -D_BITS_STDINT_UINTN_H -D_BITS_STDINT_INT= N_H=0D +=0D + #=0D + # AARCH64 uses strict alignment and avoids SIMD registers for code that = may execute=0D + # with the MMU off. This involves SEC, PEI_CORE and PEIM modules as well= as BASE=0D + # libraries, given that they may be included into such modules.=0D + # This library, even though of the BASE type, is never used in such case= s, and=0D + # avoiding the SIMD register file (which is shared with the FPU) prevent= s the=0D + # compiler from successfully building some of the OpenSSL source files t= hat=0D + # use floating point types, so clear the flags here.=0D + #=0D + GCC:*_*_AARCH64_CC_XIPFLAGS =3D=3D=0D diff --git a/CryptoPkg/Library/OpensslLib/UefiAsm.conf b/CryptoPkg/Library/= OpensslLib/UefiAsm.conf index 907582f93e2d..07273d6a1ab5 100644 --- a/CryptoPkg/Library/OpensslLib/UefiAsm.conf +++ b/CryptoPkg/Library/OpensslLib/UefiAsm.conf @@ -2,6 +2,7 @@ # UEFI assembly openssl configuration targets.=0D #=0D # Copyright (c) 2020, Intel Corporation. All rights reserved.
=0D +# Copyright (c) 2023, Arm Limited. All rights reserved.
=0D #=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D @@ -28,4 +29,9 @@ my %targets =3D ( perlasm_scheme =3D> "elf",=0D asm_arch =3D> "x86_64",=0D },=0D + "UEFI-AARCH64-GCC" =3D> {=0D + inherit_from =3D> [ "UEFI" ],=0D + asm_arch =3D> "aarch64",=0D + perlasm_scheme =3D> "linux64-aarch64",=0D + },=0D );=0D diff --git a/CryptoPkg/Library/OpensslLib/configure.py b/CryptoPkg/Library/= OpensslLib/configure.py index 4243ca4c2574..d3013dddb834 100755 --- a/CryptoPkg/Library/OpensslLib/configure.py +++ b/CryptoPkg/Library/OpensslLib/configure.py @@ -353,7 +353,8 @@ def main(): sources =3D {}=0D defines =3D {}=0D for asm in [ 'UEFI-IA32-MSFT', 'UEFI-IA32-GCC',=0D - 'UEFI-X64-MSFT', 'UEFI-X64-GCC']:=0D + 'UEFI-X64-MSFT', 'UEFI-X64-GCC',=0D + 'UEFI-AARCH64-GCC']:=0D (uefi, arch, cc) =3D asm.split('-')=0D archcc =3D f'{arch}-{cc}'=0D =0D @@ -375,6 +376,8 @@ def main(): x64accel =3D sources['X64'] + sources['X64-MSFT'] + sources['X64-G= CC']=0D update_inf(inf, ia32accel, 'IA32', defines['IA32'])=0D update_inf(inf, x64accel, 'X64', defines['X64'])=0D + aarch64accel =3D sources['AARCH64'] + sources['AARCH64-GCC']=0D + update_inf(inf, aarch64accel, 'AARCH64', defines['AARCH64'])=0D =0D # noaccel - ec enabled=0D openssl_configure(openssldir, 'UEFI', ec =3D True);=0D --=20 2.25.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110551): https://edk2.groups.io/g/devel/message/110551 Mute This Topic: https://groups.io/mt/102342398/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-