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 6AA087803E5 for ; Fri, 10 Nov 2023 10:48:32 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=O0zWGYEgpMve598vAaFrONAc+UfkLVo8RSHgT8qh2Z8=; 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=1699613311; v=1; b=aEHzTvHIhPaRN+xI7i3+fdK1jWLR55MTKnZWg7gulxH2vndgxA16fBKQbAxKylE30CPaZ9tE JsHRwFps9e8uQQgEV2IZOFNW9tLtXMVq1GsZGb9R/iOtibGvNRMksVE/sFN1yK1h+5VFXciqQcV pRJw3F3NS7UVjTEZhPqOpzyA= X-Received: by 127.0.0.2 with SMTP id rH5cYY7687511xGjWgxkQSIb; Fri, 10 Nov 2023 02:48:31 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.24945.1699613310289736097 for ; Fri, 10 Nov 2023 02:48:30 -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 933AC12FC; Fri, 10 Nov 2023 02:49:14 -0800 (PST) X-Received: from e126645.arm.com (unknown [10.57.82.190]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 081DD3F7C5; Fri, 10 Nov 2023 02:48:27 -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 v3 3/6] CryptoPkg/OpensslLib: Add native instruction support for AARCH64 Date: Fri, 10 Nov 2023 11:48:07 +0100 Message-Id: <20231110104810.2038376-4-pierre.gondois@arm.com> In-Reply-To: <20231110104810.2038376-1-pierre.gondois@arm.com> References: <20231110104810.2038376-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: VJj8bFxiVhT2fXu0X5w5ZphDx7686176AA= 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=aEHzTvHI; 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 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 | 6 +++++- 4 files changed, 51 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..dc09124f44ce 100755 --- a/CryptoPkg/Library/OpensslLib/configure.py +++ b/CryptoPkg/Library/OpensslLib/configure.py @@ -262,6 +262,7 @@ def sources_filter_fn(filename): 'provider_predefined.c',=0D 'ecp_nistz256.c',=0D 'x86_64-gcc.c',=0D + 'armcap.c',=0D ]=0D for item in exclude:=0D if item in filename:=0D @@ -353,7 +354,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 +377,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 (#111031): https://edk2.groups.io/g/devel/message/111031 Mute This Topic: https://groups.io/mt/102504420/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-