Re: [edk2-devel] [PATCH V2 1/9] UefiCpuPkg: Add CcExitLib

2022-11-04 Thread Min Xu
On November 4, 2022 10:35 PM, Tom Lendacky wrote:
> On 11/3/22 18:19, Min Xu via groups.io wrote:
> > From: Min M Xu 
> >
> > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4123
> >
> > +
> > +/**
> > +  Handle a #VC exception.
> > +
> > +  Performs the necessary processing to handle a #VC exception.
> > +
> > +  The base library function returns an error equal to VC_EXCEPTION,
> > + to be propagated to the standard exception handling stack.
> > +
> > +  @param[in, out]  ExceptionType  Pointer to an EFI_EXCEPTION_TYPE to
> be set
> > +  as value to use on error.
> > +  @param[in, out]  SystemContext  Pointer to EFI_SYSTEM_CONTEXT
> > +
> > +  @retval  EFI_SUCCESSException handled
> > +  @retval  EFI_UNSUPPORTED#VC not supported, (new) exception
> value to
> > +  propagate provided
> > +  @retval  EFI_PROTOCOL_ERROR #VC handling failed, (new) exception
> value to
> > +  propagate provided
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +CcExitHandleVc (
> 
> Sorry I didn't pick up on this before, but any reason this isn't
> CcExitLibHandleVc() to match the other APIs or have the other APIs just be
> CcExit (since the "Lib" part seems a bit excessive)?
> 
> (Same for CcExitHandleVe below)
> 
Ah it is my fault. It will should be the same as other APIs. They will be 
updated in the next version.

Thanks
Min


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95977): https://edk2.groups.io/g/devel/message/95977
Mute This Topic: https://groups.io/mt/94795607/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] 回复: [PATCH v3 1/1] MdePkg/BaseLib: Fix out-of-bounds reads in SafeString

2022-11-04 Thread Pedro Falcato
Hi Liming,

Thank you for the review. Can we please push this in time for the stable
tag?

Thanks,
Pedro

On Fri, Nov 4, 2022 at 1:22 AM gaoliming via groups.io  wrote:

> Reviewed-by: Liming Gao 
>
> > -邮件原件-
> > 发件人: Pedro Falcato 
> > 发送时间: 2022年11月3日 9:12
> > 收件人: devel@edk2.groups.io
> > 抄送: Pedro Falcato ; Vitaly Cheptsov
> > ; Marvin Häuser ;
> > Michael D Kinney ; Liming Gao
> > ; Zhiguang Liu ;
> Jiewen
> > Yao 
> > 主题: [PATCH v3 1/1] MdePkg/BaseLib: Fix out-of-bounds reads in SafeString
> >
> > There was a OOB access in *StrHexTo* functions, when passed strings like
> > "XDEADBEEF".
> >
> > OpenCore folks established an ASAN-equipped project to fuzz Ext4Dxe,
> > which was able to catch these (mostly harmless) issues.
> >
> > Cc: Vitaly Cheptsov 
> > Cc: Marvin Häuser 
> > Cc: Michael D Kinney 
> > Cc: Liming Gao 
> > Cc: Zhiguang Liu 
> > Signed-off-by: Pedro Falcato 
> > Acked-by: Michael D Kinney 
> > Reviewed-by: Jiewen Yao 
> > ---
> >  MdePkg/Library/BaseLib/SafeString.c | 25 +
> >  1 file changed, 21 insertions(+), 4 deletions(-)
> >
> > diff --git a/MdePkg/Library/BaseLib/SafeString.c
> > b/MdePkg/Library/BaseLib/SafeString.c
> > index f338a32a3a41..b75b33381732 100644
> > --- a/MdePkg/Library/BaseLib/SafeString.c
> > +++ b/MdePkg/Library/BaseLib/SafeString.c
> > @@ -863,6 +863,9 @@ StrHexToUintnS (
> >OUT   UINTN   *Data
> >)
> >  {
> > +  BOOLEAN  FoundLeadingZero;
> > +
> > +  FoundLeadingZero = FALSE;
> >ASSERT (((UINTN)String & BIT0) == 0);
> >
> >//
> > @@ -892,12 +895,14 @@ StrHexToUintnS (
> >//
> >// Ignore leading Zeros after the spaces
> >//
> > +
> > +  FoundLeadingZero = *String == L'0';
> >while (*String == L'0') {
> >  String++;
> >}
> >
> >if (CharToUpper (*String) == L'X') {
> > -if (*(String - 1) != L'0') {
> > +if (!FoundLeadingZero) {
> >*Data = 0;
> >return RETURN_SUCCESS;
> >  }
> > @@ -992,6 +997,9 @@ StrHexToUint64S (
> >OUT   UINT64  *Data
> >)
> >  {
> > +  BOOLEAN  FoundLeadingZero;
> > +
> > +  FoundLeadingZero = FALSE;
> >ASSERT (((UINTN)String & BIT0) == 0);
> >
> >//
> > @@ -1021,12 +1029,13 @@ StrHexToUint64S (
> >//
> >// Ignore leading Zeros after the spaces
> >//
> > +  FoundLeadingZero = *String == L'0';
> >while (*String == L'0') {
> >  String++;
> >}
> >
> >if (CharToUpper (*String) == L'X') {
> > -if (*(String - 1) != L'0') {
> > +if (!FoundLeadingZero) {
> >*Data = 0;
> >return RETURN_SUCCESS;
> >  }
> > @@ -2393,6 +2402,9 @@ AsciiStrHexToUintnS (
> >OUT   UINTN  *Data
> >)
> >  {
> > +  BOOLEAN  FoundLeadingZero;
> > +
> > +  FoundLeadingZero = FALSE;
> >//
> >// 1. Neither String nor Data shall be a null pointer.
> >//
> > @@ -2420,12 +2432,13 @@ AsciiStrHexToUintnS (
> >//
> >// Ignore leading Zeros after the spaces
> >//
> > +  FoundLeadingZero = *String == '0';
> >while (*String == '0') {
> >  String++;
> >}
> >
> >if (AsciiCharToUpper (*String) == 'X') {
> > -if (*(String - 1) != '0') {
> > +if (!FoundLeadingZero) {
> >*Data = 0;
> >return RETURN_SUCCESS;
> >  }
> > @@ -2517,6 +2530,9 @@ AsciiStrHexToUint64S (
> >OUT   UINT64  *Data
> >)
> >  {
> > +  BOOLEAN  FoundLeadingZero;
> > +
> > +  FoundLeadingZero = FALSE;
> >//
> >// 1. Neither String nor Data shall be a null pointer.
> >//
> > @@ -2544,12 +2560,13 @@ AsciiStrHexToUint64S (
> >//
> >// Ignore leading Zeros after the spaces
> >//
> > +  FoundLeadingZero = *String == '0';
> >while (*String == '0') {
> >  String++;
> >}
> >
> >if (AsciiCharToUpper (*String) == 'X') {
> > -if (*(String - 1) != '0') {
> > +if (!FoundLeadingZero) {
> >*Data = 0;
> >return RETURN_SUCCESS;
> >  }
> > --
> > 2.38.1
>
>
>
>
>
> 
>
>
>

-- 
Pedro Falcato


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95976): https://edk2.groups.io/g/devel/message/95976
Mute This Topic: https://groups.io/mt/94797620/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v2] CryptoPkg/Readme.md: typo and grammar fixes

2022-11-04 Thread Christopher Zurcher
Reviewed-by: Christopher Zurcher 

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Michael D
> Kinney
> Sent: Friday, November 4, 2022 08:29
> To: Laszlo Ersek ; devel@edk2.groups.io; Kinney, Michael D
> 
> Cc: Zurcher, Christopher ; Jiang, Guomin
> ; Wang, Jian J ; Yao, Jiewen
> ; Lu, Xiaoyu1 
> Subject: Re: [edk2-devel] [PATCH v2] CryptoPkg/Readme.md: typo and grammar
> fixes
> 
> Reviewed-by: Michael D Kinney 
> 
> 
> > -Original Message-
> > From: Laszlo Ersek 
> > Sent: Friday, November 4, 2022 5:02 AM
> > To: devel@edk2.groups.io; ler...@redhat.com
> > Cc: Zurcher, Christopher ; Jiang,
> > Guomin ; Wang, Jian J ;
> > Yao, Jiewen ; Kinney, Michael D
> > ; Lu, Xiaoyu1 
> > Subject: [PATCH v2] CryptoPkg/Readme.md: typo and grammar fixes
> >
> > Commit 244ce33bdd2f ("CryptoPkg: Add Readme.md", 2022-10-24) had added
> > the long-awaited documentation on the dynamic crypto services. Fix
> > some of the typos and arguable grammar errors in "Readme.md". A few
> > light clarifications are also snuck in.
> >
> > Cc: Christopher Zurcher 
> > Cc: Guomin Jiang 
> > Cc: Jian J Wang 
> > Cc: Jiewen Yao 
> > Cc: Michael D Kinney 
> > Cc: Xiaoyu Lu 
> > Signed-off-by: Laszlo Ersek 
> > ---
> >
> > Notes:
> > v2:
> >
> > - URL:
> >
> > https://pagure.io/lersek/edk2/c/8d7b26bfb6a1?branch=cryptopkg_readme_t
> > ypos_v2
> >
> > - v1 was at:
> >   - https://listman.redhat.com/archives/edk2-devel-archive/2022-
> November/055153.html
> >   - msgid <20221102093637.9132-1-ler...@redhat.com>
> >
> > - keep referring to the singular HashApiLib algorithm that
> >   PcdHashApiLibPolicy exposes for configuration in singular [Mike]
> >
> > - still fix the duplicated "to" typo
> >
> > - range-diff against v1 (i.e., first hunk dropped, second hunk
> updated):
> >
> > > 1:  a7269f170437 ! 1:  8d7b26bfb6a1 CryptoPkg/Readme.md: typo and
> grammar fixes
> > > @@ -94,18 +94,11 @@
> > >   ```
> > >   [LibraryClasses.common.DXE_RUNTIME_DRIVER]
> > >  @@
> > > - ### PCD Configuration Settings
> > > -
> > > - There are 2 PCD settings that are used to configure
> cryptographic services.
> > > --`PcdHashApiLibPolicy` is used to configure the hash algorithm
> provided by the
> > > -+`PcdHashApiLibPolicy` is used to configure the hash algorithms
> provided by the
> > > - BaseHashApiLib library instance. `PcdCryptoServiceFamilyEnable`
> is used to
> > > - configure the cryptographic services supported by the
> CryptoPei, CryptoDxe,
> > >   and CryptoSmm modules.
> > >
> > >   * `gEfiCryptoPkgTokenSpaceGuid.PcdHashApiLibPolicy` - This PCD
> indicates the
> > >  -  HASH algorithm to to use in the BaseHashApiLib to calculate
> hash of data. The
> > > -+  HASH algorithms to use in the BaseHashApiLib to calculate
> hash of data. The
> > > ++  HASH algorithm to use in the BaseHashApiLib to calculate hash
> of data. The
> > > default hashing algorithm for BaseHashApiLib is set to
> HASH_ALG_SHA256.
> > > |  Setting   |Algorithm |
> > > ||--|
> >
> >  CryptoPkg/Readme.md | 46 ++--
> >  1 file changed, 23 insertions(+), 23 deletions(-)
> >
> > diff --git a/CryptoPkg/Readme.md b/CryptoPkg/Readme.md index
> > 946aa1e99e7d..067465b8eb7d 100644
> > --- a/CryptoPkg/Readme.md
> > +++ b/CryptoPkg/Readme.md
> > @@ -39,7 +39,7 @@ provides the smallest overall firmware overhead.
> >
> >  ## Statically Linking Cryptographic Services
> >
> > -The figure below shows an example of a firmware modules that requires
> > the use of
> > +The figure below shows an example of a firmware module that requires
> > +the use of
> >  cryptographic services. The cryptographic services are provided by
> > three library  classes called BaseCryptLib, TlsLib, and HashApiLib.
> > These library classes are  implemented using APIs from the OpenSSL
> > project that are abstracted by the @@ -49,7 +49,7 @@ full C runtime
> > library for firmware components. Instead, the CryptoPkg includes  the
> > smallest subset of services required to build the OpenSSL project in the
> private library class called IntrinsicLib.
> >
> > -The CryptoPkg provides several instances if the BaseCryptLib and
> > OpensslLib with
> > +The CryptoPkg provides several instances of the BaseCryptLib and
> > +OpensslLib with
> >  different cryptographic service features and performance
> > optimizations. The  platform developer must select the correct
> > instances based on cryptographic  service requirements in each UEFI/PI
> > firmware phase (SEC, PEI, DXE, UEFI, @@ -97,9 +97,9 @@ linking is not
> available for SEC or UEFI RT modules.
> >
> >  The EDK II modules/libraries that require cryptographic services use
> > the same  BaseCryptLib/TlsLib/HashApiLib APIs. This means no source
> > changes are required -to use static linking or dyn

[edk2-devel] [Patch v1 2/2] [NetworkPkg/SnpDxe] Support SNP over UsbIo-based UNDI driver

2022-11-04 Thread Frederik van Hövell
Refactor SimpleNetworkDriverStart() and SimpleNetworkDriverStop() to
add support over UsbIo UNDI driver next to PciIo UNDI driver.

Signed-off-by: Frederik van Hövell 
---
 NetworkPkg/SnpDxe/SnpDxe.inf |   2 +-
 NetworkPkg/SnpDxe/Snp.h  |   3 +
 NetworkPkg/SnpDxe/Snp.c  | 225 
 3 files changed, 146 insertions(+), 84 deletions(-)

diff --git a/NetworkPkg/SnpDxe/SnpDxe.inf b/NetworkPkg/SnpDxe/SnpDxe.inf
index d16f1888b30f..678e5efc5d01 100644
--- a/NetworkPkg/SnpDxe/SnpDxe.inf
+++ b/NetworkPkg/SnpDxe/SnpDxe.inf
@@ -54,7 +54,6 @@ [Packages]
   MdePkg/MdePkg.dec

   NetworkPkg/NetworkPkg.dec

 

-

 [LibraryClasses]

   UefiLib

   BaseLib

@@ -72,6 +71,7 @@ [Protocols]
   gEfiDevicePathProtocolGuid## TO_START

   gEfiNetworkInterfaceIdentifierProtocolGuid_31 ## TO_START

   gEfiPciIoProtocolGuid ## TO_START

+  gEfiUsbIoProtocolGuid ## TO_START

 

 [Pcd]

   gEfiNetworkPkgTokenSpaceGuid.PcdSnpCreateExitBootServicesEvent   ## CONSUMES

diff --git a/NetworkPkg/SnpDxe/Snp.h b/NetworkPkg/SnpDxe/Snp.h
index dec238c9eb2c..cbc36c7b073d 100644
--- a/NetworkPkg/SnpDxe/Snp.h
+++ b/NetworkPkg/SnpDxe/Snp.h
@@ -13,6 +13,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 

 #include 

 #include 

+#include 

+#include 

 #include 

 #include 

 

@@ -94,6 +96,7 @@ typedef struct {
   VOID   *FillHeaderBufferUnmap;

 

   EFI_PCI_IO_PROTOCOL*PciIo;

+  EFI_USB_IO_PROTOCOL*UsbIo;

   UINT8  IoBarIndex;

   UINT8  MemoryBarIndex;

 

diff --git a/NetworkPkg/SnpDxe/Snp.c b/NetworkPkg/SnpDxe/Snp.c
index 86bf527f31dd..6ecaa57feda3 100644
--- a/NetworkPkg/SnpDxe/Snp.c
+++ b/NetworkPkg/SnpDxe/Snp.c
@@ -268,6 +268,7 @@ SimpleNetworkDriverStart (
   UINT8  BarIndex;

   PXE_STATFLAGS  InitStatFlags;

   EFI_PCI_IO_PROTOCOL*PciIo;

+  EFI_USB_IO_PROTOCOL*UsbIo;

   EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR  *BarDesc;

   BOOLEANFoundIoBar;

   BOOLEANFoundMemoryBar;

@@ -293,22 +294,44 @@ SimpleNetworkDriverStart (
   &NiiDevicePath,

   &Handle

   );

-

   if (EFI_ERROR (Status)) {

-DEBUG ((DEBUG_ERROR, "%a: Failed to locate DevicePath using PCI path %s - 
status %r\n", __FUNCTION__, ConvertDevicePathToText(NiiDevicePath, TRUE, TRUE), 
Status));

-return Status;

+DEBUG ((DEBUG_VERBOSE, "%a: Failed to locate DevicePath using 
PciIoProtocol path %s - status %r\n", __FUNCTION__, 
ConvertDevicePathToText(NiiDevicePath, TRUE, TRUE), Status));

+

+Status = gBS->LocateDevicePath (

+&gEfiUsbIoProtocolGuid,

+&NiiDevicePath,

+&Handle

+);

+if (EFI_ERROR (Status)) {

+  DEBUG ((DEBUG_VERBOSE, "%a: Failed to locate DevicePath using 
UsbIoProtocol path %s - status %r\n", __FUNCTION__, 
ConvertDevicePathToText(NiiDevicePath, TRUE, TRUE), Status));

+

+  return Status;

+} else {

+  // Found NiiDevicePath using UsbIoProtocol

+  Status = gBS->OpenProtocol (

+  Handle,

+  &gEfiUsbIoProtocolGuid,

+  (VOID **) &UsbIo,

+  This->DriverBindingHandle,

+  Controller,

+  EFI_OPEN_PROTOCOL_GET_PROTOCOL

+  );

+}

+  } else {

+// Found NiiDevicePath using PciIoProtocol

+Status = gBS->OpenProtocol (

+Handle,

+&gEfiPciIoProtocolGuid,

+(VOID **) &PciIo,

+This->DriverBindingHandle,

+Controller,

+EFI_OPEN_PROTOCOL_GET_PROTOCOL

+);

   }

 

-  Status = gBS->OpenProtocol (

-  Handle,

-  &gEfiPciIoProtocolGuid,

-  (VOID **)&PciIo,

-  This->DriverBindingHandle,

-  Controller,

-  EFI_OPEN_PROTOCOL_GET_PROTOCOL

-  );

+

   if (EFI_ERROR (Status)) {

-DEBUG ((DEBUG_ERROR, "%a: Failed to open PciIo protocol for driver %p and 
handle %p - status %r\n", __FUNCTION__, This->DriverBindingHandle, Handle, 
Status));

+DEBUG ((DEBUG_ERROR, "%a: Failed to open protocol for driver %p and handle 
%p - status %r\n", __FUNCTION__, This->DriverBindingHandle, Handle, Status));

 return Status;

   }

 

@@ -323,7 +346,7 @@ SimpleNetworkDriverStart (
   Controller,

   EFI_OPEN_PROTOCOL_BY_DRIVER

   );

-  if (EFI_ERROR (Status)) {

+  if (EFI_ERROR (Status) || Nii == NULL) {

 DEBUG ((DEBUG_ERROR, "%a: Failed to open NII protocol for driver %p and 
contro

[edk2-devel] [Patch v1 0/2] Support SNP over UsbIo-based UNDI driver

2022-11-04 Thread Frederik van Hövell
This patch series will add support for starting and stopping a SnpDxe
instance over a UsbIo based UNDI (nic) driver.

Tested with a (slightly modified) `lan78xx_uefi` UNDI driver for the
Raspberry Pi 3B+. The original lan78xx_uefi driver is available at
https://github.com/microchip-ung/lan78xx_uefi, but requires additional
changes to work on AARCH64.

Frederik van Hövell (2):
  [NetworkPkg/SnpDxe] More logging to see why SnpDxe fails to start
  [NetworkPkg/SnpDxe] Support SNP over UsbIo-based UNDI driver

 NetworkPkg/SnpDxe/SnpDxe.inf |   2 +-
 NetworkPkg/SnpDxe/Snp.h  |   4 +
 NetworkPkg/SnpDxe/Snp.c  | 228 +---
 3 files changed, 151 insertions(+), 83 deletions(-)

-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95972): https://edk2.groups.io/g/devel/message/95972
Mute This Topic: https://groups.io/mt/94814712/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [Patch v1 1/2] [NetworkPkg/SnpDxe] More logging to see why SnpDxe fails to start

2022-11-04 Thread Frederik van Hövell
Add debug logging to see where SnpDxe is failing using a UsbIo UNDI
driver.

Signed-off-by: Frederik van Hövell 
---
 NetworkPkg/SnpDxe/Snp.h | 1 +
 NetworkPkg/SnpDxe/Snp.c | 7 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/NetworkPkg/SnpDxe/Snp.h b/NetworkPkg/SnpDxe/Snp.h
index d57804ca2873..dec238c9eb2c 100644
--- a/NetworkPkg/SnpDxe/Snp.h
+++ b/NetworkPkg/SnpDxe/Snp.h
@@ -27,6 +27,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 

 #include 

 #include 

+#include 

 

 #include 

 #include 

diff --git a/NetworkPkg/SnpDxe/Snp.c b/NetworkPkg/SnpDxe/Snp.c
index 95361c3cd343..86bf527f31dd 100644
--- a/NetworkPkg/SnpDxe/Snp.c
+++ b/NetworkPkg/SnpDxe/Snp.c
@@ -160,6 +160,7 @@ SimpleNetworkDriverSupported (
   // check the version, we don't want to connect to the undi16

   //

   if (NiiProtocol->Type != EfiNetworkInterfaceUndi) {

+DEBUG ((DEBUG_NET, "%a: Unsupported type %a for handle %p\n", 
__FUNCTION__, NiiProtocol->Type, Controller));

 Status = EFI_UNSUPPORTED;

 goto Done;

   }

@@ -218,7 +219,7 @@ SimpleNetworkDriverSupported (
   }

 

   Status = EFI_SUCCESS;

-  DEBUG ((DEBUG_INFO, "Support(): supported on %p\n", Controller));

+  DEBUG ((DEBUG_INFO, "%a: supported on %p\n", __FUNCTION__, Controller));

 

 Done:

   gBS->CloseProtocol (

@@ -283,6 +284,7 @@ SimpleNetworkDriverStart (
   );

 

   if (EFI_ERROR (Status)) {

+DEBUG ((DEBUG_ERROR, "%a: Failed to get DevicePath for driver %p and 
handle %p - status %r\n", __FUNCTION__, This->DriverBindingHandle, Controller, 
Status));

 return Status;

   }

 

@@ -293,6 +295,7 @@ SimpleNetworkDriverStart (
   );

 

   if (EFI_ERROR (Status)) {

+DEBUG ((DEBUG_ERROR, "%a: Failed to locate DevicePath using PCI path %s - 
status %r\n", __FUNCTION__, ConvertDevicePathToText(NiiDevicePath, TRUE, TRUE), 
Status));

 return Status;

   }

 

@@ -305,6 +308,7 @@ SimpleNetworkDriverStart (
   EFI_OPEN_PROTOCOL_GET_PROTOCOL

   );

   if (EFI_ERROR (Status)) {

+DEBUG ((DEBUG_ERROR, "%a: Failed to open PciIo protocol for driver %p and 
handle %p - status %r\n", __FUNCTION__, This->DriverBindingHandle, Handle, 
Status));

 return Status;

   }

 

@@ -320,6 +324,7 @@ SimpleNetworkDriverStart (
   EFI_OPEN_PROTOCOL_BY_DRIVER

   );

   if (EFI_ERROR (Status)) {

+DEBUG ((DEBUG_ERROR, "%a: Failed to open NII protocol for driver %p and 
controller %p - status %r\n", __FUNCTION__, This->DriverBindingHandle, 
Controller, Status));

 gBS->CloseProtocol (

Controller,

&gEfiDevicePathProtocolGuid,

-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95973): https://edk2.groups.io/g/devel/message/95973
Mute This Topic: https://groups.io/mt/94814714/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [Patch V2 7/7] MdePkg/Test: Add port of BaseSafeIntLib unit tests to GoogleTest

2022-11-04 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4134

Cc: Liming Gao 
Cc: Zhiguang Liu 
Signed-off-by: Michael D Kinney 
---
 .../GoogleTestBaseSafeIntLib.inf  |   37 +
 .../GoogleTestBaseSafeIntLib.uni  |   13 +
 .../SafeIntLibUintnIntnUnitTests32.cpp|  425 +++
 .../SafeIntLibUintnIntnUnitTests64.cpp|  429 
 .../BaseSafeIntLib/TestBaseSafeIntLib.cpp | 2274 +
 MdePkg/Test/MdePkgHostTest.dsc|1 +
 6 files changed, 3179 insertions(+)
 create mode 100644 
MdePkg/Test/GoogleTest/Library/BaseSafeIntLib/GoogleTestBaseSafeIntLib.inf
 create mode 100644 
MdePkg/Test/GoogleTest/Library/BaseSafeIntLib/GoogleTestBaseSafeIntLib.uni
 create mode 100644 
MdePkg/Test/GoogleTest/Library/BaseSafeIntLib/SafeIntLibUintnIntnUnitTests32.cpp
 create mode 100644 
MdePkg/Test/GoogleTest/Library/BaseSafeIntLib/SafeIntLibUintnIntnUnitTests64.cpp
 create mode 100644 
MdePkg/Test/GoogleTest/Library/BaseSafeIntLib/TestBaseSafeIntLib.cpp

diff --git 
a/MdePkg/Test/GoogleTest/Library/BaseSafeIntLib/GoogleTestBaseSafeIntLib.inf 
b/MdePkg/Test/GoogleTest/Library/BaseSafeIntLib/GoogleTestBaseSafeIntLib.inf
new file mode 100644
index ..f609bfa57f7b
--- /dev/null
+++ b/MdePkg/Test/GoogleTest/Library/BaseSafeIntLib/GoogleTestBaseSafeIntLib.inf
@@ -0,0 +1,37 @@
+## @file
+# Host OS based Application that Unit Tests the SafeIntLib using Google Test
+#
+# Copyright (c) 2022, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION = 0x00010005
+  BASE_NAME   = GoogleTestBaseSafeIntLib
+  MODULE_UNI_FILE = GoogleTestBaseSafeIntLib.uni
+  FILE_GUID   = 2D9C1796-B0D2-4DA7-9529-1F8D9CCC11D3
+  MODULE_TYPE = HOST_APPLICATION
+  VERSION_STRING  = 1.0
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES   = IA32 X64
+#
+
+[Sources]
+  TestBaseSafeIntLib.cpp
+
+[Sources.IA32]
+  SafeIntLibUintnIntnUnitTests32.cpp
+
+[Sources.X64]
+  SafeIntLibUintnIntnUnitTests64.cpp
+
+[Packages]
+  MdePkg/MdePkg.dec
+  UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
+
+[LibraryClasses]
+  GoogleTestLib
+  SafeIntLib
diff --git 
a/MdePkg/Test/GoogleTest/Library/BaseSafeIntLib/GoogleTestBaseSafeIntLib.uni 
b/MdePkg/Test/GoogleTest/Library/BaseSafeIntLib/GoogleTestBaseSafeIntLib.uni
new file mode 100644
index ..1c11b9e05205
--- /dev/null
+++ b/MdePkg/Test/GoogleTest/Library/BaseSafeIntLib/GoogleTestBaseSafeIntLib.uni
@@ -0,0 +1,13 @@
+// /** @file
+// Application that Unit Tests the SafeIntLib using Google Test
+//
+// Copyright (c) 2020, Intel Corporation. All rights reserved.
+//
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+// **/
+
+#string STR_MODULE_ABSTRACT #language en-US "Application that Unit 
Tests the SafeIntLib using Google Test"
+
+#string STR_MODULE_DESCRIPTION  #language en-US "Application that Unit 
Tests the SafeIntLib using Google Test."
+
diff --git 
a/MdePkg/Test/GoogleTest/Library/BaseSafeIntLib/SafeIntLibUintnIntnUnitTests32.cpp
 
b/MdePkg/Test/GoogleTest/Library/BaseSafeIntLib/SafeIntLibUintnIntnUnitTests32.cpp
new file mode 100644
index ..6fbf302c1c5e
--- /dev/null
+++ 
b/MdePkg/Test/GoogleTest/Library/BaseSafeIntLib/SafeIntLibUintnIntnUnitTests32.cpp
@@ -0,0 +1,425 @@
+/** @file
+  IA32-specific functions for unit-testing INTN and UINTN functions in
+  SafeIntLib.
+
+  Copyright (c) Microsoft Corporation.
+  Copyright (c) 2019 - 2020, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+extern "C" {
+  #include 
+  #include 
+}
+
+TEST(ConversionTestSuite, TestSafeInt32ToUintn) {
+  RETURN_STATUS  Status;
+  INT32   Operand;
+  UINTN   Result;
+
+  //
+  // If Operand is non-negative, then it's a cast
+  //
+  Operand = 0x5bababab;
+  Result  = 0;
+  Status  = SafeInt32ToUintn (Operand, &Result);
+  ASSERT_EQ (Status, RETURN_SUCCESS);
+  ASSERT_EQ ((UINTN)0x5bababab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (-1537977259);
+  Status  = SafeInt32ToUintn (Operand, &Result);
+  ASSERT_EQ (RETURN_BUFFER_TOO_SMALL, Status);
+}
+
+TEST(ConversionTestSuite, TestSafeUint32ToIntn) {
+  RETURN_STATUS  Status;
+  UINT32  Operand;
+  INTNResult;
+
+  //
+  // If Operand is <= MAX_INTN, then it's a cast
+  //
+  Operand = 0x5bababab;
+  Result  = 0;
+  Status  = SafeUint32ToIntn (Operand, &Result);
+  ASSERT_EQ (Status, RETURN_SUCCESS);
+  ASSERT_EQ (0x5bababab, Result);
+
+  //
+  // Otherwise should result in an error status
+  //
+  Operand = (0xabababab);
+  Status  = SafeUint32ToIntn (Operand, &Result);
+  ASSERT_EQ (RETURN_BUFFER_TOO_SMALL, Status);
+}
+
+TEST(ConversionTestSuite, TestSafeIntnToInt32) {
+  RETURN_STATUS  Status;
+  INTNOperand;
+  INT32   Result;
+
+  //
+  // INTN is same as INT32 in IA32, so this is just a 

[edk2-devel] [Patch V2 6/7] BaseTools/Plugin/HostBaseUnitTestRunner: Enable gtest xml output

2022-11-04 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4134

Set environment variable GTEST_OUTPUT to specify the output
format of XML and the output file name.  Both CMOCKA_XML_FILE
and GTEST_OUTPUT are set for each host based unit test to
support both cmocka unit tests and gtest unit tests.

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yuwei Chen 
Signed-off-by: Michael D Kinney 
Reviewed-by: Bob Feng 
---
 .../HostBasedUnitTestRunner/HostBasedUnitTestRunner.py | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git 
a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py 
b/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py
index c1eeaf26251e..a8220aacd396 100644
--- a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py
+++ b/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py
@@ -85,9 +85,12 @@ class HostBasedUnitTestRunner(IUefiBuildPlugin):
 raise NotImplementedError("Unsupported Operating System")
 
 for test in testList:
-# Configure output name.
+# Configure output name if test uses cmocka.
 shell_env.set_shell_var(
-'CMOCKA_XML_FILE', test + ".%g." + arch + ".result.xml")
+'CMOCKA_XML_FILE', test + ".CMOCKA.%g." + arch + 
".result.xml")
+# Configure output name if test uses gtest.
+shell_env.set_shell_var(
+'GTEST_OUTPUT', "xml:" + test + ".GTEST." + arch + 
".result.xml")
 
 # Run the test.
 ret = RunCmd('"' + test + '"', "", workingdir=cp)
-- 
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95970): https://edk2.groups.io/g/devel/message/95970
Mute This Topic: https://groups.io/mt/94814645/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [Patch V2 3/7] UnitTestFrameworkPkg: Add googletest submodule and GoogleTestLib

2022-11-04 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4134

Add submodule for googletest and add GoogleTestLib that is
required for GoogleTest based unit tests. Add GoogleTest
documentation to Readme.md along with a port of the sample
unit test to the GoogleTest style.

Cc: Michael Kubacki 
Cc: Sean Brogan 
Signed-off-by: Michael D Kinney 
Reviewed-by: Michael Kubacki 
---
 .gitmodules   |   3 +
 .../Include/Library/GoogleTestLib.h   |  14 +
 .../Library/GoogleTestLib/GoogleTestLib.inf   |  36 +++
 .../Library/GoogleTestLib/GoogleTestLib.uni   |  14 +
 .../Library/GoogleTestLib/googletest  |   1 +
 UnitTestFrameworkPkg/ReadMe.md| 255 +++--
 .../SampleGoogleTest/SampleGoogleTest.cpp | 263 ++
 .../SampleGoogleTest/SampleGoogleTestHost.inf |  35 +++
 .../Test/UnitTestFrameworkPkgHostTest.dsc |   4 +-
 .../UnitTestFrameworkPkg.ci.yaml  |   4 +-
 UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec |   8 +
 .../UnitTestFrameworkPkgHost.dsc.inc  |   4 +-
 12 files changed, 610 insertions(+), 31 deletions(-)
 create mode 100644 UnitTestFrameworkPkg/Include/Library/GoogleTestLib.h
 create mode 100644 UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.inf
 create mode 100644 UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.uni
 create mode 16 UnitTestFrameworkPkg/Library/GoogleTestLib/googletest
 create mode 100644 
UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTest/SampleGoogleTest.cpp
 create mode 100644 
UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTest/SampleGoogleTestHost.inf

diff --git a/.gitmodules b/.gitmodules
index b845c9ee3ff0..8011a88d9d25 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -20,3 +20,6 @@
 [submodule "RedfishPkg/Library/JsonLib/jansson"]
path = RedfishPkg/Library/JsonLib/jansson
url = https://github.com/akheron/jansson
+[submodule "UnitTestFrameworkPkg/Library/GoogleTestLib/googletest"]
+   path = UnitTestFrameworkPkg/Library/GoogleTestLib/googletest
+   url = https://github.com/google/googletest.git
diff --git a/UnitTestFrameworkPkg/Include/Library/GoogleTestLib.h 
b/UnitTestFrameworkPkg/Include/Library/GoogleTestLib.h
new file mode 100644
index ..ebec766d4cf7
--- /dev/null
+++ b/UnitTestFrameworkPkg/Include/Library/GoogleTestLib.h
@@ -0,0 +1,14 @@
+/** @file
+  GoogleTestLib class with APIs from the googletest project
+
+  Copyright (c) 2022, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef GOOGLE_TEST_LIB_H_
+#define GOOGLE_TEST_LIB_H_
+
+#include 
+
+#endif
diff --git a/UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.inf 
b/UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.inf
new file mode 100644
index ..68db75d7023f
--- /dev/null
+++ b/UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.inf
@@ -0,0 +1,36 @@
+## @file
+#  This module provides GoogleTest Library implementation.
+#
+#  Copyright (c) 2022, Intel Corporation. All rights reserved.
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION = 0x00010005
+  BASE_NAME   = GoogleTestLib
+  MODULE_UNI_FILE = GoogleTestLib.uni
+  FILE_GUID   = A90E4751-AD30-43CC-980B-01E356B49ADF
+  MODULE_TYPE = BASE
+  VERSION_STRING  = 0.1
+  LIBRARY_CLASS   = GoogleTestLib|HOST_APPLICATION
+
+#
+#  VALID_ARCHITECTURES   = IA32 X64 ARM AARCH64
+#
+
+[Sources]
+  googletest/googletest/src/gtest-all.cc
+
+[Packages]
+  UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
+
+[BuildOptions]
+  MSFT:*_*_*_CC_FLAGS == /c /EHsc /Zi
+  MSFT:NOOPT_*_*_CC_FLAGS =  /Od
+
+  GCC:*_*_*_CC_FLAGS == -g -c
+
+  GCC:NOOPT_*_*_CC_FLAGS =  -O0
+  GCC:*_*_IA32_CC_FLAGS  =  -m32
+  GCC:*_*_X64_CC_FLAGS   =  -m64
diff --git a/UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.uni 
b/UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.uni
new file mode 100644
index ..14c862a23744
--- /dev/null
+++ b/UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.uni
@@ -0,0 +1,14 @@
+// /** @file
+// This module provides GoogleTest Library implementation.
+//
+// This module provides GoogleTest Library implementation.
+//
+// Copyright (c) 2022, Intel Corporation. All rights reserved.
+//
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+// **/
+
+#string STR_MODULE_ABSTRACT #language en-US "GoogleTest Library 
implementation"
+
+#string STR_MODULE_DESCRIPTION  #language en-US "This module provides 
GoogleTest Library implementation."
diff --git a/UnitTestFrameworkPkg/Library/GoogleTestLib/googletest 
b/UnitTestFrameworkPkg/Library/GoogleTestLib/googletest
new file mode 16
index ..86add13493e5
--- /dev/null
+++ b/UnitTestFrameworkPkg/Library/GoogleTestLib/googletest
@@ -0,0 +1 @@
+Subproject commit 86add13493e5c881d7e4ba77fb91c1f57752b3a4
diff --git a/UnitTestFrameworkPkg/ReadMe.md b/UnitTestF

[edk2-devel] [Patch V2 1/7] MdePkg/Include: Update Base.h to improve C++ compatibility

2022-11-04 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4134

* Map NULL to nullptr or __null when c++ compiler is used.
* Map STATIC_ASSERT to static_assert when a c++ compiler is used.
* Typecast RETURN_SUCCESS to type RETURN_STATUS to match type used
  by all return error/warning status codes.  C++ has stricter type
  checking and found this inconsistency.

Cc: Liming Gao 
Cc: Zhiguang Liu 
Signed-off-by: Michael D Kinney 
---
 MdePkg/Include/Base.h | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
index d19ddfe4bba7..d209e6de280a 100644
--- a/MdePkg/Include/Base.h
+++ b/MdePkg/Include/Base.h
@@ -309,7 +309,15 @@ struct _LIST_ENTRY {
 ///
 /// NULL pointer (VOID *)
 ///
+#if defined (__cplusplus)
+  #if defined (_MSC_EXTENSIONS)
+#define NULL  nullptr
+  #else
+#define NULL  __null
+  #endif
+#else
 #define NULL  ((VOID *) 0)
+#endif
 
 //
 // Null character
@@ -760,7 +768,7 @@ typedef UINTN *BASE_LIST;
 **/
 #ifdef MDE_CPU_EBC
 #define STATIC_ASSERT(Expression, Message)
-#elif defined (_MSC_EXTENSIONS)
+#elif defined (_MSC_EXTENSIONS) || defined (__cplusplus)
 #define STATIC_ASSERT  static_assert
 #else
 #define STATIC_ASSERT  _Static_assert
@@ -959,7 +967,7 @@ typedef UINTN RETURN_STATUS;
 ///
 /// The operation completed successfully.
 ///
-#define RETURN_SUCCESS  0
+#define RETURN_SUCCESS  (RETURN_STATUS)(0)
 
 ///
 /// The image failed to load.
-- 
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95965): https://edk2.groups.io/g/devel/message/95965
Mute This Topic: https://groups.io/mt/94814639/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [Patch V2 4/7] UnitTestFrameworkPkg/Library/CmockaLib: Enable symbol files.

2022-11-04 Thread Michael D Kinney
Cc: Michael Kubacki 
Cc: Sean Brogan 
Signed-off-by: Michael D Kinney 
Reviewed-by: Michael Kubacki 
---
 UnitTestFrameworkPkg/Library/CmockaLib/CmockaLib.inf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/UnitTestFrameworkPkg/Library/CmockaLib/CmockaLib.inf 
b/UnitTestFrameworkPkg/Library/CmockaLib/CmockaLib.inf
index 07da7a88e952..052c7f557210 100644
--- a/UnitTestFrameworkPkg/Library/CmockaLib/CmockaLib.inf
+++ b/UnitTestFrameworkPkg/Library/CmockaLib/CmockaLib.inf
@@ -26,7 +26,7 @@ [Packages]
   UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
 
 [BuildOptions]
-  MSFT:*_*_*_CC_FLAGS == /c -DHAVE_VSNPRINTF -DHAVE_SNPRINTF
+  MSFT:*_*_*_CC_FLAGS == /c -DHAVE_VSNPRINTF -DHAVE_SNPRINTF /Zi
   MSFT:NOOPT_*_*_CC_FLAGS =  /Od
 
   GCC:*_*_*_CC_FLAGS == -g -DHAVE_SIGNAL_H
-- 
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95968): https://edk2.groups.io/g/devel/message/95968
Mute This Topic: https://groups.io/mt/94814643/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [Patch V2 5/7] .pytool: Add googletest submodule to CISettings.py

2022-11-04 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4134

Cc: Sean Brogan 
Cc: Michael Kubacki 
Cc: Liming Gao 
Signed-off-by: Michael D Kinney 
Reviewed-by: Michael Kubacki 
---
 .pytool/CISettings.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.pytool/CISettings.py b/.pytool/CISettings.py
index cc2214071c96..76ac2b09dba6 100644
--- a/.pytool/CISettings.py
+++ b/.pytool/CISettings.py
@@ -192,6 +192,8 @@ class Settings(CiBuildSettingsManager, 
UpdateSettingsManager, SetupSettingsManag
 "CryptoPkg/Library/OpensslLib/openssl", False))
 rs.append(RequiredSubmodule(
 "UnitTestFrameworkPkg/Library/CmockaLib/cmocka", False))
+rs.append(RequiredSubmodule(
+"UnitTestFrameworkPkg/Library/GoogleTestLib/googletest", False))
 rs.append(RequiredSubmodule(
 "MdeModulePkg/Universal/RegularExpressionDxe/oniguruma", False))
 rs.append(RequiredSubmodule(
-- 
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95969): https://edk2.groups.io/g/devel/message/95969
Mute This Topic: https://groups.io/mt/94814644/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [Patch V2 0/7] Add GoogleTest to UnitTestFrameworkPkg

2022-11-04 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4134

PR: https://github.com/tianocore/edk2/pull/3595
Branch: https://github.com/mdkinney/edk2/tree/Bug_4134_AddGoogleTest_V2

Add GoogleTest support to UnitTestFrameworkPkg to provide an
additional host-based unit test framework to developers.

Code: https://github.com/google/googletest
Docs: https://google.github.io/googletest

GoogleTest is implemented in C++, but does support implementing
unit tests for C code.  This patch series makes a few updates for C++
compatibility and build issues related to multiple definitions of _ASSERT().
The GoogleTest git submodule is added to the UnitTestFrameworkPkg
and .pytools/CISettings.py file along with an update to the host-based
test runner plugin to set the GTEST_OUTPUT environment variable to 
specify the XML output file format and location.

A port of the unit tests for the the MdePkg BaseSafeIntLib are included
to provide an example that is in both the current unit test style and the
GoogleTest style.

New in V2
-
* Update maintainers/reviewers
* Add feature table to Readme.md and fix typos

Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: Bob Feng 
Cc: Yuwei Chen 
Cc: Sean Brogan 
Cc: Michael Kubacki 
Signed-off-by: Michael D Kinney 

Michael D Kinney (7):
  MdePkg/Include: Update Base.h to improve C++ compatibility
  MdePkg/Include/Library: Undefine _ASSERT() if already defined
  UnitTestFrameworkPkg: Add googletest submodule and GoogleTestLib
  UnitTestFrameworkPkg/Library/CmockaLib: Enable symbol files.
  .pytool: Add googletest submodule to CISettings.py
  BaseTools/Plugin/HostBaseUnitTestRunner: Enable gtest xml output
  MdePkg/Test: Add port of BaseSafeIntLib unit tests to GoogleTest

 .gitmodules   |3 +
 .pytool/CISettings.py |2 +
 .../HostBasedUnitTestRunner.py|7 +-
 MdePkg/Include/Base.h |   12 +-
 MdePkg/Include/Library/DebugLib.h |3 +
 .../GoogleTestBaseSafeIntLib.inf  |   37 +
 .../GoogleTestBaseSafeIntLib.uni  |   13 +
 .../SafeIntLibUintnIntnUnitTests32.cpp|  425 +++
 .../SafeIntLibUintnIntnUnitTests64.cpp|  429 
 .../BaseSafeIntLib/TestBaseSafeIntLib.cpp | 2274 +
 MdePkg/Test/MdePkgHostTest.dsc|1 +
 .../Include/Library/GoogleTestLib.h   |   14 +
 .../Library/CmockaLib/CmockaLib.inf   |2 +-
 .../Library/GoogleTestLib/GoogleTestLib.inf   |   36 +
 .../Library/GoogleTestLib/GoogleTestLib.uni   |   14 +
 .../Library/GoogleTestLib/googletest  |1 +
 UnitTestFrameworkPkg/ReadMe.md|  255 +-
 .../SampleGoogleTest/SampleGoogleTest.cpp |  263 ++
 .../SampleGoogleTest/SampleGoogleTestHost.inf |   35 +
 .../Test/UnitTestFrameworkPkgHostTest.dsc |4 +-
 .../UnitTestFrameworkPkg.ci.yaml  |4 +-
 UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec |8 +
 .../UnitTestFrameworkPkgHost.dsc.inc  |4 +-
 23 files changed, 3810 insertions(+), 36 deletions(-)
 create mode 100644 
MdePkg/Test/GoogleTest/Library/BaseSafeIntLib/GoogleTestBaseSafeIntLib.inf
 create mode 100644 
MdePkg/Test/GoogleTest/Library/BaseSafeIntLib/GoogleTestBaseSafeIntLib.uni
 create mode 100644 
MdePkg/Test/GoogleTest/Library/BaseSafeIntLib/SafeIntLibUintnIntnUnitTests32.cpp
 create mode 100644 
MdePkg/Test/GoogleTest/Library/BaseSafeIntLib/SafeIntLibUintnIntnUnitTests64.cpp
 create mode 100644 
MdePkg/Test/GoogleTest/Library/BaseSafeIntLib/TestBaseSafeIntLib.cpp
 create mode 100644 UnitTestFrameworkPkg/Include/Library/GoogleTestLib.h
 create mode 100644 UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.inf
 create mode 100644 UnitTestFrameworkPkg/Library/GoogleTestLib/GoogleTestLib.uni
 create mode 16 UnitTestFrameworkPkg/Library/GoogleTestLib/googletest
 create mode 100644 
UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTest/SampleGoogleTest.cpp
 create mode 100644 
UnitTestFrameworkPkg/Test/GoogleTest/Sample/SampleGoogleTest/SampleGoogleTestHost.inf

-- 
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95964): https://edk2.groups.io/g/devel/message/95964
Mute This Topic: https://groups.io/mt/94814638/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [Patch V2 2/7] MdePkg/Include/Library: Undefine _ASSERT() if already defined

2022-11-04 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4134

When unit testing is enabled, make sure _ASSERT() is not already
defined by the host environment before defining _ASSERT().  This
avoids conflicts with VS20xx builds of GoogleTest based unit tests.

Cc: Liming Gao 
Cc: Zhiguang Liu 
Signed-off-by: Michael D Kinney 
---
 MdePkg/Include/Library/DebugLib.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/MdePkg/Include/Library/DebugLib.h 
b/MdePkg/Include/Library/DebugLib.h
index 8d3d08638d73..9110be2f41b3 100644
--- a/MdePkg/Include/Library/DebugLib.h
+++ b/MdePkg/Include/Library/DebugLib.h
@@ -337,6 +337,9 @@ UnitTestDebugAssert (
   IN CONST CHAR8  *Description
   );
 
+  #if defined (_ASSERT)
+#undef _ASSERT
+  #endif
   #if defined (__clang__) && defined (__FILE_NAME__)
 #define _ASSERT(Expression)  UnitTestDebugAssert (__FILE_NAME__, 
DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
   #else
-- 
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95966): https://edk2.groups.io/g/devel/message/95966
Mute This Topic: https://groups.io/mt/94814640/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] 回复: [PATCH v9 00/19] Add Raw algorithm support using Arm TRNG interface

2022-11-04 Thread Ard Biesheuvel
On Fri, 4 Nov 2022 at 02:16, gaoliming via groups.io
 wrote:
>
> Sami, Leif, Ard:
>   Can you give your Reviewed-by for this patch set this week? If so, this
> feature can catch stable tag 202211.
>
>   Stable202211 tag soft feature freeze will start on next Monday Nov 7th.
>

I will try to look at this before monday.


> > -邮件原件-
> > 发件人: Yao, Jiewen 
> > 发送时间: 2022年11月1日 16:56
> > 收件人: pierre.gond...@arm.com; devel@edk2.groups.io
> > 抄送: Sami Mujawar ; Leif Lindholm
> > ; Ard Biesheuvel ;
> > Rebecca Cran ; Kinney, Michael D
> > ; Gao, Liming ;
> > Wang, Jian J 
> > 主题: RE: [PATCH v9 00/19] Add Raw algorithm support using Arm TRNG
> > interface
> >
> > Thanks for the update.
> >
> > For SecurityPkg (11~18), Acked-by: Jiewen Yao 
> > Since the update is for AARCH64, I recommend to have an ARM people to give
> > Reviewed-by.
> >
> > Thank you
> > Yao Jiewen
> >
> >
> > > -Original Message-
> > > From: pierre.gond...@arm.com 
> > > Sent: Friday, October 28, 2022 11:33 PM
> > > To: devel@edk2.groups.io
> > > Cc: Sami Mujawar ; Leif Lindholm
> > > ; Ard Biesheuvel
> > > ; Rebecca Cran ;
> > Kinney,
> > > Michael D ; Gao, Liming
> > > ; Yao, Jiewen ; Wang,
> > > Jian J 
> > > Subject: [PATCH v9 00/19] Add Raw algorithm support using Arm TRNG
> > > interface
> > >
> > > From: Pierre Gondois 
> > >
> > > Bugzilla: Bug 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3668)
> > >
> > > The Arm True Random Number Generator Firmware, Interface 1.0,
> > > specification
> > > defines an interface between an Operating System (OS) executing at EL1
> > and
> > > Firmware (FW) exposing a conditioned entropy source that is provided by
> a
> > > TRNG back end.
> > > This patch-set:
> > > - defines an Arm TRNG library class that provides an interface to access
> > >   the entropy source on a platform.
> > > - implements an Arm TRNG library instance that uses the Arm FW-TRNG
> > >   interface.
> > > - Adds RawAlgorithm support to RngDxe for Arm architecture using the Arm
> > >   TRNG interface.
> > > - Enables RNG support using Arm TRNG interface for Kvmtool Guest/Virtual
> > >   firmware.
> > >
> > > This patch-set is based on the v2 from Sami Mujawar:
> > > [PATCH v2 0/8] Add Raw algorithm support using Arm FW-TRNG interface
> > > v2:
> > > https://edk2.groups.io/g/devel/message/83775
> > > v3:
> > > https://edk2.groups.io/g/devel/message/90845
> > > https://github.com/PierreARM/edk2/tree/Arm_Trng_v3
> > > v4:
> > > https://github.com/PierreARM/edk2/tree/Arm_Trng_v4
> > > v5:
> > > https://github.com/PierreARM/edk2/tree/Arm_Trng_v5
> > > v6:
> > > https://github.com/PierreARM/edk2/tree/Arm_Trng_v6
> > > v7:
> > > https://github.com/PierreARM/edk2/tree/Arm_Trng_v7
> > > v8:
> > > https://github.com/PierreARM/edk2/tree/Arm_Trng_v8
> > > v9:
> > > https://github.com/PierreARM/edk2/tree/Arm_Trng_v9
> > >
> > > v9:
> > >  - Added BaseArmTrngLibNull as default in MdePkg/MdeLibs.dsc.inc.
> > [Liming]
> > >  - Renamed TrngLib to ArmTrngLib and updated documentation, commit
> > >messages, function names accordingly. [Jiewen, Leif]
> > > v8:
> > >  - Added Reviewed-by/Acked-by from Leif on ArmPkg/SecurityPkg
> > >patches. [Leif]
> > >  - Renamed FID_TRNG_* macros to ARM_SMC_ID_TRNG_*. [Leif]
> > > v7:
> > >  - Removed Reviewed-by from Leif.
> > >  - Remove Sami's Signed-off.
> > > V6:
> > >  - Added my signed-off on patches authored by Sami. [Leif]
> > >  - New patch to make it easier to add new libraries in alphabetical
> > >order: ArmPkg: Sort HVC/SMC section alphbetically in ArmPkg.dsc
> [Leif]
> > >  - Renmaed ArmHvcNullLib to ArmHvcLibNull. [Leif]
> > >  - Added RISCV64 to the list of VALID_ARCHITECTURES for
> > BaseTrngLibNull.
> > > [Leif]
> > >  - Removed unnecessary space in function parameter documentation
> > >('[in, out]'). [Rebecca]
> > >  - Updated INF_VERSION to latest spec (1.29) for new libraries.
> [Rebecca]
> > >  - Dropped the following patches [Leif]:
> > >   - ArmPkg/ArmLib: Add ArmHasRngExt()
> > >   - ArmPkg/ArmLib: Add ArmReadIdIsar0() helper
> > >   - MdePkg/BaseRngLib: Rename ArmReadIdIsar0() to ArmGetFeatRng()
> > > V5:
> > >  - Removed references in Trnglib.h to 'Special Publication'
> > >800-90A and 800-90C, and only reference 'Arm True Random
> > >Number Generator Firmware, Interface 1.0' in the Arm
> > >implementation of the TrngLib. [Jiewen]
> > > V4:
> > >  - Removed dependencies on ArmPkg and dropped patch:
> > > [PATCH v3 12/22] SecurityPkg: Update Securitypkg.ci.yaml
> > >[Jiewen]
> > >  - Use a dynamically allocated array to hold available algorithms.
> > >The array is freed in a new UNLOAD_IMAGE function and
> > >allocated in arch specific implementations of
> > >GetAvailableAlgorithms(), available in AArch64/AArch64Algo.c
> > >and Arm/ArmAlgo.c.
> > >  - Correctly reference gEfiRngAlgorithmSp80090Ctr256Guid
> > >Guid by copying its address (add missing '&'). [Jiewen]
> > > V3:
> > >  - Address Leif's comment (moving def

