public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Vineel Kovvuri" <vineelko@microsoft.com>
To: Vineel Kovvuri <vineel.kovvuri@gmail.com>,devel@edk2.groups.io
Subject: Re: [edk2-devel] [PATCH 1/2] Reconfigure OpensslLib to add elliptic curve chipher algorithms
Date: Mon, 08 Nov 2021 14:29:36 -0800	[thread overview]
Message-ID: <23891.1636410576311055186@groups.io> (raw)
In-Reply-To: <CABG47Q-PcbYndFrYpwA=Soaw_xUMpHA4yj_vBjT77j1WSzza-w@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1137 bytes --]

Hi Folks,

We are able to resolve the __ModuleEntryPoint error and was able to run below build configurations locally.

* Windows_VS2019 - Passed

* EmulatorPkg_Win_VS2019 - Passed
* OvmfPkg_Win_VS2019 - Passed

* Ubuntu_GCC5 - Passed

* ArmVirtPkg_Ubuntu_GCC5 - Passed
* EmulatorPkg_Ubuntu_GCC5 - Passed
* OvmfPkg_Ubuntu_GCC5 – Failed

* INFO - GenFv: ERROR 3000: Invalid
* INFO -   the required fv image size 0xcb2ac0 exceeds the set fv image size 0xc00000

Is it okay to increase the fv image size if so need some guidance with respected to that as it may effect other projects like QEMU etc. Any inputs here are much appreciated

For Reference: https://github.com/vineelkovvuri/edk2/pull/2 ( https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fvineelkovvuri%2Fedk2%2Fpull%2F2&data=04%7C01%7Cvineelko%40microsoft.com%7C39a86fd17084443454fa08d9a2dc1185%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637719888367133870%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Mj7FG%2FZvbQska6c6tGj9Z0xgcenZSX3COrPoL4Pe1k0%3D&reserved=0 )

