Re: [edk2-devel] [Patch v2 21/28] UefiPayloadPkg: Add ProtectedVariable reference

2022-04-29 Thread Guo Dong


Reviewed-by: Guo Dong 

-Original Message-
From: Vang, Judah  
Sent: Friday, April 29, 2022 11:04 AM
To: devel@edk2.groups.io
Cc: Wang, Jian J ; Dong, Guo ; Ni, 
Ray ; Maurice Ma ; You, Benjamin 
; Rhodes, Sean ; Mistry, Nishant 
C 
Subject: [Patch v2 21/28] UefiPayloadPkg: Add ProtectedVariable reference

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

Add reference for ProtectedVariableLib so build is successful.

Cc: Jian J Wang 
Cc: Guo Dong 
Cc: Ray Ni 
Cc: Maurice Ma 
Cc: Benjamin You 
Cc: Sean Rhodes 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 UefiPayloadPkg/UefiPayloadPkg.dsc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc 
b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 17b30589e77c..fe835eed1bc7 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -263,9 +263,11 @@ [LibraryClasses]
   
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
 !if $(VARIABLE_SUPPORT) == "EMU"
   
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
+  
ProtectedVariableLib|MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariableLibNull.inf
 !elseif $(VARIABLE_SUPPORT) == "SPI"
   
PlatformSecureLib|SecurityPkg/Library/PlatformSecureLibNull/PlatformSecureLibNull.inf
   
TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
+  
ProtectedVariableLib|SecurityPkg/Library/ProtectedVariableLib/DxeProtectedVariableLib.inf
   
S3BootScriptLib|MdePkg/Library/BaseS3BootScriptLibNull/BaseS3BootScriptLibNull.inf
   
MmUnblockMemoryLib|MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf
 !endif
-- 
2.35.1.windows.2



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




[edk2-devel] [PATCH 1/1] WhitleyOpenBoardPkg/Build: Fix GCC build issues

2022-04-29 Thread Oram, Isaac W
Fix build warning in PlatformInfo.c.
Fix script invocation issues in build_board.py for AML
content build in WilsonCityRvp and JunctionCity.

Cc: Nate DeSimone 
Cc: Chasel Chiu 
Signed-off-by: Isaac Oram 
---
 .../WhitleyOpenBoardPkg/JunctionCity/build_board.py   | 11 ---
 .../Platform/Pei/PlatformInfo/PlatformInfo.c  |  4 ++--
 .../WhitleyOpenBoardPkg/WilsonCityRvp/build_board.py  | 11 ---
 3 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/Platform/Intel/WhitleyOpenBoardPkg/JunctionCity/build_board.py 
b/Platform/Intel/WhitleyOpenBoardPkg/JunctionCity/build_board.py
index 72d0c5089a..ccf7a8c55a 100644
--- a/Platform/Intel/WhitleyOpenBoardPkg/JunctionCity/build_board.py
+++ b/Platform/Intel/WhitleyOpenBoardPkg/JunctionCity/build_board.py
@@ -62,7 +62,8 @@ def pre_build_ex(config, functions):
 
 execute_script = functions.get("execute_script")
 
-command = ["build", "-D", "MAX_SOCKET=" + config["MAX_SOCKET"]]
+# AML offset arch is X64, not sure if it matters.
+command = ["build", "-a", "X64", "-t", config["TOOL_CHAIN_TAG"], "-D", 
"MAX_SOCKET=" + config["MAX_SOCKET"]]
 
 if config["EXT_BUILD_FLAGS"] and config["EXT_BUILD_FLAGS"] != "":
 ext_build_flags = config["EXT_BUILD_FLAGS"].split(" ")
@@ -79,7 +80,11 @@ def pre_build_ex(config, functions):
 command.append(os.path.join(config["WORKSPACE"], "PreBuildReport.txt"))
 command.append("--log=" + os.path.join(config["WORKSPACE"], 
"PreBuild.log"))
 
-_, _, _, code = execute_script(command, config)
+shell = True
+if os.name == "posix":  # linux
+shell = False
+
+_, _, _, code = execute_script(command, config, shell=shell)
 if code != 0:
 print(" ".join(command))
 print("Error re-generating PlatformOffset header files")
@@ -109,7 +114,7 @@ def pre_build_ex(config, functions):
os.path.join(config["BUILD_X64"], aml_offsets_split[0], 
aml_offsets_split[1], aml_offsets_split[1], "OUTPUT", 
os.path.dirname(relative_dsdt_file_path), dsdt_file_root_ext[0] + ".offset.h")]
 
 # execute the command
-_, _, _, code = execute_script(command, config)
+_, _, _, code = execute_script(command, config, shell=shell)
 if code != 0:
 print(" ".join(command))
 print("Error re-generating PlatformOffset header files")
diff --git 
a/Platform/Intel/WhitleyOpenBoardPkg/Platform/Pei/PlatformInfo/PlatformInfo.c 
b/Platform/Intel/WhitleyOpenBoardPkg/Platform/Pei/PlatformInfo/PlatformInfo.c
index 0065819d83..439ce357f1 100644
--- 
a/Platform/Intel/WhitleyOpenBoardPkg/Platform/Pei/PlatformInfo/PlatformInfo.c
+++ 
b/Platform/Intel/WhitleyOpenBoardPkg/Platform/Pei/PlatformInfo/PlatformInfo.c
@@ -413,8 +413,8 @@ PdrGetPlatformInfo (
 return Status;
   }
 
-  if ((PlatformInfoHob->BoardId >= TypePlatformMin) && 
(PlatformInfoHob->BoardId <= TypePlatformMax) ||
-  (PlatformInfoHob->BoardId >= TypePlatformVendorMin) && 
(PlatformInfoHob->BoardId <= TypePlatformVendorMax)) {
+  if (((PlatformInfoHob->BoardId >= TypePlatformMin) && 
(PlatformInfoHob->BoardId <= TypePlatformMax)) ||
+  ((PlatformInfoHob->BoardId >= TypePlatformVendorMin) && 
(PlatformInfoHob->BoardId <= TypePlatformVendorMax))) {
 //
 // Valid Platform Identified
 //
diff --git a/Platform/Intel/WhitleyOpenBoardPkg/WilsonCityRvp/build_board.py 
b/Platform/Intel/WhitleyOpenBoardPkg/WilsonCityRvp/build_board.py
index 5f625f5f92..e2d32d3e13 100644
--- a/Platform/Intel/WhitleyOpenBoardPkg/WilsonCityRvp/build_board.py
+++ b/Platform/Intel/WhitleyOpenBoardPkg/WilsonCityRvp/build_board.py
@@ -60,7 +60,8 @@ def pre_build_ex(config, functions):
 
 execute_script = functions.get("execute_script")
 
-command = ["build", "-D", "MAX_SOCKET=" + config["MAX_SOCKET"]]
+# AML offset arch is X64, not sure if it matters.
+command = ["build", "-a", "X64", "-t", config["TOOL_CHAIN_TAG"], "-D", 
"MAX_SOCKET=" + config["MAX_SOCKET"]]
 
 if config["EXT_BUILD_FLAGS"] and config["EXT_BUILD_FLAGS"] != "":
 ext_build_flags = config["EXT_BUILD_FLAGS"].split(" ")
@@ -77,7 +78,11 @@ def pre_build_ex(config, functions):
 command.append(os.path.join(config["WORKSPACE"], "PreBuildReport.txt"))
 command.append("--log=" + os.path.join(config["WORKSPACE"], 
"PreBuild.log"))
 
-_, _, _, code = execute_script(command, config)
+shell = True
+if os.name == "posix":  # linux
+shell = False
+
+_, _, _, code = execute_script(command, config, shell=shell)
 if code != 0:
 print(" ".join(command))
 print("Error re-generating PlatformOffset header files")
@@ -107,7 +112,7 @@ def pre_build_ex(config, functions):
os.path.join(config["BUILD_X64"], aml_offsets_split[0], 
aml_offsets_split[1], aml_offsets_split[1], "OUTPUT", 
os.path.dirname(relative_dsdt_file_path), dsdt_file_root_ext[0] + ".offset.h")]
 
 # execute the command
-_, _, _, code = execute_script(command, config)
+_, _, _, code = 

Re: [edk2-devel] [edk2-platforms][PATCH v1 1/1] IntelSiliconPkg/SpiFvbService: Add support for VariableFlashInfoLib

2022-04-29 Thread Michael Kubacki

Please help review this patch when possible.

Thanks,
Michael

On 4/22/2022 10:02 AM, Michael Kubacki wrote:

Reminder to review this patch.


On 4/18/2022 7:43 PM, Michael Kubacki wrote:

From: Michael Kubacki 

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

Adds support for getting the variable flash information from
VariableFlashInfoLib. This library abstracts the source of flash
information so platforms could expect the information to come
from a different source in the library implementation than the
PCDs previously used as the information source in this module.

In particular, the library allows Standalone MM platforms to
dynamically pass the information behind the library API.

Cc: Rangasai V Chaganty 
Cc: Ray Ni 
Cc: Nate DeSimone 
Signed-off-by: Michael Kubacki 
---

Notes:
 Depends on https://bugzilla.tianocore.org/show_bug.cgi?id=3479
 to complete

  
Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/FvbInfo.c 
| 120 +---
  
Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiFvbServiceCommon.c 
|  93 +--
  
Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiFvbServiceMm.c 
|  28 -
  
Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiFvbServiceCommon.h 
|  18 ++-
  
Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiFvbServiceSmm.inf  
|   6 +-
  
Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/SpiFvbServiceStandaloneMm.inf 
|   6 +-
  
Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dsc   
|   7 ++

  7 files changed, 215 insertions(+), 63 deletions(-)

diff --git 
a/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/FvbInfo.c 
b/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/FvbInfo.c

index 7f2678fa9e5a..5e78c1ce0c14 100644
--- a/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/FvbInfo.c
+++ b/Silicon/Intel/IntelSiliconPkg/Feature/Flash/SpiFvbService/FvbInfo.c
@@ -3,6 +3,7 @@
    These data is intent to decouple FVB driver with FV header.
  Copyright (c) 2017, Intel Corporation. All rights reserved.
+Copyright (c) Microsoft Corporation.
  SPDX-License-Identifier: BSD-2-Clause-Patent
  **/
@@ -11,51 +12,84 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
  #define FIRMWARE_BLOCK_SIZE 0x1
  #define FVB_MEDIA_BLOCK_SIZE    FIRMWARE_BLOCK_SIZE
-
-#define NV_STORAGE_BASE_ADDRESS 
FixedPcdGet32(PcdFlashNvStorageVariableBase)
-#define SYSTEM_NV_BLOCK_NUM 
((FixedPcdGet32(PcdFlashNvStorageVariableSize)+ 
FixedPcdGet32(PcdFlashNvStorageFtwWorkingSize) + 
FixedPcdGet32(PcdFlashNvStorageFtwSpareSize))/ FVB_MEDIA_BLOCK_SIZE)

-
  typedef struct {
    EFI_PHYSICAL_ADDRESS    BaseAddress;
    EFI_FIRMWARE_VOLUME_HEADER  FvbInfo;
    EFI_FV_BLOCK_MAP_ENTRY  End[1];
  } EFI_FVB2_MEDIA_INFO;
-//
-// This data structure contains a template of all correct FV headers, 
which is used to restore

-// Fv header if it's corrupted.
-//
-EFI_FVB2_MEDIA_INFO mPlatformFvbMediaInfo[] = {
-  //
-  // Systen NvStorage FVB
-  //
-  {
-    NV_STORAGE_BASE_ADDRESS,
-    {
-  {0,}, //ZeroVector[16]
-  EFI_SYSTEM_NV_DATA_FV_GUID,
-  FVB_MEDIA_BLOCK_SIZE * SYSTEM_NV_BLOCK_NUM,
-  EFI_FVH_SIGNATURE,
-  0x0004feff, // check MdePkg/Include/Pi/PiFirmwareVolume.h for 
details on EFI_FVB_ATTRIBUTES_2
-  sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof 
(EFI_FV_BLOCK_MAP_ENTRY),

-  0,    //CheckSum which will be calucated dynamically.
-  0,    //ExtHeaderOffset
-  {0,}, //Reserved[1]
-  2,    //Revision
-  {
-    {
-  SYSTEM_NV_BLOCK_NUM,
-  FVB_MEDIA_BLOCK_SIZE,
-    }
-  }
-    },
-    {
-  {
-    0,
-    0
-  }
-    }
+/**
+  Returns FVB media information for NV variable storage.
+
+  @return   FvbMediaInfo  A pointer to an instance of FVB 
media info produced by this function.
+  The buffer is allocated 
internally to this function and it is the caller's

+  responsibility to free the memory
+
+**/
+typedef
+EFI_STATUS
+(*FVB_MEDIA_INFO_GENERATOR)(
+  OUT EFI_FVB2_MEDIA_INFO *FvbMediaInfo
+  );
+
+/**
+  Returns FVB media information for NV variable storage.
+
+  @return   FvbMediaInfo  A pointer to an instance of FVB 
media info produced by this function.
+  The buffer is allocated 
internally to this function and it is the caller's

+  responsibility to free the memory
+
+**/
+EFI_STATUS
+GenerateNvStorageFvbMediaInfo (
+  OUT EFI_FVB2_MEDIA_INFO *FvbMediaInfo
+  )
+{
+  UINT32  NvBlockNum;
+  UINT32  TotalNvVariableStorageSize;
+  EFI_PHYSICAL_ADDRESS    NvStorageBaseAddress;
+  EFI_FIRMWARE_VOLUME_HEADER  FvbInfo = {
+  
{0,},   

Re: [edk2-devel] [edk2-platforms][PATCH v1 0/3] MinPlatformPkg: Add FADT duty offset and width PCDs

2022-04-29 Thread Michael Kubacki
Another reminder to merge this series. Chasel has added his review and 
that is in this branch:


https://github.com/makubacki/edk2-platforms/commits/active/add_duty_pcds_minplatformpkg_v1_rb1

Thanks,
Michael

On 4/22/2022 10:04 AM, Michael Kubacki wrote:

Reminder to review this series.

Ankit Sinha has reviewed it but need a maintainer to review and merge.

On 4/11/2022 4:58 PM, Michael Kubacki wrote:

From: Michael Kubacki 

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

Adds PCDs to the MinPlatformPkg DEC file so MinPlatformPkg consumers
(board packages) can customize the DUTY_OFFSET and DUTY_CYCLE
values in their build files.

The copy of AcpiPlatform in SimicsOpenBoardPkg is also updated to
keep the change in sync with the source MinPlatformPkg module.

Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Liming Gao 
Cc: Eric Dong 
Signed-off-by: Michael Kubacki 

Michael Kubacki (3):
   MinPlatformPkg: Add FADT duty offset and duty width PCDs
   MinPlatformPkg/AcpiPlatform: Use FADT duty offset and width PCDs
   SimicsOpenBoardPkg/AcpiPlatform: Use FADT duty offset and width PCDs

  
Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
|  3 +++
  
Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/Fadt/Fadt.c   
|  4 ++--
  
Platform/Intel/SimicsOpenBoardPkg/AcpiTables/MinPlatformAcpiTables/AcpiPlatform.c   
|  3 +++
  
Platform/Intel/SimicsOpenBoardPkg/AcpiTables/MinPlatformAcpiTables/Fadt/Fadt.c  
|  4 ++--
  
Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.inf  
|  2 ++
  
Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
| 15 +++
  
Platform/Intel/SimicsOpenBoardPkg/AcpiTables/MinPlatformAcpiTables/AcpiPlatform.inf 
|  2 ++

  7 files changed, 29 insertions(+), 4 deletions(-)




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




Re: [edk2-devel] [edk2-platforms][PATCH v1 10/10] PlatformStandaloneMmPkg: Add VariableFlashInfoLib

2022-04-29 Thread Ilias Apalodimas
Thanks for the patches

On Mon, 25 Apr 2022 at 19:06, Sami Mujawar  wrote:
>
> Hi Michael,
>
> Thank you for this patch.
>
> These changes look good to me.
>
> Reviewed-by: Sami Mujawar 
>
> Regards,
>
> Sami Mujawar
>
> On 20/04/2022 09:44 pm, mikub...@linux.microsoft.com wrote:
> > From: Michael Kubacki 
> >
> > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3479
> >
> > Adds an instance for the library class VariableFlashInfoLib that
> > was recently introduced in MdeModulePkg. This change is made to
> > allow the new variable driver to build that has a dependency on
> > this library class and does not require any further platform
> > changes.
> >
> > Cc: Sami Mujawar 
> > Cc: Ilias Apalodimas 
> > Signed-off-by: Michael Kubacki 
> > ---
> >   
> > Platform/StandaloneMm/PlatformStandaloneMmPkg/PlatformStandaloneMmRpmb.dsc 
> > | 1 +
> >   1 file changed, 1 insertion(+)
> >
> > diff --git 
> > a/Platform/StandaloneMm/PlatformStandaloneMmPkg/PlatformStandaloneMmRpmb.dsc
> >  
> > b/Platform/StandaloneMm/PlatformStandaloneMmPkg/PlatformStandaloneMmRpmb.dsc
> > index 33364deb1ef0..653029c52fdb 100644
> > --- 
> > a/Platform/StandaloneMm/PlatformStandaloneMmPkg/PlatformStandaloneMmRpmb.dsc
> > +++ 
> > b/Platform/StandaloneMm/PlatformStandaloneMmPkg/PlatformStandaloneMmRpmb.dsc
> > @@ -34,6 +34,7 @@ [LibraryClasses]
> > ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
> > BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
> > SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
> > +  
> > VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
> > 
> > VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
> > BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
> > 
> > DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf

Reviewed-by: Ilias Apalodimas 


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




[edk2-devel] [Patch v2 28/28] CryptoPkg: Enable cypto HMAC KDF library

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

RPMC confidentiality feature requires HMAC-SHA256 support during
SMM phase. This allows the protected variable's data to be
encrypted in the SPI flash.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Guomin Jiang 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
index ae75bc87b5e5..28ad0bf0816d 100644
--- a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
@@ -43,7 +43,7 @@ [Sources]
   Hash/CryptCShake256.c
   Hash/CryptParallelHash.c
   Hmac/CryptHmacSha256.c
-  Kdf/CryptHkdfNull.c
+  Kdf/CryptHkdf.c
   Cipher/CryptAes.c
   Pk/CryptRsaBasic.c
   Pk/CryptRsaExtNull.c
-- 
2.35.1.windows.2



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




[edk2-devel] [Patch v2 25/28] OvmfPkg: Add ProtectedVariableLib reference

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Add reference to null ProtectedVariableLib.

Cc: Jian J Wang 
Cc: Rebecca Cran 
Cc: Peter Grehan 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 OvmfPkg/Bhyve/BhyveX64.dsc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
index a8fa4d38ab60..5b36dc2358bb 100644
--- a/OvmfPkg/Bhyve/BhyveX64.dsc
+++ b/OvmfPkg/Bhyve/BhyveX64.dsc
@@ -1,6 +1,6 @@
 #
 #  Copyright (c) 2020, Rebecca Cran 
-#  Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 #  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 #  Copyright (c) 2014, Pluribus Networks, Inc.
 #
@@ -171,6 +171,7 @@ [LibraryClasses]
   MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf
   LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
   
MemEncryptTdxLib|OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf
+  
ProtectedVariableLib|MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariableLibNull.inf
 
   
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
   
FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
-- 
2.35.1.windows.2



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




[edk2-devel] [Patch v2 27/28] OvmfPkg: Add ProtectedVariable reference

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Add reference to null ProtectedVariableLib.

Cc: Jian J Wang 
Cc: Sebastien Boeuf 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 OvmfPkg/CloudHv/CloudHvX64.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc
index d1c85f60c768..3ec7e860c613 100644
--- a/OvmfPkg/CloudHv/CloudHvX64.dsc
+++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
@@ -180,6 +180,7 @@ [LibraryClasses]
   VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf
   LoadLinuxLib|OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf
   MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf
+  
ProtectedVariableLib|MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariableLibNull.inf
 !if $(SMM_REQUIRE) == FALSE
   LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
 !endif
-- 
2.35.1.windows.2



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




[edk2-devel] [Patch v2 24/28] OvmfPkg: Add ProtectedVariableLib reference

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Add reference to null ProtectedVariableLib.

Cc: Jian J Wang 
Cc: Jiewen Yao 
Cc: Min Xu 
Cc: Brijesh Singh 
Cc: Erdem Aktas 
Cc: James Bottomley 
Cc: Tom Lendacky 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 OvmfPkg/AmdSev/AmdSevX64.dsc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc
index f0700035c116..b0072f5fb0d3 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.dsc
+++ b/OvmfPkg/AmdSev/AmdSevX64.dsc
@@ -3,7 +3,7 @@
 #  virtual machine remote attestation and secret injection
 #
 #  Copyright (c) 2020 James Bottomley, IBM Corporation.
-#  Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 #  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -176,6 +176,7 @@ [LibraryClasses]
   
FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
   
BlobVerifierLib|OvmfPkg/AmdSev/BlobVerifierLibSevHashes/BlobVerifierLibSevHashes.inf
   
MemEncryptTdxLib|OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf
+  
ProtectedVariableLib|MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariableLibNull.inf
 
 !if $(SOURCE_DEBUG_ENABLE) == TRUE
   
PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf
-- 
2.35.1.windows.2



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




[edk2-devel] [Patch v2 26/28] OvmfPkg: Add ProtectedVariableLib reference

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Add reference to null ProtectedVariableLib.

Cc: Jian J Wang 
Cc: Gerd Hoffmann 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 OvmfPkg/Microvm/MicrovmX64.dsc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc
index 20c3c9c4d862..723be8ad345c 100644
--- a/OvmfPkg/Microvm/MicrovmX64.dsc
+++ b/OvmfPkg/Microvm/MicrovmX64.dsc
@@ -1,7 +1,7 @@
 ## @file
 #  EFI/Framework Open Virtual Machine Firmware (OVMF) platform
 #
-#  Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 #  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 #  Copyright (c) Microsoft Corporation.
 #
@@ -183,6 +183,7 @@ [LibraryClasses]
   
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
   
FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
   
MemEncryptTdxLib|OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf
+  
ProtectedVariableLib|MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariableLibNull.inf
 
 !if $(SOURCE_DEBUG_ENABLE) == TRUE
   
PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf
-- 
2.35.1.windows.2



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




[edk2-devel] [Patch v2 23/28] OvmfPkg: Add ProtectedVariable reference

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Add reference to null ProtectedVariableLib.

Cc: Jian J Wang 
Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Gerd Hoffmann 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 OvmfPkg/OvmfPkgIa32.dsc| 1 +
 OvmfPkg/OvmfPkgIa32X64.dsc | 1 +
 OvmfPkg/OvmfPkgX64.dsc | 1 +
 OvmfPkg/OvmfXen.dsc| 3 ++-
 4 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index f02b371f7427..358ad991a2dc 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -178,6 +178,7 @@ [LibraryClasses]
   LoadLinuxLib|OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf
   MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf
   
MemEncryptTdxLib|OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLibNull.inf
+  
ProtectedVariableLib|MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariableLibNull.inf
 !if $(SMM_REQUIRE) == FALSE
   LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
 !endif
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index cb68e612bd35..7e46d53061b1 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -182,6 +182,7 @@ [LibraryClasses]
   LoadLinuxLib|OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf
   MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf
   
MemEncryptTdxLib|OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLibNull.inf
+  
ProtectedVariableLib|MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariableLibNull.inf
 !if $(SMM_REQUIRE) == FALSE
   LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
 !endif
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 45ffa2dbe35f..32ebe045c03d 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -189,6 +189,7 @@ [LibraryClasses]
   LoadLinuxLib|OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf
   MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf
   
MemEncryptTdxLib|OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf
+  
ProtectedVariableLib|MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariableLibNull.inf
 
 !if $(SMM_REQUIRE) == FALSE
   LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc
index a1626d06dfc3..532a3e1b2027 100644
--- a/OvmfPkg/OvmfXen.dsc
+++ b/OvmfPkg/OvmfXen.dsc
@@ -1,7 +1,7 @@
 ## @file
 #  EFI/Framework Open Virtual Machine Firmware (OVMF) platform
 #
-#  Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 #  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 #  Copyright (c) 2019, Citrix Systems, Inc.
 #  Copyright (c) Microsoft Corporation.
@@ -218,6 +218,7 @@ [LibraryClasses]
 
   
Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.inf
   
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
+  
ProtectedVariableLib|MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariableLibNull.inf
   RealTimeClockLib|OvmfPkg/Library/XenRealTimeClockLib/XenRealTimeClockLib.inf
   TimeBaseLib|EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.inf
 !ifdef $(DEBUG_ON_HYPERVISOR_CONSOLE)
-- 
2.35.1.windows.2



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




[edk2-devel] [Patch v2 22/28] EmulatorPkg: Add ProtectedVariable reference

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Add reference to null ProtectedVariableLib.

Cc: Jian J Wang 
Cc: Andrew Fish 
Cc: Ray Ni 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 EmulatorPkg/EmulatorPkg.dsc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
index 554c13ddb500..4a6d50390db7 100644
--- a/EmulatorPkg/EmulatorPkg.dsc
+++ b/EmulatorPkg/EmulatorPkg.dsc
@@ -4,7 +4,7 @@
 # The Emulation Platform can be used to debug individual modules, prior to 
creating
 # a real platform. This also provides an example for how an DSC is created.
 #
-# Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 # Portions copyright (c) 2010 - 2011, Apple Inc. All rights reserved.
 # Copyright (c) Microsoft Corporation.
 #
@@ -119,6 +119,7 @@ [LibraryClasses]
   LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf
   
CpuExceptionHandlerLib|MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLibNull.inf
   
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
+  
ProtectedVariableLib|MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariableLibNull.inf
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
   
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLibRuntimeDxe.inf
   
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
-- 
2.35.1.windows.2



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




[edk2-devel] [Patch v2 20/28] ArmVirtPkg: Add reference to ProtectedVariableNull

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Need reference to ProtectVariableNullLib otherwise build fails.

Cc: Jian J Wang 
Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 ArmVirtPkg/ArmVirtQemu.dsc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index aa0ce61630f7..cdebd94a9fce 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -1,7 +1,7 @@
 #
 #  Copyright (c) 2011-2015, ARM Limited. All rights reserved.
 #  Copyright (c) 2014, Linaro Limited. All rights reserved.
-#  Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
+#  Copyright (c) 2015 - 2022, Intel Corporation. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -81,6 +81,7 @@ [LibraryClasses.common]
   PciSegmentLib|MdePkg/Library/BasePciSegmentLibPci/BasePciSegmentLibPci.inf
   PciHostBridgeLib|OvmfPkg/Fdt/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf
   
PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf
+  
ProtectedVariableLib|MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariableLibNull.inf
 
 !if $(TPM2_ENABLE) == TRUE
   Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
-- 
2.35.1.windows.2



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




[edk2-devel] [Patch v2 21/28] UefiPayloadPkg: Add ProtectedVariable reference

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Add reference for ProtectedVariableLib so build is successful.

Cc: Jian J Wang 
Cc: Guo Dong 
Cc: Ray Ni 
Cc: Maurice Ma 
Cc: Benjamin You 
Cc: Sean Rhodes 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 UefiPayloadPkg/UefiPayloadPkg.dsc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc 
b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 17b30589e77c..fe835eed1bc7 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -263,9 +263,11 @@ [LibraryClasses]
   
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
 !if $(VARIABLE_SUPPORT) == "EMU"
   
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
+  
ProtectedVariableLib|MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariableLibNull.inf
 !elseif $(VARIABLE_SUPPORT) == "SPI"
   
PlatformSecureLib|SecurityPkg/Library/PlatformSecureLibNull/PlatformSecureLibNull.inf
   
TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
+  
ProtectedVariableLib|SecurityPkg/Library/ProtectedVariableLib/DxeProtectedVariableLib.inf
   
S3BootScriptLib|MdePkg/Library/BaseS3BootScriptLibNull/BaseS3BootScriptLibNull.inf
   
MmUnblockMemoryLib|MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf
 !endif
-- 
2.35.1.windows.2



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




[edk2-devel] [Patch v2 18/28] MdeModulePkg: Reference Null ProtectedVariableLib

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Make reference to new Null ProtectVariableLib.
The null ProtectedVariableLib is used by default.

Cc: Jian J Wang 
Cc: Liming Gao 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 MdeModulePkg/MdeModulePkg.dsc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index b1d83461865e..6d9847c0cd34 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -2,7 +2,7 @@
 # EFI/PI Reference Module Package for All Architectures
 #
 # (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
-# Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.
 # Copyright (c) Microsoft Corporation.
 #
 #SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -103,6 +103,7 @@ [LibraryClasses]
   
DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdateProgressLibGraphics.inf
   
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
   
MmUnblockMemoryLib|MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf
+  
ProtectedVariableLib|MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariableLibNull.inf
 
 [LibraryClasses.EBC.PEIM]
   IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf
@@ -316,6 +317,7 @@ [Components]
   
MdeModulePkg/Library/PlatformBootManagerLibNull/PlatformBootManagerLibNull.inf
   MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
   MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
+  MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariableLibNull.inf
   MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
   MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
   MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLibRuntimeDxe.inf
-- 
2.35.1.windows.2



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




[edk2-devel] [Patch v2 19/28] SecurityPkg: Add references to new *.inf files

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Add references to the different *ProtectedVariableLib.inf.
Also add references to VariableKeyLibNull.inf,
EncryptionVariableLibNull.inf, ProtectedVariableNull.inf.

Cc: Jian J Wang 
Cc: Jiewen Yao 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 SecurityPkg/SecurityPkg.dsc | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc
index 73a93c2285b1..6d8318c6e4bf 100644
--- a/SecurityPkg/SecurityPkg.dsc
+++ b/SecurityPkg/SecurityPkg.dsc
@@ -1,7 +1,7 @@
 ## @file
 #  Security Module Package for All Architectures.
 #
-# Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2009 - 2022, Intel Corporation. All rights reserved.
 # (C) Copyright 2015-2020 Hewlett Packard Enterprise Development LP
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -66,8 +66,11 @@ [LibraryClasses]
   TcgStorageCoreLib|SecurityPkg/Library/TcgStorageCoreLib/TcgStorageCoreLib.inf
   TcgStorageOpalLib|SecurityPkg/Library/TcgStorageOpalLib/TcgStorageOpalLib.inf
   
ResetSystemLib|MdeModulePkg/Library/BaseResetSystemLibNull/BaseResetSystemLibNull.inf
+
+  # These should be Null by default
   VariableKeyLib|SecurityPkg/Library/VariableKeyLibNull/VariableKeyLibNull.inf
   RpmcLib|SecurityPkg/Library/RpmcLibNull/RpmcLibNull.inf
+  
EncryptionVariableLib|SecurityPkg/Library/EncryptionVariableLibNull/EncryptionVariableLibNull.inf
   
TcgEventLogRecordLib|SecurityPkg/Library/TcgEventLogRecordLib/TcgEventLogRecordLib.inf
   
MmUnblockMemoryLib|MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf
   
SecureBootVariableLib|SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.inf
@@ -251,8 +254,16 @@ [Components]
   #
   # Variable Confidentiality & Integrity
   #
+  SecurityPkg/Library/ProtectedVariableLib/PeiProtectedVariableLib.inf
+  SecurityPkg/Library/ProtectedVariableLib/DxeProtectedVariableLib.inf
+  SecurityPkg/Library/ProtectedVariableLib/SmmProtectedVariableLib.inf
+  SecurityPkg/Library/ProtectedVariableLib/SmmRuntimeProtectedVariableLib.inf
+  SecurityPkg/Library/EncryptionVariableLib/EncryptionVariableLib.inf
+  SecurityPkg/Library/VariableKeyLib/VariableKeyLib.inf
+
   SecurityPkg/Library/VariableKeyLibNull/VariableKeyLibNull.inf
   SecurityPkg/Library/RpmcLibNull/RpmcLibNull.inf
+  SecurityPkg/Library/EncryptionVariableLibNull/EncryptionVariableLibNull.inf
 
   #
   # Other
-- 
2.35.1.windows.2



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




[edk2-devel] [Patch v2 14/28] SecurityPkg: Add null encryption variable libs

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Provide null ecryption variable libraries.
These will be used by default for platforms that don't
support protected variable encryption.

Cc: Jian J Wang 
Cc: Jiewen Yao 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 SecurityPkg/Library/EncryptionVariableLibNull/EncryptionVariableLibNull.inf |  
38 +++
 SecurityPkg/Library/EncryptionVariableLibNull/EncryptionVariable.c  | 
107 
 SecurityPkg/Library/EncryptionVariableLibNull/EncryptionVariableLibNull.uni |  
16 +++
 3 files changed, 161 insertions(+)

diff --git 
a/SecurityPkg/Library/EncryptionVariableLibNull/EncryptionVariableLibNull.inf 
b/SecurityPkg/Library/EncryptionVariableLibNull/EncryptionVariableLibNull.inf
new file mode 100644
index ..ff5631b336eb
--- /dev/null
+++ 
b/SecurityPkg/Library/EncryptionVariableLibNull/EncryptionVariableLibNull.inf
@@ -0,0 +1,38 @@
+## @file
+#  Provides NULL version of encryption variable services.
+#
+#  Copyright (c) 2015 - 2022, Intel Corporation. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = EncryptionVariableLibNull
+  MODULE_UNI_FILE= EncryptionVariableLib.uni
+  FILE_GUID  = 3972E6FE-74D5-45C3-A9FB-DB9E5E5C9C17
+  MODULE_TYPE= BASE
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = EncryptionVariableLib
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES   = IA32 X64
+#
+
+[Sources]
+  EncryptionVariable.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  SecurityPkg/SecurityPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  DebugLib
+
+[Guids]
+
diff --git a/SecurityPkg/Library/EncryptionVariableLibNull/EncryptionVariable.c 
b/SecurityPkg/Library/EncryptionVariableLibNull/EncryptionVariable.c
new file mode 100644
index ..58a4ae9f4282
--- /dev/null
+++ b/SecurityPkg/Library/EncryptionVariableLibNull/EncryptionVariable.c
@@ -0,0 +1,107 @@
+/** @file
+  The common variable operation routines shared by DXE_RUNTIME variable
+  module and DXE_SMM variable module.
+
+  Caution: This module requires additional review when modified.
+  This driver will have external input - variable data. They may be input in 
SMM mode.
+  This external input must be validated carefully to avoid security issue like
+  buffer overflow, integer overflow.
+
+  VariableServiceGetNextVariableName () and VariableServiceQueryVariableInfo() 
are external API.
+  They need check input parameter.
+
+  VariableServiceGetVariable() and VariableServiceSetVariable() are external 
API
+  to receive datasize and data buffer. The size should be checked carefully.
+
+  VariableServiceSetVariable() should also check authenticate data to avoid 
buffer overflow,
+  integer overflow. It should also check attribute to avoid authentication 
bypass.
+
+Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+
+#include 
+#include 
+
+/**
+  Encrypt variable data.
+
+  Null version.
+
+  @param[in, out]   VarEncInfo   Pointer to structure containing detailed
+ information about a variable.
+
+  @retval EFI_UNSUPPORTED Unsupported to encrypt variable.
+
+**/
+EFI_STATUS
+EFIAPI
+EncryptVariable (
+  IN OUT VARIABLE_ENCRYPTION_INFO  *VarEncInfo
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+/**
+  Decrypt variable data.
+
+  Null version.
+
+  @param[in, out]   VarEncInfo   Pointer to structure containing detailed
+ information about a variable.
+
+  @retval EFI_UNSUPPORTED Unsupported to encrypt variable.
+
+**/
+EFI_STATUS
+EFIAPI
+DecryptVariable (
+  IN OUT VARIABLE_ENCRYPTION_INFO  *VarEncInfo
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+/**
+  Get cipher information.
+
+  Null version.
+
+  @param[in]   VarEncInfo   Pointer to structure containing detailed
+information about a variable.
+
+  @retval EFI_UNSUPPORTED Unsupported interface.
+
+**/
+EFI_STATUS
+EFIAPI
+GetCipherDataInfo (
+  IN VARIABLE_ENCRYPTION_INFO  *VarEncInfo
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+/**
+  Set cipher information for a variable.
+
+  Null version.
+
+  @param[in]   VarEncInfo   Pointer to structure containing detailed
+information about a variable.
+
+  @retval EFI_UNSUPPORTED If this method is not supported.
+
+**/
+EFI_STATUS
+EFIAPI
+SetCipherDataInfo (
+  IN VARIABLE_ENCRYPTION_INFO  *VarEncInfo
+  )
+{
+  return EFI_UNSUPPORTED;
+}
diff --git 
a/SecurityPkg/Library/EncryptionVariableLibNull/EncryptionVariableLibNull.uni 

[edk2-devel] [Patch v2 11/28] SecurityPkg: Update RPMC APIs with index

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Update RPMC APIs with index parameter because sometimes
there are more than 1 RPMC counter on the platform.

Cc: Jian J Wang 
Cc: Jiewen Yao 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 SecurityPkg/Library/RpmcLibNull/RpmcLibNull.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/SecurityPkg/Library/RpmcLibNull/RpmcLibNull.c 
b/SecurityPkg/Library/RpmcLibNull/RpmcLibNull.c
index 792e48250e5d..557aeb6abf09 100644
--- a/SecurityPkg/Library/RpmcLibNull/RpmcLibNull.c
+++ b/SecurityPkg/Library/RpmcLibNull/RpmcLibNull.c
@@ -1,7 +1,7 @@
 /** @file
   NULL RpmcLib instance for build purpose.
 
-Copyright (c) 2020, Intel Corporation. All rights reserved.
+Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -12,6 +12,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 /**
   Requests the monotonic counter from the designated RPMC counter.
 
+  @param[in]CounterIndexThe RPMC index
   @param[out]   CounterValueA pointer to a buffer to store the 
RPMC value.
 
   @retval   EFI_SUCCESS The operation completed successfully.
@@ -21,6 +22,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 EFI_STATUS
 EFIAPI
 RequestMonotonicCounter (
+  IN  UINT8   CounterIndex,
   OUT UINT32  *CounterValue
   )
 {
@@ -31,6 +33,8 @@ RequestMonotonicCounter (
 /**
   Increments the monotonic counter in the SPI flash device by 1.
 
+  @param[in]CounterIndexThe RPMC index
+
   @retval   EFI_SUCCESS The operation completed successfully.
   @retval   EFI_DEVICE_ERRORA device error occurred while 
attempting to update the counter.
   @retval   EFI_UNSUPPORTED The operation is un-supported.
@@ -38,7 +42,7 @@ RequestMonotonicCounter (
 EFI_STATUS
 EFIAPI
 IncrementMonotonicCounter (
-  VOID
+  IN  UINT8  CounterIndex
   )
 {
   ASSERT (FALSE);
-- 
2.35.1.windows.2



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




[edk2-devel] [Patch v2 10/28] SecurityPkg: Add new KeyService types and defines

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Add new KeyService types and defines.

Cc: Jian J Wang 
Cc: Jiewen Yao 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 SecurityPkg/Include/Ppi/KeyServicePpi.h | 57 
 1 file changed, 57 insertions(+)

diff --git a/SecurityPkg/Include/Ppi/KeyServicePpi.h 
b/SecurityPkg/Include/Ppi/KeyServicePpi.h
new file mode 100644
index ..f126913d2d81
--- /dev/null
+++ b/SecurityPkg/Include/Ppi/KeyServicePpi.h
@@ -0,0 +1,57 @@
+/** @file
+  Provides Key Services.
+
+Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+@par Specification Reference:
+**/
+
+#ifndef PEI_KEY_SERVICE_PPI_H_
+#define PEI_KEY_SERVICE_PPI_H_
+///
+/// KEY SERVICE PPI GUID
+///
+extern EFI_GUID  gKeyServicePpiGuid;
+
+/**
+  Generate a new key from root key.
+
+  @param[in]   Salt Pointer to the salt(non-secret) value.
+  @param[in]   SaltSize Salt size in bytes.
+  @param[out]  NewKey   Pointer to buffer to receive new key.
+  @param[in]   NewKeySize   Size of new key bytes to generate.
+
+  @retval EFI_SUCCESS   The function completed successfully
+  @retval OTHER The function completed with failure.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *KEY_SERVICE_GEN_KEY)(
+  IN   UINT8*Salt,
+  IN   UINTNSaltSize,
+  OUT  UINT8*NewKey,
+  IN   UINTNNewKeySize
+  );
+
+#define KEY_SERVICE_PPI_REVISION  1
+#define ROOT_KEY_LEN  64
+#define SALT_SIZE_MIN_LEN 64
+#define KEY_SERVICE_KEY_NAME  L"KEY_SERVICE_KEY"
+
+typedef struct {
+  UINT8RootKey[ROOT_KEY_LEN];
+  UINT8PreviousRootKey[ROOT_KEY_LEN];
+} KEY_SERVICE_DATA;
+
+typedef struct _KEY_SERVICE_PPI KEY_SERVICE_PPI;
+
+///
+/// KEY SERVICE PPI
+/// The interface functions are for Key Service in PEI Phase
+///
+struct _KEY_SERVICE_PPI {
+  KEY_SERVICE_GEN_KEYGenerateKey; /// Generate Key
+};
+
+#endif
-- 
2.35.1.windows.2



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




[edk2-devel] [Patch v2 13/28] SecurityPkg: Fix GetVariableKey API

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Fix GetVariableKey API to match changes in header files.

Cc: Jian J Wang 
Cc: Jiewen Yao 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 SecurityPkg/Library/VariableKeyLibNull/VariableKeyLibNull.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/SecurityPkg/Library/VariableKeyLibNull/VariableKeyLibNull.c 
b/SecurityPkg/Library/VariableKeyLibNull/VariableKeyLibNull.c
index a08def767b5f..cfbad54ba106 100644
--- a/SecurityPkg/Library/VariableKeyLibNull/VariableKeyLibNull.c
+++ b/SecurityPkg/Library/VariableKeyLibNull/VariableKeyLibNull.c
@@ -1,7 +1,7 @@
 /** @file
   Null version of VariableKeyLib for build purpose. Don't use it in real 
product.
 
-Copyright (c) 2020, Intel Corporation. All rights reserved.
+Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -22,8 +22,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 EFI_STATUS
 EFIAPI
 GetVariableKey (
-  OUT VOID   **VariableKey,
-  IN  OUT UINTN  *VariableKeySize
+  OUT VOID   *VariableKey,
+  IN  UINTN  VariableKeySize
   )
 {
   ASSERT (FALSE);
-- 
2.35.1.windows.2



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




[edk2-devel] [Patch v2 16/28] SecurityPkg: Add EncryptionVariable lib with AES

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Add encryption/decryption of protected variable functionality.
Add functions to get/set cipher data of a protected variable.
This is use for supporting confidentiality for protected
variables.

Cc: Jian J Wang 
Cc: Jiewen Yao 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 SecurityPkg/Library/EncryptionVariableLib/EncryptionVariableLib.inf |  43 ++
 SecurityPkg/Library/EncryptionVariableLib/EncryptionVariable.h  |  49 ++
 SecurityPkg/Library/EncryptionVariableLib/EncryptionVariable.c  | 728 

 3 files changed, 820 insertions(+)

diff --git 
a/SecurityPkg/Library/EncryptionVariableLib/EncryptionVariableLib.inf 
b/SecurityPkg/Library/EncryptionVariableLib/EncryptionVariableLib.inf
new file mode 100644
index ..7ece52f2fb58
--- /dev/null
+++ b/SecurityPkg/Library/EncryptionVariableLib/EncryptionVariableLib.inf
@@ -0,0 +1,43 @@
+## @file
+#  Provides variable encryption/decryption services.
+#
+#  Copyright (c) 2022, Intel Corporation. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010029
+  BASE_NAME  = EncryptionVariableLib
+  FILE_GUID  = 459E2CB0-AF4B-4415-B6A1-335E71FD8B85
+  MODULE_TYPE= BASE
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = EncryptionVariableLib
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES   = IA32 X64
+#
+
+[Sources]
+  EncryptionVariable.c
+  EncryptionVariable.h
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  SecurityPkg/SecurityPkg.dec
+  CryptoPkg/CryptoPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  DebugLib
+  MemoryAllocationLib
+  BaseCryptLib
+
+[Guids]
+  gEfiVariableGuid
+  gEfiAuthenticatedVariableGuid
diff --git a/SecurityPkg/Library/EncryptionVariableLib/EncryptionVariable.h 
b/SecurityPkg/Library/EncryptionVariableLib/EncryptionVariable.h
new file mode 100644
index ..f35f9f9e3ad7
--- /dev/null
+++ b/SecurityPkg/Library/EncryptionVariableLib/EncryptionVariable.h
@@ -0,0 +1,49 @@
+/** @file
+  Definitions used by this library implementation.
+
+Copyright (c) 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef ENCRYPTION_VARIABLE_H_
+#define ENCRYPTION_VARIABLE_H_
+
+#define ENC_KEY_SEPL":"
+#define ENC_KEY_SEP_SIZE   2
+#define ENC_KEY_NAME   L"VAR_ENC_KEY"
+#define ENC_KEY_NAME_SIZE  22
+
+#define ENC_KEY_SIZE(256/8)
+#define ENC_BLOCK_SIZE  AES_BLOCK_SIZE
+#define ENC_IVEC_SIZE   ENC_BLOCK_SIZE
+
+#define ENC_PADDING_BYTE  0x0F
+
+//
+// PKCS#5 padding
+//
+// #define AES_CIPHER_DATA_SIZE(PlainDataSize)
+//  (AES_BLOCK_SIZE + (PlainDataSize)) & (~(AES_BLOCK_SIZE - 1))
+//
+#define AES_CIPHER_DATA_SIZE(PlainDataSize)  ALIGN_VALUE (PlainDataSize, 
AES_BLOCK_SIZE)
+
+#define FREE_POOL(Address)  \
+if ((Address) != NULL) {\
+  FreePool (Address);   \
+  (Address) = NULL; \
+}
+
+#pragma pack(1)
+
+typedef struct {
+  UINT32DataType; // SYM_TYPE_AES
+  UINT32HeaderSize;   // sizeof(VARIABLE_ENCRYPTION_HEADER)
+  UINT32PlainDataSize;// Plain data size
+  UINT32CipherDataSize;   // Cipher data size
+  UINT8 KeyIvec[ENC_IVEC_SIZE];
+} VARIABLE_ENCRYPTION_HEADER;
+
+#pragma pack()
+
+#endif // _ENCRYPTION_VARIABLE_H_
diff --git a/SecurityPkg/Library/EncryptionVariableLib/EncryptionVariable.c 
b/SecurityPkg/Library/EncryptionVariableLib/EncryptionVariable.c
new file mode 100644
index ..58ffb09e0373
--- /dev/null
+++ b/SecurityPkg/Library/EncryptionVariableLib/EncryptionVariable.c
@@ -0,0 +1,728 @@
+/** @file
+  Implementation of EncryptionVariableLib with AES algorithm support.
+
+Copyright (c) 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "EncryptionVariable.h"
+
+/**
+  Derive encryption key for given variable from variable root key.
+
+  The derivation algorithm is depicted below
+
+HKDF_Expand(SHA256, RootKey, Name||':'||Guid||':'||Attr||"VAR_ENC_KEY")
+
+  @param[in]VarEncInfoPointer to structure containing detailed
+  information about a variable.
+  @param[in]EncKeySizeSize of key requested.
+  @param[out]   EncKeyBuffer of key.
+
+  @retval TRUEThe key was derived successfully.
+  @retval FALSE   Failed to generate encryption key.
+
+**/
+STATIC
+BOOLEAN
+EncVarLibGenEncKey (
+  IN VARIABLE_ENCRYPTION_INFO  *VarEncInfo,
+  IN UINTN EncKeySize,
+  OUT UINT8*EncKey
+  )
+{
+  BOOLEAN  Status;
+
+  struct {
+VOID 

[edk2-devel] [Patch v2 12/28] SecurityPkg: Add new variable types and functions

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Add new variable encryption/decryption function prototypes.
Add new variable digest structure. Add new Protected
variable function prototypes. Update RPMC APIs to Add
an index because there is could more than one counter.

Cc: Jian J Wang 
Cc: Jiewen Yao 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 SecurityPkg/Include/Library/RpmcLib.h| 15 +---
 SecurityPkg/Include/Library/VariableKeyLib.h | 37 +++-
 2 files changed, 16 insertions(+), 36 deletions(-)

diff --git a/SecurityPkg/Include/Library/RpmcLib.h 
b/SecurityPkg/Include/Library/RpmcLib.h
index df4ba34ba8cf..cb71dfcd7e4d 100644
--- a/SecurityPkg/Include/Library/RpmcLib.h
+++ b/SecurityPkg/Include/Library/RpmcLib.h
@@ -1,19 +1,23 @@
 /** @file
   Public definitions for the Replay Protected Monotonic Counter (RPMC) Library.
 
-Copyright (c) 2020, Intel Corporation. All rights reserved.
+Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
 
-#ifndef _RPMC_LIB_H_
-#define _RPMC_LIB_H_
+#ifndef RPMC_LIB_H_
+#define RPMC_LIB_H_
 
 #include 
 
+#define RPMC_COUNTER_1  0
+#define RPMC_COUNTER_2  1
+
 /**
   Requests the monotonic counter from the designated RPMC counter.
 
+  @param[in]CounterIndexThe RPMC index
   @param[out]   CounterValueA pointer to a buffer to store the 
RPMC value.
 
   @retval   EFI_SUCCESS The operation completed successfully.
@@ -23,12 +27,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 EFI_STATUS
 EFIAPI
 RequestMonotonicCounter (
+  IN  UINT8   CounterIndex,
   OUT UINT32  *CounterValue
   );
 
 /**
   Increments the monotonic counter in the SPI flash device by 1.
 
+  @param[in]CounterIndexThe RPMC index
+
   @retval   EFI_SUCCESS The operation completed successfully.
   @retval   EFI_DEVICE_ERRORA device error occurred while 
attempting to update the counter.
   @retval   EFI_UNSUPPORTED The operation is un-supported.
@@ -36,7 +43,7 @@ RequestMonotonicCounter (
 EFI_STATUS
 EFIAPI
 IncrementMonotonicCounter (
-  VOID
+  IN  UINT8  CounterIndex
   );
 
 #endif
diff --git a/SecurityPkg/Include/Library/VariableKeyLib.h 
b/SecurityPkg/Include/Library/VariableKeyLib.h
index 561ebad09da2..6076c4d4731b 100644
--- a/SecurityPkg/Include/Library/VariableKeyLib.h
+++ b/SecurityPkg/Include/Library/VariableKeyLib.h
@@ -1,13 +1,13 @@
 /** @file
   Public definitions for Variable Key Library.
 
-Copyright (c) 2020, Intel Corporation. All rights reserved.
+Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
 
-#ifndef _VARIABLE_KEY_LIB_H_
-#define _VARIABLE_KEY_LIB_H_
+#ifndef VARIABLE_KEY_LIB_H_
+#define VARIABLE_KEY_LIB_H_
 
 #include 
 
@@ -25,35 +25,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 EFI_STATUS
 EFIAPI
 GetVariableKey (
-  OUT VOID   **VariableKey,
-  IN  OUT UINTN  *VariableKeySize
-  );
-
-/**
-  Regenerates the variable key.
-
-  @retval   EFI_SUCCESS The variable key was regenerated 
successfully.
-  @retval   EFI_DEVICE_ERRORAn error occurred while attempting to 
regenerate the key.
-  @retval   EFI_ACCESS_DENIED   The function was invoked after locking 
the key interface.
-  @retval   EFI_UNSUPPORTED Key regeneration is not supported in 
the current boot configuration.
-**/
-EFI_STATUS
-EFIAPI
-RegenerateVariableKey (
-  VOID
-  );
-
-/**
-  Locks the regenerate key interface.
-
-  @retval   EFI_SUCCESS The key interface was locked 
successfully.
-  @retval   EFI_UNSUPPORTED Locking the key interface is not 
supported in the current boot configuration.
-  @retval   Others  An error occurred while attempting to 
lock the key interface.
-**/
-EFI_STATUS
-EFIAPI
-LockVariableKeyInterface (
-  VOID
+  OUT VOID   *VariableKey,
+  IN  UINTN  VariableKeySize
   );
 
 #endif
-- 
2.35.1.windows.2



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




[edk2-devel] [Patch v2 15/28] SecurityPkg: Add VariableKey library function

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Provide function that retrieves the key for protected
variables.

Cc: Jian J Wang 
Cc: Jiewen Yao 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 SecurityPkg/Library/VariableKeyLib/VariableKeyLib.inf | 36 
 SecurityPkg/Library/VariableKeyLib/VariableKeyLib.c   | 59 
 2 files changed, 95 insertions(+)

diff --git a/SecurityPkg/Library/VariableKeyLib/VariableKeyLib.inf 
b/SecurityPkg/Library/VariableKeyLib/VariableKeyLib.inf
new file mode 100644
index ..f62c80ce9943
--- /dev/null
+++ b/SecurityPkg/Library/VariableKeyLib/VariableKeyLib.inf
@@ -0,0 +1,36 @@
+## @file
+#  Provides default implementation of VariableKeyLib.
+#
+#  Copyright (c) 2022, Intel Corporation. All rights reserved.
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010029
+  BASE_NAME  = VariableKeyLib
+  FILE_GUID  = 7DF5A0BA-1DBB-4E67-A9F7-9FCCB1F9D250
+  MODULE_TYPE= BASE
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = VariableKeyLib
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES   = IA32 X64 Arm AArch64
+#
+
+[Sources]
+  VariableKeyLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  SecurityPkg/SecurityPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  DebugLib
+
+[PpiS]
+  gKeyServicePpiGuid ## CONSUMES
+
diff --git a/SecurityPkg/Library/VariableKeyLib/VariableKeyLib.c 
b/SecurityPkg/Library/VariableKeyLib/VariableKeyLib.c
new file mode 100644
index ..31b22782cb0c
--- /dev/null
+++ b/SecurityPkg/Library/VariableKeyLib/VariableKeyLib.c
@@ -0,0 +1,59 @@
+/** @file
+  VariableKeyLib implementation.
+
+Copyright (c) 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+
+#define VAR_KEY_SALT   L"Key for RPMC Variable"
+#define VAR_KEY_SALT_SIZE  sizeof (VAR_KEY_SALT)
+
+/**
+  Retrieves the key for integrity and/or confidentiality of variables.
+
+  @param[out] VariableKey A pointer to pointer for the variable 
key buffer.
+  @param[in]  VariableKeySize The size in bytes of the variable key.
+
+  @retval   EFI_SUCCESS The variable key was returned.
+  @retval   EFI_DEVICE_ERRORAn error occurred while attempting to 
get the variable key.
+  @retval   EFI_ACCESS_DENIED   The function was invoked after locking 
the key interface.
+  @retval   EFI_UNSUPPORTED The variable key is not supported in 
the current boot configuration.
+**/
+EFI_STATUS
+EFIAPI
+GetVariableKey (
+  OUT VOID   *VariableKey,
+  IN  UINTN  VariableKeySize
+  )
+{
+  EFI_STATUS   Status;
+  KEY_SERVICE_PPI  *KeyService;
+
+  Status = PeiServicesLocatePpi (
+ ,
+ 0,
+ NULL,
+ (void **)
+ );
+  if (EFI_ERROR (Status)) {
+ASSERT_EFI_ERROR (Status);
+return Status;
+  }
+
+  Status = KeyService->GenerateKey (
+ (UINT8 *)VAR_KEY_SALT,
+ VAR_KEY_SALT_SIZE,
+ VariableKey,
+ VariableKeySize
+ );
+  return Status;
+}
-- 
2.35.1.windows.2



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




[edk2-devel] [Patch v2 08/28] MdeModulePkg: Add new Variable functionality

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Provide new APIs for retrieving variable information.
Add new function stubs for retrieving Protected
variable information.

Cc: Jian J Wang 
Cc: Liming Gao 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 MdeModulePkg/Universal/Variable/Pei/VariablePei.inf   |  10 +-
 MdeModulePkg/Universal/Variable/Pei/Variable.h|  80 +-
 MdeModulePkg/Universal/Variable/Pei/VariableParsing.h | 309 +++
 MdeModulePkg/Universal/Variable/Pei/VariableStore.h   | 116 +++
 MdeModulePkg/Universal/Variable/Pei/Variable.c| 886 +++---
 MdeModulePkg/Universal/Variable/Pei/VariableParsing.c | 941 

 MdeModulePkg/Universal/Variable/Pei/VariableStore.c   | 305 +++
 7 files changed, 1891 insertions(+), 756 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/Pei/VariablePei.inf 
b/MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
index 7cbdd2385e8f..af172126a011 100644
--- a/MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
+++ b/MdeModulePkg/Universal/Variable/Pei/VariablePei.inf
@@ -3,7 +3,7 @@
 #
 #  This module implements ReadOnly Variable Services required by PEIM and 
installs PEI ReadOnly Varaiable2 PPI.
 #
-#  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 ##
@@ -26,6 +26,10 @@ [Defines]
 [Sources]
   Variable.c
   Variable.h
+  VariableStore.c
+  VariableStore.h
+  VariableParsing.c
+  VariableParsing.h
 
 [Packages]
   MdePkg/MdePkg.dec
@@ -39,6 +43,7 @@ [LibraryClasses]
   DebugLib
   PeiServicesTablePointerLib
   PeiServicesLib
+  ProtectedVariableLib
 
 [Guids]
   ## CONSUMES ## GUID # Variable store header
@@ -56,7 +61,8 @@ [Guids]
   gEdkiiFaultTolerantWriteGuid
 
 [Ppis]
-  gEfiPeiReadOnlyVariable2PpiGuid   ## PRODUCES
+  gEfiPeiReadOnlyVariable2PpiGuid## PRODUCES
+  gEfiPeiVariableStoreDiscoveredPpiGuid  ## CONSUMES
 
 [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase  ## 
SOMETIMES_CONSUMES
diff --git a/MdeModulePkg/Universal/Variable/Pei/Variable.h 
b/MdeModulePkg/Universal/Variable/Pei/Variable.h
index 7f9ad5bfc357..115426edd626 100644
--- a/MdeModulePkg/Universal/Variable/Pei/Variable.h
+++ b/MdeModulePkg/Universal/Variable/Pei/Variable.h
@@ -2,7 +2,7 @@
   The internal header file includes the common header files, defines
   internal structure and functions used by PeiVariable module.
 
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -20,11 +20,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 typedef enum {
   VariableStoreTypeHob,
@@ -142,4 +144,80 @@ PeiGetNextVariableName (
   IN OUT EFI_GUID*VariableGuid
   );
 
+/**
+  This service retrieves a variable's value using its name and GUID.
+
+  Read the specified variable from the UEFI variable store. If the Data
+  buffer is too small to hold the contents of the variable, the error
+  EFI_BUFFER_TOO_SMALL is returned and DataSize is set to the required buffer
+  size to obtain the data.
+
+  @param  This  A pointer to this instance of the 
EFI_PEI_READ_ONLY_VARIABLE2_PPI.
+  @param  VariableName  A pointer to a null-terminated string that is 
the variable's name.
+  @param  VariableGuid  A pointer to an EFI_GUID that is the 
variable's GUID. The combination of
+VariableGuid and VariableName must be unique.
+  @param  AttributesIf non-NULL, on return, points to the 
variable's attributes.
+  @param  DataSize  On entry, points to the size in bytes of the 
Data buffer.
+On return, points to the size of the data 
returned in Data.
+  @param  Data  Points to the buffer which will hold the 
returned variable value.
+May be NULL with a zero DataSize in order to 
determine the size of the buffer needed.
+
+  @retval EFI_SUCCESS   The variable was read successfully.
+  @retval EFI_NOT_FOUND The variable was not found.
+  @retval EFI_BUFFER_TOO_SMALL  The DataSize is too small for the resulting 
data.
+DataSize is updated with the size required for
+the specified variable.
+  @retval EFI_INVALID_PARAMETER VariableName, VariableGuid, DataSize or Data 
is NULL.
+  @retval EFI_DEVICE_ERROR  The variable could not be retrieved because of 
a device error.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiGetVariableEx (
+  IN CONST  EFI_PEI_READ_ONLY_VARIABLE2_PPI  *This,
+  IN CONST  CHAR16   

[edk2-devel] [Patch v2 07/28] MdeModulePkg: Add Null ProtectedVariable Library

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Add Null versions of the ProtectedVariable Library.
This will be the default libraries for platforms that
do not support ProtectedVariable.

Cc: Jian J Wang 
Cc: Liming Gao 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariableLibNull.inf |  
34 ++
 MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariable.c  | 
449 
 2 files changed, 483 insertions(+)

diff --git 
a/MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariableLibNull.inf 
b/MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariableLibNull.inf
new file mode 100644
index ..6a17191c4e1e
--- /dev/null
+++ b/MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariableLibNull.inf
@@ -0,0 +1,34 @@
+## @file
+#  Provides null version of protected variable services.
+#
+#  Copyright (c) 2022, Intel Corporation. All rights reserved.
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010029
+  BASE_NAME  = ProtectedVariableLibNull
+  FILE_GUID  = 352C6A1B-403A-4E37-8517-FAA50BC45251
+  MODULE_TYPE= BASE
+  VERSION_STRING = 0.1
+  LIBRARY_CLASS  = ProtectedVariableLib
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES   = IA32 X64
+#
+
+[Sources]
+  ProtectedVariable.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  DebugLib
+
diff --git a/MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariable.c 
b/MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariable.c
new file mode 100644
index ..cc1e16c1a671
--- /dev/null
+++ b/MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariable.c
@@ -0,0 +1,449 @@
+/** @file
+  NULL version of ProtectedVariableLib used to disable protected variable 
services.
+
+Copyright (c) 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+/**
+
+  Initialization for protected varibale services.
+
+  @param[in]  ContextIn   Pointer to variable service context needed by
+  protected variable.
+
+  @retval EFI_UNSUPPORTED   Unsupported to process protected variable.
+
+**/
+EFI_STATUS
+EFIAPI
+ProtectedVariableLibInitialize (
+  IN  PROTECTED_VARIABLE_CONTEXT_IN  *ContextIn
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+/**
+
+  Get a verified copy of NV variable storage.
+
+  @param[out] VariableFvHeader  Pointer to the header of whole NV 
firmware volume.
+  @param[out] VariableStoreHeader   Pointer to the header of variable 
storage.
+
+  @retval EFI_UNSUPPORTED   Unsupported to process protected variable.
+
+**/
+EFI_STATUS
+EFIAPI
+ProtectedVariableLibGetStore (
+  OUT EFI_FIRMWARE_VOLUME_HEADER  **VariableFvHeader,
+  OUT VARIABLE_STORE_HEADER   **VariableStoreHeader
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+/**
+
+  Prepare for variable update.
+
+  @retval EFI_UNSUPPORTED   Unsupported to process protected variable.
+
+**/
+EFI_STATUS
+EFIAPI
+ProtectedVariableLibWriteInit (
+  VOID
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+/**
+
+  Update a variable with protection provided by this library.
+
+  @param[in,out]  CurrVariableVariable to be updated. It's NULL if
+  adding a new variable.
+  @param[in]  CurrVariableInDel   In-delete-transiion copy of updating 
variable.
+  @param[in,out]  NewVariable Buffer of new variable data.
+  Buffer of "MetaDataHmacVar" and new
+  variable (encrypted).
+  @param[in,out]  NewVariableSize Size of NewVariable.
+  Size of (encrypted) NewVariable and
+  "MetaDataHmacVar".
+
+  @retval EFI_UNSUPPORTED   Unsupported to process protected variable.
+
+**/
+EFI_STATUS
+EFIAPI
+ProtectedVariableLibUpdate (
+  IN  OUT VARIABLE_HEADER  *CurrVariable,
+  IN  VARIABLE_HEADER  *CurrVariableInDel,
+  IN  OUT VARIABLE_HEADER  *NewVariable,
+  IN  OUT UINTN*NewVariableSize
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+/**
+
+  Finalize a variable updating after it's written to NV variable storage
+  successfully.
+
+  @param[in]  NewVariable   Buffer of new variables and 
MetaDataHmacVar.
+  @param[in]  VariableSize  Size of buffer pointed by NewVariable.
+  @param[in]  StoreIndexNew index of the variable in store.
+
+  @retval EFI_UNSUPPORTED   Unsupported to process protected variable.
+
+**/
+EFI_STATUS
+EFIAPI

[edk2-devel] [Patch v2 06/28] MdeModulePkg: Add new include files

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Add EncryptionVariableLib.h for providing encryption and
decryption services for protected variables.
Add ProtectedVariableLib.h for providing integrity or
variables.

Cc: Jian J Wang 
Cc: Liming Gao 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 MdeModulePkg/Include/Library/EncryptionVariableLib.h | 165 +
 MdeModulePkg/Include/Library/ProtectedVariableLib.h  | 700 
 2 files changed, 865 insertions(+)

diff --git a/MdeModulePkg/Include/Library/EncryptionVariableLib.h 
b/MdeModulePkg/Include/Library/EncryptionVariableLib.h
new file mode 100644
index ..c7740e659dcf
--- /dev/null
+++ b/MdeModulePkg/Include/Library/EncryptionVariableLib.h
@@ -0,0 +1,165 @@
+/** @file
+  Provides services to encrypt/decrypt variables.
+
+Copyright (c) 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef ENCRYPTION_VARIABLE_LIB_H_
+#define ENCRYPTION_VARIABLE_LIB_H_
+
+#include 
+
+#include 
+
+#include 
+
+#define ENC_TYPE_NULL  0
+#define ENC_TYPE_AES   TPM_ALG_AES
+
+typedef struct  _VARIABLE_ENCRYPTION_FLAGS {
+  BOOLEANAuth;// Variable is authenticated or not
+  BOOLEANDecryptInPlace;  // Do decryption in place
+  BOOLEANProtected;   // Variable is protected or not
+} VARIABLE_ENCRYPTION_FLAGS;
+
+typedef struct _VARIABLE_ENCRYPTION_INFO {
+  AUTH_VARIABLE_INFO   Header;// Authenticated varabile 
header
+  VARIABLE_HEADER  *Buffer;   // Pointer to variable buffer
+  UINT64   StoreIndex;// Variable store index
+  VOID *PlainData;// Pointer to plain data
+  UINT32   PlainDataSize; // Size of plain data
+  VOID *CipherData;   // Pointer to cipher data
+  UINT32   CipherDataSize;// Size of cipher data
+  UINT32   CipherHeaderSize;  // Size of cipher header
+  UINT32   CipherDataType;// Type of cipher data
+  VOID *Key;  // Pointer to 
encrypt/decrypt key
+  UINT32   KeySize;   // Size of key
+  VARIABLE_ENCRYPTION_FLAGSFlags; // Encryption flags
+} VARIABLE_ENCRYPTION_INFO;
+
+/**
+  Encrypt variable data.
+
+  @param[in, out]   VarInfo   Pointer to structure containing detailed 
information about a variable.
+
+  @retval EFI_SUCCESS   Function successfully executed.
+  @retval EFI_INVALID_PARAMETER If ProtectedVarLibContextIn == NULL or 
ProtectedVarLibContextOut == NULL.
+  @retval EFI_OUT_OF_RESOURCES  Fail to allocate enough resource.
+  @retval EFI_UNSUPPORTED   Unsupported to process authenticated 
variable.
+
+**/
+EFI_STATUS
+EFIAPI
+EncryptVariable (
+  IN OUT VARIABLE_ENCRYPTION_INFO  *VarInfo
+  );
+
+/**
+  Decrypt variable data.
+
+  If VarEncInfo->CipherData is not NULL, it must holds the cipher data to be
+  decrypted. Otherwise, assume the cipher data from variable data buffer, i.e.
+  VarEncInfo->Header.Data.
+
+  If VarEncInfo->Flags.DecryptInPlace is TRUE, the decrypted data will be put
+  back in the same buffer as cipher buffer got above, after encryption header,
+  which helps to identify later if the data in buffer is decrypted or not. This
+  can avoid repeat decryption when accessing the same variable more than once.
+
+  If VarEncInfo->Flags.DecryptInPlace is FALSE, VarEncInfo->PlainData must be
+  passed in with a valid buffer with VarEncInfo->PlainDataSize set correctly
+  with its size.
+
+  Note the VarEncInfo->PlainData is always pointing to the buffer address with
+  decrypted data without encryption header, and VarEncInfo->PlainDataSize is
+  always the size of original variable data, if this function returned
+  successfully.
+
+  @param[in, out]   VarInfo   Pointer to structure containing detailed
+  information about a variable.
+
+  @retval EFI_SUCCESS Variable was decrypted successfully.
+  @retval EFI_INVALID_PARAMETER   Variable information in VarEncInfo is 
invalid.
+  @retval EFI_BUFFER_TOO_SMALLVarEncInfo->PlainData is not NULL but
+  VarEncInfo->PlainDataSize is too small.
+  @retval EFI_ABORTED Uknown error occurred during decrypting.
+  @retval EFI_OUT_OF_RESOURCESFail to allocate enough resource.
+  @retval EFI_COMPROMISED_DATAThe cipher header is not valid.
+  @retval EFI_UNSUPPORTED Unsupported to encrypt variable.
+
+**/
+EFI_STATUS
+EFIAPI
+DecryptVariable (
+  IN OUT VARIABLE_ENCRYPTION_INFO  *VarInfo
+  );
+
+/**
+  Get cipher information about a variable, including plaindata size,
+  cipher algorithm type, etc.
+
+  For data passed in with VarEncInfo,
+
+VarEncInfo->Header.Data
+  - The variable 

[edk2-devel] [Patch v2 05/28] MdeModulePkg: Add new ProtectedVariable GUIDs

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

New ProtectVariable GUIDs for passing variable information
from PEI phase to SMM phase.

Cc: Jian J Wang 
Cc: Liming Gao 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 MdeModulePkg/Include/Guid/ProtectedVariable.h | 22 
 1 file changed, 22 insertions(+)

diff --git a/MdeModulePkg/Include/Guid/ProtectedVariable.h 
b/MdeModulePkg/Include/Guid/ProtectedVariable.h
new file mode 100644
index ..0c6e19e0456b
--- /dev/null
+++ b/MdeModulePkg/Include/Guid/ProtectedVariable.h
@@ -0,0 +1,22 @@
+/** @file
+  The GUID definitions specific for protected variable services.
+
+Copyright (c) 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef PROTECTED_VARIABLE_H_
+#define PROTECTED_VARIABLE_H_
+
+#define EDKII_PROTECTED_VARIABLE_GLOBAL_GUID \
+  { 0x8ebf379a, 0xf18e, 0x4728, { 0xa4, 0x10, 0x0, 0xcf, 0x9a, 0x65, 0xbe, 
0x91 } }
+
+#define EDKII_METADATA_HMAC_VARIABLE_GUID \
+  { 0xb54cda50, 0xec54, 0x4b20, { 0x85, 0xb4, 0x57, 0xbf, 0x52, 0x98, 0x68, 
0x3d } }
+
+extern EFI_GUID  gEdkiiProtectedVariableGlobalGuid;
+extern EFI_GUID  gEdkiiMetaDataHmacVariableGuid;
+extern EFI_GUID  gEdkiiProtectedVariableContextGuid;
+
+#endif // __PROTECTED_VARIABLE_H__
-- 
2.35.1.windows.2



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




[edk2-devel] [Patch v2 04/28] MdeModulePkg: Add reference to new Ppi Guid

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Add reference to gEfiPeiVariableStoreDiscoveredPpiGuid which
contains information whether variable store is available.

Cc: Jian J Wang 
Cc: Liming Gao 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 MdePkg/Include/Ppi/ReadOnlyVariable2.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Include/Ppi/ReadOnlyVariable2.h 
b/MdePkg/Include/Ppi/ReadOnlyVariable2.h
index 926c0bc82a43..c5a8470565bb 100644
--- a/MdePkg/Include/Ppi/ReadOnlyVariable2.h
+++ b/MdePkg/Include/Ppi/ReadOnlyVariable2.h
@@ -2,7 +2,7 @@
   This file declares Read-only Variable Service2 PPI.
   This ppi permits read-only access to the UEFI variable store during the PEI 
phase.
 
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
   @par Revision Reference:
@@ -106,4 +106,6 @@ struct _EFI_PEI_READ_ONLY_VARIABLE2_PPI {
 
 extern EFI_GUID  gEfiPeiReadOnlyVariable2PpiGuid;
 
+extern EFI_GUID  gEfiPeiVariableStoreDiscoveredPpiGuid;
+
 #endif
-- 
2.35.1.windows.2



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




[edk2-devel] [Patch v2 02/28] SecurityPkg: Add new GUIDs for

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

The gEdkiiProtectedVariableGlobalGuid HOB contains the global
configuration data structure which is verified in PEI Phase.
The gEdkiiMetaDataHmacVariableGuid is used for saving the
meta data HMAC variable.
The gEdkiiProtectedVariableContextGuid contains the Protected
Variable context saved in PEI phase to be used later.

Cc: Jian J Wang 
Cc: Jiewen Yao 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 SecurityPkg/SecurityPkg.dec | 43 +++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/SecurityPkg/SecurityPkg.dec b/SecurityPkg/SecurityPkg.dec
index 9f7a032d60d5..ea88908ea7d2 100644
--- a/SecurityPkg/SecurityPkg.dec
+++ b/SecurityPkg/SecurityPkg.dec
@@ -5,7 +5,7 @@
 #  It also provides the definitions(including PPIs/PROTOCOLs/GUIDs and library 
classes)
 #  and libraries instances, which are used for those features.
 #
-# Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.
+# Copyright (c) 2009 - 2022, Intel Corporation. All rights reserved.
 # (C) Copyright 2015 Hewlett Packard Enterprise Development LP 
 # Copyright (c) Microsoft Corporation.
 # SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -217,6 +217,18 @@ [Guids]
   ## GUID used to specify section with default dbt content
   gDefaultdbtFileGuid= { 0x36c513ee, 0xa338, 0x4976, { 0xa0, 
0xfb, 0x6d, 0xdb, 0xa3, 0xda, 0xfe, 0x87 } }
 
+  ## Include/Guid/ProtectedVariable.h
+  # {8EBF379A-F18E-4728-A410-00CF9A65BE91}
+  gEdkiiProtectedVariableGlobalGuid = { 0x8ebf379a, 0xf18e, 0x4728, { 0xa4, 
0x10, 0x0, 0xcf, 0x9a, 0x65, 0xbe, 0x91 } }
+
+  ## Include/Guid/ProtectedVariable.h
+  # {e3e890ad-5b67-466e-904f-94ca7e9376bb}
+  gEdkiiMetaDataHmacVariableGuid = {0xe3e890ad, 0x5b67, 0x466e, {0x90, 0x4f, 
0x94, 0xca, 0x7e, 0x93, 0x76, 0xbb}}
+
+  ## Include/Guid/ProtectedVariable.h
+  # {a11a3652-875b-495a-b097-200917580b98}
+  gEdkiiProtectedVariableContextGuid = {0xa11a3652, 0x875b, 0x495a, {0xb0, 
0x97, 0x20, 0x09, 0x17, 0x58, 0x0b, 0x98} }
+
 [Ppis]
   ## The PPI GUID for that TPM physical presence should be locked.
   # Include/Ppi/LockPhysicalPresence.h
@@ -242,6 +254,10 @@ [Ppis]
   ## Include/Ppi/Tcg.h
   gEdkiiTcgPpiGuid = {0x57a13b87, 0x133d, 0x4bf3, { 0xbf, 0xf1, 0x1b, 0xca, 
0xc7, 0x17, 0x6c, 0xf1 } }
 
+  ## Key Service Ppi
+  # Include/Ppi/KeyServicePpi.h
+  gKeyServicePpiGuid = {0x583592f6, 0xEC34, 0x4CED, {0x8E, 0x81, 0xC8, 0xD1, 
0x36, 0x93, 0x04, 0x27}}
+
 #
 # [Error.gEfiSecurityPkgTokenSpaceGuid]
 #   0x8001 | Invalid value provided.
@@ -325,6 +341,31 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]
 
   
gEfiSecurityPkgTokenSpaceGuid.PcdCpuRngSupportedAlgorithm|{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}|VOID*|0x00010032
 
+  ## Progress Code for variable integrity check result.
+  #  DEFAULT: (EFI_PERIPHERAL_FIXED_MEDIA | [EFI_STATUS&0xFF])
+  # @Prompt Status Code for variable integiry check result
+  
gEfiSecurityPkgTokenSpaceGuid.PcdStatusCodeVariableIntegrity|0x0107|UINT32|0x00010033
+
+  ## Null-terminated Unicode string of the Platform Variable Name
+  # @Prompt known unprotected variable name
+  gEfiSecurityPkgTokenSpaceGuid.PcdPlatformVariableName|L""|VOID*|0x00010034
+
+  ## Guid name to identify Platform Variable Guid
+  # @Prompt known unprotected variable guid
+  gEfiSecurityPkgTokenSpaceGuid.PcdPlatformVariableGuid|{ 0x00, 0x00, 0x00, 
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 
}|VOID*|0x00010035
+
+  ## Defines Protected Variable Integrity support.
+  #   TRUE  - Enable Protected Variable Integrity.
+  #   FALSE - Disable Protected Variable Integrity.
+  # @Prompt Protected Variable Integrity support.
+  
gEfiSecurityPkgTokenSpaceGuid.PcdProtectedVariableIntegrity|FALSE|BOOLEAN|0x00010036
+
+  ## Defines Protected Variable Confidentiality support.
+  #   TRUE  - Enable Protected Variable Confidentiality.
+  #   FALSE - Disable Protected Variable Confidentiality.
+  # @Prompt Protected Variable Integrity support.
+  
gEfiSecurityPkgTokenSpaceGuid.PcdProtectedVariableConfidentiality|FALSE|BOOLEAN|0x00010037
+
 [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
   ## Image verification policy for OptionRom. Only following values are 
valid:
   #  NOTE: Do NOT use 0x5 and 0x2 since it violates the UEFI specification and 
has been removed.
-- 
2.35.1.windows.2



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




[edk2-devel] [Patch v2 03/28] MdeModulePkg: Update AUTH_VARIABLE_INFO struct

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Added NameSize and State to AUTH_VARIABLE_INFO struct.
The size of the name and state is needed when creating
the variable digest.

Cc: Jian J Wang 
Cc: Liming Gao 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 MdeModulePkg/Include/Library/AuthVariableLib.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Include/Library/AuthVariableLib.h 
b/MdeModulePkg/Include/Library/AuthVariableLib.h
index 37aceba699e6..32391bbf2b61 100644
--- a/MdeModulePkg/Include/Library/AuthVariableLib.h
+++ b/MdeModulePkg/Include/Library/AuthVariableLib.h
@@ -1,7 +1,7 @@
 /** @file
   Provides services to initialize and process authenticated variables.
 
-Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2022, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -25,9 +25,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
(OFFSET_OF (WIN_CERTIFICATE_UEFI_GUID, 
CertData)))
 
 typedef struct {
+  UINTN   NameSize;
   CHAR16  *VariableName;
   EFI_GUID*VendorGuid;
   UINT32  Attributes;
+  UINT8   State;
   UINTN   DataSize;
   VOID*Data;
   UINT32  PubKeyIndex;
-- 
2.35.1.windows.2



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




[edk2-devel] [Patch v2 01/28] MdeModulePkg: Add new GUID for Variable Store Info

2022-04-29 Thread Judah Vang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2594

Discover if Variable Store Info HOB has been published
by platform driver. It contains information in regards
to HOB or NV Variable Store availability

Cc: Jian J Wang 
Cc: Liming Gao 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 MdeModulePkg/MdeModulePkg.dec | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index cf79292ec877..f39827e4eacd 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -4,7 +4,7 @@
 # and libraries instances, which are used for those modules.
 #
 # Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
-# Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.
 # Copyright (c) 2016, Linaro Ltd. All rights reserved.
 # (C) Copyright 2016 - 2019 Hewlett Packard Enterprise Development LP
 # Copyright (c) 2017, AMD Incorporated. All rights reserved.
@@ -93,6 +93,14 @@ [LibraryClasses]
   #
   TpmMeasurementLib|Include/Library/TpmMeasurementLib.h
 
+  ## @libraryclass  Provides interfaces to encrypt/decrypt variable.
+  #
+  EncryptionVariableLib|Include/Library/EncryptionVariableLib.h
+
+  ## @libraryclass  Provides interfaces to encrypt/decrypt variable.
+  #
+  ProtectedVariableLib|Include/Library/ProtectedVariableLib.h
+
   ## @libraryclass  Provides authenticated variable services.
   #
   AuthVariableLib|Include/Library/AuthVariableLib.h
@@ -505,6 +513,9 @@ [Ppis]
   gEdkiiPeiCapsuleOnDiskPpiGuid = { 0x71a9ea61, 0x5a35, 0x4a5d, { 
0xac, 0xef, 0x9c, 0xf8, 0x6d, 0x6d, 0x67, 0xe0 } }
   gEdkiiPeiBootInCapsuleOnDiskModePpiGuid   = { 0xb08a11e4, 0xe2b7, 0x4b75, { 
0xb5, 0x15, 0xaf, 0x61, 0x6, 0x68, 0xbf, 0xd1  } }
 
+  ## Include/Ppi/ReadOnlyVariable2.h
+  gEfiPeiVariableStoreDiscoveredPpiGuid = { 0xa2fc038d, 0xfdf5, 0x4501, { 
0xaf, 0x8e, 0x69, 0xb0, 0x20, 0xec, 0xe6, 0x63 } }
+
 [Protocols]
   ## Load File protocol provides capability to load and unload EFI image into 
memory and execute it.
   #  Include/Protocol/LoadPe32Image.h
-- 
2.35.1.windows.2



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




[edk2-devel] [Patch v2 00/28] UEFI variable protection

2022-04-29 Thread Judah Vang
For a more detail description of the UEFI variable protected feature you can
view the Readme.md located at the following location:
https://github.com/judahvang/edk2/tree/rpmc-update


Judah Vang (28):
  MdeModulePkg: Add new GUID for Variable Store Info
  SecurityPkg: Add new GUIDs for
  MdeModulePkg: Update AUTH_VARIABLE_INFO struct
  MdeModulePkg: Add reference to new Ppi Guid
  MdeModulePkg: Add new ProtectedVariable GUIDs
  MdeModulePkg: Add new include files
  MdeModulePkg: Add Null ProtectedVariable Library
  MdeModulePkg: Add new Variable functionality
  MdeModulePkg: Add support for Protected Variables
  SecurityPkg: Add new KeyService types and defines
  SecurityPkg: Update RPMC APIs with index
  SecurityPkg: Add new variable types and functions
  SecurityPkg: Fix GetVariableKey API
  SecurityPkg: Add null encryption variable libs
  SecurityPkg: Add VariableKey library function
  SecurityPkg: Add EncryptionVariable lib with AES
  SecurityPkg: Add Protected Variable Services
  MdeModulePkg: Reference Null ProtectedVariableLib
  SecurityPkg: Add references to new *.inf files
  ArmVirtPkg: Add reference to ProtectedVariableNull
  UefiPayloadPkg: Add ProtectedVariable reference
  EmulatorPkg: Add ProtectedVariable reference
  OvmfPkg: Add ProtectedVariable reference
  OvmfPkg: Add ProtectedVariableLib reference
  OvmfPkg: Add ProtectedVariableLib reference
  OvmfPkg: Add ProtectedVariableLib reference
  OvmfPkg: Add ProtectedVariable reference
  CryptoPkg: Enable cypto HMAC KDF library

 MdeModulePkg/MdeModulePkg.dec   |  
 13 +-
 SecurityPkg/SecurityPkg.dec |  
 43 +-
 ArmVirtPkg/ArmVirtQemu.dsc  |  
  3 +-
 EmulatorPkg/EmulatorPkg.dsc |  
  3 +-
 MdeModulePkg/MdeModulePkg.dsc   |  
  4 +-
 OvmfPkg/AmdSev/AmdSevX64.dsc|  
  3 +-
 OvmfPkg/Bhyve/BhyveX64.dsc  |  
  3 +-
 OvmfPkg/CloudHv/CloudHvX64.dsc  |  
  1 +
 OvmfPkg/Microvm/MicrovmX64.dsc  |  
  3 +-
 OvmfPkg/OvmfPkgIa32.dsc |  
  1 +
 OvmfPkg/OvmfPkgIa32X64.dsc  |  
  1 +
 OvmfPkg/OvmfPkgX64.dsc  |  
  1 +
 OvmfPkg/OvmfXen.dsc |  
  3 +-
 SecurityPkg/SecurityPkg.dsc |  
 13 +-
 UefiPayloadPkg/UefiPayloadPkg.dsc   |  
  2 +
 CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf  |  
  2 +-
 MdeModulePkg/Library/ProtectedVariableLibNull/ProtectedVariableLibNull.inf  |  
 34 +
 MdeModulePkg/Universal/Variable/Pei/VariablePei.inf |  
 10 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf   |  
  3 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf  |  
  3 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf|  
  4 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf |  
  3 +-
 SecurityPkg/Library/EncryptionVariableLib/EncryptionVariableLib.inf |  
 43 +
 SecurityPkg/Library/EncryptionVariableLibNull/EncryptionVariableLibNull.inf |  
 38 +
 SecurityPkg/Library/ProtectedVariableLib/DxeProtectedVariableLib.inf|  
 64 +
 SecurityPkg/Library/ProtectedVariableLib/PeiProtectedVariableLib.inf|  
 68 +
 SecurityPkg/Library/ProtectedVariableLib/SmmProtectedVariableLib.inf|  
 67 +
 SecurityPkg/Library/ProtectedVariableLib/SmmRuntimeProtectedVariableLib.inf |  
 62 +
 SecurityPkg/Library/VariableKeyLib/VariableKeyLib.inf   |  
 36 +
 MdeModulePkg/Include/Guid/ProtectedVariable.h   |  
 22 +
 MdeModulePkg/Include/Library/AuthVariableLib.h  |  
  4 +-
 MdeModulePkg/Include/Library/EncryptionVariableLib.h|  
165 ++
 MdeModulePkg/Include/Library/ProtectedVariableLib.h |  
700 +++
 MdeModulePkg/Universal/Variable/Pei/Variable.h  |  
 80 +-
 MdeModulePkg/Universal/Variable/Pei/VariableParsing.h   |  
309 +++
 MdeModulePkg/Universal/Variable/Pei/VariableStore.h |  
116 ++
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h   |  
126 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.h|  
 91 +-
 MdePkg/Include/Ppi/ReadOnlyVariable2.h  |  
  4 +-
 SecurityPkg/Include/Library/RpmcLib.h

Re: [edk2-devel] [PATCH v5 0/8] Add Variable Flash Info HOB

2022-04-29 Thread Michael Kubacki
I agree that would be a useful tool and in the case of changes such as 
this that provide backward compatibility with existing functionality, 
particularly helpful.


Some packages such as MdePkg 
(https://github.com/tianocore/edk2/blob/master/MdePkg/MdeLibs.dsc.inc) 
and NetworkPkg 
(https://github.com/tianocore/edk2/blob/master/NetworkPkg/NetworkComponents.dsc.inc) 
provide DSC files that a platform can override if necessary.


However, this does not exist for all edk2 packages. I did not introduce 
such a file in MdeModulePkg because I believe that is an independent 
package design decision outside the scope of this series and, if that 
change was made, it should include libraries other than just this 
instance. That would lead to additional churn and a larger platform 
integration debate, important to that topic, but separate from the 
current state this contribution is based against.


While includes be helpful, it can encourage platform owners to ignore 
potential creep in functionality they should be aware of.


For example, the DSC update is mostly being given to platforms to fix 
their immediate build problem. But, a platform owner might also choose 
to update their FVB driver to use this interface to get flash 
information as opposed to directly using PCDs as many do today. That's a 
decision they need to evaluate and make but they should be aware of the 
interface and make that decision. By directly reviewing/integrating the 
change for their platform, they are more explicitly made aware of this 
new interface to form that decision.


Also, when many include files get involved, platform build complexity 
and developer frustration can increase due to nesting and order of 
include files. Values (library classes, PCDs, etc.) can be overridden 
more than once. Ultimately, this is technically manageable by utilizing 
build reports and understanding the EDK II build output in more detail.


Again, I think this conversation is useful but requires much more time 
to address questions such as the following:


1. Should a different mechanism for default library classes be introduced?

2. Should all packages in edk2 provide such an include file? If so, does 
it only provide the DSC file (like MdePkg) or other files (like 
NetworkPkg which includes FDF)?


3. Which library classes for a given package should be given default 
instances?


4. How would each platform package maintainer like to maintain their 
platform build?


Example: Would MinPlatformPkg prefer to keep its own "core" include 
files 
(https://github.com/tianocore/edk2-platforms/tree/master/Platform/Intel/MinPlatformPkg/Include) 
or reconcile them with include files (possibly introducing an additional 
layer of nesting)? Would others prefer not to use includes at all to 
keep a flat, simpler file?


How would someone updating the platform code due to an edk2 change be 
aware of this per-platform policy?


To my understanding, the answers to these today are:

1. No
2. No / decided on per-change basis
3. Unknown
4. Unknown

(2) adds friction to the edk2 contribution process as expectation is 
unclear.


(3) adds churn into the platform integration process as the integration 
process for existing code is subject to change over time (e.g. realize 
library class is now in DSC and remove from platform DSC to use include 
instance).


(4) adds friction to the edk2 contribution process as expectation is 
unclear. Also, somewhat error prone. There's also a level of due 
diligence needed to confirm if a platform that already has an include is 
overriding that in another DSC file. If so, is that still the correct 
behavior or should it be modified.


Regards,
Michael

On 4/29/2022 9:45 AM, Ard Biesheuvel wrote:

On Tue, 26 Apr 2022 at 03:29,  wrote:


From: Michael Kubacki 

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

Platforms: This series introduces a new library class called
VariableFlashInfoLib. Platforms using the variable modules will
need to specify these library classes. See the patches at the
end of this series for examples of the change needed in the
platform DSC file. I have attempted to update all open-source
platforms in edk2 and edk2-platforms in this series and
https://edk2.groups.io/g/devel/message/89148.



I will make the same remark here as I made in response to the
edk2-platforms series:

Could we please consider introducing a way to define the default
resolution of a library class? That way, all this churn and
unnecessary breakage would not be necessary, as defining a resolution
would only be necessary when deviating from the default. In fact, we
might be able to clean up some .DSCs considerably by defining defaults
for library classes that only have one (or very few) implementations.



The UEFI variable drivers such as VariableRuntimeDxe, VariableSmm,
VariableStandaloneMm, etc. (and their dependent protocol/library
stack), typically acquire UEFI variable store flash information
with PCDs declared in MdeModulePkg.

For 

Re: [edk2-devel] [Patch V2] UefiPayloadPkg: Add definition for PayloadCommandLine HOB

2022-04-29 Thread Guo Dong


Reviewed-by: Guo Dong 

-Original Message-
From: Tan, Dun  
Sent: Wednesday, April 27, 2022 11:46 PM
To: devel@edk2.groups.io
Cc: Tan, Dun ; Ni, Ray ; Dong, Guo 
; You, Benjamin ; Rhodes, Sean 
; Liu, Zhiguang 
Subject: [Patch V2] UefiPayloadPkg: Add definition for PayloadCommandLine HOB

From: duntan 

Add definition for UNIVERSAL_PAYLOAD_COMMAND_LINE Hob.
This Hob is used to pass command Line to Payload.

Signed-off-by: Dun Tan 
Cc: Ray Ni 
Cc: Guo Dong 
Cc: Benjamin You 
Cc: Sean Rhodes 
Cc: Zhiguang Liu 
Signed-off-by: Dun Tan 
---
 UefiPayloadPkg/Include/Guid/PayloadCommandLine.h | 28 

 UefiPayloadPkg/UefiPayloadPkg.dec|  1 +
 2 files changed, 29 insertions(+)

diff --git a/UefiPayloadPkg/Include/Guid/PayloadCommandLine.h 
b/UefiPayloadPkg/Include/Guid/PayloadCommandLine.h
new file mode 100644
index 00..845a30efe1
--- /dev/null
+++ b/UefiPayloadPkg/Include/Guid/PayloadCommandLine.h
@@ -0,0 +1,28 @@
+/** @file
+  Define the structure for the Payload command line Hob.
+
+Copyright (c) 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef PAYLOAD_COMMAND_LINE_H_
+#define PAYLOAD_COMMAND_LINE_H_
+
+#include 
+#include 
+
+#pragma pack (1)
+
+typedef struct {
+  UNIVERSAL_PAYLOAD_GENERIC_HEADERHeader;
+  UINT32  Count;
+  CHAR8   CommandLine[0];
+} UNIVERSAL_PAYLOAD_COMMAND_LINE;
+
+#pragma pack()
+
+#define UNIVERSAL_PAYLOAD_COMMAND_LINE_REVISION  1
+
+extern GUID  gEdkiiPayloadCommandLineGuid; #endif
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec 
b/UefiPayloadPkg/UefiPayloadPkg.dec
index 5c1aeb8235..1ccfc32548 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dec
+++ b/UefiPayloadPkg/UefiPayloadPkg.dec
@@ -35,6 +35,7 @@
   gUefiAcpiBoardInfoGuid   = {0xad3d31b, 0xb3d8, 0x4506, {0xae, 0x71, 0x2e, 
0xf1, 0x10, 0x6, 0xd9, 0xf}}
   gUefiSerialPortInfoGuid  = { 0x6c6872fe, 0x56a9, 0x4403, { 0xbb, 0x98, 0x95, 
0x8d, 0x62, 0xde, 0x87, 0xf1 } }
   gLoaderMemoryMapInfoGuid = { 0xa1ff7424, 0x7a1a, 0x478e, { 0xa9, 0xe4, 0x92, 
0xf3, 0x57, 0xd1, 0x28, 0x32 } }
+  gEdkiiPayloadCommandLineGuid = {0xb5aeb34f, 0x3047, 0x4955, {0xb8, 
+ 0x80, 0xad, 0xd3, 0x6d, 0x86, 0xdc, 0x0f}}
 
   # SMM variable support
   gNvVariableInfoGuid  = { 0x7a345dca, 0xc26, 0x4f2a,  { 0xa8, 0x9a, 0x57, 
0xc0, 0x8d, 0xdd, 0x22, 0xee } }
--
2.31.1.windows.1



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




Re: [edk2-devel] [PATCH v6] OvmfPkg/Bhyve: add support for QemuFwCfg

2022-04-29 Thread Rebecca Cran
The Standard_Error_Output.log file isn't even really useful (it should 
show a diff), but there's something wrong with the coding style in Bhyve.c:


Files with formatting errors:
 Formatting errors in Bhyve/AcpiPlatformDxe/Bhyve.c


--
Rebecca Cran


On 4/29/22 07:55, Ard Biesheuvel wrote:

(+ sean, mike)

I tried to merge this but it is rejected by CI, and I got lost in the
maze of CI status and report pages. Could someone please figure out
what's wrong?

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

On Wed, 27 Apr 2022 at 12:07, Corvin Köhne  wrote:

QemuFwCfg is much more powerful than BhyveFwCtl. Sadly, BhyveFwCtl
decided to use the same IO ports as QemuFwCfg. It's not possible to use
both interfaces simultaneously. So, prefer QemuFwCfg over BhyveFwCtl.

Signed-off-by: Corvin Köhne 
Reviewed-by: Rebecca Cran 
Acked-by: Gerd Hoffmann 
Acked-by: Peter Grehan 
Acked-by: Jiewen Yao 
Cc: Ard Biesheuvel 
Cc: Jordan Justen 
Cc: EDKII devel group 
Cc: FreeBSD Virtualization 
---
  OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf |  1 +
  OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c | 41 ---
  OvmfPkg/Bhyve/BhyveX64.dsc|  4 +--
  3 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf 
b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
index 595fd055f9..94c65f32dc 100644
--- a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
+++ b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
@@ -43,6 +43,7 @@
MemoryAllocationLib
OrderedCollectionLib
PcdLib
+  QemuFwCfgLib
UefiBootServicesTableLib
UefiDriverEntryPoint
UefiLib
diff --git a/OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c 
b/OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c
index 8e80aa33e1..e216a21bfa 100644
--- a/OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c
+++ b/OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c
@@ -11,6 +11,41 @@
  #include 
  #include 
  #include 
+#include  // QemuFwCfgFindFile()
+
+STATIC
+EFI_STATUS
+EFIAPI
+BhyveGetCpuCount (
+  OUT UINT32  *CpuCount
+  )
+{
+  FIRMWARE_CONFIG_ITEM  Item;
+  UINTN Size;
+
+  if (QemuFwCfgIsAvailable ()) {
+if (EFI_ERROR (QemuFwCfgFindFile ("opt/bhyve/hw.ncpu", , ))) {
+  return EFI_NOT_FOUND;
+} else if (Size != sizeof (*CpuCount)) {
+  return EFI_BAD_BUFFER_SIZE;
+}
+
+QemuFwCfgSelectItem (Item);
+QemuFwCfgReadBytes (Size, CpuCount);
+
+return EFI_SUCCESS;
+  }
+
+  //
+  // QemuFwCfg not available, try BhyveFwCtl.
+  //
+  Size = sizeof (*CpuCount);
+  if (BhyveFwCtlGet ("hw.ncpu", CpuCount, ) == RETURN_SUCCESS) {
+return EFI_SUCCESS;
+  }
+
+  return EFI_UNSUPPORTED;
+}

  STATIC
  EFI_STATUS
@@ -23,7 +58,6 @@ BhyveInstallAcpiMadtTable (
)
  {
UINT32   CpuCount;
-  UINTNcSize;
UINTNNewBufferSize;
EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER  *Madt;
EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC_STRUCTURE  *LocalApic;
@@ -36,9 +70,8 @@ BhyveInstallAcpiMadtTable (
ASSERT (AcpiTableBufferSize >= sizeof (EFI_ACPI_DESCRIPTION_HEADER));

// Query the host for the number of vCPUs
-  CpuCount = 0;
-  cSize= sizeof (CpuCount);
-  if (BhyveFwCtlGet ("hw.ncpu", , ) == RETURN_SUCCESS) {
+  Status = BhyveGetCpuCount ();
+  if (!EFI_ERROR (Status)) {
  DEBUG ((DEBUG_INFO, "Retrieved CpuCount %d\n", CpuCount));
  ASSERT (CpuCount >= 1);
} else {
diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
index a8fa4d38ab..002cef32a3 100644
--- a/OvmfPkg/Bhyve/BhyveX64.dsc
+++ b/OvmfPkg/Bhyve/BhyveX64.dsc
@@ -164,8 +164,7 @@

SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf

SerializeVariablesLib|OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf
-  QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibNull.inf
-  QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/BaseQemuFwCfgS3LibNull.inf
+  QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxeLib.inf
BhyveFwCtlLib|OvmfPkg/Library/BhyveFwCtlLib/BhyveFwCtlLib.inf
VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf

MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf
@@ -358,6 +357,7 @@
  !endif
PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
MpInitLib|UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.inf
+  QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf

  [LibraryClasses.common.UEFI_APPLICATION]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
--
2.11.0

Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans Beckhoff
Registered office: Verl, Germany | Register court: Guetersloh HRA 7075












-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online 

Re: [edk2-devel] [PATCH v6] OvmfPkg/Bhyve: add support for QemuFwCfg

2022-04-29 Thread Ard Biesheuvel
(+ sean, mike)

I tried to merge this but it is rejected by CI, and I got lost in the
maze of CI status and report pages. Could someone please figure out
what's wrong?

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

On Wed, 27 Apr 2022 at 12:07, Corvin Köhne  wrote:
>
> QemuFwCfg is much more powerful than BhyveFwCtl. Sadly, BhyveFwCtl
> decided to use the same IO ports as QemuFwCfg. It's not possible to use
> both interfaces simultaneously. So, prefer QemuFwCfg over BhyveFwCtl.
>
> Signed-off-by: Corvin Köhne 
> Reviewed-by: Rebecca Cran 
> Acked-by: Gerd Hoffmann 
> Acked-by: Peter Grehan 
> Acked-by: Jiewen Yao 
> Cc: Ard Biesheuvel 
> Cc: Jordan Justen 
> Cc: EDKII devel group 
> Cc: FreeBSD Virtualization 
> ---
>  OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf |  1 +
>  OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c | 41 
> ---
>  OvmfPkg/Bhyve/BhyveX64.dsc|  4 +--
>  3 files changed, 40 insertions(+), 6 deletions(-)
>
> diff --git a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf 
> b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
> index 595fd055f9..94c65f32dc 100644
> --- a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
> +++ b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
> @@ -43,6 +43,7 @@
>MemoryAllocationLib
>OrderedCollectionLib
>PcdLib
> +  QemuFwCfgLib
>UefiBootServicesTableLib
>UefiDriverEntryPoint
>UefiLib
> diff --git a/OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c 
> b/OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c
> index 8e80aa33e1..e216a21bfa 100644
> --- a/OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c
> +++ b/OvmfPkg/Bhyve/AcpiPlatformDxe/Bhyve.c
> @@ -11,6 +11,41 @@
>  #include 
>  #include 
>  #include 
> +#include  // QemuFwCfgFindFile()
> +
> +STATIC
> +EFI_STATUS
> +EFIAPI
> +BhyveGetCpuCount (
> +  OUT UINT32  *CpuCount
> +  )
> +{
> +  FIRMWARE_CONFIG_ITEM  Item;
> +  UINTN Size;
> +
> +  if (QemuFwCfgIsAvailable ()) {
> +if (EFI_ERROR (QemuFwCfgFindFile ("opt/bhyve/hw.ncpu", , ))) {
> +  return EFI_NOT_FOUND;
> +} else if (Size != sizeof (*CpuCount)) {
> +  return EFI_BAD_BUFFER_SIZE;
> +}
> +
> +QemuFwCfgSelectItem (Item);
> +QemuFwCfgReadBytes (Size, CpuCount);
> +
> +return EFI_SUCCESS;
> +  }
> +
> +  //
> +  // QemuFwCfg not available, try BhyveFwCtl.
> +  //
> +  Size = sizeof (*CpuCount);
> +  if (BhyveFwCtlGet ("hw.ncpu", CpuCount, ) == RETURN_SUCCESS) {
> +return EFI_SUCCESS;
> +  }
> +
> +  return EFI_UNSUPPORTED;
> +}
>
>  STATIC
>  EFI_STATUS
> @@ -23,7 +58,6 @@ BhyveInstallAcpiMadtTable (
>)
>  {
>UINT32   CpuCount;
> -  UINTNcSize;
>UINTNNewBufferSize;
>EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER  *Madt;
>EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC_STRUCTURE  *LocalApic;
> @@ -36,9 +70,8 @@ BhyveInstallAcpiMadtTable (
>ASSERT (AcpiTableBufferSize >= sizeof (EFI_ACPI_DESCRIPTION_HEADER));
>
>// Query the host for the number of vCPUs
> -  CpuCount = 0;
> -  cSize= sizeof (CpuCount);
> -  if (BhyveFwCtlGet ("hw.ncpu", , ) == RETURN_SUCCESS) {
> +  Status = BhyveGetCpuCount ();
> +  if (!EFI_ERROR (Status)) {
>  DEBUG ((DEBUG_INFO, "Retrieved CpuCount %d\n", CpuCount));
>  ASSERT (CpuCount >= 1);
>} else {
> diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
> index a8fa4d38ab..002cef32a3 100644
> --- a/OvmfPkg/Bhyve/BhyveX64.dsc
> +++ b/OvmfPkg/Bhyve/BhyveX64.dsc
> @@ -164,8 +164,7 @@
>
> SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
>UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
>
> SerializeVariablesLib|OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf
> -  QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibNull.inf
> -  QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/BaseQemuFwCfgS3LibNull.inf
> +  QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxeLib.inf
>BhyveFwCtlLib|OvmfPkg/Library/BhyveFwCtlLib/BhyveFwCtlLib.inf
>VirtioLib|OvmfPkg/Library/VirtioLib/VirtioLib.inf
>
> MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf
> @@ -358,6 +357,7 @@
>  !endif
>PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
>MpInitLib|UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.inf
> +  QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf
>
>  [LibraryClasses.common.UEFI_APPLICATION]
>PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
> --
> 2.11.0
>
> Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans 
> Beckhoff
> Registered office: Verl, Germany | Register court: Guetersloh HRA 7075
>
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#89414): https://edk2.groups.io/g/devel/message/89414
Mute This Topic: 

Re: [edk2-devel] [PATCH v5 0/8] Add Variable Flash Info HOB

2022-04-29 Thread Ard Biesheuvel
On Tue, 26 Apr 2022 at 03:29,  wrote:
>
> From: Michael Kubacki 
>
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3479
>
> Platforms: This series introduces a new library class called
> VariableFlashInfoLib. Platforms using the variable modules will
> need to specify these library classes. See the patches at the
> end of this series for examples of the change needed in the
> platform DSC file. I have attempted to update all open-source
> platforms in edk2 and edk2-platforms in this series and
> https://edk2.groups.io/g/devel/message/89148.
>

I will make the same remark here as I made in response to the
edk2-platforms series:

Could we please consider introducing a way to define the default
resolution of a library class? That way, all this churn and
unnecessary breakage would not be necessary, as defining a resolution
would only be necessary when deviating from the default. In fact, we
might be able to clean up some .DSCs considerably by defining defaults
for library classes that only have one (or very few) implementations.


> The UEFI variable drivers such as VariableRuntimeDxe, VariableSmm,
> VariableStandaloneMm, etc. (and their dependent protocol/library
> stack), typically acquire UEFI variable store flash information
> with PCDs declared in MdeModulePkg.
>
> For example:
> [Pcd]
>   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
>   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64
>   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
>
> These PCDs work as-is in the StandaloneMm driver if they are not
> dynamic such as Dynamic or DynamicEx because PCD services are not
> readily available in the Standalone MM environment. Platforms that
> use Standalone MM today, must define these PCDs as FixedAtBuild in
> their platform build. However, the PCDs do allow platforms to treat
> the PCDs as Dynamic/DynamicEx and being able to support that is
> currently a gap for Standalone MM.
>
> This patch series introduces a HOB that can be produced by the
> platform to provide the same information. The HOB list is
> available to Standalone MM.
>
> The PCD declarations are left as-is in MdeModulePkg for backward
> compatibility. This means unless a platform wants to use the HOB,
> their code will continue to work with no change (they do not need
> to produce the HOB). Only if the HOB is found, is its value used
> instead of the PCDs.
>
> Due to the large number of consumers of this information, access
> to the base address and size values is abstracted in a new library
> class (as requested in the v1 series) called VariableFlashInfoLib.
>
> The API of VariableFlashInfoLib does not bind the underlying data
> structure to the information returned to library users to allow
> flexibility in the library implementation in the future.
>
> V5 changes.
> 1. Made GetVariableFlashInfoFromHob() in BaseVariableFlashInfoLib.c
>STATIC.
> 2. Added a section in commit v5 [3/8] to explicitly state that the
>commit introduces a dependency that requires a change in platform
>build.  Please see patches v5 [5/8] - v5 [8/8] for examples of
>how to integrate this change (add VariableFlashInfoLib library
>to DSC file).
>
> V4 changes:
> 1. Add a UINT32 "Reserved" field to VARIABLE_FLASH_INFO.
> 2. Add a descriptive comment to VariableFlashInfo.h to explain
>HOB usage.
>
> V3 changes:
> 1. To better clarify usage, renamed the members
>"NvStorageBaseAddress" and "NvStorageLength" in
>"VARIABLE_FLASH_INFO" to "NvVariableBaseAddress" and
>"NvVariableLength".
> 2. Added description comments to the fields in "VARIABLE_FLASH_INFO".
>
> V2 changes:
> 1. Abstracted flash info data access with VariableFlashInfoLib.
> 2. Updated package builds in the repo that build the variable and
>FTW drivers to include VariableFlashInfoLib.
> 3. Removed a redundant variable assignment in VariableSmm.c.
> 4. Updated comments in FtwMisc.c and FaultTolerantWritePei.c to
>indicate driver assumption is UINTN (not UINT32)
> 5. Added a version field to the VARIABLE_FLASH_INFO structure.
>
> Cc: Abner Chang 
> Cc: Andrew Fish 
> Cc: Anthony Perard 
> Cc: Ard Biesheuvel 
> Cc: Benjamin You 
> Cc: Brijesh Singh 
> Cc: Erdem Aktas 
> Cc: Gerd Hoffmann 
> Cc: Guo Dong 
> Cc: Hao A Wu 
> Cc: James Bottomley 
> Cc: Jian J Wang 
> Cc: Jiewen Yao 
> Cc: Jordan Justen 
> Cc: Julien Grall 
> Cc: Leif Lindholm 
> Cc: Liming Gao 
> Cc: Maurice Ma 
> Cc: Min Xu 
> Cc: Nickle Wang 
> Cc: Peter Grehan 
> Cc: Ray Ni 
> Cc: Rebecca Cran 
> Cc: Sami Mujawar 
> Cc: Sean Rhodes 
> Cc: Sebastien Boeuf 
> Cc: Tom Lendacky 
> Signed-off-by: Michael Kubacki 
>
> Michael Kubacki (8):
>   MdeModulePkg: Add Variable Flash Info HOB
>   MdeModulePkg/VariableFlashInfoLib: Add initial library
>   MdeModulePkg/Variable: Consume Variable Flash Info
>   MdeModulePkg/FaultTolerantWrite: Consume Variable Flash Info
>   ArmVirtPkg/ArmVirt.dsc.inc: Add VariableFlashInfoLib
>   EmulatorPkg: Add VariableFlashInfoLib
>   

Re: [edk2-devel] [PATCH edk2-platforms v1 0/3] Enable PCI/CPU topology generation for Juno

2022-04-29 Thread Ard Biesheuvel
On Fri, 29 Apr 2022 at 15:39, Pierre Gondois  wrote:
>
> Hello Ard,
> Sami is on leave for the next 2 weeks.
> Also, just in case, this patch-set has a dependency on:
> https://edk2.groups.io/g/devel/message/89348
>

Yes, that is why I asked him to review: he is the DynamicTablesPkg
maintainer, so he will need to merge the dependency first.


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




Re: [edk2-devel] [edk2-platforms][PATCH v2 00/11] Add VariableFlashInfoLib

2022-04-29 Thread Ard Biesheuvel
On Tue, 26 Apr 2022 at 04:19,  wrote:
>
> From: Michael Kubacki 
>
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3479
>
> Adds an instance for the library class VariableFlashInfoLib that
> was recently introduced in MdeModulePkg. This change is made to
> allow the new variable driver to build that has a dependency on
> this library class and does not require any further platform
> changes.
>
> Note that this series is for an upcoming change in MdeModulePkg
> and requires that change to be present locally for testing.
>
> https://edk2.groups.io/g/devel/message/89296
>
> V2 Changes:
> - Add patch "VExpressPkg: Add VariableFlashInfoLib"
>
> Cc: Abner Chang 
> Cc: Ard Biesheuvel 
> Cc: Chasel Chiu 
> Cc: Daniel Schaefer 
> Cc: Eric Dong 
> Cc: Gilbert Chen 
> Cc: Graeme Gregory 
> Cc: Ilias Apalodimas 
> Cc: Jeremy Linton 
> Cc: Leif Lindholm 
> Cc: Liming Gao 
> Cc: Masami Hiramatsu 
> Cc: Nate DeSimone 
> Cc: Radoslaw Biernacki 
> Cc: Sami Mujawar 
> Cc: Thomas Abraham 
> Signed-off-by: Michael Kubacki 
>
> Michael Kubacki (11):
>   OverdriveBoard: Add VariableFlashInfoLib
>   BeagleBoardPkg: Add VariableFlashInfoLib
>   MinPlatformPkg: Add VariableFlashInfoLib
>   CelloBoard: Add VariableFlashInfoLib
>   SbsaQemu: Add VariableFlashInfoLib
>   RaspberryPi: Add VariableFlashInfoLib
>   U5SeriesPkg: Add VariableFlashInfoLib
>   Socionext: Add VariableFlashInfoLib
>   Softiron: Add VariableFlashInfoLib
>   PlatformStandaloneMmPkg: Add VariableFlashInfoLib
>   VExpressPkg: Add VariableFlashInfoLib
>

For the series

Acked-by: Ard Biesheuvel 

*However* can we please fix this in the common frameworks? None of
this would be necessary if we could define a default resolution when
declaring a library class. That way, this problem would be fixed for
everybody not just the platforms that are in the open source repo.



>  Platform/AMD/OverdriveBoard/OverdriveBoard.dsc | 
> 1 +
>  Platform/ARM/VExpressPkg/ArmVExpress.dsc.inc   | 
> 1 +
>  Platform/BeagleBoard/BeagleBoardPkg/BeagleBoardPkg.dsc | 
> 1 +
>  Platform/Intel/MinPlatformPkg/Include/Dsc/CoreCommonLib.dsc| 
> 1 +
>  Platform/LeMaker/CelloBoard/CelloBoard.dsc | 
> 1 +
>  Platform/Qemu/SbsaQemu/SbsaQemu.dsc| 
> 1 +
>  Platform/RaspberryPi/RPi3/RPi3.dsc | 
> 1 +
>  Platform/RaspberryPi/RPi4/RPi4.dsc | 
> 1 +
>  Platform/SiFive/U5SeriesPkg/FreedomU500VC707Board/U500.dsc | 
> 1 +
>  Platform/SiFive/U5SeriesPkg/FreedomU540HiFiveUnleashedBoard/U540.dsc   | 
> 1 +
>  Platform/Socionext/SynQuacerEvalBoard/SynQuacerEvalBoard.dsc   | 
> 1 +
>  Platform/SoftIron/Overdrive1000Board/Overdrive1000Board.dsc| 
> 1 +
>  Platform/StandaloneMm/PlatformStandaloneMmPkg/PlatformStandaloneMmRpmb.dsc | 
> 1 +
>  13 files changed, 13 insertions(+)
>
> --
> 2.28.0.windows.1
>


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




Re: [edk2-devel] [PATCH edk2-platforms v1 0/3] Enable PCI/CPU topology generation for Juno

2022-04-29 Thread PierreGondois

Hello Ard,
Sami is on leave for the next 2 weeks.
Also, just in case, this patch-set has a dependency on:
https://edk2.groups.io/g/devel/message/89348

Regards,
Pierre

On 4/29/22 15:35, Ard Biesheuvel wrote:

On Wed, 27 Apr 2022 at 17:00, PierreGondois  wrote:


From: Pierre Gondois 

DEPENDENCY:
This patch set relies on a fix sent at:
https://edk2.groups.io/g/devel/message/89348

The DynamicTablesPkg can now generate the AML description of the
PCI/CPU topology information. Use these new features and remove
the static ASL description of the PCI/CPU topology when the
DynamicTables are used (i.e. when -D DYNAMIC_TABLES_FRAMEWORK is
provided).

Also provide a small fix for debug printing.

Pierre Gondois (3):
   Platform/ARM: Juno: Generate ASL description of CPU topology
   Platform/ARM: Juno: Print debug values in right order
   Platform/ARM: Juno: Generate ASL description of a PCIe bus



Sami, please review this and let me know when it can be merged.


  .../AslTables/Dsdt.asl| 198 
  .../AslTables/SsdtPci.asl | 195 
  .../ConfigurationManager.c| 425 +-
  .../ConfigurationManager.h|  47 +-
  .../ConfigurationManagerDxe.inf   |   1 -
  5 files changed, 456 insertions(+), 410 deletions(-)
  delete mode 100644 
Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/AslTables/SsdtPci.asl

--
2.25.1




Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#89349): https://edk2.groups.io/g/devel/message/89349
Mute This Topic: https://groups.io/mt/90732523/5717338
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [ardb+tianoc...@kernel.org]






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




Re: [edk2-devel] [PATCH edk2-platforms v1 0/3] Enable PCI/CPU topology generation for Juno

2022-04-29 Thread Ard Biesheuvel
On Wed, 27 Apr 2022 at 17:00, PierreGondois  wrote:
>
> From: Pierre Gondois 
>
> DEPENDENCY:
> This patch set relies on a fix sent at:
> https://edk2.groups.io/g/devel/message/89348
>
> The DynamicTablesPkg can now generate the AML description of the
> PCI/CPU topology information. Use these new features and remove
> the static ASL description of the PCI/CPU topology when the
> DynamicTables are used (i.e. when -D DYNAMIC_TABLES_FRAMEWORK is
> provided).
>
> Also provide a small fix for debug printing.
>
> Pierre Gondois (3):
>   Platform/ARM: Juno: Generate ASL description of CPU topology
>   Platform/ARM: Juno: Print debug values in right order
>   Platform/ARM: Juno: Generate ASL description of a PCIe bus
>

Sami, please review this and let me know when it can be merged.

>  .../AslTables/Dsdt.asl| 198 
>  .../AslTables/SsdtPci.asl | 195 
>  .../ConfigurationManager.c| 425 +-
>  .../ConfigurationManager.h|  47 +-
>  .../ConfigurationManagerDxe.inf   |   1 -
>  5 files changed, 456 insertions(+), 410 deletions(-)
>  delete mode 100644 
> Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/AslTables/SsdtPci.asl
>
> --
> 2.25.1
>
>
>
> 
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#89349): https://edk2.groups.io/g/devel/message/89349
> Mute This Topic: https://groups.io/mt/90732523/5717338
> Group Owner: devel+ow...@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [ardb+tianoc...@kernel.org]
> 
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#89409): https://edk2.groups.io/g/devel/message/89409
Mute This Topic: https://groups.io/mt/90732523/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/1] Platform/ARM: FVP: set IORT RC address limit for FVP RevC

2022-04-29 Thread Ard Biesheuvel
On Thu, 28 Apr 2022 at 11:53, Edward Pickup  wrote:
>
> When booting Linux on FVP RevC, Linux reports the following error:
>
> ACPI: IORT: [Firmware Bug]: Root complex missing memory address limit
>
> This issue is due to the RC Address Limit not being configured in the
> configuration manager for the platform.
>
> Set the value to 64 as the RevC FVP can use the full width, fixing the
> error.
>
> Signed-off-by: Edward Pickup 
> ---
>
> The changes can be seen at 
> https://github.com/edpickup/edk2-platforms/tree/1700_fix_IORT_RC_Addr_Limit_v2
>
> Notes:
> v2:
>  - Corrected Memory Address Size Limit [Ard]
>

Reviewed-by: Ard Biesheuvel 

Pushed as 1ba46425cf8d..38855c561f90

Thanks,

>  
> Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
>  | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git 
> a/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
>  
> b/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
> index 
> 776dec999eb1ef47910835987fa4dae1b69c52fd..0ba854610becff7d2544e26ec67a331783bbe75f
>  100644
> --- 
> a/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
> +++ 
> b/Platform/ARM/VExpressPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
> @@ -312,7 +312,9 @@ EDKII_PLATFORM_REPOSITORY_INFO VExpressPlatRepositoryInfo 
> = {
>  // ATS attributes
>  EFI_ACPI_IORT_ROOT_COMPLEX_ATS_UNSUPPORTED,
>  // PCI segment number
> -0
> +0,
> +// Memory Address Size Limit
> +64
>},
>
>// Array of Device ID mappings
> --
> Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")
>
>
>
> 
>
>


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




[edk2-devel] [PATCH v3 10/10] MdePkg/CompilerIntrinsicsLib: add new sources to CompilerIntrinsicsLib.inf

2022-04-29 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
Acked-by: Liming Gao 
---
 .../CompilerIntrinsicsLib.inf| 16 
 1 file changed, 16 insertions(+)

diff --git a/MdePkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf 
b/MdePkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
index b5e11373c509..7ba5ca8c8f2b 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
+++ b/MdePkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
@@ -98,6 +98,22 @@ [Sources.IA32]
   Ia32/MathLShiftS64.nasm   | GCC
   Ia32/MathRShiftU64.nasm   | GCC
 
+  Ia32/ulldiv.c | MSFT# __aulldiv
+  Ia32/ullrem.c | MSFT# __aullrem
+  Ia32/lldiv.c  | MSFT# __alldiv
+  Ia32/llrem.c  | MSFT# __allrem
+  Ia32/lldvrm.c | MSFT# __alldvrm
+  Ia32/ulldvrm.c| MSFT# __aulldvrm
+
+  Ia32/ulldiv.c | INTEL
+  Ia32/ullrem.c | INTEL
+  Ia32/lldiv.c  | INTEL
+  Ia32/llrem.c  | INTEL
+  Ia32/lldvrm.c | INTEL
+  Ia32/ulldvrm.c| INTEL
+
+  Ia32/Gcc.c| GCC
+
 [Packages]
   MdePkg/MdePkg.dec
 
-- 
2.35.1



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




[edk2-devel] [PATCH v3 08/10] MdePkg/CompilerIntrinsicsLib: drop debug logging from Gcc.c

2022-04-29 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
Acked-by: Liming Gao 
---
 .../Library/CompilerIntrinsicsLib/Ia32/Gcc.c  | 22 ---
 1 file changed, 22 deletions(-)

diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c 
b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
index d0996d6276bc..3c47bef63c4d 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
@@ -28,7 +28,6 @@ __ashlsi3 (
   int  Count
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (int)LShiftU64 ((UINT64)Datum, (UINTN)Count);
 }
 
@@ -38,7 +37,6 @@ __ashldi3 (
   int   Count
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (long)LShiftU64 ((UINT64)Datum, (UINTN)Count);
 }
 
@@ -48,7 +46,6 @@ __ashlti3 (
   intCount
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (long long)LShiftU64 ((UINT64)Datum, (UINTN)Count);
 }
 
@@ -60,7 +57,6 @@ __ashrsi3 (
   int  Count
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (int)ARShiftU64 ((UINT64)Datum, (UINTN)Count);
 }
 
@@ -70,7 +66,6 @@ __ashrdi3 (
   int   Count
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (long)ARShiftU64 ((UINT64)Datum, (UINTN)Count);
 }
 
@@ -80,7 +75,6 @@ __ashrti3 (
   intCount
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (long long)ARShiftU64 ((UINT64)Datum, (UINTN)Count);
 }
 
@@ -92,7 +86,6 @@ __divsi3 (
   int  Divisor
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (int)DivS64x64Remainder ((INT64)Dividend, (INT64)Divisor, NULL);
 }
 
@@ -105,7 +98,6 @@ __divdi3 (
   INT64  Quotient;
 
   Quotient = DivS64x64Remainder ((INT64)Dividend, (INT64)Divisor, NULL);
-  DEBUG ((DEBUG_INFO, "%a: %Ld / %Ld = %Ld\n", __func__, Dividend, Divisor, 
Quotient));
 
   return Quotient;
 }
@@ -116,7 +108,6 @@ __divti3 (
   long long  Divisor
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (long long)DivS64x64Remainder ((INT64)Dividend, (INT64)Divisor, NULL);
 }
 
@@ -128,7 +119,6 @@ __lshrsi3 (
   int  Count
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (int)RShiftU64 ((UINT64)Datum, (UINTN)Count);
 }
 
@@ -138,7 +128,6 @@ __lshrdi3 (
   int  Count
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (long)RShiftU64 ((UINT64)Datum, (UINTN)Count);
 }
 
@@ -148,7 +137,6 @@ __lshrti3 (
   int  Count
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (long long)RShiftU64 ((UINT64)Datum, (UINTN)Count);
 }
 
@@ -163,7 +151,6 @@ __modsi3 (
   INT64  Remainder;
 
   (void)DivS64x64Remainder ((INT64)Dividend, (INT64)Divisor, );
-  DEBUG ((DEBUG_INFO, "modsi3: %d %% %d = %d\n", Dividend, Divisor, 
(int)Remainder));
 
   return (int)Remainder;
 }
@@ -177,7 +164,6 @@ __moddi3 (
   INT64  Remainder;
 
   (void)DivS64x64Remainder ((INT64)Dividend, (INT64)Divisor, );
-  DEBUG ((DEBUG_INFO, "moddi3: %Ld %% %Ld = %Ld\n", (INT64)Dividend, 
(INT64)Divisor, Remainder));
 
   return Remainder;
 }
@@ -191,7 +177,6 @@ __modti3 (
   INT64  Remainder;
 
   (void)DivS64x64Remainder ((INT64)Dividend, (INT64)Divisor, );
-  DEBUG ((DEBUG_INFO, "modti3: %Ld %% %Ld = %Ld\n", (INT64)Dividend, 
(INT64)Divisor, Remainder));
 
   return (long long)Remainder;
 }
@@ -204,7 +189,6 @@ __multi3 (
   long long  Multiplier
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (long long)MultS64x64 ((INT64)Multiplicand, (INT64)Multiplier);
 }
 
@@ -216,7 +200,6 @@ __udivsi3 (
   unsigned int  Divisor
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (int)DivU64x64Remainder ((UINT64)Dividend, (UINT64)Divisor, NULL);
 }
 
@@ -226,7 +209,6 @@ __udivdi3 (
   unsigned long  Divisor
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (long)DivU64x64Remainder ((UINT64)Dividend, (UINT64)Divisor, NULL);
 }
 
@@ -236,7 +218,6 @@ __udivti3 (
   unsigned long long  Divisor
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (long long)DivU64x64Remainder ((UINT64)Dividend, (UINT64)Divisor, 
NULL);
 }
 
@@ -249,7 +230,6 @@ __umodsi3 (
 {
   UINT64  Remainder;
 
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   (void)DivU64x64Remainder ((UINT64)Dividend, (UINT64)Divisor, );
 
   return (unsigned int)Remainder;
@@ -263,7 +243,6 @@ __umoddi3 (
 {
   UINT64  Remainder;
 
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   (void)DivU64x64Remainder ((UINT64)Dividend, (UINT64)Divisor, );
 
   return (unsigned long)Remainder;
@@ -277,7 +256,6 @@ __umodti3 (
 {
   UINT64  Remainder;
 
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   (void)DivU64x64Remainder ((UINT64)Dividend, (UINT64)Divisor, );
 
   return (unsigned long long)Remainder;
-- 
2.35.1



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



[edk2-devel] [PATCH v3 09/10] MdePkg/CompilerIntrinsicsLib: remove duplicate functions from Gcc.c

2022-04-29 Thread Gerd Hoffmann
Implementations for those functions already exist,
so remove them to avoid duplicate symbols.

Signed-off-by: Gerd Hoffmann 
Acked-by: Liming Gao 
---
 .../Library/CompilerIntrinsicsLib/Ia32/Gcc.c  | 47 ---
 1 file changed, 47 deletions(-)

diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c 
b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
index 3c47bef63c4d..7502d5afe65a 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
@@ -20,55 +20,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 #include 
 
-// Shift Datum left by Count bits.
-// ===
-int
-__ashlsi3 (
-  int  Datum,
-  int  Count
-  )
-{
-  return (int)LShiftU64 ((UINT64)Datum, (UINTN)Count);
-}
-
-long
-__ashldi3 (
-  long  Datum,
-  int   Count
-  )
-{
-  return (long)LShiftU64 ((UINT64)Datum, (UINTN)Count);
-}
-
-long long
-__ashlti3 (
-  long long  Datum,
-  intCount
-  )
-{
-  return (long long)LShiftU64 ((UINT64)Datum, (UINTN)Count);
-}
-
 // Arithmetically shift Datum right by Count bits.
 // ===
-int
-__ashrsi3 (
-  int  Datum,
-  int  Count
-  )
-{
-  return (int)ARShiftU64 ((UINT64)Datum, (UINTN)Count);
-}
-
-long
-__ashrdi3 (
-  long  Datum,
-  int   Count
-  )
-{
-  return (long)ARShiftU64 ((UINT64)Datum, (UINTN)Count);
-}
-
 long long
 __ashrti3 (
   long long  Datum,
-- 
2.35.1



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




[edk2-devel] [PATCH v3 04/10] MdePkg/CompilerIntrinsicsLib: move ia32 intrinsics and strcmp

2022-04-29 Thread Gerd Hoffmann
Move intrinsics for ia32 from CryptoPkg/Library/IntrinsicLib
to MdePkg/Library/CompilerIntrinsicsLib.  Also move strcmp.

Remove CryptoPkg/Library/IntrinsicLib.
Use MdePkg/Library/CompilerIntrinsicsLib instead.
Update all references.

Signed-off-by: Gerd Hoffmann 
Acked-by: Jiewen Yao 
Acked-by: Ard Biesheuvel 
Acked-by: Liming Gao 
---
 ArmVirtPkg/ArmVirt.dsc.inc|  2 +-
 CryptoPkg/CryptoPkg.dsc   |  3 +-
 EmulatorPkg/EmulatorPkg.dsc   |  2 +-
 FmpDevicePkg/FmpDevicePkg.dsc |  2 +-
 NetworkPkg/NetworkPkg.dsc |  2 +-
 OvmfPkg/AmdSev/AmdSevX64.dsc  |  2 +-
 OvmfPkg/Bhyve/BhyveX64.dsc|  2 +-
 OvmfPkg/CloudHv/CloudHvX64.dsc|  2 +-
 OvmfPkg/IntelTdx/IntelTdxX64.dsc  |  2 +-
 OvmfPkg/Microvm/MicrovmX64.dsc|  2 +-
 OvmfPkg/OvmfPkgIa32.dsc   |  2 +-
 OvmfPkg/OvmfPkgIa32X64.dsc|  2 +-
 OvmfPkg/OvmfPkgX64.dsc|  2 +-
 OvmfPkg/OvmfXen.dsc   |  2 +-
 SecurityPkg/SecurityPkg.dsc   | 10 +--
 SignedCapsulePkg/SignedCapsulePkg.dsc | 12 +--
 UefiPayloadPkg/UefiPayloadPkg.dsc |  2 +-
 .../Library/IntrinsicLib/IntrinsicLib.inf | 69 -
 .../CompilerIntrinsicsLib.inf | 16 
 CryptoPkg/Library/IntrinsicLib/CopyMem.c  | 47 
 .../Library/IntrinsicLib/MemoryIntrinsics.c   | 74 ---
 .../CompilerIntrinsicsLib}/Ia32/MathFtol.c|  0
 .../Ia32/MathLShiftS64.c  |  0
 .../Ia32/MathRShiftU64.c  |  0
 MdePkg/Library/CompilerIntrinsicsLib/strcmp.c | 33 +
 .../Library/IntrinsicLib/BaseIntrinsicLib.uni | 16 
 .../Ia32/MathLShiftS64.nasm   |  0
 .../CompilerIntrinsicsLib}/Ia32/MathLlmul.asm |  0
 .../CompilerIntrinsicsLib}/Ia32/MathLlshr.asm |  0
 .../Ia32/MathRShiftU64.nasm   |  0
 30 files changed, 75 insertions(+), 233 deletions(-)
 delete mode 100644 CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
 delete mode 100644 CryptoPkg/Library/IntrinsicLib/CopyMem.c
 delete mode 100644 CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c
 rename {CryptoPkg/Library/IntrinsicLib => 
MdePkg/Library/CompilerIntrinsicsLib}/Ia32/MathFtol.c (100%)
 rename {CryptoPkg/Library/IntrinsicLib => 
MdePkg/Library/CompilerIntrinsicsLib}/Ia32/MathLShiftS64.c (100%)
 rename {CryptoPkg/Library/IntrinsicLib => 
MdePkg/Library/CompilerIntrinsicsLib}/Ia32/MathRShiftU64.c (100%)
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/strcmp.c
 delete mode 100644 CryptoPkg/Library/IntrinsicLib/BaseIntrinsicLib.uni
 rename {CryptoPkg/Library/IntrinsicLib => 
MdePkg/Library/CompilerIntrinsicsLib}/Ia32/MathLShiftS64.nasm (100%)
 rename {CryptoPkg/Library/IntrinsicLib => 
MdePkg/Library/CompilerIntrinsicsLib}/Ia32/MathLlmul.asm (100%)
 rename {CryptoPkg/Library/IntrinsicLib => 
MdePkg/Library/CompilerIntrinsicsLib}/Ia32/MathLlshr.asm (100%)
 rename {CryptoPkg/Library/IntrinsicLib => 
MdePkg/Library/CompilerIntrinsicsLib}/Ia32/MathRShiftU64.nasm (100%)

diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index 97edf0487964..d8b3db4f75ce 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -154,7 +154,7 @@ [LibraryClasses.common]
   #
   # CryptoPkg libraries needed by multiple firmware features
   #
-  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
+  IntrinsicLib|MdePkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
 !if $(NETWORK_TLS_ENABLE) == TRUE
   OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
 !else
diff --git a/CryptoPkg/CryptoPkg.dsc b/CryptoPkg/CryptoPkg.dsc
index 2d4d4c2797e5..d593ae0e709c 100644
--- a/CryptoPkg/CryptoPkg.dsc
+++ b/CryptoPkg/CryptoPkg.dsc
@@ -103,7 +103,7 @@ [LibraryClasses]
   
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
  #???
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf   
   #???
   OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
-  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
+  IntrinsicLib|MdePkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
   SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
 
 [LibraryClasses.ARM]
@@ -240,7 +240,6 @@ [Components]
   CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
   CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
   CryptoPkg/Library/BaseCryptLibNull/BaseCryptLibNull.inf
-  CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
   CryptoPkg/Library/TlsLib/TlsLib.inf
   CryptoPkg/Library/TlsLibNull/TlsLibNull.inf
   CryptoPkg/Library/OpensslLib/OpensslLib.inf
diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
index 554c13ddb500..f3a97b2e4577 100644
--- a/EmulatorPkg/EmulatorPkg.dsc
+++ b/EmulatorPkg/EmulatorPkg.dsc
@@ 

[edk2-devel] [PATCH v3 07/10] MdePkg/CompilerIntrinsicsLib: drop include from Gcc.c

2022-04-29 Thread Gerd Hoffmann
Does not exist and is not needed.

Signed-off-by: Gerd Hoffmann 
Acked-by: Liming Gao 
---
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c 
b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
index bb211022c0e4..d0996d6276bc 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
@@ -17,7 +17,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 #include 
 #include 
-#include 
 
 #include 
 
-- 
2.35.1



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




[edk2-devel] [PATCH v3 06/10] MdePkg/CompilerIntrinsicsLib: add SPDX License tags

2022-04-29 Thread Gerd Hoffmann
It's not an exact match, edk2 expects "BSD-2-Clause-Patent" but
http://opensource.org/licenses/bsd-license.php references in comments
is "BSD-2-Clause".

Guess I need an explicit Intel explicitly agreeing to this even though
that is a rather minor change ...

Signed-off-by: Gerd Hoffmann 
Acked-by: Liming Gao 
---
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldiv.c   | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldvrm.c  | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llmul.c   | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llrem.c   | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshl.c   | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshr.c   | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ulldiv.c  | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ulldvrm.c | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ullrem.c  | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ullshr.c  | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ashrdi3.S | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/mulll.S   | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/shldi3.S  | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/udivdi3.S | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/umoddi3.S | 2 ++
 16 files changed, 32 insertions(+)

diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c 
b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
index 430139fc5ee0..bb211022c0e4 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
@@ -9,6 +9,8 @@
   distribution.  The full text of the license may be found at
   http://opensource.org/licenses/bsd-license.
 
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldiv.c 
b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldiv.c
index 792974d7b119..cf2eec2a70b4 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldiv.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldiv.c
@@ -9,6 +9,8 @@
   distribution.  The full text of the license may be found at
   http://opensource.org/licenses/bsd-license.php.
 
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldvrm.c 
b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldvrm.c
index a1f87f6af5c3..1fbe11bea751 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldvrm.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldvrm.c
@@ -9,6 +9,8 @@
   distribution.  The full text of the license may be found at
   http://opensource.org/licenses/bsd-license.php.
 
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llmul.c 
b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llmul.c
index 61a5c416b912..3f9c54454128 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llmul.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llmul.c
@@ -9,6 +9,8 @@
   distribution.  The full text of the license may be found at
   http://opensource.org/licenses/bsd-license.php.
 
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llrem.c 
b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llrem.c
index f415fe82dd59..5a73d539a650 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llrem.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llrem.c
@@ -9,6 +9,8 @@
   distribution.  The full text of the license may be found at
   http://opensource.org/licenses/bsd-license.php.
 
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshl.c 
b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshl.c
index f2121a713bd7..665b628b4014 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshl.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshl.c
@@ -9,6 +9,8 @@
   distribution.  The full text of the license may be found at
   http://opensource.org/licenses/bsd-license.php.
 
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshr.c 

[edk2-devel] [PATCH v3 01/10] MdePkg: promote CompilerIntrinsicsLib from ArmPkg to MdePkg

2022-04-29 Thread Gerd Hoffmann
First step in creating a single, common compiler intrinsics library for
everybody who needs it.  Move the ArmPkg library to MdePkg, update all
references.  No code changes.

Signed-off-by: Gerd Hoffmann 
Acked-by: Jiewen Yao 
Acked-by: Ard Biesheuvel 
Acked-by: Liming Gao 
---
 ArmVirtPkg/ArmVirt.dsc.inc|   2 +-
 .../UnitTestFrameworkPkgTarget.dsc.inc|   2 +-
 ArmPkg/ArmPkg.dsc |   3 +--
 .../ArmCrashDumpDxe/ArmCrashDumpDxe.dsc   |   2 +-
 ArmPlatformPkg/ArmPlatformPkg.dsc |   2 +-
 CryptoPkg/CryptoPkg.dsc   |   2 +-
 DynamicTablesPkg/DynamicTablesPkg.dsc |   2 +-
 EmbeddedPkg/EmbeddedPkg.dsc   |   2 +-
 FatPkg/FatPkg.dsc |   2 +-
 FmpDevicePkg/FmpDevicePkg.dsc |   2 +-
 MdeModulePkg/MdeModulePkg.dsc |   2 +-
 MdePkg/MdePkg.dsc |   1 +
 NetworkPkg/NetworkPkg.dsc |   2 +-
 RedfishPkg/RedfishPkg.dsc |   2 +-
 SecurityPkg/SecurityPkg.dsc   |   2 +-
 ShellPkg/ShellPkg.dsc |   2 +-
 SignedCapsulePkg/SignedCapsulePkg.dsc |   2 +-
 StandaloneMmPkg/StandaloneMmPkg.dsc   |   2 +-
 .../CompilerIntrinsicsLib.inf |   1 -
 {ArmPkg => MdePkg}/Include/AsmMacroIoLib.h|   0
 .../Library/CompilerIntrinsicsLib/memcmp_ms.c |   0
 .../Library/CompilerIntrinsicsLib/memcpy.c|   0
 .../Library/CompilerIntrinsicsLib/memcpy_ms.c |   0
 .../CompilerIntrinsicsLib/memmove_ms.c|   0
 .../Library/CompilerIntrinsicsLib/memset.c|   0
 .../Library/CompilerIntrinsicsLib/memset_ms.c |   0
 ArmPkg/ArmPkg.ci.yaml |   1 -
 .../DEBUG_XCODE31/CompilerIntrinsicsLib.lib   | Bin 36072 -> 36072 bytes
 .../DEBUG_XCODE32/CompilerIntrinsicsLib.lib   | Bin 36072 -> 36072 bytes
 .../CompilerIntrinsicsLib/AArch64/Atomics.S   |   0
 .../CompilerIntrinsicsLib/Arm/ashldi3.S   |   0
 .../CompilerIntrinsicsLib/Arm/ashrdi3.S   |   0
 .../CompilerIntrinsicsLib/Arm/clzsi2.S|   0
 .../CompilerIntrinsicsLib/Arm/ctzsi2.S|   0
 .../Library/CompilerIntrinsicsLib/Arm/div.S   |   0
 .../Library/CompilerIntrinsicsLib/Arm/div.asm |   0
 .../CompilerIntrinsicsLib/Arm/divdi3.S|   0
 .../CompilerIntrinsicsLib/Arm/divsi3.S|   0
 .../Library/CompilerIntrinsicsLib/Arm/lasr.S  |   0
 .../CompilerIntrinsicsLib/Arm/lasr.asm|   0
 .../CompilerIntrinsicsLib/Arm/ldivmod.S   |   0
 .../CompilerIntrinsicsLib/Arm/ldivmod.asm |   0
 .../Library/CompilerIntrinsicsLib/Arm/llsl.S  |   0
 .../CompilerIntrinsicsLib/Arm/llsl.asm|   0
 .../Library/CompilerIntrinsicsLib/Arm/llsr.S  |   0
 .../CompilerIntrinsicsLib/Arm/llsr.asm|   0
 .../CompilerIntrinsicsLib/Arm/lshrdi3.S   |   0
 .../CompilerIntrinsicsLib/Arm/memmove.S   |   0
 .../CompilerIntrinsicsLib/Arm/memmove.asm |   0
 .../CompilerIntrinsicsLib/Arm/moddi3.S|   0
 .../CompilerIntrinsicsLib/Arm/modsi3.S|   0
 .../CompilerIntrinsicsLib/Arm/muldi3.S|   0
 .../Library/CompilerIntrinsicsLib/Arm/mullu.S |   0
 .../CompilerIntrinsicsLib/Arm/mullu.asm   |   0
 .../CompilerIntrinsicsLib/Arm/sourcery.S  |   0
 .../CompilerIntrinsicsLib/Arm/switch.asm  |   0
 .../CompilerIntrinsicsLib/Arm/switch16.S  |   0
 .../CompilerIntrinsicsLib/Arm/switch32.S  |   0
 .../CompilerIntrinsicsLib/Arm/switch8.S   |   0
 .../CompilerIntrinsicsLib/Arm/switchu8.S  |   0
 .../CompilerIntrinsicsLib/Arm/ucmpdi2.S   |   0
 .../CompilerIntrinsicsLib/Arm/udivdi3.S   |   0
 .../CompilerIntrinsicsLib/Arm/udivmoddi4.S|   0
 .../CompilerIntrinsicsLib/Arm/udivsi3.S   |   0
 .../Library/CompilerIntrinsicsLib/Arm/uldiv.S |   0
 .../CompilerIntrinsicsLib/Arm/uldiv.asm   |   0
 .../CompilerIntrinsicsLib/Arm/umoddi3.S   |   0
 .../CompilerIntrinsicsLib/Arm/umodsi3.S   |   0
 .../Library/CompilerIntrinsicsLib/Arm/uread.S |   0
 .../CompilerIntrinsicsLib/Arm/uread.asm   |   0
 .../CompilerIntrinsicsLib/Arm/uwrite.S|   0
 .../CompilerIntrinsicsLib/Arm/uwrite.asm  |   0
 MdePkg/MdePkg.ci.yaml |   1 +
 73 files changed, 19 insertions(+), 20 deletions(-)
 rename {ArmPkg => 
MdePkg}/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf (95%)
 rename {ArmPkg => MdePkg}/Include/AsmMacroIoLib.h (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcmp_ms.c (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcpy.c (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcpy_ms.c (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memmove_ms.c (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memset.c (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memset_ms.c (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/AArch64/Atomics.S 
(100%)
 rename 

[edk2-devel] [PATCH v3 05/10] MdePkg/CompilerIntrinsicsLib: copy over intrinsics from edk2-libc repo

2022-04-29 Thread Gerd Hoffmann
Copy over unmodified (except for running through uncrustify), from
https://github.com/tianocore/edk2-libc/tree/master/StdLib/LibC/CRT

Signed-off-by: Gerd Hoffmann 
Acked-by: Liming Gao 
---
 .../Library/CompilerIntrinsicsLib/Ia32/Gcc.c  | 283 ++
 .../CompilerIntrinsicsLib/Ia32/lldiv.c|  98 ++
 .../CompilerIntrinsicsLib/Ia32/lldvrm.c   | 102 +++
 .../CompilerIntrinsicsLib/Ia32/llmul.c|  82 +
 .../CompilerIntrinsicsLib/Ia32/llrem.c|  95 ++
 .../CompilerIntrinsicsLib/Ia32/llshl.c|  57 
 .../CompilerIntrinsicsLib/Ia32/llshr.c|  61 
 .../CompilerIntrinsicsLib/Ia32/ulldiv.c   |  89 ++
 .../CompilerIntrinsicsLib/Ia32/ulldvrm.c  | 102 +++
 .../CompilerIntrinsicsLib/Ia32/ullrem.c   |  95 ++
 .../CompilerIntrinsicsLib/Ia32/ullshr.c   |  60 
 .../CompilerIntrinsicsLib/Ia32/ashrdi3.S  |  66 
 .../CompilerIntrinsicsLib/Ia32/mulll.S|  77 +
 .../CompilerIntrinsicsLib/Ia32/shldi3.S   |  62 
 .../CompilerIntrinsicsLib/Ia32/udivdi3.S  |  83 +
 .../CompilerIntrinsicsLib/Ia32/umoddi3.S  |  89 ++
 16 files changed, 1501 insertions(+)
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldiv.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldvrm.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llmul.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llrem.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshl.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshr.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ulldiv.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ulldvrm.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ullrem.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ullshr.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ashrdi3.S
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/mulll.S
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/shldi3.S
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/udivdi3.S
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/umoddi3.S

diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c 
b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
new file mode 100644
index ..430139fc5ee0
--- /dev/null
+++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
@@ -0,0 +1,283 @@
+/** @file
+  Integer Arithmetic Run-time support functions for GCC.
+  The integer arithmetic routines are used on platforms that don't provide
+  hardware support for arithmetic operations on some modes..
+
+  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+  This program and the accompanying materials are licensed and made available
+  under the terms and conditions of the BSD License which accompanies this
+  distribution.  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+#include 
+#include 
+#include 
+
+#include 
+
+// Shift Datum left by Count bits.
+// ===
+int
+__ashlsi3 (
+  int  Datum,
+  int  Count
+  )
+{
+  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
+  return (int)LShiftU64 ((UINT64)Datum, (UINTN)Count);
+}
+
+long
+__ashldi3 (
+  long  Datum,
+  int   Count
+  )
+{
+  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
+  return (long)LShiftU64 ((UINT64)Datum, (UINTN)Count);
+}
+
+long long
+__ashlti3 (
+  long long  Datum,
+  intCount
+  )
+{
+  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
+  return (long long)LShiftU64 ((UINT64)Datum, (UINTN)Count);
+}
+
+// Arithmetically shift Datum right by Count bits.
+// ===
+int
+__ashrsi3 (
+  int  Datum,
+  int  Count
+  )
+{
+  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
+  return (int)ARShiftU64 ((UINT64)Datum, (UINTN)Count);
+}
+
+long
+__ashrdi3 (
+  long  Datum,
+  int   Count
+  )
+{
+  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
+  return (long)ARShiftU64 ((UINT64)Datum, (UINTN)Count);
+}
+
+long long
+__ashrti3 (
+  long long  Datum,
+  intCount
+  )
+{
+  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
+  return (long long)ARShiftU64 ((UINT64)Datum, (UINTN)Count);
+}
+
+// Return the quotient of the signed division of Dividend and Divisor
+// ===
+int
+__divsi3 (
+  int  Dividend,
+  int  Divisor
+  )
+{
+  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
+  return (int)DivS64x64Remainder ((INT64)Dividend, (INT64)Divisor, NULL);
+}
+
+INT64
+__divdi3 (
+  INT64  Dividend,
+  INT64  Divisor
+  )
+{
+  

[edk2-devel] [PATCH v3 02/10] MdePkg/CompilerIntrinsicsLib: fix msft sources for x64

2022-04-29 Thread Gerd Hoffmann
Update #if conditions so the 64bit version is picked for X64 too.

Signed-off-by: Gerd Hoffmann 
Acked-by: Jiewen Yao 
Acked-by: Ard Biesheuvel 
Acked-by: Liming Gao 
---
 MdePkg/Library/CompilerIntrinsicsLib/memcmp_ms.c  | 2 +-
 MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c  | 2 +-
 MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c | 2 +-
 MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c  | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/MdePkg/Library/CompilerIntrinsicsLib/memcmp_ms.c 
b/MdePkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
index cedbfca47139..2fac8f1e23e3 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
@@ -7,7 +7,7 @@
 //
 // 
--
 
-#if defined (_M_ARM64)
+#if defined (_M_ARM64) || defined (_M_X64)
 typedef unsigned __int64 size_t;
 #else
 typedef unsigned __int32 size_t;
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c 
b/MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
index 0eafa83ed476..730aa806d50b 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
@@ -7,7 +7,7 @@
 //
 // 
--
 
-#if defined (_M_ARM64)
+#if defined (_M_ARM64) || defined (_M_X64)
 typedef unsigned __int64 size_t;
 #else
 typedef unsigned __int32 size_t;
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c 
b/MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c
index f68eb52a6ca5..3207b94a8675 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c
@@ -7,7 +7,7 @@
 //
 // 
--
 
-#if defined (_M_ARM64)
+#if defined (_M_ARM64) || defined (_M_X64)
 typedef unsigned __int64 size_t;
 #else
 typedef unsigned __int32 size_t;
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c 
b/MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c
index 5882cd28b06d..deb902c6ae88 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c
@@ -7,7 +7,7 @@
 //
 // 
--
 
-#if defined (_M_ARM64)
+#if defined (_M_ARM64) || defined (_M_X64)
 typedef unsigned __int64 size_t;
 #else
 typedef unsigned __int32 size_t;
-- 
2.35.1



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




[edk2-devel] [PATCH v3 03/10] MdePkg/CompilerIntrinsicsLib: move size_t typedef to header file

2022-04-29 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
Acked-by: Liming Gao 
---
 .../{memset_ms.c => types_ms.h}   | 29 +--
 .../Library/CompilerIntrinsicsLib/memcpy_ms.c |  6 +---
 .../CompilerIntrinsicsLib/memmove_ms.c|  6 +---
 .../Library/CompilerIntrinsicsLib/memset_ms.c |  6 +---
 4 files changed, 4 insertions(+), 43 deletions(-)
 copy MdePkg/Library/CompilerIntrinsicsLib/{memset_ms.c => types_ms.h} (52%)

diff --git a/MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c 
b/MdePkg/Library/CompilerIntrinsicsLib/types_ms.h
similarity index 52%
copy from MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c
copy to MdePkg/Library/CompilerIntrinsicsLib/types_ms.h
index deb902c6ae88..d8b578be1f46 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/types_ms.h
@@ -1,6 +1,6 @@
 // 
--
 //
-// Copyright (c) 2017, Pete Batard. All rights reserved.
+// Copyright (c) 2019, Pete Batard. All rights reserved.
 // Copyright (c) 2021, Arm Limited. All rights reserved.
 //
 // SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -12,30 +12,3 @@ typedef unsigned __int64 size_t;
 #else
 typedef unsigned __int32 size_t;
 #endif
-
-void *
-memset (
-  void *,
-  int,
-  size_t
-  );
-
-#pragma intrinsic(memset)
-#pragma function(memset)
-void *
-memset (
-  void*s,
-  int c,
-  size_t  n
-  )
-{
-  unsigned char  *d;
-
-  d = s;
-
-  while (n-- != 0) {
-*d++ = (unsigned char)c;
-  }
-
-  return s;
-}
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c 
b/MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
index 730aa806d50b..d2c3d7198121 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
@@ -7,11 +7,7 @@
 //
 // 
--
 
-#if defined (_M_ARM64) || defined (_M_X64)
-typedef unsigned __int64 size_t;
-#else
-typedef unsigned __int32 size_t;
-#endif
+#include "types_ms.h"
 
 void *
 memcpy (
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c 
b/MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c
index 3207b94a8675..837744a2920c 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c
@@ -7,11 +7,7 @@
 //
 // 
--
 
-#if defined (_M_ARM64) || defined (_M_X64)
-typedef unsigned __int64 size_t;
-#else
-typedef unsigned __int32 size_t;
-#endif
+#include "types_ms.h"
 
 void *
 memmove (
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c 
b/MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c
index deb902c6ae88..3569bebdf80b 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c
@@ -7,11 +7,7 @@
 //
 // 
--
 
-#if defined (_M_ARM64) || defined (_M_X64)
-typedef unsigned __int64 size_t;
-#else
-typedef unsigned __int32 size_t;
-#endif
+#include "types_ms.h"
 
 void *
 memset (
-- 
2.35.1



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




[edk2-devel] [PATCH v3 00/10] consolidate compiler intrinsics

2022-04-29 Thread Gerd Hoffmann
This is an attept to start cleaning up the messy compiler intrinsics
situation.  Today we don't have a core intrinsics library, resulting
in everybody creating their own.  ArmPkg has one, CryptoPkg has one.
I'm sure there are many more.

This doesn't make sense.  Given we can't avoid compiler intrinsics (as
proven by the existence of those libraries) we should better have them
as core library so we have to maintain a single version only.

Given we already have BaseIoLibIntrinsic in MdePkg we can place the
compiler intrinsics there too.  This little patch series does just that:
It moves over the existing ArmPkg intrinsics, fixes them to build on
non-arm too, and adds additional bits from the CryptoPkg intrinsics.

v3 changes:
 - rebase to latest master, solve conflicts.

v2 changes:
 - rebase to latest master.
 - add review tags
 - add patch moving size_t to header file (patch #3).
 - add patches copying over more intrinsics from
   edk2-libc repo (patches #5 -> #10).

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3649

take care,
  Gerd

Gerd Hoffmann (10):
  MdePkg: promote CompilerIntrinsicsLib from ArmPkg to MdePkg
  MdePkg/CompilerIntrinsicsLib: fix msft sources for x64
  MdePkg/CompilerIntrinsicsLib: move size_t typedef to header file
  MdePkg/CompilerIntrinsicsLib: move ia32 intrinsics and strcmp
  MdePkg/CompilerIntrinsicsLib: copy over intrinsics from edk2-libc repo
  MdePkg/CompilerIntrinsicsLib: add SPDX License tags
  MdePkg/CompilerIntrinsicsLib: drop include from Gcc.c
  MdePkg/CompilerIntrinsicsLib: drop debug logging from Gcc.c
  MdePkg/CompilerIntrinsicsLib: remove duplicate functions from Gcc.c
  MdePkg/CompilerIntrinsicsLib: add new sources to
CompilerIntrinsicsLib.inf

 ArmVirtPkg/ArmVirt.dsc.inc|   4 +-
 .../UnitTestFrameworkPkgTarget.dsc.inc|   2 +-
 ArmPkg/ArmPkg.dsc |   3 +-
 .../ArmCrashDumpDxe/ArmCrashDumpDxe.dsc   |   2 +-
 ArmPlatformPkg/ArmPlatformPkg.dsc |   2 +-
 CryptoPkg/CryptoPkg.dsc   |   5 +-
 DynamicTablesPkg/DynamicTablesPkg.dsc |   2 +-
 EmbeddedPkg/EmbeddedPkg.dsc   |   2 +-
 EmulatorPkg/EmulatorPkg.dsc   |   2 +-
 FatPkg/FatPkg.dsc |   2 +-
 FmpDevicePkg/FmpDevicePkg.dsc |   4 +-
 MdeModulePkg/MdeModulePkg.dsc |   2 +-
 MdePkg/MdePkg.dsc |   1 +
 NetworkPkg/NetworkPkg.dsc |   4 +-
 OvmfPkg/AmdSev/AmdSevX64.dsc  |   2 +-
 OvmfPkg/Bhyve/BhyveX64.dsc|   2 +-
 OvmfPkg/CloudHv/CloudHvX64.dsc|   2 +-
 OvmfPkg/IntelTdx/IntelTdxX64.dsc  |   2 +-
 OvmfPkg/Microvm/MicrovmX64.dsc|   2 +-
 OvmfPkg/OvmfPkgIa32.dsc   |   2 +-
 OvmfPkg/OvmfPkgIa32X64.dsc|   2 +-
 OvmfPkg/OvmfPkgX64.dsc|   2 +-
 OvmfPkg/OvmfXen.dsc   |   2 +-
 RedfishPkg/RedfishPkg.dsc |   2 +-
 SecurityPkg/SecurityPkg.dsc   |  12 +-
 ShellPkg/ShellPkg.dsc |   2 +-
 SignedCapsulePkg/SignedCapsulePkg.dsc |  14 +-
 StandaloneMmPkg/StandaloneMmPkg.dsc   |   2 +-
 UefiPayloadPkg/UefiPayloadPkg.dsc |   2 +-
 .../Library/IntrinsicLib/IntrinsicLib.inf |  69 --
 .../CompilerIntrinsicsLib.inf |  33 ++-
 {ArmPkg => MdePkg}/Include/AsmMacroIoLib.h|   0
 .../Library/CompilerIntrinsicsLib/types_ms.h  |  14 ++
 CryptoPkg/Library/IntrinsicLib/CopyMem.c  |  47 
 .../Library/IntrinsicLib/MemoryIntrinsics.c   |  74 --
 .../Library/CompilerIntrinsicsLib/Ia32/Gcc.c  | 215 ++
 .../CompilerIntrinsicsLib}/Ia32/MathFtol.c|   0
 .../Ia32/MathLShiftS64.c  |   0
 .../Ia32/MathRShiftU64.c  |   0
 .../CompilerIntrinsicsLib/Ia32/lldiv.c| 100 
 .../CompilerIntrinsicsLib/Ia32/lldvrm.c   | 104 +
 .../CompilerIntrinsicsLib/Ia32/llmul.c|  84 +++
 .../CompilerIntrinsicsLib/Ia32/llrem.c|  97 
 .../CompilerIntrinsicsLib/Ia32/llshl.c|  10 +-
 .../CompilerIntrinsicsLib/Ia32/llshr.c|  63 +
 .../CompilerIntrinsicsLib/Ia32/ulldiv.c   |  91 
 .../CompilerIntrinsicsLib/Ia32/ulldvrm.c  | 104 +
 .../CompilerIntrinsicsLib/Ia32/ullrem.c   |  97 
 .../CompilerIntrinsicsLib/Ia32/ullshr.c   |  10 +-
 .../Library/CompilerIntrinsicsLib/memcmp_ms.c |   2 +-
 .../Library/CompilerIntrinsicsLib/memcpy.c|   0
 .../Library/CompilerIntrinsicsLib/memcpy_ms.c |   6 +-
 .../CompilerIntrinsicsLib/memmove_ms.c|   6 +-
 .../Library/CompilerIntrinsicsLib/memset.c|   0
 .../Library/CompilerIntrinsicsLib/memset_ms.c |   6 +-
 MdePkg/Library/CompilerIntrinsicsLib/strcmp.c |  33 +++
 ArmPkg/ArmPkg.ci.yaml |   1 -
 

Re: [edk2-devel] [PATCH v5 4/5] Ovmf/PlatformPei: Use host-provided GPA end if available

2022-04-29 Thread Gerd Hoffmann
On Mon, Apr 25, 2022 at 11:43:49PM +0200, Ojeda Leon, Nicolas via groups.io 
wrote:
> Read the "hardware-info" item from fw-cfg to extract specifications
> of PCI host bridges and analyze the 64-bit apertures of them to
> find out the highest 64-bit MMIO address required which determines
> the address space required by the guest, and, consequently, the
> FirstNonAddress used to calculate size of physical addresses.

Is there some way to (a) figure ovmf runs on aws, and (b) figure what
the physical address space is?

IIRC I've mentioned this before:  The reason for this FirstNonAddress
logic is that ovmf tries to be very conservative because when running on
qemu 'pc' and 'q35' machine types ovmf simply can't figure reliable how
much address space it actually has.

With qemu 'microvm' machine type this is not the case so standard cpuid
can be used instead:

https://edk2.groups.io/g/devel/message/89260?p=%2C%2C%2C20%2C0%2C0%2C0%3A%3Arecentpostdate%2Fsticky%2C%2CmPhysMemAddressWidth%2C20%2C2%2C0%2C90681717

So if using PlatformAddressWidthFromCpuid() as-is or something simliar
is an option this series could be simplified.  I think you don't need
to parse hardware-info in PEI then ...

(keeping the series as-is is fine with me too).

take care,
  Gerd



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




Re: [edk2-devel] [PATCH v5 1/6] MdeModulePkg/PciHostBridge: io range is not mandatory

2022-04-29 Thread Gerd Hoffmann
  Hi,

> > > Can Linux allocate resource for PCI(E) devices? How does it deal with the 
> > > IO type?
> > 
> > Yes.  Details depend a bit on the specific configuration, but in general
> > linux will try assign io address space to pcie root ports and devices
> > plugged into those ports.  A failure is not considered fatal though.
> 
> An error message and continue? 

Not even an error message.  In case the pci core code assigns a io
window to the pci root port it will log a message saying so.  In case
it doesn't it stays silent.

> > A more common case than the pci root bridge not supporting io address
> > space at all is having more than 16 pcie root ports.  Given io bride
> > windows are 1k in size and we have 16k total there is simply not enough
> > io address space in that case, so some of the root ports stay without
> > io and linux is fine with that.
> 
> Does it have some certain policy that IO resource for first root bridge should
> be satisfied?

I don't know for sure.  From the boot logs it looks like the kernel
simply assigns resources in pci scan order, and when it runs out of
resources it stops assigning.

take care,
  Gerd



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




Re: [edk2-devel] Does BaseTools support VS2022?

2022-04-29 Thread Ni, Ray
I am asking this because I met a VS2019 build issue when I installed the 
VS2022. I had to uninstall it.
Not sure about the latest status.

From: devel@edk2.groups.io  On Behalf Of Ni, Ray
Sent: Friday, April 29, 2022 5:13 PM
To: devel@edk2.groups.io
Cc: Feng, Bob C ; Sean Brogan 
Subject: [edk2-devel] Does BaseTools support VS2022?

Hi tool experts,
I noticed that VS2022 17.1 has been released. Does BaseTools support VS2022? if 
no, any plan?

Thanks,
Ray



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




[edk2-devel] Does BaseTools support VS2022?

2022-04-29 Thread Ni, Ray
Hi tool experts,
I noticed that VS2022 17.1 has been released. Does BaseTools support VS2022? if 
no, any plan?

Thanks,
Ray


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




Re: [edk2-devel] [PATCH v5 1/6] MdeModulePkg/PciHostBridge: io range is not mandatory

2022-04-29 Thread Ni, Ray
> 
>   Hi,
> 
> > > I'd say the risk for regressions is rather low, though, given that it
> > > only affects configurations that would fail PCI resource allocation
> > > today. Or am I missing something?
> > >
> > > In any case, the PCIe spec is clear about this: I/O space is optional,
> > > and we need to incorporate this into the generic code at *some* point.
> > > It makes no sense for every individual platform to keep adding these
> > > hacks.
> > Do you know how Linux handles this?
> > Can Linux allocate resource for PCI(E) devices? How does it deal with the 
> > IO type?
> 
> Yes.  Details depend a bit on the specific configuration, but in general
> linux will try assign io address space to pcie root ports and devices
> plugged into those ports.  A failure is not considered fatal though.

An error message and continue? 

> 
> A more common case than the pci root bridge not supporting io address
> space at all is having more than 16 pcie root ports.  Given io bride
> windows are 1k in size and we have 16k total there is simply not enough
> io address space in that case, so some of the root ports stay without
> io and linux is fine with that.

Does it have some certain policy that IO resource for first root bridge should
be satisfied?

> 
> > Why changing the MdeModulePkg's IncompatiblePciDevice driver can avoid
> > stalling the patch series?
> > I feel it's enough to just change the OvmfPkg version.
> 
> It's not much of a problem for ovmf even without such an update,
> typically the devices used with microvm don't have io bars in the first
> place.
> 
> Also note that without this series pcie devices are not supported at all
> on microvm, so not supporting all devices initially wouldn't be a
> regression.
> 
> I'll look into it in any case.

The safest way is to change OVMF now.
Add @Nong, Foster and @Albecki, Mateusz for comments.

> 
> take care,
>   Gerd
> 
> 
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#89392): https://edk2.groups.io/g/devel/message/89392
Mute This Topic: https://groups.io/mt/90623478/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 00/10] consolidate compiler intrinsics

2022-04-29 Thread Gerd Hoffmann
On Fri, Apr 29, 2022 at 02:41:25PM +0800, gaoliming wrote:
> Gerd:
>   Do you plan to catch this change into edk2 202205 stable tag? 

That would be great, yes.

Working on v3 of the series right now (solving conflicts),
will the update post soon.

>   For this patch set,  Acked-by: Liming Gao 

Thanks,
  Gerd



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




Re: [edk2-devel] [PATCH v5 1/6] MdeModulePkg/PciHostBridge: io range is not mandatory

2022-04-29 Thread Gerd Hoffmann
  Hi,

> > I'd say the risk for regressions is rather low, though, given that it
> > only affects configurations that would fail PCI resource allocation
> > today. Or am I missing something?
> > 
> > In any case, the PCIe spec is clear about this: I/O space is optional,
> > and we need to incorporate this into the generic code at *some* point.
> > It makes no sense for every individual platform to keep adding these
> > hacks.
> Do you know how Linux handles this?
> Can Linux allocate resource for PCI(E) devices? How does it deal with the IO 
> type?

Yes.  Details depend a bit on the specific configuration, but in general
linux will try assign io address space to pcie root ports and devices
plugged into those ports.  A failure is not considered fatal though.

A more common case than the pci root bridge not supporting io address
space at all is having more than 16 pcie root ports.  Given io bride
windows are 1k in size and we have 16k total there is simply not enough
io address space in that case, so some of the root ports stay without
io and linux is fine with that.

> Why changing the MdeModulePkg's IncompatiblePciDevice driver can avoid
> stalling the patch series?
> I feel it's enough to just change the OvmfPkg version.

It's not much of a problem for ovmf even without such an update,
typically the devices used with microvm don't have io bars in the first
place.

Also note that without this series pcie devices are not supported at all
on microvm, so not supporting all devices initially wouldn't be a
regression.

I'll look into it in any case.

take care,
  Gerd



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




Re: [edk2-devel] [PATCH v5 1/6] MdeModulePkg/PciHostBridge: io range is not mandatory

2022-04-29 Thread Ni, Ray
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Ard Biesheuvel
> Sent: Friday, April 29, 2022 3:00 PM
> To: Gerd Hoffmann 
> Cc: Ni, Ray ; devel@edk2.groups.io; Pawel Polawski 
> ; Ard Biesheuvel
> ; Gao, Liming ; Wu, Hao 
> A ; Oliver Steffen
> ; Leif Lindholm ; Justen, 
> Jordan L ; Yao,
> Jiewen ; Chang, Abner ; Wang, Jian 
> J 
> Subject: Re: [edk2-devel] [PATCH v5 1/6] MdeModulePkg/PciHostBridge: io range 
> is not mandatory
> 
> On Fri, 29 Apr 2022 at 08:50, Gerd Hoffmann  wrote:
> >
> > On Wed, Apr 27, 2022 at 03:08:50AM +, Ni, Ray wrote:
> > > Ard,
> > > can you explain more?
> > >
> > > Your code changes the PciHostBridge driver to ignore the failure of IO 
> > > allocation.
> > > If IO requirement of certain PCI(E) devices can be ignored, can you 
> > > change the IncompatiblePciDevice protocol
> implementation to override the IO request from the devices?
> >
> > Hmm, it's a problem indeed, device initialization fails in case an
> > io bar is present even if the bar is not required to drive the device.
> >
> 
> I'd say the risk for regressions is rather low, though, given that it
> only affects configurations that would fail PCI resource allocation
> today. Or am I missing something?
> 
> In any case, the PCIe spec is clear about this: I/O space is optional,
> and we need to incorporate this into the generic code at *some* point.
> It makes no sense for every individual platform to keep adding these
> hacks.
Do you know how Linux handles this?
Can Linux allocate resource for PCI(E) devices? How does it deal with the IO 
type?

> 
> > Suggestions how to deal with this best?  ovmf has it's own
> > IncompatiblePciDevice Protocol implementation, so I could
> > handle it there because only OvmfPkg/Microvm needs this.
> >
> > Or should the MdeModulePkg version be updated too?
> >
> 
> I'd say we do both, to avoid stalling your series forever :-)

Why changing the MdeModulePkg's IncompatiblePciDevice driver can avoid
stalling the patch series?
I feel it's enough to just change the OvmfPkg version.



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




Re: [edk2-devel] [PATCH v5 1/6] MdeModulePkg/PciHostBridge: io range is not mandatory

2022-04-29 Thread Ard Biesheuvel
On Fri, 29 Apr 2022 at 08:50, Gerd Hoffmann  wrote:
>
> On Wed, Apr 27, 2022 at 03:08:50AM +, Ni, Ray wrote:
> > Ard,
> > can you explain more?
> >
> > Your code changes the PciHostBridge driver to ignore the failure of IO 
> > allocation.
> > If IO requirement of certain PCI(E) devices can be ignored, can you change 
> > the IncompatiblePciDevice protocol implementation to override the IO 
> > request from the devices?
>
> Hmm, it's a problem indeed, device initialization fails in case an
> io bar is present even if the bar is not required to drive the device.
>

I'd say the risk for regressions is rather low, though, given that it
only affects configurations that would fail PCI resource allocation
today. Or am I missing something?

In any case, the PCIe spec is clear about this: I/O space is optional,
and we need to incorporate this into the generic code at *some* point.
It makes no sense for every individual platform to keep adding these
hacks.

> Suggestions how to deal with this best?  ovmf has it's own
> IncompatiblePciDevice Protocol implementation, so I could
> handle it there because only OvmfPkg/Microvm needs this.
>
> Or should the MdeModulePkg version be updated too?
>

I'd say we do both, to avoid stalling your series forever :-)


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




Re: [edk2-devel] [PATCH v5 1/6] MdeModulePkg/PciHostBridge: io range is not mandatory

2022-04-29 Thread Gerd Hoffmann
On Wed, Apr 27, 2022 at 03:08:50AM +, Ni, Ray wrote:
> Ard,
> can you explain more?
> 
> Your code changes the PciHostBridge driver to ignore the failure of IO 
> allocation.
> If IO requirement of certain PCI(E) devices can be ignored, can you change 
> the IncompatiblePciDevice protocol implementation to override the IO request 
> from the devices?

Hmm, it's a problem indeed, device initialization fails in case an
io bar is present even if the bar is not required to drive the device.

Suggestions how to deal with this best?  ovmf has it's own
IncompatiblePciDevice Protocol implementation, so I could
handle it there because only OvmfPkg/Microvm needs this.

Or should the MdeModulePkg version be updated too?

thanks,
  Gerd



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




[edk2-devel] 回复: [PATCH v2 00/10] consolidate compiler intrinsics

2022-04-29 Thread gaoliming
Gerd:
  Do you plan to catch this change into edk2 202205 stable tag? 

  For this patch set,  Acked-by: Liming Gao 

Thanks
Liming
> -邮件原件-
> 发件人: Gerd Hoffmann 
> 发送时间: 2022年4月12日 22:07
> 收件人: devel@edk2.groups.io
> 抄送: Maurice Ma ; Andrew Fish
> ; Pawel Polawski ; Benjamin You
> ; Yuwei Chen ; Zhiguang
> Liu ; Rebecca Cran ; Xiaoyu
> Lu ; Supreeth Venkatesh
> ; Zhichao Gao ;
> Brijesh Singh ; Julien Grall ; Erdem
> Aktas ; Maciej Rabeda
> ; Liming Gao ;
> Michael D Kinney ; kilian_ke...@hotmail.com;
> Siyuan Fu ; Oliver Steffen ; Ray
> Ni ; Abner Chang ; James
> Bottomley ; Sean Brogan
> ; Alexei Fedorov ;
> Tom Lendacky ; Guo Dong
> ; Jiewen Yao ; Sami Mujawar
> ; Sebastien Boeuf ;
> Peter Grehan ; Min Xu ;
> Anthony Perard ; Jordan Justen
> ; Jian J Wang ; Gerd
> Hoffmann ; Bob Feng ; Bret
> Barkelew ; Nickle Wang
> ; Wei6 Xu ; Daniel Schaefer
> ; Jiaxin Wu ; Leif Lindholm
> ; Guomin Jiang ; Sami
> Mujawar ; Ard Biesheuvel
> 
> 主题: [PATCH v2 00/10] consolidate compiler intrinsics
> 
> This is an attept to start cleaning up the messy compiler intrinsics
> situation.  Today we don't have a core intrinsics library, resulting
> in everybody creating their own.  ArmPkg has one, CryptoPkg has one.
> I'm sure there are many more.
> 
> This doesn't make sense.  Given we can't avoid compiler intrinsics (as
> proven by the existence of those libraries) we should better have them
> as core library so we have to maintain a single version only.
> 
> Given we already have BaseIoLibIntrinsic in MdePkg we can place the
> compiler intrinsics there too.  This little patch series does just that:
> It moves over the existing ArmPkg intrinsics, fixes them to build on
> non-arm too, and adds additional bits from the CryptoPkg intrinsics.
> 
> v2 changes:
>  - rebase to latest master.
>  - add review tags
>  - add patch moving size_t to header file (patch #3).
>  - add patches copying over more intrinsics from
>edk2-libc repo (patches #5 -> #10).
> 
> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3649
> 
> take care,
>   Gerd
> 
> Gerd Hoffmann (10):
>   MdePkg: promote CompilerIntrinsicsLib from ArmPkg to MdePkg
>   MdePkg/CompilerIntrinsicsLib: fix msft sources for x64
>   MdePkg/CompilerIntrinsicsLib: move size_t typedef to header file
>   MdePkg/CompilerIntrinsicsLib: move ia32 intrinsics and strcmp
>   MdePkg/CompilerIntrinsicsLib: copy over intrinsics from edk2-libc repo
>   MdePkg/CompilerIntrinsicsLib: add SPDX License tags
>   MdePkg/CompilerIntrinsicsLib: drop include from Gcc.c
>   MdePkg/CompilerIntrinsicsLib: drop debug logging from Gcc.c
>   MdePkg/CompilerIntrinsicsLib: remove duplicate functions from Gcc.c
>   MdePkg/CompilerIntrinsicsLib: add new sources to
> CompilerIntrinsicsLib.inf
> 
>  ArmVirtPkg/ArmVirt.dsc.inc|   4 +-
>  .../UnitTestFrameworkPkgTarget.dsc.inc|   2 +-
>  ArmPkg/ArmPkg.dsc |   3 +-
>  .../ArmCrashDumpDxe/ArmCrashDumpDxe.dsc   |   2 +-
>  ArmPlatformPkg/ArmPlatformPkg.dsc |   2 +-
>  CryptoPkg/CryptoPkg.dsc   |   5 +-
>  DynamicTablesPkg/DynamicTablesPkg.dsc |   2 +-
>  EmbeddedPkg/EmbeddedPkg.dsc   |   2 +-
>  EmulatorPkg/EmulatorPkg.dsc   |   2 +-
>  FatPkg/FatPkg.dsc |   2 +-
>  FmpDevicePkg/FmpDevicePkg.dsc |   4 +-
>  MdeModulePkg/MdeModulePkg.dsc |   2 +-
>  MdePkg/MdePkg.dsc |   1 +
>  NetworkPkg/NetworkPkg.dsc |   4 +-
>  OvmfPkg/AmdSev/AmdSevX64.dsc  |   2 +-
>  OvmfPkg/Bhyve/BhyveX64.dsc|   2 +-
>  OvmfPkg/CloudHv/CloudHvX64.dsc|   2 +-
>  OvmfPkg/IntelTdx/IntelTdxX64.dsc  |   2 +-
>  OvmfPkg/Microvm/MicrovmX64.dsc|   2 +-
>  OvmfPkg/OvmfPkgIa32.dsc   |   2 +-
>  OvmfPkg/OvmfPkgIa32X64.dsc|   2 +-
>  OvmfPkg/OvmfPkgX64.dsc|   2 +-
>  OvmfPkg/OvmfXen.dsc   |   2 +-
>  RedfishPkg/RedfishPkg.dsc |   2 +-
>  SecurityPkg/SecurityPkg.dsc   |  12 +-
>  ShellPkg/ShellPkg.dsc |   2 +-
>  SignedCapsulePkg/SignedCapsulePkg.dsc |  14 +-
>  StandaloneMmPkg/StandaloneMmPkg.dsc   |   2 +-
>  UefiPayloadPkg/UefiPayloadPkg.dsc |   2 +-
>  .../Library/IntrinsicLib/IntrinsicLib.inf |  67 --
>  .../CompilerIntrinsicsLib.inf |  35 ++-
>  {ArmPkg => MdePkg}/Include/AsmMacroIoLib.h|   0
>  .../Library/CompilerIntrinsicsLib/types_ms.h  |  14 ++
>  CryptoPkg/Library/IntrinsicLib/CopyMem.c  |  47 
>  .../Library/IntrinsicLib/MemoryIntrinsics.c   |  74 --
>  .../Library/CompilerIntrinsicsLib/Ia32/Gcc.c  | 215 ++
>  .../CompilerIntrinsicsLib}/Ia32/MathFtol.c|   0
>  .../Ia32/MathLShiftS64.c  |   0
>  

回复: [edk2-devel] [PATCH] PcAtChipsetPkg: Change the flow of PcRtcInit()

2022-04-29 Thread gaoliming
Zhuoran:
  Ray is the maintainer of PcAtChipsetPkg. Can you collect his feedback on
this change?

Thanks
Liming
> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 Zhuoran Chao
> 发送时间: 2022年4月29日 13:43
> 收件人: devel@edk2.groups.io; Gao, Liming 
> 抄送: Ni, Ray 
> 主题: Re: [edk2-devel] [PATCH] PcAtChipsetPkg: Change the flow of
> PcRtcInit()
> 
> Hi Liming:
> Could you help to give a nudge on the below issue because it is related to
a
> bug fixing of Intel server platform enabling team.
> 
> Thanks
> Zhuoran
> 
> -Original Message-
> From: Chao, Zhuoran 
> Sent: Monday, April 25, 2022 11:47 PM
> To: devel@edk2.groups.io
> Cc: Chao, Zhuoran ; Ni, Ray 
> Subject: [PATCH] PcAtChipsetPkg: Change the flow of PcRtcInit()
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3913
> 
> The original flow of PcRtcInit() is like:
> 1. Guarantee atomic accesses to the RTC time registers and
>read out the value.
> 2. Program RTC register B. (adopt 12h mode or 24h mode. Current
>bios code sets RTC to 24h mode by default).
> 3. Then function ConvertRtcTimeToEfiTime converts the RTC time
>value to their 24h mode by checking the hour format bit
>(1:24h mode,0:12h mode).
> And here lies the problem: Step3 will fail to adjust the value if Step2
already
> sets RTC to 24h mode. The hour value in 12h mode will not be converted to
its
> 24h mode.
> 
> The solution is to program RTC register B a little later when all the
original RTC
> registers' value is retrieved, adjusted and validated.
> 
> Cc: Ray Ni 
> 
> Signed-off-by: Zhuoran Chao 
> ---
>  PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
> b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
> index 0fbfa4bcee..ea56a66267 100644
> --- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
> +++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c
> @@ -269,13 +269,6 @@ PcRtcInit (
>Time.Month  = RtcRead (RTC_ADDRESS_MONTH);
>Time.Year   = RtcRead (RTC_ADDRESS_YEAR);
> 
> -  //
> -  // Set RTC configuration after get original time
> -  // The value of bit AIE should be reserved.
> -  //
> -  RegisterB.Data = FixedPcdGet8 (PcdInitialValueRtcRegisterB) |
> (RegisterB.Data & BIT5);
> -  RtcWrite (RTC_ADDRESS_REGISTER_B, RegisterB.Data);
> -
>//
>// Release RTC Lock.
>//
> @@ -330,6 +323,13 @@ PcRtcInit (
>  Time.Daylight   = 0;
>}
> 
> +  //
> +  // Set RTC configuration after get original time  // The value of bit
> + AIE should be reserved.
> +  //
> +  RegisterB.Data = FixedPcdGet8 (PcdInitialValueRtcRegisterB) |
> + (RegisterB.Data & BIT5);  RtcWrite (RTC_ADDRESS_REGISTER_B,
> + RegisterB.Data);
> +
>//
>// Reset time value according to new RTC configuration
>//
> --
> 2.31.1.windows.1
> 
> 
> 
> 
> 





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