Re: [edk2-devel] [Patch 3/7] UnitTestFrameworkPkg: Add googletest submodule and GoogleTestLib

2022-11-04 Thread Michael D Kinney
Hi Michael,

Here is a first pass at a feature matrix.  Can you think of other features to 
add?

### Framework and GoogleTest Feature Comparison

| Feature   | Framework | GoogleTest |
|:--|:-:|:--:|
| Host based unit tests |YES|YES |
| Target based unit tests   |YES| NO |
| Unit test source language | C |C++ |
| Register Test Suite   |YES|Auto|
| Register Test Case|YES|Auto|
| Setup/Teardown Hooks  |YES|YES |
| Value-Parameterized Tests |NO |YES |
| Typed Tests   |NO |YES |
| Type-Parameterized Tests  |NO |YES |
| Mocking Support   |   Cmocka  | NO |
| JUNIT XML Reports |YES|YES |
| Execute subset of tests   |NO |YES |
| VS Code Extensions|NO |YES |

Thanks,

Mike



From: Michael Kubacki  
Sent: Friday, November 4, 2022 7:45 AM
To: Kinney, Michael D ; devel@edk2.groups.io
Subject: Re: [edk2-devel] [Patch 3/7] UnitTestFrameworkPkg: Add googletest 
submodule and GoogleTestLib

Reviewed-by: Michael Kubacki 

There's a typo in UnitTestFrameworkPkg/ReadMe.md. You'll find it by searching 
for "ued".

The ReadMe.md updates are very helpful. Something else to consider would be a 
brief feature matrix at the top for the "framework" vs GoogleTest. I think it 
would be a little easier to parse which to choose than picking apart the key 
differences in the text. 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95962): https://edk2.groups.io/g/devel/message/95962
Mute This Topic: https://groups.io/mt/94799427/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 1/2] MdePkg/IndustryStandard: add definitions for ACPI APMT

2022-11-04 Thread Jeff Brasen via groups.io
This adds #defines and struct typedefs for the various node types in

the  ACPI Arm Performance Monitoring Unit (APMT) table.



Signed-off-by: Jeff Brasen 

---

 MdePkg/Include/IndustryStandard/Acpi64.h  |  5 ++

 .../ArmPerformanceMonitoringUnitTable.h   | 69 +++

 2 files changed, 74 insertions(+)

 create mode 100644 
MdePkg/Include/IndustryStandard/ArmPerformanceMonitoringUnitTable.h



diff --git a/MdePkg/Include/IndustryStandard/Acpi64.h 
b/MdePkg/Include/IndustryStandard/Acpi64.h

index fe5ebfac2b..575ca0430c 100644

--- a/MdePkg/Include/IndustryStandard/Acpi64.h

+++ b/MdePkg/Include/IndustryStandard/Acpi64.h

@@ -2847,6 +2847,11 @@ typedef struct {

 ///

 #define EFI_ACPI_6_4_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE  
SIGNATURE_32('A', 'P', 'I', 'C')

 

+///

+/// "APMT" Arm Performance Monitoring Unit Table

+///

+#define EFI_ACPI_6_4_ARM_PERFORMANCE_MONITORING_UNIT_TABLE_SIGNATURE  
SIGNATURE_32('A', 'P', 'M', 'T')

+

 ///

 /// "BERT" Boot Error Record Table

 ///

diff --git 
a/MdePkg/Include/IndustryStandard/ArmPerformanceMonitoringUnitTable.h 
b/MdePkg/Include/IndustryStandard/ArmPerformanceMonitoringUnitTable.h

new file mode 100644

index 00..fe7084cffd

--- /dev/null

+++ b/MdePkg/Include/IndustryStandard/ArmPerformanceMonitoringUnitTable.h

@@ -0,0 +1,69 @@

+/** @file

+  ACPI Arm Performance Monitoring Unit (APMT) table

+  as specified in ARM spec DEN0117

+

+  Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.

+  Copyright (c) 2022, ARM Limited. All rights reserved.

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+**/

+

+#ifndef ARM_PERFORMANCE_MONITORING_UNIT_TABLE_H_

+#define ARM_PERFORMANCE_MONITORING_UNIT_TABLE_H_

+

+#include 

+

+#pragma pack(1)

+

+///

+/// Arm Performance Monitoring Unit (APMT) tabl

+///

+typedef struct {

+  EFI_ACPI_DESCRIPTION_HEADERHeader;

+} EFI_ACPI_ARM_PERFORMANCE_MONITORING_UNIT_TABLE_HEADER;

+

+///

+/// APMT Revision (as defined in DEN0117.)

+///

+#define EFI_ACPI_ARM_PERFORMANCE_MONITORING_UNIT_TABLE_REVISION  0x00

+

+///

+/// Arm PMU Node Structure

+///

+

+// Node Flags

+#define EFI_ACPI_APMT_DUAL_PAGE_EXTENSION_SUPPORTED  BIT0

+#define EFI_ACPI_APMT_PROCESSOR_AFFINITY_TYPE_CONTAINER  BIT1

+#define EFI_ACPI_APMT_PROCESSOR_AFFINITY_TYPE_PROCESSOR  0 // BIT 1

+#define EFI_ACPI_APMT_64BIT_SINGLE_COPY_ATOMICITY_SUPPORTED  BIT2

+

+// Interrupt Flags

+#define EFI_ACPI_APMT_INTERRUPT_MODE_EDGE_TRIGGERED   BIT0

+#define EFI_ACPI_APMT_INTERRUPT_MODE_LEVEL_TRIGGERED  0 // BIT 0

+#define EFI_ACPI_APMT_INTERRUPT_TYPE_WIRED0 // BIT 1

+

+// Node Type

+#define EFI_ACPI_APMT_NODE_TYPE_MEMORY_CONTROLLER  0x00

+#define EFI_ACPI_APMT_NODE_TYPE_SMMU   0x01

+#define EFI_ACPI_APMT_NODE_TYPE_PCIE_ROOT_COMPLEX  0x02

+#define EFI_ACPI_APMT_NODE_TYPE_ACPI_DEVICE0x03

+#define EFI_ACPI_APMT_NODE_TYPE_CPU_CACHE  0x04

+

+typedef struct {

+  UINT16Length;

+  UINT8 NodeFlags;

+  UINT8 NodeType;

+  UINT32Identifier;

+  UINT64NodeInstancePrimary;

+  UINT32NodeInstanceSecondary;

+  UINT64BaseAddress0;

+  UINT64BaseAddress1;

+  UINT32OverflowInterrupt;

+  UINT32Reserved1;

+  UINT32OverflowInterruptFlags;

+  UINT32ProcessorAffinity;

+  UINT32ImplementationId;

+} EFI_ACPI_ARM_PERFORMANCE_MONITORING_UNIT_NODE;

+

+#pragma pack()

+

+#endif

-- 

2.25.1





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95961): https://edk2.groups.io/g/devel/message/95961
Mute This Topic: https://groups.io/mt/94808915/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 2/2] ShellPkg/AcpiView: APMT Parser

2022-11-04 Thread Jeff Brasen via groups.io
Add a new parser for the Arm Performance Monitoring Unit Table.

The APMT table describes the properties of PMU support

implemented by components in an Arm-based system.



Signed-off-by: Jeff Brasen 

---

 .../UefiShellAcpiViewCommandLib/AcpiParser.h  |  21 

 .../Parsers/Apmt/ApmtParser.c | 106 ++

 .../UefiShellAcpiViewCommandLib.c |   1 +

 .../UefiShellAcpiViewCommandLib.inf   |   1 +

 .../UefiShellAcpiViewCommandLib.uni   |   1 +

 5 files changed, 130 insertions(+)

 create mode 100644 
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Apmt/ApmtParser.c



diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h

index db8c88f6df..6a1de4e12b 100644

--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h

+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h

@@ -531,6 +531,27 @@ ParseAcpiAest (

   IN UINT8AcpiTableRevision

   );

 

+/**

+  This function parses the ACPI APMT table.

+  When trace is enabled this function parses the APMT table and

+  traces the ACPI table fields.

+

+  This function also performs validation of the ACPI table fields.

+

+  @param [in] Trace  If TRUE, trace the ACPI fields.

+  @param [in] PtrPointer to the start of the buffer.

+  @param [in] AcpiTableLengthLength of the ACPI table.

+  @param [in] AcpiTableRevision  Revision of the ACPI table.

+**/

+VOID

+EFIAPI

+ParseAcpiApmt (

+  IN BOOLEAN  Trace,

+  IN UINT8*Ptr,

+  IN UINT32   AcpiTableLength,

+  IN UINT8AcpiTableRevision

+  );

+

 /**

   This function parses the ACPI BGRT table.

   When trace is enabled this function parses the BGRT table and

diff --git 
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Apmt/ApmtParser.c 
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Apmt/ApmtParser.c

new file mode 100644

index 00..ad64adbb0a

--- /dev/null

+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Apmt/ApmtParser.c

@@ -0,0 +1,106 @@

+/** @file

+  APMT table parser

+

+  Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.

+  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.

+  SPDX-License-Identifier: BSD-2-Clause-Patent

+

+  @par Reference(s):

+- ACPI 6.2 Specification - Errata A, September 2017

+**/

+

+#include 

+#include 

+#include 

+#include "AcpiParser.h"

+#include "AcpiTableParser.h"

+

+// Local variables

+STATIC ACPI_DESCRIPTION_HEADER_INFO  AcpiHdrInfo;

+STATIC CONST UINT16  *NodeLength;

+

+/**

+  An ACPI_PARSER array describing the ACPI APMT Table.

+**/

+STATIC CONST ACPI_PARSER  ApmtParser[] = {

+  PARSE_ACPI_HEADER (&AcpiHdrInfo)

+};

+

+/**

+  An ACPI_PARSER array describing the ACPI Arm PMU Node.

+**/