[-- Attachment #1.2: Type: text/html, Size: 3244 bytes --]

[-- Attachment #2: 0001-ECC-Fixes.patch --]
[-- Type: application/octet-stream, Size: 9317 bytes --]

From 0533837d64939b47379572c1c2bae08acad6a569 Mon Sep 17 00:00:00 2001
From: Vineel Kovvuri <vineelko@microsoft.com>
Date: Sat, 16 Oct 2021 22:36:58 -0700
Subject: [PATCH 1/3] ECC Fixes

Signed-off-by: Vineel Kovvuri <vineelko@microsoft.com>
---
 .../Library/Include/openssl/opensslconf.h     | 23 ++-------
 CryptoPkg/Library/OpensslLib/OpensslLib.inf   | 50 +++++++++++++++++++
 .../Library/OpensslLib/OpensslLibCrypto.inf   | 50 +++++++++++++++++++
 CryptoPkg/Library/OpensslLib/process_files.pl |  1 -
 4 files changed, 104 insertions(+), 20 deletions(-)

diff --git a/CryptoPkg/Library/Include/openssl/opensslconf.h b/CryptoPkg/Library/Include/openssl/opensslconf.h
index b8d59aebe8..e097de7797 100644
--- a/CryptoPkg/Library/Include/openssl/opensslconf.h
+++ b/CryptoPkg/Library/Include/openssl/opensslconf.h
@@ -55,9 +55,6 @@ extern "C" {
 #ifndef OPENSSL_NO_DSA
 # define OPENSSL_NO_DSA
 #endif
-#ifndef OPENSSL_NO_EC
-# define OPENSSL_NO_EC
-#endif
 #ifndef OPENSSL_NO_IDEA
 # define OPENSSL_NO_IDEA
 #endif
@@ -88,9 +85,6 @@ extern "C" {
 #ifndef OPENSSL_NO_SEED
 # define OPENSSL_NO_SEED
 #endif
-#ifndef OPENSSL_NO_SM2
-# define OPENSSL_NO_SM2
-#endif
 #ifndef OPENSSL_NO_SRP
 # define OPENSSL_NO_SRP
 #endif
@@ -154,12 +148,6 @@ extern "C" {
 #ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
 # define OPENSSL_NO_EC_NISTP_64_GCC_128
 #endif
-#ifndef OPENSSL_NO_ECDH
-# define OPENSSL_NO_ECDH
-#endif
-#ifndef OPENSSL_NO_ECDSA
-# define OPENSSL_NO_ECDSA
-#endif
 #ifndef OPENSSL_NO_EGD
 # define OPENSSL_NO_EGD
 #endif
@@ -226,9 +214,6 @@ extern "C" {
 #ifndef OPENSSL_NO_TESTS
 # define OPENSSL_NO_TESTS
 #endif
-#ifndef OPENSSL_NO_TLS1_3
-# define OPENSSL_NO_TLS1_3
-#endif
 #ifndef OPENSSL_NO_UBSAN
 # define OPENSSL_NO_UBSAN
 #endif
@@ -265,11 +250,11 @@ extern "C" {
 #   undef DECLARE_DEPRECATED
 #   define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));
 #  endif
-#elif defined(__SUNPRO_C)
-#if (__SUNPRO_C >= 0x5130)
-#undef DECLARE_DEPRECATED
+# elif defined(__SUNPRO_C)
+#  if (__SUNPRO_C >= 0x5130)
+#   undef DECLARE_DEPRECATED
 #define DECLARE_DEPRECATED(f)    f __attribute__ ((deprecated));
-#endif
+#  endif
 # endif
 #endif
 
diff --git a/CryptoPkg/Library/OpensslLib/OpensslLib.inf b/CryptoPkg/Library/OpensslLib/OpensslLib.inf
index d84bde056a..bd3d9cc90f 100644
--- a/CryptoPkg/Library/OpensslLib/OpensslLib.inf
+++ b/CryptoPkg/Library/OpensslLib/OpensslLib.inf
@@ -199,6 +199,43 @@
   $(OPENSSL_PATH)/crypto/dso/dso_vms.c
   $(OPENSSL_PATH)/crypto/dso/dso_win32.c
   $(OPENSSL_PATH)/crypto/ebcdic.c
+  $(OPENSSL_PATH)/crypto/ec/curve25519.c
+  $(OPENSSL_PATH)/crypto/ec/curve448/arch_32/f_impl.c
+  $(OPENSSL_PATH)/crypto/ec/curve448/curve448.c
+  $(OPENSSL_PATH)/crypto/ec/curve448/curve448_tables.c
+  $(OPENSSL_PATH)/crypto/ec/curve448/eddsa.c
+  $(OPENSSL_PATH)/crypto/ec/curve448/f_generic.c
+  $(OPENSSL_PATH)/crypto/ec/curve448/scalar.c
+  $(OPENSSL_PATH)/crypto/ec/ec2_oct.c
+  $(OPENSSL_PATH)/crypto/ec/ec2_smpl.c
+  $(OPENSSL_PATH)/crypto/ec/ec_ameth.c
+  $(OPENSSL_PATH)/crypto/ec/ec_asn1.c
+  $(OPENSSL_PATH)/crypto/ec/ec_check.c
+  $(OPENSSL_PATH)/crypto/ec/ec_curve.c
+  $(OPENSSL_PATH)/crypto/ec/ec_cvt.c
+  $(OPENSSL_PATH)/crypto/ec/ec_err.c
+  $(OPENSSL_PATH)/crypto/ec/ec_key.c
+  $(OPENSSL_PATH)/crypto/ec/ec_kmeth.c
+  $(OPENSSL_PATH)/crypto/ec/ec_lib.c
+  $(OPENSSL_PATH)/crypto/ec/ec_mult.c
+  $(OPENSSL_PATH)/crypto/ec/ec_oct.c
+  $(OPENSSL_PATH)/crypto/ec/ec_pmeth.c
+  $(OPENSSL_PATH)/crypto/ec/ec_print.c
+  $(OPENSSL_PATH)/crypto/ec/ecdh_kdf.c
+  $(OPENSSL_PATH)/crypto/ec/ecdh_ossl.c
+  $(OPENSSL_PATH)/crypto/ec/ecdsa_ossl.c
+  $(OPENSSL_PATH)/crypto/ec/ecdsa_sign.c
+  $(OPENSSL_PATH)/crypto/ec/ecdsa_vrf.c
+  $(OPENSSL_PATH)/crypto/ec/eck_prn.c
+  $(OPENSSL_PATH)/crypto/ec/ecp_mont.c
+  $(OPENSSL_PATH)/crypto/ec/ecp_nist.c
+  $(OPENSSL_PATH)/crypto/ec/ecp_nistp224.c
+  $(OPENSSL_PATH)/crypto/ec/ecp_nistp256.c
+  $(OPENSSL_PATH)/crypto/ec/ecp_nistp521.c
+  $(OPENSSL_PATH)/crypto/ec/ecp_nistputil.c
+  $(OPENSSL_PATH)/crypto/ec/ecp_oct.c
+  $(OPENSSL_PATH)/crypto/ec/ecp_smpl.c
+  $(OPENSSL_PATH)/crypto/ec/ecx_meth.c
   $(OPENSSL_PATH)/crypto/err/err.c
   $(OPENSSL_PATH)/crypto/err/err_prn.c
   $(OPENSSL_PATH)/crypto/evp/bio_b64.c
@@ -384,6 +421,10 @@
   $(OPENSSL_PATH)/crypto/siphash/siphash.c
   $(OPENSSL_PATH)/crypto/siphash/siphash_ameth.c
   $(OPENSSL_PATH)/crypto/siphash/siphash_pmeth.c
+  $(OPENSSL_PATH)/crypto/sm2/sm2_crypt.c
+  $(OPENSSL_PATH)/crypto/sm2/sm2_err.c
+  $(OPENSSL_PATH)/crypto/sm2/sm2_pmeth.c
+  $(OPENSSL_PATH)/crypto/sm2/sm2_sign.c
   $(OPENSSL_PATH)/crypto/sm3/m_sm3.c
   $(OPENSSL_PATH)/crypto/sm3/sm3.c
   $(OPENSSL_PATH)/crypto/sm4/sm4.c
@@ -496,6 +537,15 @@
   $(OPENSSL_PATH)/crypto/conf/conf_local.h
   $(OPENSSL_PATH)/crypto/dh/dh_local.h
   $(OPENSSL_PATH)/crypto/dso/dso_local.h
+  $(OPENSSL_PATH)/crypto/ec/ec_local.h
+  $(OPENSSL_PATH)/crypto/ec/curve448/curve448_local.h
+  $(OPENSSL_PATH)/crypto/ec/curve448/curve448utils.h
+  $(OPENSSL_PATH)/crypto/ec/curve448/ed448.h
+  $(OPENSSL_PATH)/crypto/ec/curve448/field.h
+  $(OPENSSL_PATH)/crypto/ec/curve448/point_448.h
+  $(OPENSSL_PATH)/crypto/ec/curve448/word.h
+  $(OPENSSL_PATH)/crypto/ec/curve448/arch_32/arch_intrinsics.h
+  $(OPENSSL_PATH)/crypto/ec/curve448/arch_32/f_impl.h
   $(OPENSSL_PATH)/crypto/evp/evp_local.h
   $(OPENSSL_PATH)/crypto/hmac/hmac_local.h
   $(OPENSSL_PATH)/crypto/lhash/lhash_local.h
diff --git a/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf b/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
index cdeed0d073..38ccf1a5b6 100644
--- a/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
+++ b/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
@@ -199,6 +199,43 @@
   $(OPENSSL_PATH)/crypto/dso/dso_vms.c
   $(OPENSSL_PATH)/crypto/dso/dso_win32.c
   $(OPENSSL_PATH)/crypto/ebcdic.c
+  $(OPENSSL_PATH)/crypto/ec/curve25519.c
+  $(OPENSSL_PATH)/crypto/ec/curve448/arch_32/f_impl.c
+  $(OPENSSL_PATH)/crypto/ec/curve448/curve448.c
+  $(OPENSSL_PATH)/crypto/ec/curve448/curve448_tables.c
+  $(OPENSSL_PATH)/crypto/ec/curve448/eddsa.c
+  $(OPENSSL_PATH)/crypto/ec/curve448/f_generic.c
+  $(OPENSSL_PATH)/crypto/ec/curve448/scalar.c
+  $(OPENSSL_PATH)/crypto/ec/ec2_oct.c
+  $(OPENSSL_PATH)/crypto/ec/ec2_smpl.c
+  $(OPENSSL_PATH)/crypto/ec/ec_ameth.c
+  $(OPENSSL_PATH)/crypto/ec/ec_asn1.c
+  $(OPENSSL_PATH)/crypto/ec/ec_check.c
+  $(OPENSSL_PATH)/crypto/ec/ec_curve.c
+  $(OPENSSL_PATH)/crypto/ec/ec_cvt.c
+  $(OPENSSL_PATH)/crypto/ec/ec_err.c
+  $(OPENSSL_PATH)/crypto/ec/ec_key.c
+  $(OPENSSL_PATH)/crypto/ec/ec_kmeth.c
+  $(OPENSSL_PATH)/crypto/ec/ec_lib.c
+  $(OPENSSL_PATH)/crypto/ec/ec_mult.c
+  $(OPENSSL_PATH)/crypto/ec/ec_oct.c
+  $(OPENSSL_PATH)/crypto/ec/ec_pmeth.c
+  $(OPENSSL_PATH)/crypto/ec/ec_print.c
+  $(OPENSSL_PATH)/crypto/ec/ecdh_kdf.c
+  $(OPENSSL_PATH)/crypto/ec/ecdh_ossl.c
+  $(OPENSSL_PATH)/crypto/ec/ecdsa_ossl.c
+  $(OPENSSL_PATH)/crypto/ec/ecdsa_sign.c
+  $(OPENSSL_PATH)/crypto/ec/ecdsa_vrf.c
+  $(OPENSSL_PATH)/crypto/ec/eck_prn.c
+  $(OPENSSL_PATH)/crypto/ec/ecp_mont.c
+  $(OPENSSL_PATH)/crypto/ec/ecp_nist.c
+  $(OPENSSL_PATH)/crypto/ec/ecp_nistp224.c
+  $(OPENSSL_PATH)/crypto/ec/ecp_nistp256.c
+  $(OPENSSL_PATH)/crypto/ec/ecp_nistp521.c
+  $(OPENSSL_PATH)/crypto/ec/ecp_nistputil.c
+  $(OPENSSL_PATH)/crypto/ec/ecp_oct.c
+  $(OPENSSL_PATH)/crypto/ec/ecp_smpl.c
+  $(OPENSSL_PATH)/crypto/ec/ecx_meth.c
   $(OPENSSL_PATH)/crypto/err/err.c
   $(OPENSSL_PATH)/crypto/err/err_prn.c
   $(OPENSSL_PATH)/crypto/evp/bio_b64.c
@@ -384,6 +421,10 @@
   $(OPENSSL_PATH)/crypto/siphash/siphash.c
   $(OPENSSL_PATH)/crypto/siphash/siphash_ameth.c
   $(OPENSSL_PATH)/crypto/siphash/siphash_pmeth.c
+  $(OPENSSL_PATH)/crypto/sm2/sm2_crypt.c
+  $(OPENSSL_PATH)/crypto/sm2/sm2_err.c
+  $(OPENSSL_PATH)/crypto/sm2/sm2_pmeth.c
+  $(OPENSSL_PATH)/crypto/sm2/sm2_sign.c
   $(OPENSSL_PATH)/crypto/sm3/m_sm3.c
   $(OPENSSL_PATH)/crypto/sm3/sm3.c
   $(OPENSSL_PATH)/crypto/sm4/sm4.c
@@ -496,6 +537,15 @@
   $(OPENSSL_PATH)/crypto/conf/conf_local.h
   $(OPENSSL_PATH)/crypto/dh/dh_local.h
   $(OPENSSL_PATH)/crypto/dso/dso_local.h
+  $(OPENSSL_PATH)/crypto/ec/ec_local.h
+  $(OPENSSL_PATH)/crypto/ec/curve448/curve448_local.h
+  $(OPENSSL_PATH)/crypto/ec/curve448/curve448utils.h
+  $(OPENSSL_PATH)/crypto/ec/curve448/ed448.h
+  $(OPENSSL_PATH)/crypto/ec/curve448/field.h
+  $(OPENSSL_PATH)/crypto/ec/curve448/point_448.h
+  $(OPENSSL_PATH)/crypto/ec/curve448/word.h
+  $(OPENSSL_PATH)/crypto/ec/curve448/arch_32/arch_intrinsics.h
+  $(OPENSSL_PATH)/crypto/ec/curve448/arch_32/f_impl.h
   $(OPENSSL_PATH)/crypto/evp/evp_local.h
   $(OPENSSL_PATH)/crypto/hmac/hmac_local.h
   $(OPENSSL_PATH)/crypto/lhash/lhash_local.h
diff --git a/CryptoPkg/Library/OpensslLib/process_files.pl b/CryptoPkg/Library/OpensslLib/process_files.pl
index 42bff05fa6..2ebfbbbca0 100755
--- a/CryptoPkg/Library/OpensslLib/process_files.pl
+++ b/CryptoPkg/Library/OpensslLib/process_files.pl
@@ -169,7 +169,6 @@ BEGIN {
                 "no-dgram",
                 "no-dsa",
                 "no-dynamic-engine",
-                "no-ec",
                 "no-ec2m",
                 "no-engine",
                 "no-err",
-- 
2.31.0.vfs.0.1


[-- Attachment #3: 0002-Port-VsIntrinsicLib-from-Project-Mu.patch --]
[-- Type: application/octet-stream, Size: 7906 bytes --]

From 23788c199dd9f615b03d0730ab68c5411f56bf87 Mon Sep 17 00:00:00 2001
From: Vineel Kovvuri <vineelko@microsoft.com>
Date: Sat, 6 Nov 2021 01:00:26 -0700
Subject: [PATCH 2/3] Port VsIntrinsicLib from Project Mu

Signed-off-by: Vineel Kovvuri <vineelko@microsoft.com>
---
 MdePkg/Library/VsIntrinsicLib/IA32/Llmul.asm  | 98 +++++++++++++++++++
 MdePkg/Library/VsIntrinsicLib/IA32/Llshr.asm  | 79 +++++++++++++++
 .../Library/VsIntrinsicLib/VsIntrinsicLib.inf | 38 +++++++
 .../Library/VsIntrinsicLib/VsIntrinsicLib.uni | 17 ++++
 4 files changed, 232 insertions(+)
 create mode 100644 MdePkg/Library/VsIntrinsicLib/IA32/Llmul.asm
 create mode 100644 MdePkg/Library/VsIntrinsicLib/IA32/Llshr.asm
 create mode 100644 MdePkg/Library/VsIntrinsicLib/VsIntrinsicLib.inf
 create mode 100644 MdePkg/Library/VsIntrinsicLib/VsIntrinsicLib.uni

diff --git a/MdePkg/Library/VsIntrinsicLib/IA32/Llmul.asm b/MdePkg/Library/VsIntrinsicLib/IA32/Llmul.asm
new file mode 100644
index 0000000000..190392da1b
--- /dev/null
+++ b/MdePkg/Library/VsIntrinsicLib/IA32/Llmul.asm
@@ -0,0 +1,98 @@
+;***
+;llmul.asm - long multiply routine
+;
+;       Copyright (c) Microsoft Corporation. All rights reserved.
+;       SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+;Purpose:
+;       Defines long multiply routine
+;       Both signed and unsigned routines are the same, since multiply's
+;       work out the same in 2's complement
+;       creates the following routine:
+;           __allmul
+;
+;Original Implemenation: MSVC 14.12.25827
+;
+;*******************************************************************************
+    .686
+    .model  flat,C
+    .code
+
+
+;***
+;llmul - long multiply routine
+;
+;Purpose:
+;       Does a long multiply (same for signed/unsigned)
+;       Parameters are not changed.
+;
+;Entry:
+;       Parameters are passed on the stack:
+;               1st pushed: multiplier (QWORD)
+;               2nd pushed: multiplicand (QWORD)
+;
+;Exit:
+;       EDX:EAX - product of multiplier and multiplicand
+;       NOTE: parameters are removed from the stack
+;
+;Uses:
+;       ECX
+;
+;Exceptions:
+;
+;*******************************************************************************
+_allmul PROC NEAR
+
+A       EQU     [esp + 4]       ; stack address of a
+B       EQU     [esp + 12]      ; stack address of b
+
+HIGH_PART  EQU     [4]             ; 
+LOW_PART   EQU     [0]
+
+;
+;       AHI, BHI : upper 32 bits of A and B
+;       ALO, BLO : lower 32 bits of A and B
+;
+;             ALO * BLO
+;       ALO * BHI
+; +     BLO * AHI
+; ---------------------
+;
+
+        mov     eax,HIGH_PART(A)
+        mov     ecx,HIGH_PART(B)
+        or      ecx,eax         ;test for both high dwords zero.
+        mov     ecx,LOW_PART(B)
+        jnz     short hard      ;both are zero, just mult ALO and BLO
+
+        mov     eax,LOW_PART(A)
+        mul     ecx
+
+        ret     16              ; callee restores the stack
+
+hard:
+        push    ebx
+
+; must redefine A and B since esp has been altered
+
+A2      EQU     [esp + 8]       ; stack address of a
+B2      EQU     [esp + 16]      ; stack address of b
+
+        mul     ecx             ;eax has AHI, ecx has BLO, so AHI * BLO
+        mov     ebx,eax         ;save result
+
+        mov     eax,LOW_PART(A2)
+        mul     dword ptr HIGH_PART(B2) ;ALO * BHI
+        add     ebx,eax         ;ebx = ((ALO * BHI) + (AHI * BLO))
+
+        mov     eax,LOW_PART(A2);ecx = BLO
+        mul     ecx             ;so edx:eax = ALO*BLO
+        add     edx,ebx         ;now edx has all the LO*HI stuff
+
+        pop     ebx
+
+        ret     16              ; callee restores the stack
+
+_allmul ENDP
+
+        end
diff --git a/MdePkg/Library/VsIntrinsicLib/IA32/Llshr.asm b/MdePkg/Library/VsIntrinsicLib/IA32/Llshr.asm
new file mode 100644
index 0000000000..81c5240c16
--- /dev/null
+++ b/MdePkg/Library/VsIntrinsicLib/IA32/Llshr.asm
@@ -0,0 +1,79 @@
+        title   llshr - long shift right
+;***
+;llshr.asm - long shift right
+;
+;       Copyright (c) Microsoft Corporation. All rights reserved.
+;       SPDX-License-Identifier: BSD-2-Clause-Patent
+;
+;Purpose:
+;       define signed long shift right routine
+;           __allshr
+;
+;Original Implemenation: MSVC 14.12.25827
+;
+;*******************************************************************************
+    .686
+    .model  flat,C
+    .code
+
+
+
+;***
+;llshr - long shift right
+;
+;Purpose:
+;       Does a signed Long Shift Right
+;       Shifts a long right any number of bits.
+;
+;Entry:
+;       EDX:EAX - long value to be shifted
+;       CL    - number of bits to shift by
+;
+;Exit:
+;       EDX:EAX - shifted value
+;
+;Uses:
+;       CL is destroyed.
+;
+;Exceptions:
+;
+;*******************************************************************************
+_allshr PROC NEAR
+
+;
+; Handle shifts of 64 bits or more (if shifting 64 bits or more, the result
+; depends only on the high order bit of edx).
+;
+        cmp     cl,64
+        jae     short RETSIGN
+
+;
+; Handle shifts of between 0 and 31 bits
+;
+        cmp     cl, 32
+        jae     short MORE32
+        shrd    eax,edx,cl
+        sar     edx,cl
+        ret
+
+;
+; Handle shifts of between 32 and 63 bits
+;
+MORE32:
+        mov     eax,edx
+        sar     edx,31
+        and     cl,31
+        sar     eax,cl
+        ret
+
+;
+; Return double precision 0 or -1, depending on the sign of edx
+;
+RETSIGN:
+        sar     edx,31
+        mov     eax,edx
+        ret
+
+_allshr ENDP
+
+        end
diff --git a/MdePkg/Library/VsIntrinsicLib/VsIntrinsicLib.inf b/MdePkg/Library/VsIntrinsicLib/VsIntrinsicLib.inf
new file mode 100644
index 0000000000..d55bfcbd22
--- /dev/null
+++ b/MdePkg/Library/VsIntrinsicLib/VsIntrinsicLib.inf
@@ -0,0 +1,38 @@
+## @file
+#  Visual Studio 2017 C compiler intrinsic Library implementation.
+#
+#  Since the C compiler does very aggressive full program optimizations there are cases
+#  where some small number of compiler inserted functions can not be avoided.
+#  To handle that case this NULL library can be injected into all 32bit modules
+#  so that the link time dependency is met and the modules compile.
+#
+#  The routines are based on src delivered with the visual studio product.  it is
+#  critical that calling convention, stack usage, register usage, etc is in line
+#  with what the compiler expects as there is no way to influence the behaviors
+#  for compiler inserted functions.
+#
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = VsIntrinsicLib
+  MODULE_UNI_FILE                = VsIntrinsicLib.uni
+  FILE_GUID                      = ed449fc0-3265-40ed-91b8-435b8df0aa5f
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = NULL
+
+#
+#  VALID_ARCHITECTURES           = IA32
+#
+
+[Sources]
+
+[Sources.Ia32]
+  IA32/Llmul.asm
+  IA32/Llshr.asm
+
+[Packages]
+  MdePkg/MdePkg.dec
diff --git a/MdePkg/Library/VsIntrinsicLib/VsIntrinsicLib.uni b/MdePkg/Library/VsIntrinsicLib/VsIntrinsicLib.uni
new file mode 100644
index 0000000000..c4513808fd
--- /dev/null
+++ b/MdePkg/Library/VsIntrinsicLib/VsIntrinsicLib.uni
@@ -0,0 +1,17 @@
+// /** @file
+// VsIntrinsic Library implementation.
+//
+// VsIntrinsic Library implementation.
+//
+//
+//
+//Copyright (c) Microsoft Corporation. All rights reserved.
+//SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+//**/
+
+
+#string STR_MODULE_ABSTRACT             #language en-US "VsIntrinsic Library implementation"
+
+#string STR_MODULE_DESCRIPTION          #language en-US "VsIntrinsic Library implementation"
+
-- 
2.31.0.vfs.0.1


[-- Attachment #4: 0003-Reference-VsIntrinsicLib.patch --]
[-- Type: application/octet-stream, Size: 3785 bytes --]

From 799b36c6560c1a3fd5f9b30856ff61c002694e4c Mon Sep 17 00:00:00 2001
From: Vineel Kovvuri <vineelko@microsoft.com>
Date: Sat, 6 Nov 2021 01:01:13 -0700
Subject: [PATCH 3/3] Reference VsIntrinsicLib

Signed-off-by: Vineel Kovvuri <vineelko@microsoft.com>
---
 CryptoPkg/CryptoPkg.dsc     | 3 +++
 EmulatorPkg/EmulatorPkg.dsc | 3 +++
 MdePkg/MdePkg.ci.yaml       | 2 +-
 MdePkg/MdePkg.dsc           | 4 ++++
 OvmfPkg/OvmfPkgIa32.dsc     | 5 +++++
 OvmfPkg/OvmfPkgIa32X64.dsc  | 5 +++++
 6 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/CryptoPkg/CryptoPkg.dsc b/CryptoPkg/CryptoPkg.dsc
index 0aa72ed878..9a01554f19 100644
--- a/CryptoPkg/CryptoPkg.dsc
+++ b/CryptoPkg/CryptoPkg.dsc
@@ -67,6 +67,9 @@
   HashApiLib|CryptoPkg/Library/BaseHashApiLib/BaseHashApiLib.inf
   RngLib|MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf
 
+[LibraryClasses.IA32]
+  NULL|MdePkg/Library/VsIntrinsicLib/VsIntrinsicLib.inf
+
 [LibraryClasses.ARM, LibraryClasses.AARCH64]
   #
   # It is not possible to prevent the ARM compiler for generic intrinsic functions.
diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
index 554c13ddb5..483ee0d036 100644
--- a/EmulatorPkg/EmulatorPkg.dsc
+++ b/EmulatorPkg/EmulatorPkg.dsc
@@ -138,6 +138,9 @@
   AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
 !endif
 
+[LibraryClasses.IA32]
+  NULL|MdePkg/Library/VsIntrinsicLib/VsIntrinsicLib.inf
+
 [LibraryClasses.common.SEC]
   PeiServicesLib|EmulatorPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
diff --git a/MdePkg/MdePkg.ci.yaml b/MdePkg/MdePkg.ci.yaml
index 3ea8eec331..b339686433 100644
--- a/MdePkg/MdePkg.ci.yaml
+++ b/MdePkg/MdePkg.ci.yaml
@@ -54,7 +54,7 @@
 
     ## options defined ci/Plugin/DscCompleteCheck
     "DscCompleteCheck": {
-        "IgnoreInf": [""],
+        "IgnoreInf": ["MdePkg/Library/VsIntrinsicLib/VsIntrinsicLib.inf"],
         "DscPath": "MdePkg.dsc"
     },
 
diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc
index a94959169b..3a4b9d093e 100644
--- a/MdePkg/MdePkg.dsc
+++ b/MdePkg/MdePkg.dsc
@@ -176,6 +176,10 @@
   MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
   MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf
 
+[Components.IA32]
+  # For VS2017 support link the VsIntrinsicLib into all 32 bit modules
+  MdePkg/Library/VsIntrinsicLib/VsIntrinsicLib.inf
+
 [Components.EBC]
   MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
   MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 6a5be97c05..f52d48d83a 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -240,6 +240,11 @@
   TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
 !endif
 
+!if $(TOOL_CHAIN_TAG) == "VS2019"
+[LibraryClasses.IA32.UEFI_DRIVER]
+  NULL|MdePkg/Library/VsIntrinsicLib/VsIntrinsicLib.inf
+!endif
+
 [LibraryClasses.common]
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
   VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 71227d1b70..a53555240e 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -244,6 +244,11 @@
   TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
 !endif
 
+!if $(TOOL_CHAIN_TAG) == "VS2019"
+[LibraryClasses.IA32.UEFI_DRIVER]
+  NULL|MdePkg/Library/VsIntrinsicLib/VsIntrinsicLib.inf
+!endif
+
 [LibraryClasses.common]
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
   VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
-- 
2.31.0.vfs.0.1


  reply	other threads:[~2021-11-08 22:29 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-12  5:38 [PATCH 1/2] Reconfigure OpensslLib to add elliptic curve chipher algorithms Vineel Kovvuri
2021-10-12  5:38 ` [PATCH 2/2] Allow wildcards in hostname Vineel Kovvuri
2021-10-13  2:50   ` Yao, Jiewen
2021-10-13  2:45 ` [PATCH 1/2] Reconfigure OpensslLib to add elliptic curve chipher algorithms Yao, Jiewen
2021-10-17  2:49 ` Yao, Jiewen
2021-10-18 20:06   ` vineelko
2021-11-03  0:37     ` Yao, Jiewen
2021-11-03  8:34       ` Vineel Kovvuri
2021-11-08 22:29         ` Vineel Kovvuri [this message]
2021-11-09  8:06           ` [edk2-devel] " Yao, Jiewen
2021-11-09  8:58             ` Gerd Hoffmann
2021-11-10 16:18               ` Vineel Kovvuri
2021-11-11 13:05                 ` Gerd Hoffmann
2021-11-11 13:26                   ` Yao, Jiewen
2021-11-18 18:40                     ` Vineel Kovvuri
2022-02-23  2:32                       ` yi1 li
2022-02-23  2:46                         ` Vineel Kovvuri
2022-02-23  2:54                           ` yi1 li
2022-02-24  6:51                             ` Vineel Kovvuri
2022-02-24  8:20                               ` yi1 li
2022-02-25 17:51                                 ` Vineel Kovvuri
2022-02-26 15:54                                   ` yi1 li
2022-02-28  8:24                                   ` yi1 li
2022-03-01 14:04                                     ` Gerd Hoffmann
2022-03-01 17:38                                       ` Sean
2022-03-02  4:23                                       ` yi1 li
2022-03-02  6:59                                         ` Yao, Jiewen
2022-03-02  7:42                                           ` Gerd Hoffmann
2022-03-02 11:56                                             ` Yao, Jiewen
2022-03-03  8:43                                               ` yi1 li
2022-03-03 10:05                                                 ` Yao, Jiewen
2022-03-04  2:15                                                   ` Vineel Kovvuri
2022-03-02  7:58                                         ` Gerd Hoffmann
2022-03-03  6:30                                   ` Vineel Kovvuri
2022-03-03  6:37                                     ` Vineel Kovvuri
2021-11-09  8:55           ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=23891.1636410576311055186@groups.io \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox