Re: [PATCH v5 0/2] CryptoPkg/OpensslLib: Add native instruction support for X64

Zurcher, Christopher J

I think some of these errors are not relevant based on the nature of the commit:

One of the errors reported is that the added typedefs (ptrdiff_t, wchar_t) do not follow coding guidelines, but the typedefs are required for OpenSSL compatibility and they match the already-existing style:

typedef UINTN size_t;
typedef UINTN u_int;
+typedef INTN ptrdiff_t;
typedef INTN ssize_t;
typedef INT32 time_t;
typedef UINT8 __uint8_t;
typedef UINT8 sa_family_t;
typedef UINT8 u_char;
typedef UINT32 uid_t;
typedef UINT32 gid_t;
+typedef CHAR16 wchar_t;

Another error is that the auto-generated assembly files do not start with capital letters, but these filenames come from OpenSSL with lowercase filenames, and we already have opensslconf.h in the Include folder which has a lowercase filename.

Another error type reported is that the auto-generated assembly files do not have "SPDX-License-Identifier: BSD-2-Clause-Patent" but it was already discussed on the list that these would be checked in with the OpenSSL header similar to opensslconf.h:

Additionally, there is an error that OpensslLibX64.inf is not in CryptoPkg.dsc, but I am not sure if it is appropriate to include as the module is not compatible with GCC builds.

How should I proceed here?

Christopher Zurcher

-----Original Message-----
From: Yao, Jiewen <>
Sent: Thursday, November 5, 2020 22:14
To:; Yao, Jiewen <>; Zurcher,
Christopher J <>
Cc: Wang, Jian J <>; Lu, XiaoyuX <>;
Kinney, Michael D <>; Ard Biesheuvel
Subject: RE: [edk2-devel] [PATCH v5 0/2] CryptoPkg/OpensslLib: Add native
instruction support for X64

Hi Zurcher
I created

However, there are failures in CI test. So this patch is NOT merged.

Please take a look and resolve it.

Thank you
Yao Jiewen

-----Original Message-----
From: <> On Behalf Of Yao,
Sent: Friday, November 6, 2020 1:56 PM
To: Zurcher, Christopher J <>;
Cc: Wang, Jian J <>; Lu, XiaoyuX
<>; Kinney, Michael D <>;
Ard Biesheuvel <>
Subject: Re: [edk2-devel] [PATCH v5 0/2] CryptoPkg/OpensslLib: Add native
instruction support for X64

Patch 1/2 reviewed-by: Jiewen Yao <>

-----Original Message-----
From: Christopher J Zurcher <>
Sent: Wednesday, November 4, 2020 5:59 AM
Cc: Yao, Jiewen <>; Wang, Jian J
<>; Lu, XiaoyuX <>; Kinney,
Michael D <>; Ard Biesheuvel
Subject: [PATCH v5 0/2] CryptoPkg/OpensslLib: Add native instruction
support for X64

V5 Changes:
Move ApiHooks.c into X64 folder
Update to clean architecture-specific subfolders
removing them
Rebased INF file to merge latest changes regarding RngLib vs. TimerLib

V4 Changes:
Add copyright header to uefi-asm.conf
Move [Sources.X64] block to cover entire X64-specific config

V3 Changes:
Added definitions for ptrdiff_t and wchar_t to CrtLibSupport.h for
LLVM/Clang build support.
Added -UWIN32 to GCC Flags for LLVM/Clang build support.
Added missing AES GCM assembly file.

V2 Changes:
Limit scope of assembly config to SHA and AES functions.
Removed IA32 native support (reduced config was causing build failure
can be added in a later patch).
Removed XMM instructions from assembly generation.
Added automatic copyright header porting for generated assembly files.

This patch adds support for building the native instruction algorithms
the X64 architecture in OpensslLib. The script was
to parse the .asm file targets from the OpenSSL build config data struct,
generate the necessary assembly files for the EDK2 build environment.

For the X64 variant, OpenSSL includes calls to a Windows error handling
and that function has been stubbed out in ApiHooks.c.

For all variants, a constructor is added to call the required CPUID
within OpenSSL to facilitate processor capability checks in the native

Additional native architecture variants should be simple to add by
the changes made for this architecture.

The OpenSSL assembly files are traditionally generated at build time
using a
perl script. To avoid that burden on EDK2 users, these end-result
files are generated during the configuration steps performed by the
maintainer (through The perl generator scripts inside
OpenSSL do not parse file comments as they are only meant to create
intermediate build files, so contains additional hooks
preserve the copyright headers as well as clean up tabs and line endings
comply with EDK2 coding standards. The resulting file headers align with
the generated .h files which are already included in the EDK2 repository.

Cc: Jiewen Yao <>
Cc: Jian J Wang <>
Cc: Xiaoyu Lu <>
Cc: Mike Kinney <>
Cc: Ard Biesheuvel <>

Christopher J Zurcher (2):
CryptoPkg/OpensslLib: Add native instruction support for X64
CryptoPkg/OpensslLib: Commit the auto-generated assembly files for X64

CryptoPkg/Library/OpensslLib/OpensslLib.inf |
2 +-
CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf |
2 +-
CryptoPkg/Library/OpensslLib/OpensslLibX64.inf |
653 +++
CryptoPkg/Library/Include/CrtLibSupport.h |
2 +
CryptoPkg/Library/Include/openssl/opensslconf.h |
3 -
CryptoPkg/Library/OpensslLib/OpensslLibConstructor.c |
34 +
CryptoPkg/Library/OpensslLib/X64/ApiHooks.c |
18 +
CryptoPkg/Library/OpensslLib/X64/crypto/aes/aesni-mb-x86_64.nasm |
732 +++
CryptoPkg/Library/OpensslLib/X64/crypto/aes/aesni-sha1-x86_64.nasm |
1916 ++++++++
78 +
CryptoPkg/Library/OpensslLib/X64/crypto/aes/aesni-x86_64.nasm |
5103 ++++++++++++++++++++
CryptoPkg/Library/OpensslLib/X64/crypto/aes/vpaes-x86_64.nasm |
1173 +++++
| 34 +
CryptoPkg/Library/OpensslLib/X64/crypto/modes/ghash-x86_64.nasm |
1569 ++++++
CryptoPkg/Library/OpensslLib/X64/crypto/sha/sha1-mb-x86_64.nasm |
3137 ++++++++++++
CryptoPkg/Library/OpensslLib/X64/crypto/sha/sha1-x86_64.nasm |
2884 +++++++++++
3461 +++++++++++++
CryptoPkg/Library/OpensslLib/X64/crypto/sha/sha256-x86_64.nasm |
3313 +++++++++++++
CryptoPkg/Library/OpensslLib/X64/crypto/sha/sha512-x86_64.nasm |
1938 ++++++++
CryptoPkg/Library/OpensslLib/X64/crypto/x86_64cpuid.nasm |
CryptoPkg/Library/OpensslLib/ |
232 +-
CryptoPkg/Library/OpensslLib/uefi-asm.conf |
21 +
22 files changed, 26746 insertions(+), 50 deletions(-)
create mode 100644 CryptoPkg/Library/OpensslLib/OpensslLibX64.inf
create mode 100644
create mode 100644 CryptoPkg/Library/OpensslLib/X64/ApiHooks.c
create mode 100644 CryptoPkg/Library/OpensslLib/X64/crypto/aes/aesni-
create mode 100644 CryptoPkg/Library/OpensslLib/X64/crypto/aes/aesni-
create mode 100644 CryptoPkg/Library/OpensslLib/X64/crypto/aes/aesni-
create mode 100644 CryptoPkg/Library/OpensslLib/X64/crypto/aes/aesni-
create mode 100644 CryptoPkg/Library/OpensslLib/X64/crypto/aes/vpaes-
create mode 100644
create mode 100644
create mode 100644 CryptoPkg/Library/OpensslLib/X64/crypto/sha/sha1-
create mode 100644 CryptoPkg/Library/OpensslLib/X64/crypto/sha/sha1-
create mode 100644
create mode 100644
create mode 100644
create mode 100644
create mode 100644 CryptoPkg/Library/OpensslLib/uefi-asm.conf


Join to automatically receive all group messages.