+STATIC CONST ACPI_PARSER  ArmPmuNodeParser[] = {

+  { L"Length",   2, 0,  L"0x%x",  NULL, (VOID **)&NodeLength, 
NULL, NULL },

+  { L"Node flags",   1, 2,  L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Node type",1, 3,  L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Identifier",   4, 4,  L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Node Instance primary",8, 8,  L"0x%lx", NULL, NULL, 
NULL, NULL },

+  { L"Node Instance secondary",  4, 16, L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Base address 0",   8, 20, L"0x%lx", NULL, NULL, 
NULL, NULL },

+  { L"Base address 1",   8, 28, L"0x%lx", NULL, NULL, 
NULL, NULL },

+  { L"Overflow interrupt",   4, 36, L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Reserved1",4, 40, L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Overflow interrupt flags", 4, 44, L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Processor affinity",   4, 48, L"0x%x",  NULL, NULL, 
NULL, NULL },

+  { L"Implementation ID",4, 52, L"0x%x",  NULL, NULL, 
NULL, NULL }

+};

+

+/**

+  This function parses the ACPI APMT table.

+  When trace is enabled this function parses the APMT table and

+  traces the ACPI table fields.

+

+  This function also performs validation of the ACPI table fields.

+

+  @param [in] Trace  If TRUE, trace the ACPI fields.

+  @param [in] PtrPointer to the start of the buffer.

+  @param [in] AcpiTableLengthLength of the ACPI table.

+  @param [in] AcpiTableRevision  Revision of the ACPI table.

+**/

+VOID

+EFIAPI

+ParseAcpiApmt (

+  IN BOOLEAN  Trace,

+  IN UINT8*Ptr,

+  IN UINT32   AcpiTableLength,

+  IN UINT8AcpiTableRevision

+  )

+{

+  UINT32  Offset;

+

+  if (!Trace) {

+return;

+  }

+

+  ParseAcpi (

+Trace,

+0,

+"APMT",

+Ptr,

+AcpiTableLength,

+PARSER_PARAMS (ApmtPar

Re: [edk2-devel] [PATCH v2] CryptoPkg/Readme.md: typo and grammar fixes

2022-11-04 Thread Michael D Kinney
Reviewed-by: Michael D Kinney 


> -Original Message-
> From: Laszlo Ersek 
> Sent: Friday, November 4, 2022 5:02 AM
> To: devel@edk2.groups.io; ler...@redhat.com
> Cc: Zurcher, Christopher ; Jiang, Guomin 
> ; Wang, Jian J
> ; Yao, Jiewen ; Kinney, Michael 
> D ; Lu, Xiaoyu1
> 
> Subject: [PATCH v2] CryptoPkg/Readme.md: typo and grammar fixes
> 
> Commit 244ce33bdd2f ("CryptoPkg: Add Readme.md", 2022-10-24) had added the
> long-awaited documentation on the dynamic crypto services. Fix some of the
> typos and arguable grammar errors in "Readme.md". A few light
> clarifications are also snuck in.
> 
> Cc: Christopher Zurcher 
> Cc: Guomin Jiang 
> Cc: Jian J Wang 
> Cc: Jiewen Yao 
> Cc: Michael D Kinney 
> Cc: Xiaoyu Lu 
> Signed-off-by: Laszlo Ersek 
> ---
> 
> Notes:
> v2:
> 
> - URL:
>   
> https://pagure.io/lersek/edk2/c/8d7b26bfb6a1?branch=cryptopkg_readme_typos_v2
> 
> - v1 was at:
>   - 
> https://listman.redhat.com/archives/edk2-devel-archive/2022-November/055153.html
>   - msgid <20221102093637.9132-1-ler...@redhat.com>
> 
> - keep referring to the singular HashApiLib algorithm that
>   PcdHashApiLibPolicy exposes for configuration in singular [Mike]
> 
> - still fix the duplicated "to" typo
> 
> - range-diff against v1 (i.e., first hunk dropped, second hunk updated):
> 
> > 1:  a7269f170437 ! 1:  8d7b26bfb6a1 CryptoPkg/Readme.md: typo and 
> grammar fixes
> > @@ -94,18 +94,11 @@
> >   ```
> >   [LibraryClasses.common.DXE_RUNTIME_DRIVER]
> >  @@
> > - ### PCD Configuration Settings
> > -
> > - There are 2 PCD settings that are used to configure cryptographic 
> services.
> > --`PcdHashApiLibPolicy` is used to configure the hash algorithm 
> provided by the
> > -+`PcdHashApiLibPolicy` is used to configure the hash algorithms 
> provided by the
> > - BaseHashApiLib library instance. `PcdCryptoServiceFamilyEnable` 
> is used to
> > - configure the cryptographic services supported by the CryptoPei, 
> CryptoDxe,
> >   and CryptoSmm modules.
> >
> >   * `gEfiCryptoPkgTokenSpaceGuid.PcdHashApiLibPolicy` - This PCD 
> indicates the
> >  -  HASH algorithm to to use in the BaseHashApiLib to calculate 
> hash of data. The
> > -+  HASH algorithms to use in the BaseHashApiLib to calculate hash 
> of data. The
> > ++  HASH algorithm to use in the BaseHashApiLib to calculate hash 
> of data. The
> > default hashing algorithm for BaseHashApiLib is set to 
> HASH_ALG_SHA256.
> > |  Setting   |Algorithm |
> > ||--|
> 
>  CryptoPkg/Readme.md | 46 ++--
>  1 file changed, 23 insertions(+), 23 deletions(-)
> 
> diff --git a/CryptoPkg/Readme.md b/CryptoPkg/Readme.md
> index 946aa1e99e7d..067465b8eb7d 100644
> --- a/CryptoPkg/Readme.md
> +++ b/CryptoPkg/Readme.md
> @@ -39,7 +39,7 @@ provides the smallest overall firmware overhead.
> 
>  ## Statically Linking Cryptographic Services
> 
> -The figure below shows an example of a firmware modules that requires the 
> use of
> +The figure below shows an example of a firmware module that requires the use 
> of
>  cryptographic services. The cryptographic services are provided by three 
> library
>  classes called BaseCryptLib, TlsLib, and HashApiLib. These library classes 
> are
>  implemented using APIs from the OpenSSL project that are abstracted by the
> @@ -49,7 +49,7 @@ full C runtime library for firmware components. Instead, 
> the CryptoPkg includes
>  the smallest subset of services required to build the OpenSSL project in the
>  private library class called IntrinsicLib.
> 
> -The CryptoPkg provides several instances if the BaseCryptLib and OpensslLib 
> with
> +The CryptoPkg provides several instances of the BaseCryptLib and OpensslLib 
> with
>  different cryptographic service features and performance optimizations. The
>  platform developer must select the correct instances based on cryptographic
>  service requirements in each UEFI/PI firmware phase (SEC, PEI, DXE, UEFI,
> @@ -97,9 +97,9 @@ linking is not available for SEC or UEFI RT modules.
> 
>  The EDK II modules/libraries that require cryptographic services use the same
>  BaseCryptLib/TlsLib/HashApiLib APIs. This means no source changes are 
> required
> -to use static linking or dynamic linking. It is a platform configuration 
> options
> -to select static linking or dynamic linking. This choice can be make 
> globally,
> -per firmware module type, or individual modules.
> +to use static linking or dynamic linking. It is a platform configuration 
> option
> +to select static linking or dynamic linking. This choice can be made 
> globally,
> +per firmware module type, or for individual modules.
> 
>  ```
>  +===++===+ +===+
> @@ -159,7 +159,7 @@ The table below provides a summary of the

Re: [edk2-devel] [Patch 4/7] UnitTestFrameworkPkg/Library/CmockaLib: Enable symbol files.

2022-11-04 Thread Michael Kubacki
Reviewed-by: Michael Kubacki 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95957): https://edk2.groups.io/g/devel/message/95957
Mute This Topic: https://groups.io/mt/94799428/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [Patch 3/7] UnitTestFrameworkPkg: Add googletest submodule and GoogleTestLib

2022-11-04 Thread Michael Kubacki
Reviewed-by: Michael Kubacki 

There's a typo in UnitTestFrameworkPkg/ReadMe.md. You'll find it by searching 
for "ued".

The ReadMe.md updates are very helpful. Something else to consider would be a 
brief feature matrix at the top for the "framework" vs GoogleTest. I think it 
would be a little easier to parse which to choose than picking apart the key 
differences in the text.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95956): https://edk2.groups.io/g/devel/message/95956
Mute This Topic: https://groups.io/mt/94799427/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH V2 1/9] UefiCpuPkg: Add CcExitLib

2022-11-04 Thread Lendacky, Thomas via groups.io

On 11/3/22 18:19, Min Xu via groups.io wrote:

From: Min M Xu 

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4123

CcExitLib is designed to support handling #VC/#VE exceptions and issuing
VMGEXIT instructions. It can be used to perform these:
   - Handling #VC exceptions
   - Handling #VE exceptions
   - Preparing for and issuing a VMGEXIT
   - Performing MMIO-related write operations to support flash emulation
   - Performing AP related boot opeations

The base functions in this driver will not do anything and will return
an error if a return value is required. It is expected that other packages
(like OvmfPkg) will create a version of the library to fully support an
CC gueste (such as SEV-ES and TDX).

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Brijesh Singh 
Cc: Erdem Aktas 
Cc: Gerd Hoffmann 
Cc: James Bottomley 
Cc: Jiewen Yao 
Cc: Tom Lendacky 
Signed-off-by: Min Xu 
---
  UefiCpuPkg/Include/Library/CcExitLib.h| 176 
  .../Library/CcExitLibNull/CcExitLibNull.c | 194 ++
  .../Library/CcExitLibNull/CcExitLibNull.inf   |  28 +++
  .../Library/CcExitLibNull/CcExitLibNull.uni   |  14 ++
  UefiCpuPkg/UefiCpuPkg.dec |   3 +
  5 files changed, 415 insertions(+)
  create mode 100644 UefiCpuPkg/Include/Library/CcExitLib.h
  create mode 100644 UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.c
  create mode 100644 UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.inf
  create mode 100644 UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.uni

diff --git a/UefiCpuPkg/Include/Library/CcExitLib.h 
b/UefiCpuPkg/Include/Library/CcExitLib.h
new file mode 100644
index ..40372e10b39e
--- /dev/null
+++ b/UefiCpuPkg/Include/Library/CcExitLib.h
@@ -0,0 +1,176 @@
+/** @file
+  Public header file for the CcExitLib.
+
+  This library class defines some routines used for below CcExit handler.
+   - Invoking the VMGEXIT instruction in support of SEV-ES and to handle
+ #VC exceptions.
+   - Handle #VE exception in TDX.
+
+  Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.
+  Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef CC_EXIT_LIB_H_
+#define CC_EXIT_LIB_H_
+
+#include 
+#include 
+
+#define VE_EXCEPTION  20
+
+/**
+  Perform VMGEXIT.
+
+  Sets the necessary fields of the GHCB, invokes the VMGEXIT instruction and
+  then handles the return actions.
+
+  @param[in, out]  Ghcb   A pointer to the GHCB
+  @param[in]   ExitCode   VMGEXIT code to be assigned to the SwExitCode
+  field of the GHCB.
+  @param[in]   ExitInfo1  VMGEXIT information to be assigned to the
+  SwExitInfo1 field of the GHCB.
+  @param[in]   ExitInfo2  VMGEXIT information to be assigned to the
+  SwExitInfo2 field of the GHCB.
+
+  @retval  0  VMGEXIT succeeded.
+  @return Exception number to be propagated, VMGEXIT
+  processing did not succeed.
+
+**/
+UINT64
+EFIAPI
+CcExitLibVmgExit (
+  IN OUT GHCB*Ghcb,
+  IN UINT64  ExitCode,
+  IN UINT64  ExitInfo1,
+  IN UINT64  ExitInfo2
+  );
+
+/**
+  Perform pre-VMGEXIT initialization/preparation.
+
+  Performs the necessary steps in preparation for invoking VMGEXIT. Must be
+  called before setting any fields within the GHCB.
+
+  @param[in, out]  GhcbA pointer to the GHCB
+  @param[in, out]  InterruptState  A pointer to hold the current interrupt
+   state, used for restoring in 
CcExitLibVmgDone ()
+
+**/
+VOID
+EFIAPI
+CcExitLibVmgInit (
+  IN OUT GHCB *Ghcb,
+  IN OUT BOOLEAN  *InterruptState
+  );
+
+/**
+  Perform post-VMGEXIT cleanup.
+
+  Performs the necessary steps to cleanup after invoking VMGEXIT. Must be
+  called after obtaining needed fields within the GHCB.
+
+  @param[in, out]  GhcbA pointer to the GHCB
+  @param[in]   InterruptState  An indicator to conditionally (re)enable
+   interrupts
+
+**/
+VOID
+EFIAPI
+CcExitLibVmgDone (
+  IN OUT GHCB *Ghcb,
+  IN BOOLEAN  InterruptState
+  );
+
+/**
+  Marks a specified offset as valid in the GHCB.
+
+  The ValidBitmap area represents the areas of the GHCB that have been marked
+  valid. Set the bit in ValidBitmap for the input offset.
+
+  @param[in, out]  Ghcb   A pointer to the GHCB
+  @param[in]   Offset Qword offset in the GHCB to mark valid
+
+**/
+VOID
+EFIAPI
+CcExitLibVmgSetOffsetValid (
+  IN OUT GHCB   *Ghcb,
+  IN GHCB_REGISTER  Offset
+  );
+
+/**
+  Checks if a specified offset is valid in the GHCB.
+
+  The ValidBitmap area represents the areas of the GHCB that have been marked
+  valid. Return whether the bit in the ValidBitmap is set for the input offset.
+
+  @param[in]  GhcbA pointer to the GHCB
+  @param[in]  Offset  Qword offset in the GHCB 

Re: [edk2-devel] [Patch 6/7] BaseTools/Plugin/HostBaseUnitTestRunner: Enable gtest xml output

2022-11-04 Thread Bob Feng
Reviewed-by: Bob Feng 

-Original Message-
From: Kinney, Michael D  
Sent: Friday, November 4, 2022 11:31 AM
To: devel@edk2.groups.io
Cc: Feng, Bob C ; Gao, Liming ; 
Chen, Christine 
Subject: [Patch 6/7] BaseTools/Plugin/HostBaseUnitTestRunner: Enable gtest xml 
output

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4134

Set environment variable GTEST_OUTPUT to specify the output format of XML and 
the output file name.  Both CMOCKA_XML_FILE and GTEST_OUTPUT are set for each 
host based unit test to support both cmocka unit tests and gtest unit tests.

Cc: Bob Feng 
Cc: Liming Gao 
Cc: Yuwei Chen 
Signed-off-by: Michael D Kinney 
---
 .../HostBasedUnitTestRunner/HostBasedUnitTestRunner.py | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git 
a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py 
b/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py
index c1eeaf26251e..a8220aacd396 100644
--- a/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py
+++ b/BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.p
+++ y
@@ -85,9 +85,12 @@ class HostBasedUnitTestRunner(IUefiBuildPlugin):
 raise NotImplementedError("Unsupported Operating System")
 
 for test in testList:
-# Configure output name.
+# Configure output name if test uses cmocka.
 shell_env.set_shell_var(
-'CMOCKA_XML_FILE', test + ".%g." + arch + ".result.xml")
+'CMOCKA_XML_FILE', test + ".CMOCKA.%g." + arch + 
".result.xml")
+# Configure output name if test uses gtest.
+shell_env.set_shell_var(
+'GTEST_OUTPUT', "xml:" + test + ".GTEST." + arch + 
+ ".result.xml")
 
 # Run the test.
 ret = RunCmd('"' + test + '"', "", workingdir=cp)
--
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95954): https://edk2.groups.io/g/devel/message/95954
Mute This Topic: https://groups.io/mt/94799430/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] How to add a DXE driver to an OVMF image?

2022-11-04 Thread d.meneses via groups.io
Using *DebugLib* instead to print a message, I was able to confirm that my 
driver is now running properly:
*cat debug.log | grep Hello*
This works both when adding it in the OVMF build and also when inserted by 
UEFITool.

The drivers is not being listed by the EFI Shell *drivers* command.
This is expected to me as Dxe Drivers are unloaded after they return.
Nonetheless, the same is happening when I package it as a *DXE_RUNTIME_DRIVER*.
What is it that I'm missing?

Thank you for your attention,
Diogo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95953): https://edk2.groups.io/g/devel/message/95953
Mute This Topic: https://groups.io/mt/94734592/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2] CryptoPkg/Readme.md: typo and grammar fixes

2022-11-04 Thread Laszlo Ersek
Commit 244ce33bdd2f ("CryptoPkg: Add Readme.md", 2022-10-24) had added the
long-awaited documentation on the dynamic crypto services. Fix some of the
typos and arguable grammar errors in "Readme.md". A few light
clarifications are also snuck in.

Cc: Christopher Zurcher 
Cc: Guomin Jiang 
Cc: Jian J Wang 
Cc: Jiewen Yao 
Cc: Michael D Kinney 
Cc: Xiaoyu Lu 
Signed-off-by: Laszlo Ersek 
---

Notes:
v2:

- URL:
  
https://pagure.io/lersek/edk2/c/8d7b26bfb6a1?branch=cryptopkg_readme_typos_v2

- v1 was at:
  - 
https://listman.redhat.com/archives/edk2-devel-archive/2022-November/055153.html
  - msgid <20221102093637.9132-1-ler...@redhat.com>

- keep referring to the singular HashApiLib algorithm that
  PcdHashApiLibPolicy exposes for configuration in singular [Mike]

- still fix the duplicated "to" typo

- range-diff against v1 (i.e., first hunk dropped, second hunk updated):

> 1:  a7269f170437 ! 1:  8d7b26bfb6a1 CryptoPkg/Readme.md: typo and grammar 
fixes
> @@ -94,18 +94,11 @@
>   ```
>   [LibraryClasses.common.DXE_RUNTIME_DRIVER]
>  @@
> - ### PCD Configuration Settings
> -
> - There are 2 PCD settings that are used to configure cryptographic 
services.
> --`PcdHashApiLibPolicy` is used to configure the hash algorithm 
provided by the
> -+`PcdHashApiLibPolicy` is used to configure the hash algorithms 
provided by the
> - BaseHashApiLib library instance. `PcdCryptoServiceFamilyEnable` is 
used to
> - configure the cryptographic services supported by the CryptoPei, 
CryptoDxe,
>   and CryptoSmm modules.
>
>   * `gEfiCryptoPkgTokenSpaceGuid.PcdHashApiLibPolicy` - This PCD 
indicates the
>  -  HASH algorithm to to use in the BaseHashApiLib to calculate hash 
of data. The
> -+  HASH algorithms to use in the BaseHashApiLib to calculate hash of 
data. The
> ++  HASH algorithm to use in the BaseHashApiLib to calculate hash of 
data. The
> default hashing algorithm for BaseHashApiLib is set to 
HASH_ALG_SHA256.
> |  Setting   |Algorithm |
> ||--|

 CryptoPkg/Readme.md | 46 ++--
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/CryptoPkg/Readme.md b/CryptoPkg/Readme.md
index 946aa1e99e7d..067465b8eb7d 100644
--- a/CryptoPkg/Readme.md
+++ b/CryptoPkg/Readme.md
@@ -39,7 +39,7 @@ provides the smallest overall firmware overhead.
 
 ## Statically Linking Cryptographic Services
 
-The figure below shows an example of a firmware modules that requires the use 
of
+The figure below shows an example of a firmware module that requires the use of
 cryptographic services. The cryptographic services are provided by three 
library
 classes called BaseCryptLib, TlsLib, and HashApiLib. These library classes are
 implemented using APIs from the OpenSSL project that are abstracted by the
@@ -49,7 +49,7 @@ full C runtime library for firmware components. Instead, the 
CryptoPkg includes
 the smallest subset of services required to build the OpenSSL project in the
 private library class called IntrinsicLib.
 
-The CryptoPkg provides several instances if the BaseCryptLib and OpensslLib 
with
+The CryptoPkg provides several instances of the BaseCryptLib and OpensslLib 
with
 different cryptographic service features and performance optimizations. The
 platform developer must select the correct instances based on cryptographic
 service requirements in each UEFI/PI firmware phase (SEC, PEI, DXE, UEFI,
@@ -97,9 +97,9 @@ linking is not available for SEC or UEFI RT modules.
 
 The EDK II modules/libraries that require cryptographic services use the same
 BaseCryptLib/TlsLib/HashApiLib APIs. This means no source changes are required
-to use static linking or dynamic linking. It is a platform configuration 
options
-to select static linking or dynamic linking. This choice can be make globally,
-per firmware module type, or individual modules.
+to use static linking or dynamic linking. It is a platform configuration option
+to select static linking or dynamic linking. This choice can be made globally,
+per firmware module type, or for individual modules.
 
 ```
 +===++===+ +===+
@@ -159,7 +159,7 @@ The table below provides a summary of the supported 
cryptographic services. It
 indicates if the family or service is deprecated or recommended to not be used.
 It also shows which *CryptLib library instances support the family or service.
 If a cell is blank then the service or family is always disabled and the
-`PcdCryptoServiceFamilyEnable` settings for that family or service is ignored.
+`PcdCryptoServiceFamilyEnable` setting for that family or service is ignored.
 If the cell is not blank, then the service or family is configurable using
 `PcdCryptoServiceFamilyEnable` as long as the correct Open

Re: [edk2-devel] 回复: [edk2-devel] [PATCH] ShellPkg:Improved Smbios Type 9 data under smbiosview

2022-11-04 Thread Sainadh Nagolu via groups.io
Hi Liming,

Created Pull request and passed CI check.

https://github.com/tianocore/edk2/pull/3593

Thanks,
Sainadh.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95951): https://edk2.groups.io/g/devel/message/95951
Mute This Topic: https://groups.io/mt/94797341/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-