Re: [edk2-devel][PATCH V2] UefiPayloadPkg: Fix boot shell issue for universal UEFI payload

2023-05-12 Thread Guo Dong


Hi Liming,
I know EDK2 is code freeze now. This patch fixes the UEFI payload boot to shell 
bug and it got reviewed and should have no impact to other packages.
Do you think we could merge it for this stable release?
https://github.com/tianocore/edk2/pull/4377

Thanks,
Guo

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Guo Dong
Sent: Friday, May 12, 2023 3:44 PM
To: devel@edk2.groups.io
Cc: Dong, Guo ; Ni, Ray ; Rhodes, Sean 
; Lu, James ; Guo, Gua 

Subject: [edk2-devel][PATCH V2] UefiPayloadPkg: Fix boot shell issue for 
universal UEFI payload

From: Guo Dong 

After moving BDS driver to a new FV for universal UEFI payload, the shell boot 
option path is not correct since it used the BDS FV instead of DXE FV in its 
device path.
This patch would find the correct FV by reading shell file.
It also removed PcdShellFile by using gUefiShellFileGuid.

Signed-off-by: Guo Dong 
Cc: Ray Ni 
Cc: Sean Rhodes 
Cc: James Lu 
Cc: Gua Guo 
Reviewed-by: James Lu 
Reviewed-by: Gua Guo 
---
 UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c  | 82 
+++---
 UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |  5 
+++--
 UefiPayloadPkg/UefiPayloadPkg.dec|  3 
---
 3 files changed, 78 insertions(+), 12 deletions(-)

diff --git 
a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c 
b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
index 62637ae6aa..1660d6c330 100644
--- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
+++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.
+++ c
@@ -2,7 +2,7 @@
   This file include all platform action which can be customized   by IBV/OEM. 
-Copyright (c) 2015 - 2021, Intel Corporation. All rights 
reserved.+Copyright (c) 2015 - 2023, Intel Corporation. All rights 
reserved. SPDX-License-Identifier: BSD-2-Clause-Patent  **/@@ -11,6 +11,7 
@@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include "PlatformConsole.h" #include  #include 
+#include   /**   Signal EndOfDxe 
event and install SMM Ready to lock protocol.@@ -89,6 +90,77 @@ 
PlatformFindLoadOption (
   return -1; } +/**+  Get the FV device path for the shell file.++  @return   
A pointer to device path structure.+**/+EFI_DEVICE_PATH_PROTOCOL 
*+BdsGetShellFvDevicePath (+  VOID+  )+{+  UINTN  
FvHandleCount;+  EFI_HANDLE *FvHandleBuffer;+  UINTN
  Index;+  EFI_STATUS Status;+  
EFI_FIRMWARE_VOLUME2_PROTOCOL  *Fv;+  UINTN  Size;+  
UINT32 AuthenticationStatus;+  EFI_DEVICE_PATH_PROTOCOL 
  *DevicePath;+  EFI_FV_FILETYPEFoundType;+  
EFI_FV_FILE_ATTRIBUTES FileAttributes;++  Status = EFI_SUCCESS;+  
gBS->LocateHandleBuffer (+ ByProtocol,+ 
,+ NULL,+ ,+  
   + );++  for (Index = 0; Index < FvHandleCount; 
Index++) {+Size   = 0;+gBS->HandleProtocol (+   
FvHandleBuffer[Index],+   ,+   
(VOID **)+   );+Status = Fv->ReadFile (+   Fv,+  
 ,+   NULL,+ 
  ,+   ,+   ,+
   +   );+if (!EFI_ERROR 
(Status)) {+  //+  // Found the shell file+  //+  break;+}+ 
 }++  if (EFI_ERROR (Status)) {+if (FvHandleCount) {+  FreePool 
(FvHandleBuffer);+}++return NULL;+  }++  DevicePath = 
DevicePathFromHandle (FvHandleBuffer[Index]);++  if (FvHandleCount) {+
FreePool (FvHandleBuffer);+  }++  return DevicePath;+}+ /**   Register a boot 
option using a file GUID in the FV. @@ -109,15 +181,11 @@ 
PlatformRegisterFvBootOption (
   EFI_BOOT_MANAGER_LOAD_OPTION   *BootOptions;   UINTN 
 BootOptionCount;   MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  FileNode;-  
EFI_LOADED_IMAGE_PROTOCOL  *LoadedImage;   EFI_DEVICE_PATH_PROTOCOL 
  *DevicePath; -  Status = gBS->HandleProtocol (gImageHandle, 
, (VOID **));-  ASSERT_EFI_ERROR 
(Status);-   EfiInitializeFwVolDevicepathNode (, FileGuid);   
DevicePath = AppendDevicePathNode (- DevicePathFromHandle 
(LoadedImage->DeviceHandle),+ BdsGetShellFvDevicePath (),   
   (EFI_DEVICE_PATH_PROTOCOL *)  ); @@ -248,7 
+316,7 @@ PlatformBootManagerAfterConsole (
   //   // Register UEFI Shell   //-  PlatformRegisterFvBootOption (PcdGetPtr 
(PcdShellFile), L"UEFI Shell", LOAD_OPTION_ACTIVE);+  
PlatformRegisterFvBootOption (, L"UEFI Shell", 
LOAD_OPTION_ACTIVE);if (FixedPcdGetBool (PcdBootManagerEscape)) { Print 
(diff --git 
a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf 

[edk2-devel][PATCH V2] UefiPayloadPkg: Fix boot shell issue for universal UEFI payload

2023-05-12 Thread Guo Dong
From: Guo Dong 

After moving BDS driver to a new FV for universal UEFI payload,
the shell boot option path is not correct since it used the BDS
FV instead of DXE FV in its device path.
This patch would find the correct FV by reading shell file.
It also removed PcdShellFile by using gUefiShellFileGuid.

Signed-off-by: Guo Dong 
Cc: Ray Ni 
Cc: Sean Rhodes 
Cc: James Lu 
Cc: Gua Guo 
Reviewed-by: James Lu 
Reviewed-by: Gua Guo 
---
 UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c  | 82 
+++---
 UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |  5 
+++--
 UefiPayloadPkg/UefiPayloadPkg.dec|  3 
---
 3 files changed, 78 insertions(+), 12 deletions(-)

diff --git 
a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c 
b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
index 62637ae6aa..1660d6c330 100644
--- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
+++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
@@ -2,7 +2,7 @@
   This file include all platform action which can be customized
   by IBV/OEM.
 
-Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2023, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -11,6 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include "PlatformConsole.h"
 #include 
 #include 
+#include 
 
 /**
   Signal EndOfDxe event and install SMM Ready to lock protocol.
@@ -89,6 +90,77 @@ PlatformFindLoadOption (
   return -1;
 }
 
+/**
+  Get the FV device path for the shell file.
+
+  @return   A pointer to device path structure.
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+BdsGetShellFvDevicePath (
+  VOID
+  )
+{
+  UINTN  FvHandleCount;
+  EFI_HANDLE *FvHandleBuffer;
+  UINTN  Index;
+  EFI_STATUS Status;
+  EFI_FIRMWARE_VOLUME2_PROTOCOL  *Fv;
+  UINTN  Size;
+  UINT32 AuthenticationStatus;
+  EFI_DEVICE_PATH_PROTOCOL   *DevicePath;
+  EFI_FV_FILETYPEFoundType;
+  EFI_FV_FILE_ATTRIBUTES FileAttributes;
+
+  Status = EFI_SUCCESS;
+  gBS->LocateHandleBuffer (
+ ByProtocol,
+ ,
+ NULL,
+ ,
+ 
+ );
+
+  for (Index = 0; Index < FvHandleCount; Index++) {
+Size   = 0;
+gBS->HandleProtocol (
+   FvHandleBuffer[Index],
+   ,
+   (VOID **)
+   );
+Status = Fv->ReadFile (
+   Fv,
+   ,
+   NULL,
+   ,
+   ,
+   ,
+   
+   );
+if (!EFI_ERROR (Status)) {
+  //
+  // Found the shell file
+  //
+  break;
+}
+  }
+
+  if (EFI_ERROR (Status)) {
+if (FvHandleCount) {
+  FreePool (FvHandleBuffer);
+}
+
+return NULL;
+  }
+
+  DevicePath = DevicePathFromHandle (FvHandleBuffer[Index]);
+
+  if (FvHandleCount) {
+FreePool (FvHandleBuffer);
+  }
+
+  return DevicePath;
+}
+
 /**
   Register a boot option using a file GUID in the FV.
 
@@ -109,15 +181,11 @@ PlatformRegisterFvBootOption (
   EFI_BOOT_MANAGER_LOAD_OPTION   *BootOptions;
   UINTN  BootOptionCount;
   MEDIA_FW_VOL_FILEPATH_DEVICE_PATH  FileNode;
-  EFI_LOADED_IMAGE_PROTOCOL  *LoadedImage;
   EFI_DEVICE_PATH_PROTOCOL   *DevicePath;
 
-  Status = gBS->HandleProtocol (gImageHandle, , 
(VOID **));
-  ASSERT_EFI_ERROR (Status);
-
   EfiInitializeFwVolDevicepathNode (, FileGuid);
   DevicePath = AppendDevicePathNode (
- DevicePathFromHandle (LoadedImage->DeviceHandle),
+ BdsGetShellFvDevicePath (),
  (EFI_DEVICE_PATH_PROTOCOL *)
  );
 
@@ -248,7 +316,7 @@ PlatformBootManagerAfterConsole (
   //
   // Register UEFI Shell
   //
-  PlatformRegisterFvBootOption (PcdGetPtr (PcdShellFile), L"UEFI Shell", 
LOAD_OPTION_ACTIVE);
+  PlatformRegisterFvBootOption (, L"UEFI Shell", 
LOAD_OPTION_ACTIVE);
 
   if (FixedPcdGetBool (PcdBootManagerEscape)) {
 Print (
diff --git 
a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf 
b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
index f9626175e2..a3951b7a7e 100644
--- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
@@ -1,7 +1,7 @@
 ## @file
 #  Include all platform action which can be customized by IBV/OEM.
 #
-#  Copyright (c) 2012 - 2021, Intel Corporation. All rights reserved.
+#  Copyright (c) 2012 - 2023, Intel Corporation. All rights reserved.
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 ##
@@ -32,6 

Re: [edk2-devel][PATCH] UefiPayloadPkg: Fix boot shell issue for universal UEFI payload

2023-05-12 Thread Guo Dong

Hi Mike,
Thanks to share the details. I think you are right the "buffer" need be freed 
using ReadSection().
I don't really want to read the shell file, so I would update this patch to use 
ReadFile() which supports NULL for the file buffer.

Thanks,
Guo
-Original Message-
From: Mike Maslenkin  
Sent: Thursday, May 11, 2023 1:00 PM
To: devel@edk2.groups.io; Dong, Guo 
Cc: Ni, Ray ; Rhodes, Sean ; Lu, James 
; Guo, Gua 
Subject: Re: [edk2-devel][PATCH] UefiPayloadPkg: Fix boot shell issue for 
universal UEFI payload

Hi Guo,
thanks for your explanation.

I may be wrong, but there is a different logic used.
Passing pointer to NULL means request for callee allocation.
I assume EFI_FIRMWARE_VOLUME2_PROTOCOL implemented in 
MdeModulePkg/Core/Dxe/FwVol.
So, Fv->ReadSection() actually is FvReadFileSection() call [1].
This function passes pointer to pointer to buffer (aka void **) into
GetSection() function.
edk2 contains only one implementation of this function in 
MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c
And the code [2] handling Buffer variable is below:

  if (*Buffer != NULL) {
//
// Caller allocated buffer.  Fill to size and return required size...
//
if (*BufferSize < CopySize) {
  Status   = EFI_WARN_BUFFER_TOO_SMALL;
  CopySize = *BufferSize;
}
  } else {
//
// Callee allocated buffer.  Allocate buffer and return size.
//
*Buffer = AllocatePool (CopySize);
if (*Buffer == NULL) {
  Status = EFI_OUT_OF_RESOURCES;
  goto GetSection_Done;
}
  }

Same pattern used in FvReadFile() implementation.

[1]  
https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c#L508
[2]  
https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c#L1339

Regards,
Mike

On Thu, May 11, 2023 at 8:16 PM Guo Dong  wrote:
>
>
> Hi Mike,
> Thanks for your comments.
> The "Buffer" is initialized to NULL for ReadSection call, we don't need free 
> "Buffer" since there is no data really read to Buffer.
> With "Buffer" set to NULL, it just test if the file exists in the FV. If it 
> exists, it will return success with file size.
>
> Thanks,
> Guo
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Mike 
> Maslenkin
> Sent: Wednesday, May 10, 2023 12:14 AM
> To: devel@edk2.groups.io; Dong, Guo 
> Cc: Ni, Ray ; Rhodes, Sean ; 
> Lu, James ; Guo, Gua 
> Subject: Re: [edk2-devel][PATCH] UefiPayloadPkg: Fix boot shell issue 
> for universal UEFI payload
>
> Hi, Guo Dong
>
> Don't you need to free "Buffer" after Fv->ReadSection() call ?
>
> Regards,
> Mike.
>
> On Wed, May 10, 2023 at 6:58 AM Guo Dong  wrote:
> >
> > From: Guo Dong 
> >
> > After moving BDS driver to a new FV for universal UEFI payload, the 
> > shell boot option path is not correct since it used the BDS FV 
> > instead of DXE FV in its device path.
> > This patch would find the correct FV by reading shell file.
> > It also removed PcdShellFile by using gUefiShellFileGuid.
> >
> > Signed-off-by: Guo Dong 
> > Cc: Ray Ni 
> > Cc: Sean Rhodes 
> > Cc: James Lu 
> > Cc: Gua Guo 
> > ---
> >  UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c  | 
> > 76 
> > ++--
> >  UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf | 
> >  5 +++--
> >  UefiPayloadPkg/UefiPayloadPkg.dec| 
> >  3 ---
> >  3 files changed, 73 insertions(+), 11 deletions(-)
> >
> > diff --git
> > a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.
> > c 
> > b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.
> > c
> > index 62637ae6aa..cf72783af1 100644
> > ---
> > a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.
> > c
> > +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootMana
> > +++ ge
> > +++ r.c
> > @@ -2,7 +2,7 @@
> >This file include all platform action which can be customized
> >by IBV/OEM.
> >
> > -Copyright (c) 2015 - 2021, Intel Corporation. All rights 
> > reserved.
> > +Copyright (c) 2015 - 2023, Intel Corporation. All rights 
> > +reserved.
> >  SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> >  **/
> > @@ -11,6 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent 
> > #include "PlatformConsole.h"
> >  #include 
> >  #include 
> > +#include 
> >
> >  /**
> >Signal EndOfDxe event and install SMM Ready to lock protocol.
> > @@ -89,6 +90,72 @@ PlatformFindLoadOption (
> >return -1;
> >  }
> >
> > +
> > +EFI_DEVICE_PATH_PROTOCOL *
> > +BdsGetShellFvDevicePath (
> > +  VOID
> > +  )
> > +{
> > +  UINTN FvHandleCount;
> > +  EFI_HANDLE*FvHandleBuffer;
> > +  UINTN Index;
> > +  EFI_STATUSStatus;
> > +  EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
> > +  UINTN 

Re: [edk2-devel] PATCH [1/1] ArmPkg: Fix GicV2 BaseAddress types

2023-05-12 Thread Pedro Falcato
(+CC maintainers)

On Thu, May 11, 2023 at 5:47 PM  wrote:
>
> The GIC v2 base addresses can be 64bit, don't limit to 32 on 64bit
> machines.
>
> Signed-off-by: Neil Jones 
> ---
>  ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c 
> b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c
> index 25290342bd..b990bf3a8a 100644
> --- a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c
> +++ b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Dxe.c
> @@ -25,8 +25,8 @@ Abstract:
>  extern EFI_HARDWARE_INTERRUPT_PROTOCOL   gHardwareInterruptV2Protocol;
>  extern EFI_HARDWARE_INTERRUPT2_PROTOCOL  gHardwareInterrupt2V2Protocol;
>
> -STATIC UINT32  mGicInterruptInterfaceBase;
> -STATIC UINT32  mGicDistributorBase;
> +STATIC UINTN mGicInterruptInterfaceBase;
> +STATIC UINTN mGicDistributorBase;
>
>  /**
>Enable interrupt source Source.
> --
> 2.39.2

LGTM, particularly as the PCDs are 64-bit already.
Reviewed-by: Pedro Falcato 

but CC'ing the proper maintainers (please do so in the future!)

-- 
Pedro


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




[edk2-devel] [PATCH edk2-platforms 2/2] Silicon/Qemu: use dynamic Pcds for SbsaQemu GIC addresses

2023-05-12 Thread Leif Lindholm
The GIC addresses as currently declared as FixedPcd for SbsaQemu.
Change them to dynamic, to enable future patches to support these
being determined at runtime.

Signed-off-by: Leif Lindholm 
Cc: Ard Biesheuvel 
Cc: Graeme Gregory 
Cc: Radoslaw Biernacki 
Cc: Marcin Juszkiewicz 
---
 Platform/Qemu/SbsaQemu/SbsaQemu.dsc  | 12 ++--
 Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf  |  7 ---
 .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf  |  5 +++--
 .../SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h |  2 +-
 .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c|  2 +-
 5 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc 
b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
index 9ca030cfe9a7..0bd0df4f0239 100644
--- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
+++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
@@ -406,12 +406,6 @@ [PcdsFixedAtBuild.common]
   # Size of the region used by UEFI in permanent memory (Reserved 64MB)
   gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x0400
 
-  #
-  # ARM General Interrupt Controller
-  #
-  gArmTokenSpaceGuid.PcdGicDistributorBase|0x4006
-  gArmTokenSpaceGuid.PcdGicRedistributorsBase|0x4008
-
   ## Default Terminal Type
   ## 0-PCANSI, 1-VT100, 2-VT00+, 3-UTF8, 4-TTYTERM
   gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|4
@@ -523,6 +517,12 @@ [PcdsDynamicDefault.common]
   # TODO as no DT will be used we should pass this by some other method
   gArmTokenSpaceGuid.PcdSystemMemorySize|0x0800
 
+  #
+  # ARM General Interrupt Controller
+  #
+  gArmTokenSpaceGuid.PcdGicDistributorBase|0x4006
+  gArmTokenSpaceGuid.PcdGicRedistributorsBase|0x4008
+
   #
   # Set video resolution for boot options
   # PlatformDxe can set the former at runtime.
diff --git a/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf 
b/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf
index 176d8fab835b..0501c670d565 100644
--- a/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf
+++ b/Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf
@@ -32,9 +32,6 @@ [Packages]
   Silicon/Qemu/SbsaQemu/SbsaQemu.dec
 
 [FixedPcd]
-  gArmTokenSpaceGuid.PcdGicDistributorBase
-  gArmTokenSpaceGuid.PcdGicRedistributorsBase
-
   gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum
   gArmTokenSpaceGuid.PcdArmArchTimerIntrNum
   gArmTokenSpaceGuid.PcdArmArchTimerHypIntrNum
@@ -74,3 +71,7 @@ [FixedPcd]
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciSize
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformEhciBase
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformEhciSize
+
+[Pcd]
+  gArmTokenSpaceGuid.PcdGicDistributorBase
+  gArmTokenSpaceGuid.PcdGicRedistributorsBase
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf 
b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf
index c6de685bd2c4..c1c33788567d 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf
@@ -46,6 +46,9 @@ [Pcd]
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdCoreCount
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdClusterCount
 
+  gArmTokenSpaceGuid.PcdGicDistributorBase
+  gArmTokenSpaceGuid.PcdGicRedistributorsBase
+
 [Depex]
   gEfiAcpiTableProtocolGuid   ## CONSUMES
 
@@ -57,8 +60,6 @@ [Protocols]
 
 [FixedPcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision
-  gArmTokenSpaceGuid.PcdGicDistributorBase
-  gArmTokenSpaceGuid.PcdGicRedistributorsBase
 
   gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId
   gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision
diff --git a/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h 
b/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h
index dcafcbca5a48..853b81b34df5 100644
--- a/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h
+++ b/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h
@@ -33,7 +33,7 @@
EFI_ACPI_6_0_GICR,/* Type */
\
sizeof (EFI_ACPI_6_0_GICR_STRUCTURE), /* Length */  
\
EFI_ACPI_RESERVED_WORD,   /* Reserved */
\
-   FixedPcdGet64 (PcdGicRedistributorsBase), /* DiscoveryRangeBaseAddress */   
\
+   PcdGet64 (PcdGicRedistributorsBase),  /* DiscoveryRangeBaseAddress */   
\
SBSAQEMU_MADT_GICR_SIZE   /* DiscoveryRangeLength */
\
}
 
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c 
b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
index 58330a3e7005..ae5397bab768 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
@@ -83,7 +83,7 @@ AddMadtTable (
   EFI_ACPI_6_0_GIC_DISTRIBUTOR_STRUCTURE Gicd =
 EFI_ACPI_6_0_GIC_DISTRIBUTOR_INIT (
   0,
-  FixedPcdGet64 (PcdGicDistributorBase),
+  

[edk2-devel] [PATCH edk2-platforms 1/2] Silicon/Qemu: use 64-bit Pcds for SbsaQemu GIC addresses

2023-05-12 Thread Leif Lindholm
gArmTokenSpaceGuid.PcdGicDistributorBase and
gArmTokenSpaceGuid.PcdGicRedistributorsBase are both defined as UINT64 in
ArmPkg.dec, but SbsaQemuAcpiDxe and its exported header file use
PcdGet32. While this currently works, it will break once these Pcds are
made dynamic - so fix.

Signed-off-by: Leif Lindholm 
Cc: Ard Biesheuvel 
Cc: Graeme Gregory 
Cc: Radoslaw Biernacki 
Cc: Marcin Juszkiewicz 
---
 Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h   | 2 +-
 Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h 
b/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h
index 4d5b05ba17c6..dcafcbca5a48 100644
--- a/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h
+++ b/Silicon/Qemu/SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h
@@ -33,7 +33,7 @@
EFI_ACPI_6_0_GICR,/* Type */
\
sizeof (EFI_ACPI_6_0_GICR_STRUCTURE), /* Length */  
\
EFI_ACPI_RESERVED_WORD,   /* Reserved */
\
-   FixedPcdGet32 (PcdGicRedistributorsBase), /* DiscoveryRangeBaseAddress */   
\
+   FixedPcdGet64 (PcdGicRedistributorsBase), /* DiscoveryRangeBaseAddress */   
\
SBSAQEMU_MADT_GICR_SIZE   /* DiscoveryRangeLength */
\
}
 
diff --git a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c 
b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
index 7ba9e8e9deeb..58330a3e7005 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c
@@ -83,7 +83,7 @@ AddMadtTable (
   EFI_ACPI_6_0_GIC_DISTRIBUTOR_STRUCTURE Gicd =
 EFI_ACPI_6_0_GIC_DISTRIBUTOR_INIT (
   0,
-  FixedPcdGet32 (PcdGicDistributorBase),
+  FixedPcdGet64 (PcdGicDistributorBase),
   0,
   3 /* GicVersion */
 );
-- 
2.30.2



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




[edk2-devel] [PATCH edk2-platforms 0/2] SbsaQemu: make GIC base address Pcds dynamic

2023-05-12 Thread Leif Lindholm
Currently, the GIC and redistributors base addresses are defined using
FixedPcds.

In order to enable the QEMU platform to evolve to provide ITS frames,
as well as newer versions of the GIC, convert these accesses to Dynamic.

Firtsly, this requires fixing the bug of the addresses being read as 32-bit
Pcds, and then moving the declarations and calls to the dynamic form.

Cc: Ard Biesheuvel 
Cc: Graeme Gregory 
Cc: Radoslaw Biernacki 
Cc: Marcin Juszkiewicz 

Leif Lindholm (2):
  Silicon/Qemu: use 64-bit Pcds for SbsaQemu GIC addresses
  Silicon/Qemu: use dynamic Pcds for SbsaQemu GIC addresses

 Platform/Qemu/SbsaQemu/SbsaQemu.dsc  | 12 ++--
 Silicon/Qemu/SbsaQemu/AcpiTables/AcpiTables.inf  |  7 ---
 .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.inf  |  5 +++--
 .../SbsaQemu/Include/IndustryStandard/SbsaQemuAcpi.h |  2 +-
 .../Drivers/SbsaQemuAcpiDxe/SbsaQemuAcpiDxe.c|  2 +-
 5 files changed, 15 insertions(+), 13 deletions(-)

-- 
2.30.2



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




Re: [edk2-devel] [PATCH v11 0/8] Adds AmdSmmCpuFeaturesLib and MmSaveStateLib

2023-05-12 Thread Attar, AbdulLateef (Abdul Lateef) via groups.io
[AMD Official Use Only - General]

Hi Ray,
Looks like some issue with my mailbox, I saw your mail after submitting 
patch V12.
I'll rework and send V13 patch series.

Thanks
AbduL

-Original Message-
From: Ni, Ray 
Sent: 12 May 2023 09:11
To: devel@edk2.groups.io; Ni, Ray ; Attar, AbdulLateef (Abdul 
Lateef) ; Wu, Jiaxin 
Cc: Grimes, Paul ; Chang, Abner ; 
Dong, Eric ; Kumar, Rahul R ; 
Gerd Hoffmann ; Kinney, Michael D 
; Gao, Liming ; Liu, 
Zhiguang ; Ard Biesheuvel ; 
Yao, Jiewen ; Justen, Jordan L 
; Holthaus, CJ 
Subject: RE: [edk2-devel] [PATCH v11 0/8] Adds AmdSmmCpuFeaturesLib and 
MmSaveStateLib

Caution: This message originated from an External Source. Use proper caution 
when opening attachments, clicking links, or responding.


Abdul,
I checked your V12 patch. It seems none of comments I have for your V11 are not 
addressed. (check my inline reply below)

Can we get aligned firstly then you send out next version patches?

This could also save my time on downloading your changes and reviewing them one 
by one.

Thanks,
Ray


> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Ni, Ray
> Sent: Thursday, May 11, 2023 2:56 PM
> To: Abdul Lateef Attar ; devel@edk2.groups.io; Wu,
> Jiaxin 
> Cc: Paul Grimes ; Abner Chang
> ; Dong, Eric ; Kumar, Rahul
> R ; Gerd Hoffmann ;
> Kinney, Michael D ; Gao, Liming
> ; Liu, Zhiguang ;
> Ard Biesheuvel ; Yao, Jiewen
> ; Justen, Jordan L ;
> Holthaus, CJ 
> Subject: Re: [edk2-devel] [PATCH v11 0/8] Adds AmdSmmCpuFeaturesLib
> and MmSaveStateLib
>
> >   UefiCpuPkg: Adds MmSaveStateLib library class
> You can take "Reviewed-by: Ray Ni " for this patch.
>
> > UefiCpuPkg/SmmCpuFeaturesLib: Restructure arch-dependent code
> You can take "Reviewed-by: Ray Ni " for this patch.
>
> > UefiCpuPkg: Implements SmmCpuFeaturesLib for AMD Family
> One comment: can you please change the BASE_NAME in lib INF to
> "AmdSmmCpuFeaturesLib"?
> The BASE_NAME guides tool to generate the .Lib file in the disk.
> Choosing different BASE_NAME for Intel and AMD lib instance can avoid
> one LIB file is replaced by the other during pkg build.
>
> > UefiCpuPkg: Implements MmSaveStateLib for Intel
> 1. MmSaveStateLib local functions should not have "EFIAPI". Please
> only add "EFIAPI" for lib APIs.

1. not addressed in V12.

> 2. MmSaveStateGetRegisterLma() doesn't need to carry "CpuIndex" as
> parameter. Can you please remove the parameter?


2. not addressed in V12.

> 3. MmSaveStateGetRegisterIndex () returns wrong value for Intel
> processors because it uses Offset ( = 2) but Intel implementation uses Offset 
> ( = 4).
>
> (I remember comments #1, #3 were both raised last time when I reviewed
> the
> patch.)

3. not addressed in V12.

>
> > UefiCpuPkg: Removes SmmCpuFeaturesReadSaveStateRegister
> You can take "Reviewed-by: Ray Ni " for this patch.
>
>
> One more comment:
> Can you please avoid FILE_GUID overridden in UefiCpuPkg.dsc for Intel
> instance of SmmCpu driver?
> AMD instance can override the FILE_GUID for sure.

4. not addressed in V12.

>
> @Wu, Jiaxin, we will need to change the close-source SmmCpuFeatureLib
> accordingly (separating the SaveState access code into a different
> lib) when this patch series are merged.
>
> > -Original Message-
> > From: Abdul Lateef Attar 
> > Sent: Saturday, May 6, 2023 12:07 PM
> > To: devel@edk2.groups.io
> > Cc: Abdul Lateef Attar ; Paul Grimes
> > ; Abner Chang ; Dong, Eric
> > ; Ni, Ray ; Kumar, Rahul R
> > ; Gerd Hoffmann ;
> > Kinney, Michael D ; Gao, Liming
> > ; Liu, Zhiguang ;
> > Ard Biesheuvel ; Yao, Jiewen
> ;
> > Justen, Jordan L 
> > Subject: [PATCH v11 0/8] Adds AmdSmmCpuFeaturesLib and
> > MmSaveStateLib
> >
> > PR: https://github.com/tianocore/edk2/pull/4341
> >
> > V11: Delta changes
> > Drop the OVMF implementation of MmSaveStateLib
> > V10: Delta changes:
> >   Addressed review comments from Abner.
> > V9: Delta changes:
> >   Addressed review comments.
> >   Rename to MmSaveStateLib.
> >   Also rename SMM_ defines to MM_.
> >   Implemented OVMF MmSaveStateLib.
> >   Removes SmmCpuFeaturesReadSaveStateRegister and
> > SmmCpuFeaturesWriteSaveStateRegister
> >   function interface.
> > V8 delta changes:
> >Addressed review comments from Abner,
> >Fix the whitespace error.
> >Seperate the Ovmf changes to another patch
> > V7 delta changes:
> >Adds SmmSmramSaveStateLib for Intel processor.
> >Integrate SmmSmramSaveStateLib library.
> > V6 delta changes:
> >Addressed review comments for Ray NI.
> >removed unnecessary EFIAPI.
> > V5 delta changes:
> >rebase to master branch.
> >updated Reviewed-by
> > V4 delta changes:
> >   rebase to master branch.
> >   added reviewed-by.
> > V3 delta changes:
> >   Addressed review comments from Abner chang.
> >   Re-arranged patch order.
> >
> > Cc: Paul Grimes 
> > Cc: Abner Chang 
> > Cc: Eric Dong 
> > Cc: Ray Ni 
> > Cc: Rahul Kumar 
> > Cc: Gerd Hoffmann 
> > Cc: Michael D Kinney 
> > Cc: Liming Gao 
> > Cc: 

[edk2-devel] [PATCH 4/5] ArmVirt/PlatformBootManagerLib: set up virtio serial as console

2023-05-12 Thread Gerd Hoffmann
In case a virtio serial device is found in the system register the first
console port as EFI console, by updating ConIn, ConOut and ErrOut.

Signed-off-by: Gerd Hoffmann 
---
 .../PlatformBootManagerLib/PlatformBm.c   | 163 ++
 1 file changed, 163 insertions(+)

diff --git a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c 
b/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
index ed38c42a43ee..7010d73c1388 100644
--- a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
+++ b/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
@@ -312,6 +312,21 @@ IsVirtioRng (
   return IsVirtio (Handle, ReportText, VIRTIO_SUBSYSTEM_ENTROPY_SOURCE);
 }
 
+/**
+  This FILTER_FUNCTION checks if a handle corresponds to a Virtio serial 
device at
+  the VIRTIO_DEVICE_PROTOCOL level.
+**/
+STATIC
+BOOLEAN
+EFIAPI
+IsVirtioSerial (
+  IN EFI_HANDLEHandle,
+  IN CONST CHAR16  *ReportText
+  )
+{
+  return IsVirtio (Handle, ReportText, VIRTIO_SUBSYSTEM_CONSOLE);
+}
+
 /**
   This function checks if a handle corresponds to the Virtio Device ID given
   at the EFI_PCI_IO_PROTOCOL level.
@@ -446,6 +461,21 @@ IsVirtioPciRng (
   return IsVirtioPci (Handle, ReportText, VIRTIO_SUBSYSTEM_ENTROPY_SOURCE);
 }
 
+/**
+  This FILTER_FUNCTION checks if a handle corresponds to a Virtio serial 
device at
+  the EFI_PCI_IO_PROTOCOL level.
+**/
+STATIC
+BOOLEAN
+EFIAPI
+IsVirtioPciSerial (
+  IN EFI_HANDLEHandle,
+  IN CONST CHAR16  *ReportText
+  )
+{
+  return IsVirtioPci (Handle, ReportText, VIRTIO_SUBSYSTEM_CONSOLE);
+}
+
 /**
   This CALLBACK_FUNCTION attempts to connect a handle non-recursively, asking
   the matching driver to produce all first-level child handles.
@@ -534,6 +564,133 @@ AddOutput (
 ));
 }
 
+/**
+  This CALLBACK_FUNCTION retrieves the EFI_DEVICE_PATH_PROTOCOL from
+  the handle, appends serial, uart and terminal nodes, finally updates
+  ConIn, ConOut and ErrOut.
+**/
+STATIC
+VOID
+EFIAPI
+SetupVirtioSerial (
+  IN EFI_HANDLEHandle,
+  IN CONST CHAR16  *ReportText
+  )
+{
+  STATIC ACPI_HID_DEVICE_PATH  SerialNode = {
+{
+  ACPI_DEVICE_PATH,
+  ACPI_DP,
+  {
+(UINT8)(sizeof (ACPI_HID_DEVICE_PATH)),
+(UINT8)((sizeof (ACPI_HID_DEVICE_PATH)) >> 8)
+  },
+},
+EISA_PNP_ID (0x0501),
+0
+  };
+
+  STATIC UART_DEVICE_PATH  UartNode = {
+{
+  MESSAGING_DEVICE_PATH,
+  MSG_UART_DP,
+  {
+(UINT8)(sizeof (UART_DEVICE_PATH)),
+(UINT8)((sizeof (UART_DEVICE_PATH)) >> 8)
+  },
+},
+0,
+115200,
+8,
+1,
+1
+  };
+
+  STATIC VENDOR_DEVICE_PATH  TerminalNode = {
+{
+  MESSAGING_DEVICE_PATH,
+  MSG_VENDOR_DP,
+  {
+(UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+(UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+  },
+},
+DEVICE_PATH_MESSAGING_VT_UTF8
+  };
+
+  EFI_STATUSStatus;
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
+
+  DevicePath = DevicePathFromHandle (Handle);
+
+  if (DevicePath == NULL) {
+DEBUG ((
+  DEBUG_ERROR,
+  "%a: %s: handle %p: device path not found\n",
+  __func__,
+  ReportText,
+  Handle
+  ));
+return;
+  }
+
+  DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)
+ );
+  DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)
+ );
+  DevicePath = AppendDevicePathNode (
+ DevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)
+ );
+
+  Status = EfiBootManagerUpdateConsoleVariable (ConIn, DevicePath, NULL);
+  if (EFI_ERROR (Status)) {
+DEBUG ((
+  DEBUG_ERROR,
+  "%a: %s: adding to ConIn: %r\n",
+  __func__,
+  ReportText,
+  Status
+  ));
+return;
+  }
+
+  Status = EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
+  if (EFI_ERROR (Status)) {
+DEBUG ((
+  DEBUG_ERROR,
+  "%a: %s: adding to ConOut: %r\n",
+  __func__,
+  ReportText,
+  Status
+  ));
+return;
+  }
+
+  Status = EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
+  if (EFI_ERROR (Status)) {
+DEBUG ((
+  DEBUG_ERROR,
+  "%a: %s: adding to ErrOut: %r\n",
+  __func__,
+  ReportText,
+  Status
+  ));
+return;
+  }
+
+  DEBUG ((
+DEBUG_VERBOSE,
+"%a: %s: added to ConIn, ConOut and ErrOut\n",
+__func__,
+ReportText
+));
+}
+
 STATIC
 VOID
 PlatformRegisterFvBootOption (
@@ -932,6 +1089,12 @@ PlatformBootManagerBeforeConsole (
   // instances on Virtio PCI RNG devices.
   //
   FilterAndProcess (, IsVirtioPciRng, Connect);
+
+  //
+  // Register Virtio serial devices as console.
+  //
+  FilterAndProcess (, IsVirtioSerial, 
SetupVirtioSerial);
+  FilterAndProcess (, IsVirtioPciSerial, 
SetupVirtioSerial);
 }
 
 /**
-- 
2.40.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to 

[edk2-devel] [PATCH 0/5] ArmVirt: add VirtioSerialDxe

2023-05-12 Thread Gerd Hoffmann



Gerd Hoffmann (5):
  ArmVirt: add VirtioSerialDxe to ArmVirtQemu builds
  ArmVirt/PlatformBootManagerLib: factor out IsVirtio()
  ArmVirt/PlatformBootManagerLib: factor out IsVirtioPci()
  ArmVirt/PlatformBootManagerLib: set up virtio serial as console
  OvmfPkg/VirtioSerialDxe: use TPL_NOTIFY

 ArmVirtPkg/ArmVirtQemu.dsc|   1 +
 ArmVirtPkg/ArmVirtQemuKernel.dsc  |   1 +
 .../PlatformBootManagerLib/PlatformBm.c   | 215 +-
 OvmfPkg/VirtioSerialDxe/VirtioSerialPort.c|   4 +-
 ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc  |   1 +
 5 files changed, 210 insertions(+), 12 deletions(-)

-- 
2.40.1



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




[edk2-devel] [PATCH 5/5] OvmfPkg/VirtioSerialDxe: use TPL_NOTIFY

2023-05-12 Thread Gerd Hoffmann
Apparently TPL_CALLBACK is too low, code runs into an ASSERT
complaining the new TPL is lower than the old TPL.

Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/VirtioSerialDxe/VirtioSerialPort.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/OvmfPkg/VirtioSerialDxe/VirtioSerialPort.c 
b/OvmfPkg/VirtioSerialDxe/VirtioSerialPort.c
index 522b25e9698c..e4a58deff162 100644
--- a/OvmfPkg/VirtioSerialDxe/VirtioSerialPort.c
+++ b/OvmfPkg/VirtioSerialDxe/VirtioSerialPort.c
@@ -158,7 +158,7 @@ VirtioSerialIoWrite (
 
   VirtioSerialRingClearTx (SerialIo->Dev, PortTx (SerialIo->PortId));
 
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
   if (SerialIo->WriteOffset &&
   (SerialIo->WriteOffset + *BufferSize > PORT_TX_BUFSIZE))
   {
@@ -201,7 +201,7 @@ VirtioSerialIoRead (
 goto NoData;
   }
 
-  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+  OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
   if (SerialIo->WriteOffset) {
 DEBUG ((DEBUG_VERBOSE, "%a:%d: WriteFlush %d\n", __func__, __LINE__, 
SerialIo->WriteOffset));
 VirtioSerialRingSendBuffer (
-- 
2.40.1



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




[edk2-devel] [PATCH 3/5] ArmVirt/PlatformBootManagerLib: factor out IsVirtioPci()

2023-05-12 Thread Gerd Hoffmann
IsVirtioPciRng() becomes just a thin wrapper for IsVirtioPci().
This allows to add similar thin wrappers for other virtio
devices in the future.

Signed-off-by: Gerd Hoffmann 
---
 .../PlatformBootManagerLib/PlatformBm.c   | 30 ++-
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c 
b/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
index 5eb6f0f9c14a..ed38c42a43ee 100644
--- a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
+++ b/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
@@ -313,15 +313,16 @@ IsVirtioRng (
 }
 
 /**
-  This FILTER_FUNCTION checks if a handle corresponds to a Virtio RNG device at
-  the EFI_PCI_IO_PROTOCOL level.
+  This function checks if a handle corresponds to the Virtio Device ID given
+  at the EFI_PCI_IO_PROTOCOL level.
 **/
 STATIC
 BOOLEAN
 EFIAPI
-IsVirtioPciRng (
+IsVirtioPci (
   IN EFI_HANDLEHandle,
-  IN CONST CHAR16  *ReportText
+  IN CONST CHAR16  *ReportText,
+  IN UINT16VirtIoDeviceId
   )
 {
   EFI_STATUS   Status;
@@ -387,11 +388,11 @@ IsVirtioPciRng (
   //
   // From DeviceId and RevisionId, determine whether the device is a
   // modern-only Virtio 1.0 device. In case of Virtio 1.0, DeviceId can
-  // immediately be restricted to VIRTIO_SUBSYSTEM_ENTROPY_SOURCE, and
+  // immediately be restricted to VirtIoDeviceId, and
   // SubsystemId will only play a sanity-check role. Otherwise, DeviceId can
   // only be sanity-checked, and SubsystemId will decide.
   //
-  if ((DeviceId == 0x1040 + VIRTIO_SUBSYSTEM_ENTROPY_SOURCE) &&
+  if ((DeviceId == 0x1040 + VirtIoDeviceId) &&
   (RevisionId >= 0x01))
   {
 Virtio10 = TRUE;
@@ -419,7 +420,7 @@ IsVirtioPciRng (
 return TRUE;
   }
 
-  if (!Virtio10 && (SubsystemId == VIRTIO_SUBSYSTEM_ENTROPY_SOURCE)) {
+  if (!Virtio10 && (SubsystemId == VirtIoDeviceId)) {
 return TRUE;
   }
 
@@ -430,6 +431,21 @@ IsVirtioPciRng (
   return FALSE;
 }
 
+/**
+  This FILTER_FUNCTION checks if a handle corresponds to a Virtio RNG device at
+  the EFI_PCI_IO_PROTOCOL level.
+**/
+STATIC
+BOOLEAN
+EFIAPI
+IsVirtioPciRng (
+  IN EFI_HANDLEHandle,
+  IN CONST CHAR16  *ReportText
+  )
+{
+  return IsVirtioPci (Handle, ReportText, VIRTIO_SUBSYSTEM_ENTROPY_SOURCE);
+}
+
 /**
   This CALLBACK_FUNCTION attempts to connect a handle non-recursively, asking
   the matching driver to produce all first-level child handles.
-- 
2.40.1



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




[edk2-devel] [PATCH 2/5] ArmVirt/PlatformBootManagerLib: factor out IsVirtio()

2023-05-12 Thread Gerd Hoffmann
IsVirtioRng() becomes just a thin wrapper for IsVirtio().
This allows to add similar thin wrappers for other virtio
devices in the future.

Signed-off-by: Gerd Hoffmann 
---
 .../PlatformBootManagerLib/PlatformBm.c   | 26 +++
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c 
b/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
index 10c815378cd5..5eb6f0f9c14a 100644
--- a/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
+++ b/ArmVirtPkg/Library/PlatformBootManagerLib/PlatformBm.c
@@ -269,15 +269,16 @@ IsPciDisplay (
 }
 
 /**
-  This FILTER_FUNCTION checks if a handle corresponds to a Virtio RNG device at
-  the VIRTIO_DEVICE_PROTOCOL level.
+  This function checks if a handle corresponds to the Virtio Device ID given
+  at the VIRTIO_DEVICE_PROTOCOL level.
 **/
 STATIC
 BOOLEAN
 EFIAPI
-IsVirtioRng (
+IsVirtio (
   IN EFI_HANDLEHandle,
-  IN CONST CHAR16  *ReportText
+  IN CONST CHAR16  *ReportText,
+  IN UINT16VirtIoDeviceId
   )
 {
   EFI_STATUS  Status;
@@ -293,7 +294,22 @@ IsVirtioRng (
   }
 
   return (BOOLEAN)(VirtIo->SubSystemDeviceId ==
-   VIRTIO_SUBSYSTEM_ENTROPY_SOURCE);
+   VirtIoDeviceId);
+}
+
+/**
+  This FILTER_FUNCTION checks if a handle corresponds to a Virtio RNG device at
+  the VIRTIO_DEVICE_PROTOCOL level.
+**/
+STATIC
+BOOLEAN
+EFIAPI
+IsVirtioRng (
+  IN EFI_HANDLEHandle,
+  IN CONST CHAR16  *ReportText
+  )
+{
+  return IsVirtio (Handle, ReportText, VIRTIO_SUBSYSTEM_ENTROPY_SOURCE);
 }
 
 /**
-- 
2.40.1



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




[edk2-devel] [PATCH 1/5] ArmVirt: add VirtioSerialDxe to ArmVirtQemu builds

2023-05-12 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 ArmVirtPkg/ArmVirtQemu.dsc   | 1 +
 ArmVirtPkg/ArmVirtQemuKernel.dsc | 1 +
 ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc | 1 +
 3 files changed, 3 insertions(+)

diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index 449e73b9e132..d998f816b2b3 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -448,6 +448,7 @@ [Components.common]
   OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
   OvmfPkg/VirtioNetDxe/VirtioNet.inf
   OvmfPkg/VirtioRngDxe/VirtioRng.inf
+  OvmfPkg/VirtioSerialDxe/VirtioSerial.inf
 
   #
   # FAT filesystem + GPT/MBR partitioning + UDF filesystem + virtio-fs
diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
index 3cb9120e4e10..c9d2b18392b9 100644
--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
+++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
@@ -353,6 +353,7 @@ [Components.common]
   OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
   OvmfPkg/VirtioNetDxe/VirtioNet.inf
   OvmfPkg/VirtioRngDxe/VirtioRng.inf
+  OvmfPkg/VirtioSerialDxe/VirtioSerial.inf
 
   #
   # FAT filesystem + GPT/MBR partitioning + UDF filesystem + virtio-fs
diff --git a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc 
b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc
index 8a063bac04ac..2894bc853a46 100644
--- a/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc
+++ b/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc
@@ -98,6 +98,7 @@ [FV.FvMain]
   INF OvmfPkg/VirtioNetDxe/VirtioNet.inf
   INF OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
   INF OvmfPkg/VirtioRngDxe/VirtioRng.inf
+  INF OvmfPkg/VirtioSerialDxe/VirtioSerial.inf
 
   INF ShellPkg/Application/Shell/Shell.inf
   INF ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf
-- 
2.40.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104800): https://edk2.groups.io/g/devel/message/104800
Mute This Topic: https://groups.io/mt/98850077/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 11/12] OvmfPkg/Xen: Replace the OVMF-specific SataControllerDxe

2023-05-12 Thread Anthony PERARD via groups.io
On Tue, May 09, 2023 at 05:32:11PM +0100, Pedro Falcato wrote:
> Replace the OVMF-specific SataControllerDxe (to be later removed) with
> the generic, MdeModulePkg one, for the OvmfXen platform.
> 
> Cc: Ard Biesheuvel 
> Cc: Jiewen Yao 
> Cc: Jordan Justen 
> Cc: Gerd Hoffmann 
> Cc: Anthony Perard 
> Cc: Julien Grall 
> Signed-off-by: Pedro Falcato 

Acked-by: Anthony PERARD 

Thanks,

-- 
Anthony PERARD


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




[edk2-devel] [PATCH v13 8/8] OvmfPkg: Uses MmSaveStateLib library

2023-05-12 Thread Abdul Lateef Attar via groups.io
From: Abdul Lateef Attar 

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

Uses new MmSaveStateLib library instance.

Cc: Paul Grimes 
Cc: Abner Chang 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Signed-off-by: Abdul Lateef Attar 
Acked-by: Jiewen Yao 
---
 OvmfPkg/OvmfPkgIa32.dsc   |   1 +
 OvmfPkg/OvmfPkgIa32X64.dsc|   3 +
 OvmfPkg/OvmfPkgX64.dsc|   1 +
 .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 767 --
 4 files changed, 5 insertions(+), 767 deletions(-)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index e333b8b41803..86fc9f6174b2 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -972,6 +972,7 @@ [Components]
 
   
SmmCpuPlatformHookLib|OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.inf
   SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
+  MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
   }
 
   #
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 25974230a27e..da5fd7042f4f 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -4,6 +4,7 @@
 #  Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.
 #  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 #  Copyright (c) Microsoft Corporation.
+#  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -444,6 +445,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
   
SmmCpuRendezvousLib|UefiCpuPkg/Library/SmmCpuRendezvousLib/SmmCpuRendezvousLib.inf
+  MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
 
 [LibraryClasses.common.SMM_CORE]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
@@ -990,6 +992,7 @@ [Components.X64]
 
   
SmmCpuPlatformHookLib|OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.inf
   SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
+  MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
   }
 
   #
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index c1762ffca445..ae706a5099c5 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -1066,6 +1066,7 @@ [Components]
 
   
SmmCpuPlatformHookLib|OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.inf
   SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
+  MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
   }
 
   #
diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c 
b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
index a009123dae88..4c354bafe42f 100644
--- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
+++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
@@ -578,773 +578,6 @@ SmmCpuFeaturesSetSmmRegister (
   ASSERT (FALSE);
 }
 
-///
-/// Macro used to simplify the lookup table entries of type
-/// CPU_SMM_SAVE_STATE_LOOKUP_ENTRY
-///
-#define SMM_CPU_OFFSET(Field)  OFFSET_OF (QEMU_SMRAM_SAVE_STATE_MAP, Field)
-
-///
-/// Macro used to simplify the lookup table entries of type
-/// CPU_SMM_SAVE_STATE_REGISTER_RANGE
-///
-#define SMM_REGISTER_RANGE(Start, End)  { Start, End, End - Start + 1 }
-
-///
-/// Structure used to describe a range of registers
-///
-typedef struct {
-  EFI_SMM_SAVE_STATE_REGISTERStart;
-  EFI_SMM_SAVE_STATE_REGISTEREnd;
-  UINTN  Length;
-} CPU_SMM_SAVE_STATE_REGISTER_RANGE;
-
-///
-/// Structure used to build a lookup table to retrieve the widths and offsets
-/// associated with each supported EFI_SMM_SAVE_STATE_REGISTER value
-///
-
-#define SMM_SAVE_STATE_REGISTER_FIRST_INDEX  1
-
-typedef struct {
-  UINT8  Width32;
-  UINT8  Width64;
-  UINT16 Offset32;
-  UINT16 Offset64Lo;
-  UINT16 Offset64Hi;
-  BOOLEANWriteable;
-} CPU_SMM_SAVE_STATE_LOOKUP_ENTRY;
-
-///
-/// Table used by GetRegisterIndex() to convert an EFI_SMM_SAVE_STATE_REGISTER
-/// value to an index into a table of type CPU_SMM_SAVE_STATE_LOOKUP_ENTRY
-///
-STATIC CONST CPU_SMM_SAVE_STATE_REGISTER_RANGE  mSmmCpuRegisterRanges[] = {
-  SMM_REGISTER_RANGE (
-EFI_SMM_SAVE_STATE_REGISTER_GDTBASE,
-EFI_SMM_SAVE_STATE_REGISTER_LDTINFO
-),
-  SMM_REGISTER_RANGE (
-EFI_SMM_SAVE_STATE_REGISTER_ES,
-EFI_SMM_SAVE_STATE_REGISTER_RIP
-),
-  SMM_REGISTER_RANGE (
-EFI_SMM_SAVE_STATE_REGISTER_RFLAGS,
-EFI_SMM_SAVE_STATE_REGISTER_CR4
-),
-  { (EFI_SMM_SAVE_STATE_REGISTER)0, (EFI_SMM_SAVE_STATE_REGISTER)0,0 }
-};
-
-///
-/// Lookup table used to retrieve the widths and offsets associated with each
-/// supported EFI_SMM_SAVE_STATE_REGISTER 

[edk2-devel] [PATCH v13 6/8] UefiCpuPkg: Implements MmSaveStateLib for Intel

2023-05-12 Thread Abdul Lateef Attar via groups.io
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4182

Implements MmSaveStateLib library interfaces
to read and write save state
registers for Intel processor family.

Moves Intel and AMD common functionality to common area.

Cc: Paul Grimes 
Cc: Abner Chang 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Abner Chang 
---
 UefiCpuPkg/UefiCpuPkg.dsc |   3 +
 .../MmSaveStateLib/IntelMmSaveStateLib.inf|  34 ++
 .../Library/MmSaveStateLib/IntelMmSaveState.c | 410 ++
 3 files changed, 447 insertions(+)
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveStateLib.inf
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveState.c

diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
index 6e29850bed17..eb6bdc5bef63 100644
--- a/UefiCpuPkg/UefiCpuPkg.dsc
+++ b/UefiCpuPkg/UefiCpuPkg.dsc
@@ -101,6 +101,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
   MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
+  MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveStateLib.inf
 
 [LibraryClasses.common.MM_STANDALONE]
   
MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
@@ -174,6 +175,7 @@ [Components.IA32, Components.X64]
   FILE_GUID = B7242C74-BD21-49EE-84B4-07162E8C080D
 
   
SmmCpuFeaturesLib|UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
+  MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
   }
   UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
   UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf
@@ -191,6 +193,7 @@ [Components.IA32, Components.X64]
   
UnitTestResultReportLib|UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.inf
   }
   UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
+  UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveStateLib.inf
   UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
 
 [Components.X64]
diff --git a/UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveStateLib.inf 
b/UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveStateLib.inf
new file mode 100644
index ..b92dfa643203
--- /dev/null
+++ b/UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveStateLib.inf
@@ -0,0 +1,34 @@
+## @file
+# SMM Smram save state service lib.
+#
+# This is SMM Smram save state service lib that provide service to read and
+# save savestate area registers.
+#
+# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 1.29
+  BASE_NAME  = IntelMmSaveStateLib
+  FILE_GUID  = 37E8137B-9F74-4250-8951-7A970A3C39C0
+  MODULE_TYPE= DXE_SMM_DRIVER
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = MmSaveStateLib
+
+[Sources]
+  MmSaveState.h
+  MmSaveStateCommon.c
+  IntelMmSaveState.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  UefiCpuPkg/UefiCpuPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  DebugLib
+  SmmServicesTableLib
diff --git a/UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveState.c 
b/UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveState.c
new file mode 100644
index ..fd321bb571d5
--- /dev/null
+++ b/UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveState.c
@@ -0,0 +1,410 @@
+/** @file
+Provides services to access SMRAM Save State Map
+
+Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "MmSaveState.h"
+#include 
+#include 
+#include 
+
+#define INTEL_MM_SAVE_STATE_REGISTER_SMMREVID_INDEX   1
+#define INTEL_MM_SAVE_STATE_REGISTER_IOMISC_INDEX 2
+#define INTEL_MM_SAVE_STATE_REGISTER_IOMEMADDR_INDEX  3
+#define INTEL_MM_SAVE_STATE_REGISTER_MAX_INDEX4
+
+///
+/// Macro used to simplify the lookup table entries of type 
CPU_MM_SAVE_STATE_LOOKUP_ENTRY
+///
+#define MM_CPU_OFFSET(Field)  OFFSET_OF (SMRAM_SAVE_STATE_MAP, Field)
+
+///
+/// Lookup table used to retrieve the widths and offsets associated with each
+/// supported EFI_MM_SAVE_STATE_REGISTER value
+///
+CONST CPU_MM_SAVE_STATE_LOOKUP_ENTRY  mCpuWidthOffset[] = {
+  { 0, 0, 0, 0,  
0,  FALSE }, //  Reserved
+
+  //
+  // Internally defined CPU Save State Registers. Not defined in PI SMM CPU 
Protocol.
+  //
+  { 4, 4, MM_CPU_OFFSET (x86.SMMRevId),  MM_CPU_OFFSET (x64.SMMRevId),   
0,  FALSE }, // 
INTEL_MM_SAVE_STATE_REGISTER_SMMREVID_INDEX  = 1
+  { 4, 4, MM_CPU_OFFSET (x86.IOMisc),MM_CPU_OFFSET 

[edk2-devel] [PATCH v13 5/8] UefiCpuPkg: Implements SmmCpuFeaturesLib for AMD Family

2023-05-12 Thread Abdul Lateef Attar via groups.io
From: Abdul Lateef Attar 

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

Implements interfaces to read and write save state
registers of AMD's processor family.
Initializes processor SMMADDR and MASK depends
on PcdSmrrEnable flag.
Program or corrects the IP once control returns from SMM.

Cc: Paul Grimes 
Cc: Abner Chang 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Abner Chang 
---
 UefiCpuPkg/UefiCpuPkg.dsc |   7 +
 .../AmdSmmCpuFeaturesLib.inf  |  38 ++
 .../SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c  | 445 ++
 3 files changed, 490 insertions(+)
 create mode 100644 
UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
 create mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c

diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
index 8b0cb02a80e8..6e29850bed17 100644
--- a/UefiCpuPkg/UefiCpuPkg.dsc
+++ b/UefiCpuPkg/UefiCpuPkg.dsc
@@ -169,6 +169,12 @@ [Components.IA32, Components.X64]
 
   
SmmCpuFeaturesLib|UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf
   }
+  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
+
+  FILE_GUID = B7242C74-BD21-49EE-84B4-07162E8C080D
+
+  
SmmCpuFeaturesLib|UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
+  }
   UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
   UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf
   UefiCpuPkg/Library/SmmCpuRendezvousLib/SmmCpuRendezvousLib.inf
@@ -185,6 +191,7 @@ [Components.IA32, Components.X64]
   
UnitTestResultReportLib|UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.inf
   }
   UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
+  UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
 
 [Components.X64]
   
UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionHandlerLibUnitTest.inf
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf 
b/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
new file mode 100644
index ..5ee8a2e720c9
--- /dev/null
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
@@ -0,0 +1,38 @@
+## @file
+#  The CPU specific programming for PiSmmCpuDxeSmm module.
+#
+#  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+#  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = AmdSmmCpuFeaturesLib
+  MODULE_UNI_FILE= SmmCpuFeaturesLib.uni
+  FILE_GUID  = 5849E964-78EC-428E-8CBD-848A7E359134
+  MODULE_TYPE= DXE_SMM_DRIVER
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = SmmCpuFeaturesLib
+  CONSTRUCTOR= SmmCpuFeaturesLibConstructor
+
+[Sources]
+  SmmCpuFeaturesLib.c
+  SmmCpuFeaturesLibCommon.c
+  AmdSmmCpuFeaturesLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  UefiCpuPkg/UefiCpuPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  PcdLib
+  MemoryAllocationLib
+  DebugLib
+  MmSaveStateLib
+
+[FeaturePcd]
+  gUefiCpuPkgTokenSpaceGuid.PcdSmrrEnable   ## CONSUMES
+  gUefiCpuPkgTokenSpaceGuid.PcdSmmFeatureControlEnable  ## CONSUMES
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c 
b/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c
new file mode 100644
index ..1473f0a51fe2
--- /dev/null
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c
@@ -0,0 +1,445 @@
+/** @file
+Implementation specific to the SmmCpuFeatureLib library instance
+for AMD based platforms.
+
+Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) Microsoft Corporation.
+Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// EFER register LMA bit
+#define LMA  BIT10
+
+// Machine Specific Registers (MSRs)
+#define SMMADDR_ADDRESS  0xC0010112ul
+#define SMMMASK_ADDRESS  0xC0010113ul
+#define EFER_ADDRESS 0XC080ul
+
+// The mode of the CPU at the time an SMI occurs
+STATIC UINT8  mSmmSaveStateRegisterLma;
+
+/**
+  Read an SMM Save State register on the target processor.  If this function
+  returns EFI_UNSUPPORTED, then the caller is responsible for reading the
+  SMM Save Sate register.
+
+  @param[in]  CpuIndex  The index of the CPU to read the SMM Save State.  The
+value must be between 0 and the NumberOfCpus field in
+the System Management System Table (SMST).
+  @param[in]  Register  The SMM Save State register to read.
+  @param[in]  Width The number of bytes to read from the CPU save state.
+  @param[out] BufferUpon return, this holds the CPU register value 

[edk2-devel] [PATCH v13 7/8] UefiCpuPkg: Removes SmmCpuFeaturesReadSaveStateRegister

2023-05-12 Thread Abdul Lateef Attar via groups.io
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4182

Removes SmmCpuFeaturesReadSaveStateRegister and 
SmmCpuFeaturesWirteSaveStateRegister
function from SmmCpuFeaturesLib library.

MmSaveStateLib library replaces the functionality of the above
functions.
Platform old/new need to use MmSaveStateLib library to read/write save
state registers.
Current implementation supports Intel and AMD.

Cc: Paul Grimes 
Cc: Abner Chang 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Abner Chang 
Reviewed-by: Ray Ni 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf  |   2 +
 .../Include/Library/SmmCpuFeaturesLib.h   |  52 --
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h|  56 +-
 .../SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c  |  58 --
 .../IntelSmmCpuFeaturesLib.c  |  58 --
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c|  11 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c| 500 +-
 7 files changed, 9 insertions(+), 728 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf 
b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
index 158e05e2646c..bd83b4afab26 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
@@ -6,6 +6,7 @@
 #
 # Copyright (c) 2009 - 2023, Intel Corporation. All rights reserved.
 # Copyright (c) 2017, AMD Incorporated. All rights reserved.
+# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -97,6 +98,7 @@ [LibraryClasses]
   ReportStatusCodeLib
   SmmCpuFeaturesLib
   PeCoffGetEntryPointLib
+  MmSaveStateLib
 
 [Protocols]
   gEfiSmmAccess2ProtocolGuid   ## CONSUMES
diff --git a/UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h 
b/UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h
index 52160c7145ba..733f0d03ebaa 100644
--- a/UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h
+++ b/UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h
@@ -324,58 +324,6 @@ SmmCpuFeaturesSetSmmRegister (
   IN UINT64Value
   );
 
-/**
-  Read an SMM Save State register on the target processor.  If this function
-  returns EFI_UNSUPPORTED, then the caller is responsible for reading the
-  SMM Save Sate register.
-
-  @param[in]  CpuIndex  The index of the CPU to read the SMM Save State.  The
-value must be between 0 and the NumberOfCpus field in
-the System Management System Table (SMST).
-  @param[in]  Register  The SMM Save State register to read.
-  @param[in]  Width The number of bytes to read from the CPU save state.
-  @param[out] BufferUpon return, this holds the CPU register value read
-from the save state.
-
-  @retval EFI_SUCCESS   The register was read from Save State.
-  @retval EFI_INVALID_PARAMETER  Buffer is NULL.
-  @retval EFI_UNSUPPORTED   This function does not support reading 
Register.
-
-**/
-EFI_STATUS
-EFIAPI
-SmmCpuFeaturesReadSaveStateRegister (
-  IN  UINTNCpuIndex,
-  IN  EFI_SMM_SAVE_STATE_REGISTER  Register,
-  IN  UINTNWidth,
-  OUT VOID *Buffer
-  );
-
-/**
-  Writes an SMM Save State register on the target processor.  If this function
-  returns EFI_UNSUPPORTED, then the caller is responsible for writing the
-  SMM Save Sate register.
-
-  @param[in] CpuIndex  The index of the CPU to write the SMM Save State.  The
-   value must be between 0 and the NumberOfCpus field in
-   the System Management System Table (SMST).
-  @param[in] Register  The SMM Save State register to write.
-  @param[in] Width The number of bytes to write to the CPU save state.
-  @param[in] BufferUpon entry, this holds the new CPU register value.
-
-  @retval EFI_SUCCESS   The register was written to Save State.
-  @retval EFI_INVALID_PARAMETER  Buffer is NULL.
-  @retval EFI_UNSUPPORTED   This function does not support writing 
Register.
-**/
-EFI_STATUS
-EFIAPI
-SmmCpuFeaturesWriteSaveStateRegister (
-  IN UINTNCpuIndex,
-  IN EFI_SMM_SAVE_STATE_REGISTER  Register,
-  IN UINTNWidth,
-  IN CONST VOID   *Buffer
-  );
-
 /**
   This function is hook point called after the gEfiSmmReadyToLockProtocolGuid
   notification is completely processed.
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h 
b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
index a5c2bdd971ca..106808b08e17 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
@@ -3,6 +3,7 @@ Agent Module to load other modules to deploy SMM Entry Vector 
for X86 CPU.
 
 Copyright (c) 2009 - 2023, Intel Corporation. All rights reserved.
 Copyright (c) 2017, AMD Incorporated. All rights reserved.
+Copyright (C) 2023 Advanced Micro 

[edk2-devel] [PATCH v13 4/8] UefiCpuPkg/SmmCpuFeaturesLib: Restructure arch-dependent code

2023-05-12 Thread Abdul Lateef Attar via groups.io
From: Abdul Lateef Attar 

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

moves Intel-specific code to the arch-dependent file.
Other processor families might have different
implementation of these functions.
Hence, moving out of the common file.

Cc: Abner Chang 
Cc: Paul Grimes 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Abner Chang 
Reviewed-by: Ray Ni 
---
 .../IntelSmmCpuFeaturesLib.c  | 128 ++
 .../SmmCpuFeaturesLibCommon.c | 128 --
 2 files changed, 128 insertions(+), 128 deletions(-)

diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c 
b/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c
index 1a2c706fa1f1..8f382b60266c 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c
@@ -417,3 +417,131 @@ SmmCpuFeaturesSetSmmRegister (
 AsmWriteMsr64 (SMM_FEATURES_LIB_SMM_FEATURE_CONTROL, Value);
   }
 }
+
+/**
+  This function updates the SMRAM save state on the currently executing CPU
+  to resume execution at a specific address after an RSM instruction.  This
+  function must evaluate the SMRAM save state to determine the execution mode
+  the RSM instruction resumes and update the resume execution address with
+  either NewInstructionPointer32 or NewInstructionPoint.  The auto HALT restart
+  flag in the SMRAM save state must always be cleared.  This function returns
+  the value of the instruction pointer from the SMRAM save state that was
+  replaced.  If this function returns 0, then the SMRAM save state was not
+  modified.
+
+  This function is called during the very first SMI on each CPU after
+  SmmCpuFeaturesInitializeProcessor() to set a flag in normal execution mode
+  to signal that the SMBASE of each CPU has been updated before the default
+  SMBASE address is used for the first SMI to the next CPU.
+
+  @param[in] CpuIndex The index of the CPU to hook.  The value
+  must be between 0 and the NumberOfCpus
+  field in the System Management System 
Table
+  (SMST).
+  @param[in] CpuState Pointer to SMRAM Save State Map for the
+  currently executing CPU.
+  @param[in] NewInstructionPointer32  Instruction pointer to use if resuming to
+  32-bit execution mode from 64-bit SMM.
+  @param[in] NewInstructionPointerInstruction pointer to use if resuming to
+  same execution mode as SMM.
+
+  @retval 0This function did modify the SMRAM save state.
+  @retval > 0  The original instruction pointer value from the SMRAM save state
+   before it was replaced.
+**/
+UINT64
+EFIAPI
+SmmCpuFeaturesHookReturnFromSmm (
+  IN UINTN CpuIndex,
+  IN SMRAM_SAVE_STATE_MAP  *CpuState,
+  IN UINT64NewInstructionPointer32,
+  IN UINT64NewInstructionPointer
+  )
+{
+  return 0;
+}
+
+/**
+  Read an SMM Save State register on the target processor.  If this function
+  returns EFI_UNSUPPORTED, then the caller is responsible for reading the
+  SMM Save Sate register.
+
+  @param[in]  CpuIndex  The index of the CPU to read the SMM Save State.  The
+value must be between 0 and the NumberOfCpus field in
+the System Management System Table (SMST).
+  @param[in]  Register  The SMM Save State register to read.
+  @param[in]  Width The number of bytes to read from the CPU save state.
+  @param[out] BufferUpon return, this holds the CPU register value read
+from the save state.
+
+  @retval EFI_SUCCESS   The register was read from Save State.
+  @retval EFI_INVALID_PARAMETER  Buffer is NULL.
+  @retval EFI_UNSUPPORTED   This function does not support reading 
Register.
+
+**/
+EFI_STATUS
+EFIAPI
+SmmCpuFeaturesReadSaveStateRegister (
+  IN  UINTNCpuIndex,
+  IN  EFI_SMM_SAVE_STATE_REGISTER  Register,
+  IN  UINTNWidth,
+  OUT VOID *Buffer
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+/**
+  Writes an SMM Save State register on the target processor.  If this function
+  returns EFI_UNSUPPORTED, then the caller is responsible for writing the
+  SMM Save Sate register.
+
+  @param[in] CpuIndex  The index of the CPU to write the SMM Save State.  The
+   value must be between 0 and the NumberOfCpus field in
+   the System Management System Table (SMST).
+  @param[in] Register  The SMM Save State register to write.
+  @param[in] Width The number of bytes to write to the CPU save state.
+  @param[in] BufferUpon entry, this holds the new CPU register value.
+
+  @retval 

[edk2-devel] [PATCH v13 3/8] UefiCpuPkg: Implements MmSaveStateLib library instance

2023-05-12 Thread Abdul Lateef Attar via groups.io
From: Abdul Lateef Attar 

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

Implements MmSaveStateLib Library class for
AMD cpu family.

Cc: Paul Grimes 
Cc: Abner Chang 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 

Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Abner Chang 
---
 UefiCpuPkg/UefiCpuPkg.dsc |   3 +
 .../MmSaveStateLib/AmdMmSaveStateLib.inf  |  34 ++
 .../Library/MmSaveStateLib/MmSaveState.h  |  94 ++
 .../Library/MmSaveStateLib/AmdMmSaveState.c   | 309 ++
 .../MmSaveStateLib/MmSaveStateCommon.c| 132 
 5 files changed, 572 insertions(+)
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/MmSaveState.h
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveState.c
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/MmSaveStateCommon.c

diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
index 593c11cc7482..8b0cb02a80e8 100644
--- a/UefiCpuPkg/UefiCpuPkg.dsc
+++ b/UefiCpuPkg/UefiCpuPkg.dsc
@@ -2,6 +2,7 @@
 #  UefiCpuPkg Package
 #
 #  Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.
+#  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -99,6 +100,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
   
MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
+  MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
 
 [LibraryClasses.common.MM_STANDALONE]
   
MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
@@ -182,6 +184,7 @@ [Components.IA32, Components.X64]
 
   
UnitTestResultReportLib|UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.inf
   }
+  UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
 
 [Components.X64]
   
UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionHandlerLibUnitTest.inf
diff --git a/UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf 
b/UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
new file mode 100644
index ..5c0685f283d3
--- /dev/null
+++ b/UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
@@ -0,0 +1,34 @@
+## @file
+# MM Smram save state service lib.
+#
+# This is MM Smram save state service lib that provide service to read and
+# save savestate area registers.
+#
+# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 1.29
+  BASE_NAME  = AmdMmSaveStateLib
+  FILE_GUID  = FB7D0A60-E8D4-4EFA-90AA-B357BC569879
+  MODULE_TYPE= DXE_SMM_DRIVER
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = MmSaveStateLib
+
+[Sources]
+  MmSaveState.h
+  MmSaveStateCommon.c
+  AmdMmSaveState.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  UefiCpuPkg/UefiCpuPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  DebugLib
+  SmmServicesTableLib
diff --git a/UefiCpuPkg/Library/MmSaveStateLib/MmSaveState.h 
b/UefiCpuPkg/Library/MmSaveStateLib/MmSaveState.h
new file mode 100644
index ..c3499cbb3b17
--- /dev/null
+++ b/UefiCpuPkg/Library/MmSaveStateLib/MmSaveState.h
@@ -0,0 +1,94 @@
+/** @file
+  SMRAM Save State Map header file.
+
+  Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef MM_SAVESTATE_H_
+#define MM_SAVESTATE_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Macro used to simplify the lookup table entries of type 
CPU_MM_SAVE_STATE_REGISTER_RANGE
+#define MM_REGISTER_RANGE(Start, End)  { Start, End, End - Start + 1 }
+
+// Structure used to describe a range of registers
+typedef struct {
+  EFI_MM_SAVE_STATE_REGISTERStart;
+  EFI_MM_SAVE_STATE_REGISTEREnd;
+  UINTN Length;
+} CPU_MM_SAVE_STATE_REGISTER_RANGE;
+
+// Structure used to build a lookup table to retrieve the widths and offsets
+// associated with each supported EFI_MM_SAVE_STATE_REGISTER value
+
+typedef struct {
+  UINT8  Width32;
+  UINT8  Width64;
+  UINT16 Offset32;
+  UINT16 Offset64Lo;
+  UINT16 Offset64Hi;
+  BOOLEANWriteable;
+} CPU_MM_SAVE_STATE_LOOKUP_ENTRY;
+
+/**
+  Returns LMA value of the Processor.
+
+  @retval UINT8 returns LMA bit value.
+**/
+UINT8
+MmSaveStateGetRegisterLma (
+  VOID
+  );
+
+/**
+  Read information from the CPU save state.
+
+  @param  Register  Specifies the CPU register to read form the save state.
+  @param  RegOffset 

[edk2-devel] [PATCH v13 2/8] UefiCpuPkg: Adds MmSaveStateLib library class

2023-05-12 Thread Abdul Lateef Attar via groups.io
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4182

Adds MmSaveStateLib Library class in UefiCpuPkg.dec.
Adds function declaration header file.

Cc: Paul Grimes 
Cc: Abner Chang 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 

Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Abner Chang 
Reviewed-by: Ray Ni 
---
 UefiCpuPkg/UefiCpuPkg.dec   |  4 ++
 UefiCpuPkg/Include/Library/MmSaveStateLib.h | 70 +
 2 files changed, 74 insertions(+)
 create mode 100644 UefiCpuPkg/Include/Library/MmSaveStateLib.h

diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
index d31c3b127c0b..1f1b10e702bf 100644
--- a/UefiCpuPkg/UefiCpuPkg.dec
+++ b/UefiCpuPkg/UefiCpuPkg.dec
@@ -2,6 +2,7 @@
 # This Package provides UEFI compatible CPU modules and libraries.
 #
 # Copyright (c) 2007 - 2023, Intel Corporation. All rights reserved.
+# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -60,6 +61,9 @@ [LibraryClasses.IA32, LibraryClasses.X64]
   ##  @libraryclass  Provides function for manipulating x86 paging structures.
   CpuPageTableLib|Include/Library/CpuPageTableLib.h
 
+  ## @libraryclass   Provides functions for manipulating smram savestate 
registers.
+  MmSaveStateLib|Include/Library/MmSaveStateLib.h
+
 [Guids]
   gUefiCpuPkgTokenSpaceGuid  = { 0xac05bf33, 0x995a, 0x4ed4, { 0xaa, 0xb8, 
0xef, 0x7a, 0xe8, 0xf, 0x5c, 0xb0 }}
   gMsegSmramGuid = { 0x5802bce4, 0x, 0x4e33, { 0xa1, 0x30, 
0xeb, 0xad, 0x27, 0xf0, 0xe4, 0x39 }}
diff --git a/UefiCpuPkg/Include/Library/MmSaveStateLib.h 
b/UefiCpuPkg/Include/Library/MmSaveStateLib.h
new file mode 100644
index ..6817fb3b9786
--- /dev/null
+++ b/UefiCpuPkg/Include/Library/MmSaveStateLib.h
@@ -0,0 +1,70 @@
+/** @file
+Library that provides service to read/write CPU specific smram save state 
registers.
+
+Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef MM_SAVE_STATE_LIB_H_
+#define MM_SAVE_STATE_LIB_H_
+
+#include 
+#include 
+
+/**
+  Read a save state register on the target processor.  If this function
+  returns EFI_UNSUPPORTED, then the caller is responsible for reading the
+  MM Save State register.
+
+  @param[in]  CpuIndex  The index of the CPU to read the Save State register.
+The value must be between 0 and the NumberOfCpus field 
in
+the System Management System Table (SMST).
+  @param[in]  Register  The MM Save State register to read.
+  @param[in]  Width The number of bytes to read from the CPU save state.
+  @param[out] BufferUpon return, this holds the CPU register value read
+from the save state.
+
+  @retval EFI_SUCCESS   The register was read from Save State.
+  @retval EFI_INVALID_PARAMTER  Buffer is NULL.
+  @retval EFI_UNSUPPORTED   This function does not support reading 
Register.
+  @retval EFI_NOT_FOUND If desired Register not found.
+**/
+EFI_STATUS
+EFIAPI
+MmSaveStateReadRegister (
+  IN  UINTN   CpuIndex,
+  IN  EFI_MM_SAVE_STATE_REGISTER  Register,
+  IN  UINTN   Width,
+  OUT VOID*Buffer
+  );
+
+/**
+  Writes a save state register on the target processor.  If this function
+  returns EFI_UNSUPPORTED, then the caller is responsible for writing the
+  MM save state register.
+
+  @param[in] CpuIndex  The index of the CPU to write the MM Save State.  The
+   value must be between 0 and the NumberOfCpus field in
+   the System Management System Table (SMST).
+  @param[in] Register  The MM Save State register to write.
+  @param[in] Width The number of bytes to write to the CPU save state.
+  @param[in] BufferUpon entry, this holds the new CPU register value.
+
+  @retval EFI_SUCCESS   The register was written to Save State.
+  @retval EFI_INVALID_PARAMTER  Buffer is NULL.
+  @retval EFI_UNSUPPORTED   This function does not support writing 
Register.
+  @retval EFI_NOT_FOUND If desired Register not found.
+**/
+EFI_STATUS
+EFIAPI
+MmSaveStateWriteRegister (
+  IN UINTN   CpuIndex,
+  IN EFI_MM_SAVE_STATE_REGISTER  Register,
+  IN UINTN   Width,
+  IN CONST VOID  *Buffer
+  );
+
+#endif
-- 
2.25.1



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




[edk2-devel] [PATCH v13 1/8] MdePkg: Adds AMD SMRAM save state map

2023-05-12 Thread Abdul Lateef Attar via groups.io
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4182

Adds an SMM SMRAM save-state map for AMD processors.
SMRAM save state maps for the AMD processor family are now supported.

Save state map structure is added based on
AMD64 Architecture Programmer's Manual, Volume 2, Section 10.2.

The AMD legacy save state map for 32-bit architecture is defined.
The AMD64 save state map for 64-bit architecture is defined. 

Also added Amd/SmramSaveStateMap.h to IgnoreFiles of EccCheck,
because structures defined in this file are derived from
Intel/SmramSaveStateMap.h.

Cc: Paul Grimes 
Cc: Abner Chang 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 

Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Abner Chang 
Reviewed-by: Michael D Kinney 
---
 .../Include/Register/Amd/SmramSaveStateMap.h  | 194 ++
 MdePkg/MdePkg.ci.yaml |   4 +-
 2 files changed, 197 insertions(+), 1 deletion(-)
 create mode 100644 MdePkg/Include/Register/Amd/SmramSaveStateMap.h

diff --git a/MdePkg/Include/Register/Amd/SmramSaveStateMap.h 
b/MdePkg/Include/Register/Amd/SmramSaveStateMap.h
new file mode 100644
index ..0607d2a19145
--- /dev/null
+++ b/MdePkg/Include/Register/Amd/SmramSaveStateMap.h
@@ -0,0 +1,194 @@
+/** @file
+  AMD SMRAM Save State Map Definitions.
+
+  SMRAM Save State Map definitions based on contents of the
+AMD64 Architecture Programmer Manual:
+Volume 2, System Programming, Section 10.2 SMM Resources
+
+  Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
+  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved .
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_SMRAM_SAVE_STATE_MAP_H_
+#define AMD_SMRAM_SAVE_STATE_MAP_H_
+
+///
+/// Default SMBASE address
+///
+#define SMM_DEFAULT_SMBASE  0x3
+
+///
+/// Offset of SMM handler from SMBASE
+///
+#define SMM_HANDLER_OFFSET  0x8000
+
+// SMM-Revision Identifier for AMD64 Architecture.
+#define AMD_SMM_MIN_REV_ID_X64  0x30064
+
+#pragma pack (1)
+
+///
+/// 32-bit SMRAM Save State Map
+///
+typedef struct {
+  // Padded an extra 0x200 bytes to match Intel/EDK2
+  UINT8 Reserved[0x200]; // fc00h
+  // AMD Save State area starts @ 0xfe00
+  UINT8 Reserved1[0xf8]; // fe00h
+  UINT32SMBASE;  // fef8h
+  UINT32SMMRevId;// fefch
+  UINT16IORestart;   // ff00h
+  UINT16AutoHALTRestart; // ff02h
+  UINT8 Reserved2[0x84]; // ff04h
+  UINT32GDTBase; // ff88h
+  UINT64Reserved3;   // ff8ch
+  UINT32IDTBase; // ff94h
+  UINT8 Reserved4[0x10]; // ff98h
+  UINT32_ES; // ffa8h
+  UINT32_CS; // ffach
+  UINT32_SS; // ffb0h
+  UINT32_DS; // ffb4h
+  UINT32_FS; // ffb8h
+  UINT32_GS; // ffbch
+  UINT32LDTBase; // ffc0h
+  UINT32_TR; // ffc4h
+  UINT32_DR7;// ffc8h
+  UINT32_DR6;// ffcch
+  UINT32_EAX;// ffd0h
+  UINT32_ECX;// ffd4h
+  UINT32_EDX;// ffd8h
+  UINT32_EBX;// ffdch
+  UINT32_ESP;// ffe0h
+  UINT32_EBP;// ffe4h
+  UINT32_ESI;// ffe8h
+  UINT32_EDI;// ffech
+  UINT32_EIP;// fff0h
+  UINT32_EFLAGS; // fff4h
+  UINT32_CR3;// fff8h
+  UINT32_CR0;// fffch
+} AMD_SMRAM_SAVE_STATE_MAP32;
+
+///
+/// 64-bit SMRAM Save State Map
+///
+typedef struct {
+  // Padded an extra 0x200 bytes to match Intel/EDK2
+  UINT8 Reserved[0x200]; // fc00h
+  // AMD Save State area starts @ 0xfe00
+  UINT16_ES;  // fe00h
+  UINT16_ESAttributes;// fe02h
+  UINT32_ESLimit; // fe04h
+  UINT64_ESBase;  // fe08h
+
+  UINT16_CS;  // fe10h
+  UINT16_CSAttributes;// fe12h
+  UINT32_CSLimit; // fe14h
+  UINT64_CSBase;  // fe18h
+
+  UINT16_SS;  // fe20h
+  UINT16_SSAttributes;// fe22h
+  UINT32_SSLimit; // fe24h
+  UINT64_SSBase;  // fe28h
+
+  UINT16_DS;  // fe30h
+  UINT16_DSAttributes;// fe32h
+  UINT32_DSLimit; // fe34h
+  UINT64_DSBase;  // fe38h
+
+  UINT16_FS;  // fe40h
+  UINT16_FSAttributes;// fe42h
+  UINT32_FSLimit; // fe44h
+  UINT64_FSBase;  // fe48h
+
+  UINT16_GS;  // fe50h
+  UINT16_GSAttributes;// fe52h
+  UINT32_GSLimit; // fe54h
+  UINT64_GSBase;  // fe58h
+
+  UINT32_GDTRReserved1;   // fe60h
+  UINT16_GDTRLimit;   // fe64h
+  UINT16_GDTRReserved2;   // fe66h
+  // UINT64  _GDTRBase;// fe68h
+  UINT32_GDTRBaseLoDword;
+  UINT32_GDTRBaseHiDword;
+
+  UINT16_LDTR;// fe70h
+  UINT16_LDTRAttributes;  // fe72h
+  UINT32

[edk2-devel] [PATCH v13 0/8] Adds AmdSmmCpuFeaturesLib and MmSaveStateLib

2023-05-12 Thread Abdul Lateef Attar via groups.io
Backward-compatibility changes:
  This patch series removes the SmmCpuFeaturesReadSaveStateRegister
  and SmmCpuFeaturesWriteSaveStateRegister interface/function.
  SmmReadSaveState() and SmmWriteSaveState() now directly invokes MmSaveStateLib
  routines to save/restore registers.

PR: https://github.com/tianocore/edk2/pull/4392

V13: Delta changes
  Address review comments from Ray Ni
  Changed the BASE _NAME of AmdSmmCpuFeaturesLib.
  Removed EFIAPI from local function.
  Removed CpuIndex parameter from MmSaveStateGetRegisterLma
  Modifed MmSaveStateGetRegisterIndex () to accept RegOffset
as second parameter.
  Removed FILE_GUID library instance for intel implemention from UefiCpuPkg.dsc.

V12:
  Addressed review comments from Michael.
  Added LibraryClasses to .inf file.
  removed duplicate MACRO definations.
  Moved related MACRO defination to respective file.
V11: Delta changes
  Drop the OVMF implementation of MmSaveStateLib
V10: Delta changes:
  Addressed review comments from Abner.
V9: Delta changes:
  Addressed review comments.
  Rename to MmSaveStateLib.
  Also rename SMM_ defines to MM_.
  Implemented OVMF MmSaveStateLib.
  Removes SmmCpuFeaturesReadSaveStateRegister and 
SmmCpuFeaturesWriteSaveStateRegister
  function interface.
V8 delta changes:
   Addressed review comments from Abner,
   Fix the whitespace error.
   Seperate the Ovmf changes to another patch
V7 delta changes:
   Adds SmmSmramSaveStateLib for Intel processor.
   Integrate SmmSmramSaveStateLib library.
V6 delta changes:
   Addressed review comments for Ray NI.
   removed unnecessary EFIAPI.
V5 delta changes:
   rebase to master branch.
   updated Reviewed-by
V4 delta changes:
  rebase to master branch.
  added reviewed-by.
V3 delta changes:
  Addressed review comments from Abner chang.
  Re-arranged patch order.

Cc: Paul Grimes 
Cc: Abner Chang 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Abdul Lateef Attar 

Abdul Lateef Attar (8):
  MdePkg: Adds AMD SMRAM save state map
  UefiCpuPkg: Adds MmSaveStateLib library class
  UefiCpuPkg: Implements MmSaveStateLib library instance
  UefiCpuPkg/SmmCpuFeaturesLib: Restructure arch-dependent code
  UefiCpuPkg: Implements SmmCpuFeaturesLib for AMD Family
  UefiCpuPkg: Implements MmSaveStateLib for Intel
  UefiCpuPkg: Removes SmmCpuFeaturesReadSaveStateRegister
  OvmfPkg: Uses MmSaveStateLib library

 UefiCpuPkg/UefiCpuPkg.dec |   4 +
 OvmfPkg/OvmfPkgIa32.dsc   |   1 +
 OvmfPkg/OvmfPkgIa32X64.dsc|   3 +
 OvmfPkg/OvmfPkgX64.dsc|   1 +
 UefiCpuPkg/UefiCpuPkg.dsc |  13 +
 .../MmSaveStateLib/AmdMmSaveStateLib.inf  |  34 +
 .../MmSaveStateLib/IntelMmSaveStateLib.inf|  34 +
 .../AmdSmmCpuFeaturesLib.inf  |  38 +
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf  |   2 +
 .../Include/Register/Amd/SmramSaveStateMap.h  | 194 +
 UefiCpuPkg/Include/Library/MmSaveStateLib.h   |  70 ++
 .../Include/Library/SmmCpuFeaturesLib.h   |  52 --
 .../Library/MmSaveStateLib/MmSaveState.h  |  94 +++
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h|  56 +-
 .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 767 --
 .../Library/MmSaveStateLib/AmdMmSaveState.c   | 309 +++
 .../Library/MmSaveStateLib/IntelMmSaveState.c | 410 ++
 .../MmSaveStateLib/MmSaveStateCommon.c| 132 +++
 .../SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c  | 387 +
 .../IntelSmmCpuFeaturesLib.c  |  70 ++
 .../SmmCpuFeaturesLibCommon.c | 128 ---
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c|  11 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c| 500 +---
 MdePkg/MdePkg.ci.yaml |   4 +-
 24 files changed, 1806 insertions(+), 1508 deletions(-)
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveStateLib.inf
 create mode 100644 
UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
 create mode 100644 MdePkg/Include/Register/Amd/SmramSaveStateMap.h
 create mode 100644 UefiCpuPkg/Include/Library/MmSaveStateLib.h
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/MmSaveState.h
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveState.c
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveState.c
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/MmSaveStateCommon.c
 create mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c

-- 
2.25.1



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

[edk2-devel] [PATCH] MdePkg Include: Fix typos

2023-05-12 Thread Giri Mudusuru via groups.io
compatability->compatibility
EFI_MEDIA_CHNAGED->EFI_MEDIA_CHANGED
Funtion->Function
exhausive->exhaustive
Propery->Property
StartAdress->StartAddress
sucessful->successful
writting->writing

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: Andrew Fish 
Signed-off-by: Giri Mudusuru 
---
 MdePkg/Include/IndustryStandard/Acpi10.h  |  2 +-
 MdePkg/Include/Library/DebugLib.h | 50 +--
 MdePkg/Include/Library/PerformanceLib.h   |  2 +-
 MdePkg/Include/Library/PostCodeLib.h  | 12 ++---
 MdePkg/Include/Library/ReportStatusCodeLib.h  | 26 +-
 MdePkg/Include/Library/S3PciLib.h |  4 +-
 MdePkg/Include/Library/S3PciSegmentLib.h  |  4 +-
 MdePkg/Include/Library/UefiLib.h  |  2 +-
 MdePkg/Include/Protocol/BlockIo.h |  4 +-
 MdePkg/Include/Protocol/BlockIo2.h|  6 +--
 MdePkg/Include/Protocol/BlockIoCrypto.h   |  2 +-
 MdePkg/Include/Protocol/DiskIo.h  |  4 +-
 MdePkg/Include/Protocol/DiskIo2.h |  6 +--
 MdePkg/Include/Protocol/Ip4.h |  4 +-
 MdePkg/Include/Protocol/Ip6.h |  4 +-
 .../Protocol/NetworkInterfaceIdentifier.h |  4 +-
 MdePkg/Include/Protocol/Pkcs7Verify.h |  2 +-
 MdePkg/Include/Protocol/RamDisk.h |  2 +-
 MdePkg/Include/Protocol/ScsiIo.h  |  2 +-
 MdePkg/Include/Protocol/ScsiPassThru.h|  2 +-
 MdePkg/Include/Protocol/ServiceBinding.h  |  2 +-
 MdePkg/Include/Protocol/Shell.h   |  2 +-
 MdePkg/Include/Protocol/ShellDynamicCommand.h |  2 +-
 MdePkg/Include/Protocol/Tcp4.h|  4 +-
 MdePkg/Include/Protocol/Tcp6.h|  4 +-
 MdePkg/Include/Protocol/Udp4.h|  4 +-
 MdePkg/Include/Protocol/Udp6.h|  4 +-
 MdePkg/Include/Protocol/UfsDeviceConfig.h |  2 +-
 MdePkg/Include/Protocol/UgaDraw.h |  2 +-
 MdePkg/Include/Protocol/Usb2HostController.h  |  2 +-
 MdePkg/Include/Protocol/UsbHostController.h   |  2 +-
 31 files changed, 87 insertions(+), 87 deletions(-)

diff --git a/MdePkg/Include/IndustryStandard/Acpi10.h 
b/MdePkg/Include/IndustryStandard/Acpi10.h
index 9cc02edb3e..5a47f8a54c 100644
--- a/MdePkg/Include/IndustryStandard/Acpi10.h
+++ b/MdePkg/Include/IndustryStandard/Acpi10.h
@@ -321,7 +321,7 @@ typedef struct {
 #define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_MEMORY(0 << 3)
 #define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_RESERVED  (1 << 3)
 #define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_ACPI  (2 << 3)
-#define EFI_APCI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_NVS   (3 << 3)
+#define EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_ADDRESS_RANGE_NVS   (3 << 3)
 //
 // Bit [5]: Memory to I/O Translation, _TTP
 //
diff --git a/MdePkg/Include/Library/DebugLib.h 
b/MdePkg/Include/Library/DebugLib.h
index f0c9f64487..56c9e0c781 100644
--- a/MdePkg/Include/Library/DebugLib.h
+++ b/MdePkg/Include/Library/DebugLib.h
@@ -185,8 +185,8 @@ DebugBPrint (
 
   Print a message of the form "ASSERT (): 
\n"
   to the debug output device.  If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit 
of
-  PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if
-  DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then
+  PcdDebugPropertyMask is set then CpuBreakpoint() is called. Otherwise, if
+  DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugPropertyMask is set 
then
   CpuDeadLoop() is called.  If neither of these bits are set, then this 
function
   returns immediately after the message is printed to the debug output device.
   DebugAssert() must actively prevent recursion.  If DebugAssert() is called 
while
@@ -234,10 +234,10 @@ DebugClearMemory (
   Returns TRUE if ASSERT() macros are enabled.
 
   This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of
-  PcdDebugProperyMask is set.  Otherwise, FALSE is returned.
+  PcdDebugPropertyMask is set.  Otherwise, FALSE is returned.
 
-  @retval  TRUEThe DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of 
PcdDebugProperyMask is set.
-  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of 
PcdDebugProperyMask is clear.
+  @retval  TRUEThe DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of 
PcdDebugPropertyMask is set.
+  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of 
PcdDebugPropertyMask is clear.
 
 **/
 BOOLEAN
@@ -250,10 +250,10 @@ DebugAssertEnabled (
   Returns TRUE if DEBUG() macros are enabled.
 
   This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of
-  PcdDebugProperyMask is set.  Otherwise, FALSE is returned.
+  PcdDebugPropertyMask is set.  Otherwise, FALSE is returned.
 
-  @retval  TRUEThe DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of 
PcdDebugProperyMask is set.
-  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of 
PcdDebugProperyMask is clear.
+  @retval  TRUEThe 

[edk2-devel] [PATCH] MdePkg Library: Fix typos

2023-05-12 Thread Giri Mudusuru via groups.io
addres->address
orignal->original
Propery->Property
StartAdress->StartAddress
sucessfully->successfully
uinstance->instance

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: Andrew Fish 
Signed-off-by: Giri Mudusuru 
---
 MdePkg/Library/BaseDebugLibNull/DebugLib.c| 28 +--
 .../Library/BaseDebugLibSerialPort/DebugLib.c | 28 +--
 .../BaseDebugPrintErrorLevelLib.c |  4 +--
 MdePkg/Library/BaseLib/X64/Thunk16.nasm   |  2 +-
 MdePkg/Library/BasePciCf8Lib/PciCf8Lib.c  |  4 +--
 .../Library/BasePciExpressLib/PciExpressLib.c |  4 +--
 MdePkg/Library/BasePciLibCf8/PciLib.c |  4 +--
 MdePkg/Library/BasePciLibPciExpress/PciLib.c  |  4 +--
 .../BasePciSegmentLibPci/PciSegmentLib.c  |  4 +--
 .../BasePeCoffLib/Arm/PeCoffLoaderEx.c|  4 +--
 .../Library/BasePostCodeLibDebug/PostCode.c   |  8 +++---
 .../Library/BasePostCodeLibPort80/PostCode.c  |  8 +++---
 .../BaseReportStatusCodeLib.c | 18 ++--
 MdePkg/Library/BaseS3PciLib/S3PciLib.c|  4 +--
 .../BaseS3PciSegmentLib/S3PciSegmentLib.c |  4 +--
 .../BaseUefiDecompressLib.c   |  2 +-
 .../DxeRuntimeDebugLibSerialPort/DebugLib.c   | 28 +--
 .../PostCode.c|  8 +++---
 MdePkg/Library/PeiPciLibPciCfg2/PciLib.c  |  4 +--
 .../PeiPciSegmentLibPciCfg2/PciSegmentLib.c   |  4 +--
 MdePkg/Library/UefiDebugLibConOut/DebugLib.c  | 28 +--
 .../UefiDebugLibDebugPortProtocol/DebugLib.c  | 28 +--
 MdePkg/Library/UefiDebugLibStdErr/DebugLib.c  | 28 +--
 .../UefiFileHandleLib/UefiFileHandleLib.c |  2 +-
 .../UefiPciLibPciRootBridgeIo/PciLib.c|  4 +--
 .../PciSegmentLib.c   |  4 +--
 26 files changed, 134 insertions(+), 134 deletions(-)

diff --git a/MdePkg/Library/BaseDebugLibNull/DebugLib.c 
b/MdePkg/Library/BaseDebugLibNull/DebugLib.c
index e01a095781..922857904d 100644
--- a/MdePkg/Library/BaseDebugLibNull/DebugLib.c
+++ b/MdePkg/Library/BaseDebugLibNull/DebugLib.c
@@ -92,8 +92,8 @@ DebugBPrint (
 
   Print a message of the form "ASSERT (): 
\n"
   to the debug output device.  If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit 
of
-  PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if
-  DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then
+  PcdDebugPropertyMask is set then CpuBreakpoint() is called. Otherwise, if
+  DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugPropertyMask is set 
then
   CpuDeadLoop() is called.  If neither of these bits are set, then this 
function
   returns immediately after the message is printed to the debug output device.
   DebugAssert() must actively prevent recursion.  If DebugAssert() is called 
while
@@ -146,10 +146,10 @@ DebugClearMemory (
   Returns TRUE if ASSERT() macros are enabled.
 
   This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of
-  PcdDebugProperyMask is set.  Otherwise FALSE is returned.
+  PcdDebugPropertyMask is set.  Otherwise FALSE is returned.
 
-  @retval  TRUEThe DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of 
PcdDebugProperyMask is set.
-  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of 
PcdDebugProperyMask is clear.
+  @retval  TRUEThe DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of 
PcdDebugPropertyMask is set.
+  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of 
PcdDebugPropertyMask is clear.
 
 **/
 BOOLEAN
@@ -165,10 +165,10 @@ DebugAssertEnabled (
   Returns TRUE if DEBUG() macros are enabled.
 
   This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of
-  PcdDebugProperyMask is set.  Otherwise FALSE is returned.
+  PcdDebugPropertyMask is set.  Otherwise FALSE is returned.
 
-  @retval  TRUEThe DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of 
PcdDebugProperyMask is set.
-  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of 
PcdDebugProperyMask is clear.
+  @retval  TRUEThe DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of 
PcdDebugPropertyMask is set.
+  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of 
PcdDebugPropertyMask is clear.
 
 **/
 BOOLEAN
@@ -184,10 +184,10 @@ DebugPrintEnabled (
   Returns TRUE if DEBUG_CODE() macros are enabled.
 
   This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of
-  PcdDebugProperyMask is set.  Otherwise FALSE is returned.
+  PcdDebugPropertyMask is set.  Otherwise FALSE is returned.
 
-  @retval  TRUEThe DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of 
PcdDebugProperyMask is set.
-  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of 
PcdDebugProperyMask is clear.
+  @retval  TRUEThe DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of 
PcdDebugPropertyMask is set.
+  @retval  FALSE   The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of 
PcdDebugPropertyMask is clear.
 
 **/
 BOOLEAN
@@ -203,10 +203,10 @@ DebugCodeEnabled (
   Returns TRUE if 

[edk2-devel] [edk2-platforms][PATCH 2/2] ManageabilityPkg/IpmiBmcElog: Add to ManageabilityPkg

2023-05-12 Thread Chang, Abner via groups.io
From: Abner Chang 

Add IpmiBmcElog to ManageabilityPkg.

Signed-off-by: Abner Chang 
Cc: Isaac Oram 
Cc: Abdul Lateef Attar 
Cc: Nickle Wang 
---
 Features/ManageabilityPkg/ManageabilityPkg.dec  | 1 +
 Features/ManageabilityPkg/Include/Manageability.dsc | 4 
 Features/ManageabilityPkg/ManageabilityPkg.dsc  | 2 ++
 Features/ManageabilityPkg/Include/PostMemory.fdf| 4 
 4 files changed, 11 insertions(+)

diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dec 
b/Features/ManageabilityPkg/ManageabilityPkg.dec
index 38813c5f48..7c36ec93ff 100644
--- a/Features/ManageabilityPkg/ManageabilityPkg.dec
+++ b/Features/ManageabilityPkg/ManageabilityPkg.dec
@@ -79,4 +79,5 @@
   
gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmEnable|FALSE|BOOLEAN|0x1004
   
gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable|FALSE|BOOLEAN|0x1005
   
gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmSmbiosTransferEnable|FALSE|BOOLEAN|0x1006
+  
gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiBmcElog|FALSE|BOOLEAN|0x100A
 
diff --git a/Features/ManageabilityPkg/Include/Manageability.dsc 
b/Features/ManageabilityPkg/Include/Manageability.dsc
index a432b0ff26..6806093d98 100644
--- a/Features/ManageabilityPkg/Include/Manageability.dsc
+++ b/Features/ManageabilityPkg/Include/Manageability.dsc
@@ -51,3 +51,7 @@
 !if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable == TRUE
   ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocolDxe.inf
 !endif
+
+!if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiBmcElog == TRUE
+  ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.inf
+!endif
diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dsc 
b/Features/ManageabilityPkg/ManageabilityPkg.dsc
index e3baf27f2a..2262362f97 100644
--- a/Features/ManageabilityPkg/ManageabilityPkg.dsc
+++ b/Features/ManageabilityPkg/ManageabilityPkg.dsc
@@ -37,6 +37,7 @@
   gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmEnable  
|TRUE
   gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable  
|TRUE
   
gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmSmbiosTransferEnable|TRUE
+  gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiBmcElog 
|TRUE
 
 #
 # Include common libraries
@@ -53,5 +54,6 @@
 
 [LibraryClasses]
   
ManageabilityTransportLib|ManageabilityPkg/Library/BaseManageabilityTransportNullLib/BaseManageabilityTransportNull.inf
+  IpmiLib|MdeModulePkg/Library/BaseIpmiLibNull/BaseIpmiLibNull.inf
 
 !include Include/Manageability.dsc
diff --git a/Features/ManageabilityPkg/Include/PostMemory.fdf 
b/Features/ManageabilityPkg/Include/PostMemory.fdf
index 9100cb2646..e4eed660fd 100644
--- a/Features/ManageabilityPkg/Include/PostMemory.fdf
+++ b/Features/ManageabilityPkg/Include/PostMemory.fdf
@@ -26,3 +26,7 @@
 !if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable == TRUE
   INF ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocolDxe.inf
 !endif
+
+!if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiBmcElog == TRUE
+  INF ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.inf
+!endif
-- 
2.37.1.windows.1



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




[edk2-devel] [edk2-platforms][PATCH 1/2] ManageabilityPkg/IpmiBmcElog: IPMI BMC Elog Driver

2023-05-12 Thread Chang, Abner via groups.io
From: Abner Chang 

IpmiBmcElog is cloned from
edk2-platforms/Features/Intel/OutOfBandManagement/
IpmiFeaturePkg/BmcElog in order to consolidate
edk2 system manageability support in one place.
Uncustify is applied to C files and no functionalities
are changed in this patch.

We will still keep the one under IpmiFeaturePkg/BmcElog
until the reference to this instance are removed from
platforms.

Signed-off-by: Abner Chang 
Cc: Isaac Oram 
Cc: Abdul Lateef Attar 
Cc: Nickle Wang 
Cc: Tinh Nguyen 
---
 .../Universal/IpmiBmcElog/BmcElog.inf |  33 +++
 .../Universal/IpmiBmcElog/BmcElog.c   | 192 ++
 2 files changed, 225 insertions(+)
 create mode 100644 Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.inf
 create mode 100644 Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.c

diff --git a/Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.inf 
b/Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.inf
new file mode 100644
index 00..4c28862fe5
--- /dev/null
+++ b/Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.inf
@@ -0,0 +1,33 @@
+### @file
+# Component description file for BMC ELOG.
+#
+# Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+###
+
+[Defines]
+  INF_VERSION  = 0x00010005
+  BASE_NAME= BmcElog
+  FILE_GUID= A0FF2235-B652-45E3-B3D2-B20F3E714E6F
+  MODULE_TYPE  = DXE_DRIVER
+  PI_SPECIFICATION_VERSION = 0x0001000A
+  VERSION_STRING   = 1.0
+  ENTRY_POINT  = InitializeBmcElogLayer
+
+[Sources]
+  BmcElog.c
+
+[Packages]
+  ManageabilityPkg/ManageabilityPkg.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
+  IpmiCommandLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+
+[Depex]
+  TRUE
diff --git a/Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.c 
b/Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.c
new file mode 100644
index 00..ab179e9d49
--- /dev/null
+++ b/Features/ManageabilityPkg/Universal/IpmiBmcElog/BmcElog.c
@@ -0,0 +1,192 @@
+/** @file
+  BMC Event Log functions.
+
+Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+EFI_STATUS
+EFIAPI
+CheckIfSelIsFull (
+  VOID
+  );
+
+/**
+  This function erases event logs and waits unti complete.
+
+  @param [in]  ResvId  - Reserved ID
+
+  @retval  EFI_STATUS   EFI_SUCCESS
+EFI_NO_RESPONSE
+
+**/
+EFI_STATUS
+WaitTillErased (
+  IN  UINT8  *ResvId
+  )
+{
+  INTN Counter;
+  IPMI_CLEAR_SEL_REQUEST   ClearSel;
+  IPMI_CLEAR_SEL_RESPONSE  ClearSelResponse;
+
+  Counter = 0x200;
+  ZeroMem (, sizeof (ClearSelResponse));
+
+  while (TRUE) {
+ZeroMem (, sizeof (ClearSel));
+ClearSel.Reserve[0] = ResvId[0];
+ClearSel.Reserve[1] = ResvId[1];
+ClearSel.AscC   = 0x43;
+ClearSel.AscL   = 0x4C;
+ClearSel.AscR   = 0x52;
+ClearSel.Erase  = 0x00;
+
+IpmiClearSel (
+  ,
+  
+  );
+
+if ((ClearSelResponse.ErasureProgress & 0xf) == 1) {
+  return EFI_SUCCESS;
+}
+
+//
+//  If there is not a response from the BMC controller we need to return 
and not hang.
+//
+--Counter;
+if (Counter == 0x0) {
+  return EFI_NO_RESPONSE;
+}
+  }
+}
+
+/**
+  This function activates BMC event log.
+
+  @param [in] EnableElog  Enable/Disable event log
+  @param [out] ElogStatus  return log status
+
+  @retval  EFI_STATUS
+
+**/
+EFI_STATUS
+EfiActivateBmcElog (
+  IN BOOLEAN   *EnableElog,
+  OUT BOOLEAN  *ElogStatus
+  )
+{
+  EFI_STATUSStatus;
+  UINT8 ElogStat;
+  IPMI_SET_BMC_GLOBAL_ENABLES_REQUEST   SetBmcGlobalEnables;
+  IPMI_GET_BMC_GLOBAL_ENABLES_RESPONSE  GetBmcGlobalEnables;
+  UINT8 CompletionCode;
+
+  Status   = EFI_SUCCESS;
+  ElogStat = 0;
+
+  Status = IpmiGetBmcGlobalEnables ();
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+
+  if (EnableElog == NULL) {
+*ElogStatus = GetBmcGlobalEnables.GetEnables.Bits.SystemEventLogging;
+  } else {
+if (Status == EFI_SUCCESS) {
+  if (*EnableElog) {
+ElogStat = 1;
+  }
+
+  CopyMem (, (UINT8 *) + 1, sizeof 
(UINT8));
+  SetBmcGlobalEnables.SetEnables.Bits.SystemEventLogging = ElogStat;
+
+  Status = IpmiSetBmcGlobalEnables (, );
+}
+  }
+
+  return Status;
+}
+
+/**
+
+  @retval  EFI_STATUS
+
+**/
+EFI_STATUS
+SetElogRedirInstall (
+  VOID
+  )
+{
+  BOOLEAN  EnableElog;
+  BOOLEAN  ElogStatus;
+
+  //
+  // Activate the Event Log (This should depend upon Setup).
+  //
+  EfiActivateBmcElog (, );
+  return EFI_SUCCESS;
+}
+
+/**
+  Entry point of BmcElog DXE driver
+
+  @param [in]  ImageHandle  ImageHandle of 

[edk2-devel] [PATCH] MdeModulePkg SdMmcPciHcDxe: SD/MMC capability debug print is incorrect

2023-05-12 Thread Giri Mudusuru via groups.io
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4394

Fix DumpCapabilityReg() debug log to print 64 bit capability instead of 32 bit 
pointer

Cc: Hao A Wu 
Cc: Ray Ni 
Cc: Jian J Wang 
Cc: Liming Gao 
Cc: Andrew Fish 
Signed-off-by: Giri Mudusuru 
---
 MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c 
b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
index aab6815328..2e7497a89d 100644
--- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
+++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c
@@ -30,7 +30,7 @@ DumpCapabilityReg (
   //
   // Dump Capability Data
   //
-  DEBUG ((DEBUG_INFO, " == Slot [%d] Capability is 0x%x ==\n", Slot, 
Capability));
+  DEBUG ((DEBUG_INFO, " == Slot [%d] Capability is 0x%llx ==\n", Slot, 
*(UINT64 *)Capability));
   DEBUG ((DEBUG_INFO, "   Timeout Clk Freq  %d%a\n", Capability->TimeoutFreq, 
(Capability->TimeoutUnit) ? "MHz" : "KHz"));
   DEBUG ((DEBUG_INFO, "   Base Clk Freq %dMHz\n", 
Capability->BaseClkFreq));
   DEBUG ((DEBUG_INFO, "   Max Blk Len   %dbytes\n", 512 * (1 << 
Capability->MaxBlkLen)));
-- 
2.39.2 (Apple Git-144)



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




Re: [edk2-devel] 回复: [PATCH v4 0/3] Add IPMI SSIF definitions

2023-05-12 Thread Tinh Nguyen via groups.io

oh, sorry, I have some personal issues and not follow up recently,
Abner, thanks for letting me know

- Tinh

On 12/05/2023 16:16, Chang, Abner wrote:

[AMD Official Use Only - General]

Hi Tinh,  It is already merged.
Abner


-Original Message-
From: Tinh Nguyen 
Sent: Friday, May 12, 2023 4:50 PM
To: gaoliming ; 'Tinh Nguyen'
; devel@edk2.groups.io
Cc: patc...@amperecomputing.com; michael.d.kin...@intel.com;
zhiguang@intel.com; Chang, Abner 
Subject: Re: 回复: [PATCH v4 0/3] Add IPMI SSIF definitions

Caution: This message originated from an External Source. Use proper
caution when opening attachments, clicking links, or responding.


Hi Liming,

If there are no concerns, can you assist in merging them?

Thanks

- Tinh

On 08/05/2023 08:07, gaoliming wrote:

Reviewed-by: Liming Gao 


-邮件原件-
发件人: Tinh Nguyen 
发送时间: 2023年5月7日 17:29
收件人: devel@edk2.groups.io
抄送: patc...@amperecomputing.com; michael.d.kin...@intel.com;
gaolim...@byosoft.com.cn; zhiguang@intel.com;

abner.ch...@amd.com;

Tinh Nguyen 
主题: [PATCH v4 0/3] Add IPMI SSIF definitions

Change from v3:
- Add IPMI key word to commit subject

Change from v2:
- Add the carbon copy (Cc) in the commit message.
- Add Bugzilla ID in the commit message.
- Mention why I set the number of retries as 250.

Change from v1:
- Separate the commit for the IPMI SSIF header and IPMI SSIF PCDs
- Correct some indent and comment style.
- Change the PCDs name for a more readable.
- Support KCS/SMIC Interface Capabilities too.

Tinh Nguyen (3):
MdePkg/IndustryStandard: Add definitions for IPMI SSIF
MdePkg: Add new PCDs for IPMI SSIF
MdePkg/IndustryStandard: Add IPMI Interface Capabilities definitions

   MdePkg/MdePkg.dec  | 27 ++
   MdePkg/Include/IndustryStandard/IpmiNetFnApp.h | 46 +
   MdePkg/Include/IndustryStandard/IpmiSsif.h | 98

   3 files changed, 171 insertions(+)
   create mode 100644 MdePkg/Include/IndustryStandard/IpmiSsif.h

--
2.40.0



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




Re: [edk2-devel] [PATCH v7] MinPlatformPkg: Update HWSignature filed in FACS

2023-05-12 Thread Ni, Ray



> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of VincentX Ke
> Sent: Thursday, May 11, 2023 6:00 PM
> To: devel@edk2.groups.io
> Cc: Ke, VincentX ; Chiu, Chasel
> ; Desimone, Nathaniel L
> ; Oram, Isaac W ;
> Gao, Liming ; Dong, Eric ;
> Sinha, Ankit 
> Subject: [edk2-devel] [PATCH v7] MinPlatformPkg: Update HWSignature filed in
> FACS
> 
> From: VincentX Ke 
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4428
> 
> Calculating CRC based on each ACPI table.
> Update HWSignature filed in FACS based on CRC while ACPI table changed.
> 
> Change-Id: Ic0ca66ff10cda0fbcd0683020fab1bc9aea9b78c
> Signed-off-by: VincentX Ke 
> Cc: Chasel Chiu 
> Cc: Nate DeSimone 
> Cc: Isaac Oram 
> Cc: Liming Gao 
> Cc: Eric Dong 
> Cc: Ankit Sinha
> Signed-off-by: VincentX Ke 
> ---
>  Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c   | 287
> +++-
>  Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.inf |   1 +
>  2 files changed, 223 insertions(+), 65 deletions(-)
> 
> diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
> b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
> index e967031a3b..3dca6f99f7 100644
> --- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
> +++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
> @@ -1191,98 +1191,255 @@ PlatformUpdateTables (
>  }
> 
> 
> 
>  /**
> 
> -  This function calculates RCR based on PCI Device ID and Vendor ID from the
> devices
> 
> -  available on the platform.
> 
> -  It also includes other instances of BIOS change to calculate CRC and 
> provides
> as
> 
> -  HWSignature filed in FADT table.
> 
> +  This function calculates CRC based on each offset in the ACPI table.
> 
> +
> 
> +  @param[in] Table  The ACPI table required to calculate CRC.
> 
> +
> 
> +  @retval CRC   A pointer to allocate UINT32 that
> 
> +contains the CRC32 data.
> 
> +**/
> 
> +UINT32
> 
> +AcpiTableCrcCalculator (
> 
> +  IN  EFI_ACPI_COMMON_HEADER  *Table
> 
> +  )
> 
> +{
> 
> +  EFI_STATUS  Status;
> 
> +  UINT32  CRC;
> 
> +
> 
> +  Status = EFI_SUCCESS;
> 
> +  CRC= 0;
> 
> +
> 
> +  //
> 
> +  // Calculate CRC value.
> 
> +  //
> 
> +  if (Table->Signature ==
> EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE) {
> 
> +//
> 
> +// Zero HardwareSignature field before Calculating FACS CRC
> 
> +//
> 
> +((EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE *)Table)-
> >HardwareSignature = 0;
> 
> +  }
> 
> +
> 
> +  Status = gBS->CalculateCrc32 ((UINT8 *)Table, (UINTN)Table->Length, );
> 
> +  return CRC;
> 
> +}
> 
> +
> 
> +/**
> 
> +  This function count ACPI tables in RSDT/XSDT and return the result.
> 
> +
> 
> +  @param[in] SdtACPI XSDT/RSDT.
> 
> +  @param[in] TablePointerSize   Size of table pointer:
> 
> +4(RSDT) or 8(XSDT).
> 
> +
> 
> +  @retval TableCountThe total number of ACPI tables in
> 
> +RSDT or XSDT.
> 
> +**/
> 
> +UINTN
> 
> +CountTableInSDT (
> 
> +  IN  EFI_ACPI_DESCRIPTION_HEADER  *Sdt,
> 
> +  IN  UINTNTablePointerSize
> 
> +  )
> 
> +{
> 
> +  UINTN   Index;
> 
> +  UINTN   TableCount;
> 
> +  UINTN   EntryCount;
> 
> +  UINT64  EntryPtr;
> 
> +  UINTN   BasePtr;
> 
> +  EFI_ACPI_COMMON_HEADER  *Table;
> 
> +
> 
> +  EntryCount = (Sdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) /
> TablePointerSize;
> 
> +  BasePtr= (UINTN)(Sdt + 1);
> 
> +
> 
> +  for (Index = 0, TableCount = 0; Index < EntryCount; Index++) {
> 
> +EntryPtr = 0;
> 
> +Table= NULL;
> 
> +CopyMem (, (VOID *)(BasePtr + Index * TablePointerSize),
> TablePointerSize);
> 
> +Table = (EFI_ACPI_COMMON_HEADER *)((UINTN)(EntryPtr));
> 
> +if (Table) {

1. if (Table != NULL)

> 
> +  TableCount++;
> 
> +}
> 
> +
> 
> +if (Table->Signature ==
> EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE) {
> 
> +  CopyMem ((VOID *), (VOID *)Table, sizeof
> (EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE));

2. Different versions of FADT have different sizes. This CopyMem is dangerous.
And why do you CopyMem()?

> 
> +  if (Fadt.FirmwareCtrl || Fadt.XFirmwareCtrl) {

3. if (Fadt.FirmwareCtrl != 0 || ...)

> 
> +TableCount++;
> 
> +  }
> 
> +
> 
> +  if (Fadt.Dsdt || Fadt.XDsdt) {

4. if (Fadt. Dsdt != 0 || ...)

> 
> +TableCount++;
> 
> +  }
> 
> +}
> 
> +  }
> 
> +
> 
> +  return TableCount;
> 
> +}
> 
> +
> 
> +/**
> 
> +  This function calculates CRC based on each ACPI table.
> 
> +  It also calculates CRC and provides as HWSignature filed in FACS.
> 
>  **/
> 
>  VOID
> 
> -IsHardwareChange (
> 
> +IsAcpiTableChange (
> 
>VOID
> 
>)
> 
>  {
> 
> -  EFI_STATUSStatus;
> 
> -  UINTN Index;
> 
> -  UINTN

Re: [edk2-devel] 回复: [PATCH v4 0/3] Add IPMI SSIF definitions

2023-05-12 Thread Chang, Abner via groups.io
[AMD Official Use Only - General]

Hi Tinh,  It is already merged. 
Abner

> -Original Message-
> From: Tinh Nguyen 
> Sent: Friday, May 12, 2023 4:50 PM
> To: gaoliming ; 'Tinh Nguyen'
> ; devel@edk2.groups.io
> Cc: patc...@amperecomputing.com; michael.d.kin...@intel.com;
> zhiguang@intel.com; Chang, Abner 
> Subject: Re: 回复: [PATCH v4 0/3] Add IPMI SSIF definitions
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> Hi Liming,
> 
> If there are no concerns, can you assist in merging them?
> 
> Thanks
> 
> - Tinh
> 
> On 08/05/2023 08:07, gaoliming wrote:
> > Reviewed-by: Liming Gao 
> >
> >> -邮件原件-
> >> 发件人: Tinh Nguyen 
> >> 发送时间: 2023年5月7日 17:29
> >> 收件人: devel@edk2.groups.io
> >> 抄送: patc...@amperecomputing.com; michael.d.kin...@intel.com;
> >> gaolim...@byosoft.com.cn; zhiguang@intel.com;
> abner.ch...@amd.com;
> >> Tinh Nguyen 
> >> 主题: [PATCH v4 0/3] Add IPMI SSIF definitions
> >>
> >> Change from v3:
> >>- Add IPMI key word to commit subject
> >>
> >> Change from v2:
> >>- Add the carbon copy (Cc) in the commit message.
> >>- Add Bugzilla ID in the commit message.
> >>- Mention why I set the number of retries as 250.
> >>
> >> Change from v1:
> >>- Separate the commit for the IPMI SSIF header and IPMI SSIF PCDs
> >>- Correct some indent and comment style.
> >>- Change the PCDs name for a more readable.
> >>- Support KCS/SMIC Interface Capabilities too.
> >>
> >> Tinh Nguyen (3):
> >>MdePkg/IndustryStandard: Add definitions for IPMI SSIF
> >>MdePkg: Add new PCDs for IPMI SSIF
> >>MdePkg/IndustryStandard: Add IPMI Interface Capabilities definitions
> >>
> >>   MdePkg/MdePkg.dec  | 27 ++
> >>   MdePkg/Include/IndustryStandard/IpmiNetFnApp.h | 46 +
> >>   MdePkg/Include/IndustryStandard/IpmiSsif.h | 98
> >> 
> >>   3 files changed, 171 insertions(+)
> >>   create mode 100644 MdePkg/Include/IndustryStandard/IpmiSsif.h
> >>
> >> --
> >> 2.40.0
> >


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




Re: [edk2-devel] 回复: [PATCH v4 0/3] Add IPMI SSIF definitions

2023-05-12 Thread Tinh Nguyen via groups.io

Hi Liming,

If there are no concerns, can you assist in merging them?

Thanks

- Tinh

On 08/05/2023 08:07, gaoliming wrote:

Reviewed-by: Liming Gao 


-邮件原件-
发件人: Tinh Nguyen 
发送时间: 2023年5月7日 17:29
收件人: devel@edk2.groups.io
抄送: patc...@amperecomputing.com; michael.d.kin...@intel.com;
gaolim...@byosoft.com.cn; zhiguang@intel.com; abner.ch...@amd.com;
Tinh Nguyen 
主题: [PATCH v4 0/3] Add IPMI SSIF definitions

Change from v3:
   - Add IPMI key word to commit subject

Change from v2:
   - Add the carbon copy (Cc) in the commit message.
   - Add Bugzilla ID in the commit message.
   - Mention why I set the number of retries as 250.

Change from v1:
   - Separate the commit for the IPMI SSIF header and IPMI SSIF PCDs
   - Correct some indent and comment style.
   - Change the PCDs name for a more readable.
   - Support KCS/SMIC Interface Capabilities too.

Tinh Nguyen (3):
   MdePkg/IndustryStandard: Add definitions for IPMI SSIF
   MdePkg: Add new PCDs for IPMI SSIF
   MdePkg/IndustryStandard: Add IPMI Interface Capabilities definitions

  MdePkg/MdePkg.dec  | 27 ++
  MdePkg/Include/IndustryStandard/IpmiNetFnApp.h | 46 +
  MdePkg/Include/IndustryStandard/IpmiSsif.h | 98

  3 files changed, 171 insertions(+)
  create mode 100644 MdePkg/Include/IndustryStandard/IpmiSsif.h

--
2.40.0





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104781): https://edk2.groups.io/g/devel/message/104781
Mute This Topic: https://groups.io/mt/98752949/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 1/2] ManageabilityPkg/IpmiFru: IPMI FRU Driver

2023-05-12 Thread Tinh Nguyen via groups.io

Reviewed-by: Tinh Nguyen 

Thanks,

- Tinh

On 12/05/2023 10:26, abner.ch...@amd.com wrote:

From: Abner Chang 

IpmiFru is cloned from
edk2-platforms/Features/Intel/OutOfBandManagement/
IpmiFeaturePkg/IpmiFru in order to consolidate
edk2 system manageability support in one place.
Uncustify is applied to C files and no functionalities
are changed in this patch.

We will still keep the one under IpmiFeaturePkg/IpmiFru
until the reference to this instance are removed from
platforms.

Signed-off-by: Abner Chang 
Cc: Isaac Oram 
Cc: Abdul Lateef Attar 
Cc: Nickle Wang 
Cc: Tinh Nguyen 
---
  .../Universal/IpmiFru/IpmiFru.inf | 34 ++
  .../Universal/IpmiFru/IpmiFru.c   | 67 +++
  2 files changed, 101 insertions(+)
  create mode 100644 Features/ManageabilityPkg/Universal/IpmiFru/IpmiFru.inf
  create mode 100644 Features/ManageabilityPkg/Universal/IpmiFru/IpmiFru.c

diff --git a/Features/ManageabilityPkg/Universal/IpmiFru/IpmiFru.inf 
b/Features/ManageabilityPkg/Universal/IpmiFru/IpmiFru.inf
new file mode 100644
index 00..ddef310309
--- /dev/null
+++ b/Features/ManageabilityPkg/Universal/IpmiFru/IpmiFru.inf
@@ -0,0 +1,34 @@
+### @file
+# Component description file for IPMI FRU.
+#
+# Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+###
+
+[Defines]
+  INF_VERSION  = 0x00010005
+  BASE_NAME= IpmiFru
+  FILE_GUID= CD9B99D9-E86F-48CF-A8EB-20120AC22666
+  MODULE_TYPE  = DXE_DRIVER
+  PI_SPECIFICATION_VERSION = 0x0001000A
+  VERSION_STRING   = 1.0
+  ENTRY_POINT  = InitializeFru
+
+[Sources]
+  IpmiFru.c
+
+[Packages]
+  ManageabilityPkg/ManageabilityPkg.dec
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
+  IpmiCommandLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+  UefiLib
+
+[Depex]
+  TRUE
diff --git a/Features/ManageabilityPkg/Universal/IpmiFru/IpmiFru.c 
b/Features/ManageabilityPkg/Universal/IpmiFru/IpmiFru.c
new file mode 100644
index 00..2b489410db
--- /dev/null
+++ b/Features/ManageabilityPkg/Universal/IpmiFru/IpmiFru.c
@@ -0,0 +1,67 @@
+/** @file
+  IPMI FRU Driver.
+
+Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*++
+
+Routine Description:
+
+  Initialize SM Redirection Fru Layer
+
+Arguments:
+
+  ImageHandle - ImageHandle of the loaded driver
+  SystemTable - Pointer to the System Table
+
+Returns:
+
+  EFI_STATUS
+
+--*/
+EFI_STATUS
+EFIAPI
+InitializeFru (
+  IN EFI_HANDLEImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  EFI_STATUS Status;
+  IPMI_GET_DEVICE_ID_RESPONSEControllerInfo;
+  IPMI_GET_FRU_INVENTORY_AREA_INFO_REQUEST   GetFruInventoryAreaInfoRequest;
+  IPMI_GET_FRU_INVENTORY_AREA_INFO_RESPONSE  GetFruInventoryAreaInfoResponse;
+
+  //
+  //  Get all the SDR Records from BMC and retrieve the Record ID from the 
structure for future use.
+  //
+  Status = IpmiGetDeviceId ();
+  if (EFI_ERROR (Status)) {
+DEBUG ((DEBUG_ERROR, "!!! IpmiFru  IpmiGetDeviceId Status=%x\n", Status));
+return Status;
+  }
+
+  DEBUG ((DEBUG_ERROR, "!!! IpmiFru  FruInventorySupport %x\n", 
ControllerInfo.DeviceSupport.Bits.FruInventorySupport));
+
+  if (ControllerInfo.DeviceSupport.Bits.FruInventorySupport) {
+GetFruInventoryAreaInfoRequest.DeviceId = 0;
+Status  = IpmiGetFruInventoryAreaInfo 
(, );
+if (EFI_ERROR (Status)) {
+  DEBUG ((DEBUG_ERROR, "!!! IpmiFru  IpmiGetFruInventoryAreaInfo 
Status=%x\n", Status));
+  return Status;
+}
+
+DEBUG ((DEBUG_ERROR, "!!! IpmiFru  InventoryAreaSize=%x\n", 
GetFruInventoryAreaInfoResponse.InventoryAreaSize));
+  }
+
+  return EFI_SUCCESS;
+}



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104780): https://edk2.groups.io/g/devel/message/104780
Mute This Topic: https://groups.io/mt/98842631/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 2/2] ManageabilityPkg/IpmiOsWdt: Add to ManageabilityPkg

2023-05-12 Thread Nickle Wang via groups.io
Reviewed-by: Nickle Wang 

Regards,
Nickle


> -Original Message-
> From: abner.ch...@amd.com 
> Sent: Friday, May 12, 2023 12:07 PM
> To: devel@edk2.groups.io
> Cc: Isaac Oram ; Abdul Lateef Attar
> ; Nickle Wang 
> Subject: [edk2-platforms][PATCH 2/2] ManageabilityPkg/IpmiOsWdt: Add to
> ManageabilityPkg
> 
> External email: Use caution opening links or attachments
> 
> 
> From: Abner Chang 
> 
> Add IpmiOsWdt to ManageabilityPkg.
> 
> Signed-off-by: Abner Chang 
> Cc: Isaac Oram 
> Cc: Abdul Lateef Attar 
> Cc: Nickle Wang 
> ---
>  Features/ManageabilityPkg/ManageabilityPkg.dec  | 1 +
>  Features/ManageabilityPkg/Include/Manageability.dsc | 4 
>  Features/ManageabilityPkg/ManageabilityPkg.dsc  | 2 ++
>  Features/ManageabilityPkg/Include/PostMemory.fdf| 4 
>  4 files changed, 11 insertions(+)
> 
> diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dec
> b/Features/ManageabilityPkg/ManageabilityPkg.dec
> index 38813c5f48..0a1c527107 100644
> --- a/Features/ManageabilityPkg/ManageabilityPkg.dec
> +++ b/Features/ManageabilityPkg/ManageabilityPkg.dec
> @@ -79,4 +79,5 @@
> 
> gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmEnable|FALSE|BO
> OLEAN|0x1004
> 
> gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable|FALSE|BO
> OLEAN|0x1005
> 
> gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmSmbiosTransferEna
> ble|FALSE|BOOLEAN|0x1006
> +
> gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiOsWdt|FALSE|BOO
> LEAN|0x1008
> 
> diff --git a/Features/ManageabilityPkg/Include/Manageability.dsc
> b/Features/ManageabilityPkg/Include/Manageability.dsc
> index a432b0ff26..439f3be1ce 100644
> --- a/Features/ManageabilityPkg/Include/Manageability.dsc
> +++ b/Features/ManageabilityPkg/Include/Manageability.dsc
> @@ -51,3 +51,7 @@
>  !if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable ==
> TRUE
>ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocolDxe.inf
>  !endif
> +
> +!if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiOsWdt ==
> TRUE
> +  ManageabilityPkg/Universal/IpmiOsWdt/OsWdt.inf
> +!endif
> diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dsc
> b/Features/ManageabilityPkg/ManageabilityPkg.dsc
> index e3baf27f2a..177c900360 100644
> --- a/Features/ManageabilityPkg/ManageabilityPkg.dsc
> +++ b/Features/ManageabilityPkg/ManageabilityPkg.dsc
> @@ -37,6 +37,7 @@
>gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmEnable
> |TRUE
>gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable
> |TRUE
> 
> gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmSmbiosTransferEna
> ble|TRUE
> +  gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiOsWdt
> |TRUE
> 
>  #
>  # Include common libraries
> @@ -53,5 +54,6 @@
> 
>  [LibraryClasses]
> 
> ManageabilityTransportLib|ManageabilityPkg/Library/BaseManageabilityTransp
> ortNullLib/BaseManageabilityTransportNull.inf
> +  IpmiLib|MdeModulePkg/Library/BaseIpmiLibNull/BaseIpmiLibNull.inf
> 
>  !include Include/Manageability.dsc
> diff --git a/Features/ManageabilityPkg/Include/PostMemory.fdf
> b/Features/ManageabilityPkg/Include/PostMemory.fdf
> index 9100cb2646..1a2fed2253 100644
> --- a/Features/ManageabilityPkg/Include/PostMemory.fdf
> +++ b/Features/ManageabilityPkg/Include/PostMemory.fdf
> @@ -26,3 +26,7 @@
>  !if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable ==
> TRUE
>INF ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocolDxe.inf
>  !endif
> +
> +!if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiOsWdt ==
> TRUE
> +  INF ManageabilityPkg/Universal/IpmiOsWdt/OsWdt.inf
> +!endif
> --
> 2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104779): https://edk2.groups.io/g/devel/message/104779
Mute This Topic: https://groups.io/mt/98843096/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 1/2] ManageabilityPkg/IpmiOsWdt: IPMI OS Watchdog timer Driver

2023-05-12 Thread Nickle Wang via groups.io
Reviewed-by: Nickle Wang 

Regards,
Nickle

> -Original Message-
> From: abner.ch...@amd.com 
> Sent: Friday, May 12, 2023 12:07 PM
> To: devel@edk2.groups.io
> Cc: Isaac Oram ; Abdul Lateef Attar
> ; Nickle Wang ; Tinh Nguyen
> 
> Subject: [edk2-platforms][PATCH 1/2] ManageabilityPkg/IpmiOsWdt: IPMI OS
> Watchdog timer Driver
> 
> External email: Use caution opening links or attachments
> 
> 
> From: Abner Chang 
> 
> IpmiOsWdt is cloned from
> edk2-platforms/Features/Intel/OutOfBandManagement/
> IpmiFeaturePkg/OsWdt in order to consolidate
> edk2 system manageability support in one place.
> Uncustify is applied to C files and no functionalities are changed in this 
> patch.
> 
> We will still keep the one under IpmiFeaturePkg/OsWdt until the reference to 
> this
> instance are removed from platforms.
> 
> Signed-off-by: Abner Chang 
> Cc: Isaac Oram 
> Cc: Abdul Lateef Attar 
> Cc: Nickle Wang 
> Cc: Tinh Nguyen 
> ---
>  .../Universal/IpmiOsWdt/OsWdt.inf |  33 ++
>  .../Universal/IpmiOsWdt/OsWdt.c   | 112 ++
>  2 files changed, 145 insertions(+)
>  create mode 100644
> Features/ManageabilityPkg/Universal/IpmiOsWdt/OsWdt.inf
>  create mode 100644 Features/ManageabilityPkg/Universal/IpmiOsWdt/OsWdt.c
> 
> diff --git a/Features/ManageabilityPkg/Universal/IpmiOsWdt/OsWdt.inf
> b/Features/ManageabilityPkg/Universal/IpmiOsWdt/OsWdt.inf
> new file mode 100644
> index 00..b5af3b25e1
> --- /dev/null
> +++ b/Features/ManageabilityPkg/Universal/IpmiOsWdt/OsWdt.inf
> @@ -0,0 +1,33 @@
> +### @file
> +# Component description file for IPMI OS watch dog timer driver.
> +#
> +# Copyright (c) 2018 - 2019, Intel Corporation. All rights
> +reserved. # # SPDX-License-Identifier: BSD-2-Clause-Patent # ###
> +
> +[Defines]
> +  INF_VERSION= 0x00010005
> +  BASE_NAME  = OsWdt
> +  FILE_GUID  = BA4FD21F-8443-4017-8D13-70EC92F4BD4C
> +  MODULE_TYPE= DXE_DRIVER
> +  VERSION_STRING = 1.0
> +  ENTRY_POINT= DriverInit
> +
> +[Sources]
> +  OsWdt.c
> +
> +[Packages]
> +  ManageabilityPkg/ManageabilityPkg.dec
> +  MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> +  DebugLib
> +  IpmiCommandLib
> +  UefiBootServicesTableLib
> +  UefiDriverEntryPoint
> +  UefiLib
> +
> +[Depex]
> +  TRUE
> diff --git a/Features/ManageabilityPkg/Universal/IpmiOsWdt/OsWdt.c
> b/Features/ManageabilityPkg/Universal/IpmiOsWdt/OsWdt.c
> new file mode 100644
> index 00..e2bbd95b83
> --- /dev/null
> +++ b/Features/ManageabilityPkg/Universal/IpmiOsWdt/OsWdt.c
> @@ -0,0 +1,112 @@
> +/** @file
> +  IPMI Os watchdog timer Driver.
> +
> +Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
> +SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +BOOLEAN  mOsWdtFlag = FALSE;
> +
> +EFI_EVENT  mExitBootServicesEvent;
> +
> +/*++
> +
> +Routine Description:
> +  Enable the OS Boot Watchdog Timer.
> +  Is called only on legacy or EFI OS boot.
> +
> +Arguments:
> +  Event- Event type
> +  *Context - Context for the event
> +
> +Returns:
> +  None
> +
> +--*/
> +VOID
> +EFIAPI
> +EnableEfiOsBootWdtHandler (
> +  IN EFI_EVENT  Event,
> +  IN VOID   *Context
> +  )
> +{
> +  EFI_STATUSStatus;
> +  IPMI_SET_WATCHDOG_TIMER_REQUEST   SetWatchdogTimer;
> +  UINT8 CompletionCode;
> +  IPMI_GET_WATCHDOG_TIMER_RESPONSE  GetWatchdogTimer;
> +  static BOOLEANOsWdtEventHandled = FALSE;
> +
> +  DEBUG ((DEBUG_ERROR, "!!! EnableEfiOsBootWdtHandler()!!!\n"));
> +
> +  //
> +  // Make sure it processes once only. And proceess it only if
> + OsWdtFlag==TRUE;  //  if (OsWdtEventHandled || !mOsWdtFlag) {
> +return;
> +  }
> +
> +  OsWdtEventHandled = TRUE;
> +
> +  Status = IpmiGetWatchdogTimer ();  if (EFI_ERROR
> + (Status)) {
> +return;
> +  }
> +
> +  ZeroMem (, sizeof (SetWatchdogTimer));  //  // Just
> + flip the Timer Use bit. This should release the timer.
> +  //
> +  SetWatchdogTimer.TimerUse.Bits.TimerRunning= 1;
> +  SetWatchdogTimer.TimerUse.Bits.TimerUse=
> IPMI_WATCHDOG_TIMER_OS_LOADER;
> +  SetWatchdogTimer.TimerActions.Uint8=
> IPMI_WATCHDOG_TIMER_ACTION_HARD_RESET;
> +  SetWatchdogTimer.TimerUseExpirationFlagsClear &= ~BIT4;
> + SetWatchdogTimer.TimerUseExpirationFlagsClear |= BIT1 | BIT2;
> +  SetWatchdogTimer.InitialCountdownValue = 600; // 100ms / count
> +
> +  Status = IpmiSetWatchdogTimer (, );
> +  return;
> +}
> +
> +/*++
> +
> +Routine Description:
> +  This is the standard EFI driver point. This function intitializes
> +  the private data required for creating ASRR Driver.
> +
> +Arguments:
> +  As required for DXE driver enrty routine.
> +  ImageHandle - ImageHandle of the loaded driver
> +  SystemTable - Pointer to the System Table
> +
> +Returns:
> +  @retval 

[edk2-devel] [edk2-platforms][PATCH 2/2] ManageabilityPkg/IpmiSolStatus: Add to ManageabilityPkg

2023-05-12 Thread Chang, Abner via groups.io
From: Abner Chang 

Add IpmiSolStatus to ManageabilityPkg.

Signed-off-by: Abner Chang 
Cc: Isaac Oram 
Cc: Abdul Lateef Attar 
Cc: Nickle Wang 
---
 Features/ManageabilityPkg/ManageabilityPkg.dec  | 1 +
 Features/ManageabilityPkg/Include/Manageability.dsc | 4 
 Features/ManageabilityPkg/ManageabilityPkg.dsc  | 2 ++
 Features/ManageabilityPkg/Include/PostMemory.fdf| 4 
 4 files changed, 11 insertions(+)

diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dec 
b/Features/ManageabilityPkg/ManageabilityPkg.dec
index c11bf5d0df..6bf65feda4 100644
--- a/Features/ManageabilityPkg/ManageabilityPkg.dec
+++ b/Features/ManageabilityPkg/ManageabilityPkg.dec
@@ -83,4 +83,5 @@
   
gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmEnable|FALSE|BOOLEAN|0x1004
   
gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable|FALSE|BOOLEAN|0x1005
   
gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmSmbiosTransferEnable|FALSE|BOOLEAN|0x1006
+  
gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiSolStatus|FALSE|BOOLEAN|0x1009
 
diff --git a/Features/ManageabilityPkg/Include/Manageability.dsc 
b/Features/ManageabilityPkg/Include/Manageability.dsc
index a432b0ff26..5f014b5d8d 100644
--- a/Features/ManageabilityPkg/Include/Manageability.dsc
+++ b/Features/ManageabilityPkg/Include/Manageability.dsc
@@ -51,3 +51,7 @@
 !if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable == TRUE
   ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocolDxe.inf
 !endif
+
+!if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiSolStatus == TRUE
+  ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.inf
+!endif
diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dsc 
b/Features/ManageabilityPkg/ManageabilityPkg.dsc
index e3baf27f2a..6426f84f1f 100644
--- a/Features/ManageabilityPkg/ManageabilityPkg.dsc
+++ b/Features/ManageabilityPkg/ManageabilityPkg.dsc
@@ -37,6 +37,7 @@
   gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmEnable  
|TRUE
   gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable  
|TRUE
   
gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmSmbiosTransferEnable|TRUE
+  gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiSolStatus   
|TRUE
 
 #
 # Include common libraries
@@ -53,5 +54,6 @@
 
 [LibraryClasses]
   
ManageabilityTransportLib|ManageabilityPkg/Library/BaseManageabilityTransportNullLib/BaseManageabilityTransportNull.inf
+  IpmiLib|MdeModulePkg/Library/BaseIpmiLibNull/BaseIpmiLibNull.inf
 
 !include Include/Manageability.dsc
diff --git a/Features/ManageabilityPkg/Include/PostMemory.fdf 
b/Features/ManageabilityPkg/Include/PostMemory.fdf
index 9100cb2646..2d04e736c1 100644
--- a/Features/ManageabilityPkg/Include/PostMemory.fdf
+++ b/Features/ManageabilityPkg/Include/PostMemory.fdf
@@ -26,3 +26,7 @@
 !if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable == TRUE
   INF ManageabilityPkg/Universal/MctpProtocol/Dxe/MctpProtocolDxe.inf
 !endif
+
+!if gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiSolStatus == TRUE
+  INF ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.inf
+!endif
-- 
2.37.1.windows.1



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




[edk2-devel] [edk2-platforms][PATCH 1/2] ManageabilityPkg/IpmiSolStatus: IPMI Serail over Lan Driver

2023-05-12 Thread Chang, Abner via groups.io
From: Abner Chang 

IpmiSolStatus is cloned from
edk2-platforms/Features/Intel/OutOfBandManagement/
IpmiFeaturePkg/SolStatus in order to consolidate
edk2 system manageability support in one place.
Uncustify is applied to C files and no functionalities
are changed in this patch.

We will still keep the one under IpmiFeaturePkg/SolStatus
until the reference to this instance are removed from
platforms.

Signed-off-by: Abner Chang 
Cc: Isaac Oram 
Cc: Abdul Lateef Attar 
Cc: Nickle Wang 
Cc: Tinh Nguyen 
---
 .../ManageabilityPkg/ManageabilityPkg.dec |   4 +
 .../Universal/IpmiSolStatus/SolStatus.inf |  37 
 .../Universal/IpmiSolStatus/SolStatus.c   | 164 ++
 3 files changed, 205 insertions(+)
 create mode 100644 
Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.inf
 create mode 100644 
Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.c

diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dec 
b/Features/ManageabilityPkg/ManageabilityPkg.dec
index 38813c5f48..c11bf5d0df 100644
--- a/Features/ManageabilityPkg/ManageabilityPkg.dec
+++ b/Features/ManageabilityPkg/ManageabilityPkg.dec
@@ -72,6 +72,10 @@
   # @Prompt MCTP KCS (Memory mapped) I/O base address
   gManageabilityPkgTokenSpaceGuid.PcdMctpKcsBaseAddress|0xca2|UINT32|0x0004
 
+  ## This is the value of SOL channels supported on platform.
+  # @Prompt SOL channel number
+  gManageabilityPkgTokenSpaceGuid.PcdMaxSolChannels|3|UINT8|0x0100
+
 [PcdsFeatureFlag]
   
gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiEnable|FALSE|BOOLEAN|0x1001
   
gManageabilityPkgTokenSpaceGuid.PcdManageabilitySmmIpmiEnable|FALSE|BOOLEAN|0x1002
diff --git a/Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.inf 
b/Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.inf
new file mode 100644
index 00..1d7cbf1a08
--- /dev/null
+++ b/Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.inf
@@ -0,0 +1,37 @@
+### @file
+# Component description file for IPMI Serial Over LAN (SOL) driver.
+#
+# Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+###
+
+[Defines]
+  INF_VERSION  = 0x00010005
+  BASE_NAME= SolStatus
+  FILE_GUID= 1AF7E6C4-7678-4A6D-9240-E8BA17C3B772
+  MODULE_TYPE  = DXE_DRIVER
+  PI_SPECIFICATION_VERSION = 0x0001000A
+  VERSION_STRING   = 1.0
+  ENTRY_POINT  = SolStatusEntryPoint
+
+[Sources]
+  SolStatus.c
+
+[Packages]
+  ManageabilityPkg/ManageabilityPkg.dec
+  MdePkg/MdePkg.dec
+
+[Pcd]
+  gManageabilityPkgTokenSpaceGuid.PcdMaxSolChannels
+
+[LibraryClasses]
+  DebugLib
+  IpmiCommandLib
+  PcdLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+
+[Depex]
+  TRUE
diff --git a/Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.c 
b/Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.c
new file mode 100644
index 00..996386372e
--- /dev/null
+++ b/Features/ManageabilityPkg/Universal/IpmiSolStatus/SolStatus.c
@@ -0,0 +1,164 @@
+/** @file
+  IPMI Serial Over Lan Driver.
+
+Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define SOL_CMD_RETRY_COUNT  10
+
+/*++
+
+Routine Description:
+
+This routine gets the SOL payload status or settings for a specific 
channel.
+
+Arguments:
+Channel - LAN channel naumber.
+ParamSel- Configuration parameter selection.
+Data- Information returned from BMC.
+Returns:
+EFI_SUCCESS - SOL configuration parameters are successfully read from 
BMC.
+Others  - SOL configuration parameters could not be read from BMC.
+
+--*/
+EFI_STATUS
+GetSolStatus (
+  IN UINT8  Channel,
+  IN UINT8  ParamSel,
+  IN OUT UINT8  *Data
+  )
+{
+  EFI_STATUS  Status = EFI_SUCCESS;
+  IPMI_GET_SOL_CONFIGURATION_PARAMETERS_REQUEST   
GetConfigurationParametersRequest;
+  IPMI_GET_SOL_CONFIGURATION_PARAMETERS_RESPONSE  
GetConfigurationParametersResponse;
+  UINT32  DataSize;
+  UINT8   RetryCount;
+
+  for (RetryCount = 0; RetryCount < SOL_CMD_RETRY_COUNT; RetryCount++) {
+ZeroMem (, sizeof 
(GetConfigurationParametersRequest));
+GetConfigurationParametersRequest.ChannelNumber.Bits.ChannelNumber = 
Channel;
+GetConfigurationParametersRequest.ParameterSelector= 
ParamSel;
+
+ZeroMem (, sizeof 
(GetConfigurationParametersResponse));
+
+DataSize = sizeof (GetConfigurationParametersResponse);
+Status   = IpmiGetSolConfigurationParameters (
+ ,
+ ,
+ 
+ );
+
+if (Status == EFI_SUCCESS) {
+  break;
+} else {
+  

[edk2-devel] [edk2-redfish-client][PATCH 3/3] RedfishClientPkg: Utilize RedfishAddendumLib

2023-05-12 Thread Nickle Wang via groups.io
Bios feature driver utilizes RedfishAddendumLib and get additional data
before sending BIOS attributes to Redfish service.

Signed-off-by: Nickle Wang 
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
---
 .../Features/Bios/v1_0_9/Dxe/BiosDxe.inf  |   2 +
 .../Include/RedfishResourceCommon.h   |   2 +
 .../Features/Bios/v1_0_9/Common/BiosCommon.c  | 100 ++
 3 files changed, 104 insertions(+)

diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.inf 
b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.inf
index 8c01a3b8..37346e50 100644
--- a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.inf
+++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.inf
@@ -1,6 +1,7 @@
 ## @file
 #
 #  (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
+#  Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -37,6 +38,7 @@
   RedfishResourceIdentifyLib
   UefiLib
   UefiDriverEntryPoint
+  RedfishAddendumLib
 
 [Protocols]
   gEdkIIRedfishConfigHandlerProtocolGuid  ## PRODUCED
diff --git a/RedfishClientPkg/Include/RedfishResourceCommon.h 
b/RedfishClientPkg/Include/RedfishResourceCommon.h
index c270f92b..b006755d 100644
--- a/RedfishClientPkg/Include/RedfishResourceCommon.h
+++ b/RedfishClientPkg/Include/RedfishResourceCommon.h
@@ -2,6 +2,7 @@
   Redfish feature driver common header file.
 
   (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
+  Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -30,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 //
 // Protocols
diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c 
b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
index 22074559..c7c77a02 100644
--- a/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
+++ b/RedfishClientPkg/Features/Bios/v1_0_9/Common/BiosCommon.c
@@ -2,6 +2,7 @@
   Redfish feature driver implementation - common functions
 
   (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
+  Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -265,6 +266,7 @@ ProvisioningBiosResource (
   )
 {
   CHAR8   *Json;
+  CHAR8   *JsonWithAddendum;
   EFI_STATUS  Status;
   EFI_STRING  NewResourceLocation;
   CHAR8   *EtagStr;
@@ -290,6 +292,38 @@ ProvisioningBiosResource (
 return Status;
   }
 
+  //
+  // Check and see if platform has OEM data or not
+  //
+  Status = RedfishGetOemData (
+ Private->Uri,
+ RESOURCE_SCHEMA,
+ RESOURCE_SCHEMA_VERSION,
+ Json,
+ 
+ );
+  if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) {
+FreePool (Json);
+Json = JsonWithAddendum;
+JsonWithAddendum = NULL;
+  }
+
+  //
+  // Check and see if platform has addendum data or not
+  //
+  Status = RedfishGetAddendumData (
+ Private->Uri,
+ RESOURCE_SCHEMA,
+ RESOURCE_SCHEMA_VERSION,
+ Json,
+ 
+ );
+  if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) {
+FreePool (Json);
+Json = JsonWithAddendum;
+JsonWithAddendum = NULL;
+  }
+
   Status = CreatePayloadToPostResource (Private->RedfishService, 
Private->Payload, Json, , );
   if (EFI_ERROR (Status)) {
 DEBUG ((DEBUG_ERROR, "%a, post Bios resource for %s failed: %r\n", 
__FUNCTION__, ConfigureLang, Status));
@@ -369,6 +403,7 @@ ProvisioningBiosExistResource (
   EFI_STRING  ConfigureLang;
   CHAR8   *EtagStr;
   CHAR8   *Json;
+  CHAR8   *JsonWithAddendum;
 
   if (Private == NULL) {
 return EFI_INVALID_PARAMETER;
@@ -401,6 +436,38 @@ ProvisioningBiosExistResource (
 goto ON_RELEASE;
   }
 
+  //
+  // Check and see if platform has OEM data or not
+  //
+  Status = RedfishGetOemData (
+ Private->Uri,
+ RESOURCE_SCHEMA,
+ RESOURCE_SCHEMA_VERSION,
+ Json,
+ 
+ );
+  if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) {
+FreePool (Json);
+Json = JsonWithAddendum;
+JsonWithAddendum = NULL;
+  }
+
+  //
+  // Check and see if platform has addendum data or not
+  //
+  Status = RedfishGetAddendumData (
+ Private->Uri,
+ RESOURCE_SCHEMA,
+ RESOURCE_SCHEMA_VERSION,
+ Json,
+ 
+ );
+  if (!EFI_ERROR (Status) && (JsonWithAddendum != NULL)) {
+FreePool (Json);
+Json = JsonWithAddendum;
+JsonWithAddendum = NULL;
+  }
+
   DEBUG ((REDFISH_DEBUG_TRACE, "%a, provisioning existing resource for %s\n", 
__FUNCTION__, ConfigureLang));
   //
   // PUT back to instance
@@ -528,6 +595,7 @@ RedfishUpdateResourceCommon (
 {
   EFI_STATUS  Status;
   CHAR8   *Json;
+  CHAR8   

[edk2-devel] [edk2-redfish-client][PATCH 2/3] RedfishClientPkg: Add Redfish Resource Addendum Library

2023-05-12 Thread Nickle Wang via groups.io
Implement RedfishAddendumLib to support Redfish Resource Addendum Protocol.
Feature driver calls this library to get addendum data before providing
data to Redfish service

Signed-off-by: Nickle Wang 
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
---
 RedfishClientPkg/RedfishClientLibs.dsc.inc|   4 +-
 RedfishClientPkg/RedfishClientPkg.dsc |   2 +
 .../RedfishAddendumLib/RedfishAddendumLib.inf |  40 +++
 .../Include/Library/RedfishAddendumLib.h  |  65 +
 .../RedfishAddendumLib/RedfishAddendumLib.c   | 262 ++
 5 files changed, 372 insertions(+), 1 deletion(-)
 create mode 100644 
RedfishClientPkg/Library/RedfishAddendumLib/RedfishAddendumLib.inf
 create mode 100644 RedfishClientPkg/Include/Library/RedfishAddendumLib.h
 create mode 100644 
RedfishClientPkg/Library/RedfishAddendumLib/RedfishAddendumLib.c

diff --git a/RedfishClientPkg/RedfishClientLibs.dsc.inc 
b/RedfishClientPkg/RedfishClientLibs.dsc.inc
index fe0c4b08..5ea38015 100644
--- a/RedfishClientPkg/RedfishClientLibs.dsc.inc
+++ b/RedfishClientPkg/RedfishClientLibs.dsc.inc
@@ -2,10 +2,11 @@
 # Redfish DSC include file for [LibraryClasses*] section of all Architectures.
 #
 # This file can be included to the [LibraryClasses*] section(s) of a platform 
DSC file
-# by using "!include RedfishPkg/RedfisLibs.dsc.inc" to specify the library 
instances
+# by using "!include RedfishPkg/RedfishLibs.dsc.inc" to specify the library 
instances
 # of EDKII network library classes.
 #
 # (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
+# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 #
 #SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -37,3 +38,4 @@
   
EdkIIRedfishResourceConfigLib|RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigLib.inf
   RedfishEventLib|RedfishClientPkg/Library/RedfishEventLib/RedfishEventLib.inf
   
RedfishVersionLib|RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.inf
+  
RedfishAddendumLib|RedfishClientPkg/Library/RedfishAddendumLib/RedfishAddendumLib.inf
diff --git a/RedfishClientPkg/RedfishClientPkg.dsc 
b/RedfishClientPkg/RedfishClientPkg.dsc
index 2b2149cc..d3b645b6 100644
--- a/RedfishClientPkg/RedfishClientPkg.dsc
+++ b/RedfishClientPkg/RedfishClientPkg.dsc
@@ -2,6 +2,7 @@
 # Redfish Client Package
 #
 # (C) Copyright 2021 Hewlett-Packard Enterprise Development LP.
+# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 #
 #SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -49,5 +50,6 @@
 
   
RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf
   RedfishClientPkg/PrivateLibrary/RedfishLib/RedfishLib.inf
+  RedfishClientPkg/Library/RedfishAddendumLib/RedfishAddendumLib.inf
 
   !include RedfishClientPkg/RedfishClient.dsc.inc
diff --git a/RedfishClientPkg/Library/RedfishAddendumLib/RedfishAddendumLib.inf 
b/RedfishClientPkg/Library/RedfishAddendumLib/RedfishAddendumLib.inf
new file mode 100644
index ..1ecfaa69
--- /dev/null
+++ b/RedfishClientPkg/Library/RedfishAddendumLib/RedfishAddendumLib.inf
@@ -0,0 +1,40 @@
+## @file
+#
+#  Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights 
reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010006
+  BASE_NAME  = RedfishAddendumLib
+  FILE_GUID  = 7B227D39-746D-4247-8291-27B0FA79A7AF
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = RedfishAddendumLib| DXE_DRIVER UEFI_DRIVER
+
+#
+#  VALID_ARCHITECTURES   = IA32 X64 EBC
+#
+
+[Sources]
+  RedfishAddendumLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  RedfishPkg/RedfishPkg.dec
+  RedfishClientPkg/RedfishClientPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  DebugLib
+  UefiBootServicesTableLib
+  MemoryAllocationLib
+  UefiLib
+  JsonLib
+
+[Protocols]
+  gEdkIIRedfishResourceAddendumProtocolGuid   ## CONSUMED ##
+
diff --git a/RedfishClientPkg/Include/Library/RedfishAddendumLib.h 
b/RedfishClientPkg/Include/Library/RedfishAddendumLib.h
new file mode 100644
index ..d77347fd
--- /dev/null
+++ b/RedfishClientPkg/Include/Library/RedfishAddendumLib.h
@@ -0,0 +1,65 @@
+/** @file
+  This file defines the Redfish addendum library interface.
+
+  Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights 
reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef REDFISH_ADDENDUM_LIB_H_
+#define REDFISH_ADDENDUM_LIB_H_
+
+#include 
+#include 
+#include 
+
+/**
+  Provide redfish resource with addendum data in given schema.
+
+  @param[in]   Uri  Uri of input resource.
+  @param[in]   Schema   Redfish schema string.
+  @param[in]   Version  Schema version string.
+  @param[in]   JsonText Input resource in JSON format string.
+  @param[out]  JsonWithAddendum The input 

[edk2-devel] [edk2-redfish-client][PATCH 1/3] RedfishClientPkg: Add Redfish Resource Addendum Protocol

2023-05-12 Thread Nickle Wang via groups.io
Introduce Redfish Resource Addendum Protocol to Redfish feature driver.
Feature driver uses this protocol to query OEM resource from platform in
order to support Redfish OEM property. This protocol is also used to get
addendum data that is required by BMC to manage Redfish BIOS service.

Signed-off-by: Nickle Wang 
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
---
 RedfishClientPkg/RedfishClientPkg.dec |  2 +
 .../EdkIIRedfishResourceAddendumProtocol.h| 80 +++
 2 files changed, 82 insertions(+)
 create mode 100644 
RedfishClientPkg/Include/Protocol/EdkIIRedfishResourceAddendumProtocol.h

diff --git a/RedfishClientPkg/RedfishClientPkg.dec 
b/RedfishClientPkg/RedfishClientPkg.dec
index c0ab30ab..84bceca3 100644
--- a/RedfishClientPkg/RedfishClientPkg.dec
+++ b/RedfishClientPkg/RedfishClientPkg.dec
@@ -43,6 +43,8 @@
   gEdkIIRedfishConfigLangMapProtocolGuid= { 0x1d9ba9fe, 0x5d5a, 0x4b66, 
{0x83, 0x5b, 0xe2, 0x5d, 0x13, 0x93, 0x4a, 0x9c } }
   ## Include/Protocol/EdkIIRedfishInterchangeData.h
   gEdkIIRedfishFeatureInterchangeDataProtocolGuid = { 0x4B8FF71C, 0x4A7B, 
0x9478, { 0xB7, 0x81, 0x35, 0x9B, 0x0A, 0xF2, 0x00, 0x91 } }
+  ## Include/Protocol/EdkIIRedfishResourceAddendumProtocol.h
+  gEdkIIRedfishResourceAddendumProtocolGuid = { 0xda36b12b, 0xaad4, 0x4e90, { 
0xba, 0xcb, 0xe3, 0xb5, 0x3b, 0x08, 0xbc, 0x54 } }
 
 [Guids]
   ## Include/Guid/RedfishClientPkgTokenSpace.h
diff --git 
a/RedfishClientPkg/Include/Protocol/EdkIIRedfishResourceAddendumProtocol.h 
b/RedfishClientPkg/Include/Protocol/EdkIIRedfishResourceAddendumProtocol.h
new file mode 100644
index ..fd28aba4
--- /dev/null
+++ b/RedfishClientPkg/Include/Protocol/EdkIIRedfishResourceAddendumProtocol.h
@@ -0,0 +1,80 @@
+/** @file
+  This file defines the EDKII_REDFISH_RESOURCE_ADDENDUM_PROTOCOL interface.
+
+  Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights 
reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef EDKII_REDFISH_RESOURCE_ADDENDUM_PROTOCOL_H_
+#define EDKII_REDFISH_RESOURCE_ADDENDUM_PROTOCOL_H_
+
+#include 
+
+typedef struct _EDKII_REDFISH_RESOURCE_ADDENDUM_PROTOCOL 
EDKII_REDFISH_RESOURCE_ADDENDUM_PROTOCOL;
+
+//
+// The definition of REDFISH_SCHEMA_INFO
+//
+typedef struct {
+  CHAR8*Uri;
+  CHAR8*Schema;
+  CHAR8*Version;
+} REDFISH_RESOURCE_SCHEMA_INFO;
+
+/**
+  Provide redfish resource with addendum data in given schema.
+
+  @param[in]  This Pointer to 
EDKII_REDFISH_RESOURCE_ADDENDUM_PROTOCOL instance.
+  @param[in]  SchemaInfo   Redfish schema information.
+  @param[in,out]  Json On input, this is the Redfish data in given 
Uri in JSON object.
+   On output, This is the Redfish data with 
addendum information
+   which platform would like to add to Redfish 
service.
+
+  @retval EFI_SUCCESS  Addendum data is attached.
+  @retval EFI_UNSUPPORTED  No addendum data is required in given 
schema.
+  @retval Others   Some error happened.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EDKII_REDFISH_RESOURCE_ADDENDUM_PROVISIONING)(
+  IN EDKII_REDFISH_RESOURCE_ADDENDUM_PROTOCOL  *This,
+  IN REDFISH_RESOURCE_SCHEMA_INFO  *SchemaInfo,
+  IN OUT EDKII_JSON_VALUE  Json
+  );
+
+/**
+  Provide redfish OEM resource with given schema information.
+
+  @param[in]   This Pointer to 
EDKII_REDFISH_RESOURCE_ADDENDUM_PROTOCOL instance.
+  @param[in]   SchemaInfo   Redfish schema information.
+  @param[out]  Json This is the Redfish data which is attached to 
OEM object in given
+schema.
+
+  @retval EFI_SUCCESS  OEM data is attached.
+  @retval EFI_UNSUPPORTED  No OEM data is required in given schema.
+  @retval Others   Some error happened.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EDKII_REDFISH_RESOURCE_ADDENDUM_OEM)(
+  IN   EDKII_REDFISH_RESOURCE_ADDENDUM_PROTOCOL  *This,
+  IN   REDFISH_RESOURCE_SCHEMA_INFO  *SchemaInfo,
+  OUT  EDKII_JSON_VALUE  Json
+  );
+
+//
+// The definition of _EDKII_REDFISH_RESOURCE_ADDENDUM_PROTOCOL
+//
+struct _EDKII_REDFISH_RESOURCE_ADDENDUM_PROTOCOL {
+  UINT64  Revision;
+  EDKII_REDFISH_RESOURCE_ADDENDUM_OEM OemCallback;
+  EDKII_REDFISH_RESOURCE_ADDENDUM_PROVISIONINGProvisioningCallback;
+};
+
+extern EFI_GUID  gEdkIIRedfishResourceAddendumProtocolGuid;
+
+#endif
-- 
2.17.1



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




[edk2-devel] [edk2-redfish-client][PATCH 0/3] Introduce resource addendum protocol

2023-05-12 Thread Nickle Wang via groups.io
Introduce EDKII_REDFISH_RESOURCE_ADDENDUM_PROTOCOL to Redfish feature driver.
Feature driver uses this protocol to query OEM resource from platform in
order to support Redfish OEM property. This protocol is also used to get
addendum data that is required by BMC to manage Redfish BIOS service.

Signed-off-by: Nickle Wang 
Cc: Abner Chang 
Cc: Igor Kulchytskyy 

Nickle Wang (3):
  RedfishClientPkg: Add Redfish Resource Addendum Protocol
  RedfishClientPkg: Add Redfish Resource Addendum Library
  RedfishClientPkg: Utilize RedfishAddendumLib

 RedfishClientPkg/RedfishClientPkg.dec |   2 +
 RedfishClientPkg/RedfishClientLibs.dsc.inc|   4 +-
 RedfishClientPkg/RedfishClientPkg.dsc |   2 +
 .../Features/Bios/v1_0_9/Dxe/BiosDxe.inf  |   2 +
 .../RedfishAddendumLib/RedfishAddendumLib.inf |  40 +++
 .../Include/Library/RedfishAddendumLib.h  |  65 +
 .../EdkIIRedfishResourceAddendumProtocol.h|  80 ++
 .../Include/RedfishResourceCommon.h   |   2 +
 .../Features/Bios/v1_0_9/Common/BiosCommon.c  | 100 +++
 .../RedfishAddendumLib/RedfishAddendumLib.c   | 262 ++
 10 files changed, 558 insertions(+), 1 deletion(-)
 create mode 100644 
RedfishClientPkg/Library/RedfishAddendumLib/RedfishAddendumLib.inf
 create mode 100644 RedfishClientPkg/Include/Library/RedfishAddendumLib.h
 create mode 100644 
RedfishClientPkg/Include/Protocol/EdkIIRedfishResourceAddendumProtocol.h
 create mode 100644 
RedfishClientPkg/Library/RedfishAddendumLib/RedfishAddendumLib.c

-- 
2.17.1



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




Re: [edk2-devel] [PATCH v1 0/1] Maintainers.txt: Update reviewers and maintainer for FdtLib

2023-05-12 Thread Chiu, Chasel

Hi Liming,

PR has been updated with all RB: 
https://github.com/tianocore/edk2/pull/4389/commits

Thanks,
Chasel


> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Chiu, Chasel
> Sent: Friday, May 12, 2023 12:11 AM
> To: devel@edk2.groups.io; Gao, Liming ; Guo,
> Gua 
> Cc: 'Andrew Fish' ; 'Leif Lindholm'
> ; Kinney, Michael D 
> Subject: Re: [edk2-devel] [PATCH v1 0/1] Maintainers.txt: Update reviewers and
> maintainer for FdtLib
> 
> 
> Thanks Liming!
> 
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of
> > gaoliming via groups.io
> > Sent: Thursday, May 11, 2023 7:45 PM
> > To: Chiu, Chasel ; devel@edk2.groups.io; Guo,
> > Gua 
> > Cc: 'Andrew Fish' ; 'Leif Lindholm'
> > ; Kinney, Michael D
> > 
> > Subject: 回复: [edk2-devel] [PATCH v1 0/1] Maintainers.txt: Update
> > reviewers and maintainer for FdtLib
> >
> > Chasel:
> >   I agree to merge this change together with code change for this stable 
> > tag.
> >
> > Thanks
> > Liming
> > > -邮件原件-
> > > 发件人: Chiu, Chasel 
> > > 发送时间: 2023年5月12日 10:35
> > > 收件人: devel@edk2.groups.io; Guo, Gua ; Gao,
> Liming
> > > 
> > > 抄送: Andrew Fish ; Leif Lindholm
> > > ; Kinney, Michael D
> > > 
> > > 主题: RE: [edk2-devel] [PATCH v1 0/1] Maintainers.txt: Update
> > > reviewers
> > and
> > > maintainer for FdtLib
> > >
> > >
> > > Hi Liming,
> > >
> > > We are considering this is a missing when merging FdtLib support earlier.
> > > Do we need to wait for Stewards approval for adding maintainers?
> > >
> > > Thanks,
> > > Chasel
> > >
> > >
> > > > -Original Message-
> > > > From: devel@edk2.groups.io  On Behalf Of
> > > > Guo,
> > > Gua
> > > > Sent: Thursday, May 11, 2023 7:31 PM
> > > > To: devel@edk2.groups.io; Gao, Liming 
> > > > Subject: Re: [edk2-devel] [PATCH v1 0/1] Maintainers.txt: Update
> > reviewers
> > > and
> > > > maintainer for FdtLib
> > > >
> > > > Hi Liming,
> > > >
> > > > Do you know whether for code freeze also include Maintainers.txt
> > > > update
> > ?
> > > > Or maybe we can submit it once the change approve.
> > > >
> > > > Thanks,
> > > > Gua
> > > > -Original Message-
> > > > From: Guo, Gua 
> > > > Sent: Friday, May 12, 2023 10:11 AM
> > > > To: devel@edk2.groups.io
> > > > Cc: Guo, Gua 
> > > > Subject: [PATCH v1 0/1] Maintainers.txt: Update reviewers and
> > > > maintainer
> > > for
> > > > FdtLib
> > > >
> > > > From: Gua Guo 
> > > >
> > > > V1
> > > >   PR: https://github.com/tianocore/edk2/pull/4389
> > > >   Maintainer: Benny Lin 
> > > >   Reviewer: Gua Guo 
> > > >   Reviewer: Chasel Chiu 
> > > >   Reviewer: James Lu 
> > > >
> > > > Gua Guo (1):
> > > >   Maintainers.txt: Update reviewers and maintainers for FdtLib. Update
> > > > reviewers and maintainers for FdtLib.
> > > >
> > > >  Maintainers.txt | 8 
> > > >  1 file changed, 8 insertions(+)
> > > >
> > > > --
> > > > 2.39.2.windows.1
> > > >
> > > >
> > > >
> > > >
> > > >
> >
> >
> >
> >
> >
> >
> >
> 
> 
> 
> 
> 



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




Re: [edk2-devel] [PATCH v1 0/1] Maintainers.txt: Update reviewers and maintainer for FdtLib

2023-05-12 Thread Chiu, Chasel

Thanks Liming!

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of gaoliming
> via groups.io
> Sent: Thursday, May 11, 2023 7:45 PM
> To: Chiu, Chasel ; devel@edk2.groups.io; Guo, Gua
> 
> Cc: 'Andrew Fish' ; 'Leif Lindholm'
> ; Kinney, Michael D 
> Subject: 回复: [edk2-devel] [PATCH v1 0/1] Maintainers.txt: Update reviewers
> and maintainer for FdtLib
> 
> Chasel:
>   I agree to merge this change together with code change for this stable tag.
> 
> Thanks
> Liming
> > -邮件原件-
> > 发件人: Chiu, Chasel 
> > 发送时间: 2023年5月12日 10:35
> > 收件人: devel@edk2.groups.io; Guo, Gua ; Gao, Liming
> > 
> > 抄送: Andrew Fish ; Leif Lindholm
> > ; Kinney, Michael D
> > 
> > 主题: RE: [edk2-devel] [PATCH v1 0/1] Maintainers.txt: Update reviewers
> and
> > maintainer for FdtLib
> >
> >
> > Hi Liming,
> >
> > We are considering this is a missing when merging FdtLib support earlier.
> > Do we need to wait for Stewards approval for adding maintainers?
> >
> > Thanks,
> > Chasel
> >
> >
> > > -Original Message-
> > > From: devel@edk2.groups.io  On Behalf Of Guo,
> > Gua
> > > Sent: Thursday, May 11, 2023 7:31 PM
> > > To: devel@edk2.groups.io; Gao, Liming 
> > > Subject: Re: [edk2-devel] [PATCH v1 0/1] Maintainers.txt: Update
> reviewers
> > and
> > > maintainer for FdtLib
> > >
> > > Hi Liming,
> > >
> > > Do you know whether for code freeze also include Maintainers.txt
> > > update
> ?
> > > Or maybe we can submit it once the change approve.
> > >
> > > Thanks,
> > > Gua
> > > -Original Message-
> > > From: Guo, Gua 
> > > Sent: Friday, May 12, 2023 10:11 AM
> > > To: devel@edk2.groups.io
> > > Cc: Guo, Gua 
> > > Subject: [PATCH v1 0/1] Maintainers.txt: Update reviewers and
> > > maintainer
> > for
> > > FdtLib
> > >
> > > From: Gua Guo 
> > >
> > > V1
> > >   PR: https://github.com/tianocore/edk2/pull/4389
> > >   Maintainer: Benny Lin 
> > >   Reviewer: Gua Guo 
> > >   Reviewer: Chasel Chiu 
> > >   Reviewer: James Lu 
> > >
> > > Gua Guo (1):
> > >   Maintainers.txt: Update reviewers and maintainers for FdtLib. Update
> > > reviewers and maintainers for FdtLib.
> > >
> > >  Maintainers.txt | 8 
> > >  1 file changed, 8 insertions(+)
> > >
> > > --
> > > 2.39.2.windows.1
> > >
> > >
> > >
> > >
> > >
> 
> 
> 
> 
> 
> 
> 



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




Re: [edk2-devel] 回复: [PATCH] BaseTools/tools_def: Drop ref to undefined CLANGDWARF_ARM_PREFIX

2023-05-12 Thread Ard Biesheuvel
On Fri, 12 May 2023 at 03:43, gaoliming via groups.io
 wrote:
>
> Ard:
>   This change is good to me.  Reviewed-by: Liming Gao
> 
>
>   Will it be merged for this stable tag?
>

Yes I will merge it today.

Thanks,

> > -邮件原件-
> > 发件人: Ard Biesheuvel 
> > 发送时间: 2023年5月11日 15:00
> > 收件人: devel@edk2.groups.io
> > 抄送: Ard Biesheuvel ; Rebecca Cran
> > ; Liming Gao 
> > 主题: [PATCH] BaseTools/tools_def: Drop ref to undefined
> > CLANGDWARF_ARM_PREFIX
> >
> > When using CLANGDWARF to build for the ARM architecture, objcopy is
> >
> > references via the wrong environment variable, resulting in the wrong
> >
> > llvm-objcopy to be used (if one exists), or the build to fail (if
> >
> > CLANGDWARF_BIN points to the only available instance)
> >
> >
> >
> > So use CLANGDWARF_BIN instead, which was what was intended.
> >
> >
> >
> > Cc: Rebecca Cran 
> >
> > Cc: Liming Gao 
> >
> > Fixes: ecbc394365f50f3c ("BaseTools: Set CLANGDWARF RC path ...")
> >
> > Signed-off-by: Ard Biesheuvel 
> >
> > ---
> >
> >  BaseTools/Conf/tools_def.template | 2 +-
> >
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> >
> >
> > diff --git a/BaseTools/Conf/tools_def.template
> > b/BaseTools/Conf/tools_def.template
> >
> > index 4ae21b85a8571f93..503a6687c1f03f56 100755
> >
> > --- a/BaseTools/Conf/tools_def.template
> >
> > +++ b/BaseTools/Conf/tools_def.template
> >
> > @@ -1957,7 +1957,7 @@ DEFINE CLANGDWARF_ARM_DLINK_FLAGS   =
> > DEF(CLANGDWARF_ARM_TARGET) DEF(GCC_ARM_DLI
> >
> >  *_CLANGDWARF_ARM_ASLDLINK_PATH  =
> > ENV(CLANGDWARF_BIN)clang
> >
> >
> >
> >
> >
> >  *_CLANGDWARF_ARM_SLINK_PATH =
> > ENV(CLANGDWARF_BIN)llvm-ar
> >
> >
> > -*_CLANGDWARF_ARM_RC_PATH=
> > ENV(CLANGDWARF_ARM_PREFIX)llvm-objcopy
> >
> >
> > +*_CLANGDWARF_ARM_RC_PATH=
> > ENV(CLANGDWARF_BIN)llvm-objcopy
> >
> >
> >
> >
> >
> >  *_CLANGDWARF_ARM_ASLCC_FLAGS= DEF(GCC_ASLCC_FLAGS)
> > -fno-lto
> >
> >
> >  *_CLANGDWARF_ARM_ASLDLINK_FLAGS =
> > DEF(CLANGDWARF_ARM_TARGET) DEF(GCC_ARM_ASLDLINK_FLAGS)
> >
> >
> > --
> >
> > 2.39.2
> >
> >
>
>
>
>
>
> 
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104769): https://edk2.groups.io/g/devel/message/104769
Mute This Topic: https://groups.io/mt/98841231/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 3/5] MdeModulePkg/DxeIpl: Align Page table Level setting with previous level.

2023-05-12 Thread Ni, Ray
> +  //
> +  // Check cpu runs in 64bit long mode or 32bit protected mode.
1. this comment seems to be redundant.

> +  //
> +  if (sizeof (UINTN) == sizeof (UINT64)) {
> +//
> +// If cpu has already runned in 64bit long mode PEI, Page table Level in 
> DXE
> must align with previous level.
2. runned -> run

> +//
> +Cr4.UintN = AsmReadCr4 ();
> +Page5LevelSupport = Cr4.Bits.LA57 ? TRUE : FALSE;

3. "Cr4.Bits.LA57 != 0"

> +ASSERT (PcdGetBool (PcdUse5LevelPageTable) == Page5LevelSupport);

4. Good check!




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




Re: [edk2-devel] [PATCH] BaseTools/tools_def: Disable overzealous unused variable warning on Clang

2023-05-12 Thread Ard Biesheuvel
Liming:

I'd like to merge this one for the stable tag - any objections?


On Thu, 11 May 2023 at 06:55, Gerd Hoffmann  wrote:
>
> On Wed, May 10, 2023 at 04:50:08PM +0200, Ard Biesheuvel wrote:
> > The warnings Clang emits when enabling -Wunneeded-internal-declaration
> > (which is part of -Wall) are generating false positives for variables
> > whose size gets taken but are not referenced beyond that.
> >
> > This may happen legitimately in debug code, so let's disable this
> > warning for Clang, rather than tiptoe around it in the code base.
> >
> > This fixes the RELEASE build for OVMF, which triggers this issue in the
> > newly added VirtioSerialDxe driver.
> >
> > Cc: Rebecca Cran 
> > Cc: Gerd Hoffmann 
> > Cc: Liming Gao 
> > Signed-off-by: Ard Biesheuvel 
>
> Acked-by: Gerd Hoffmann 
>
>
>
> 
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104767): https://edk2.groups.io/g/devel/message/104767
Mute This Topic: https://groups.io/mt/98807494/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 2/5] UefiCpuPkg/CpuMpPei: Enable PAE page table if CR0.PG is not set

2023-05-12 Thread Ni, Ray
1. can you please change the commit title as "UefiCpuPkg/CpuMpPei: 
Conditionally enable PAE paging in 32bit mode"?

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Wu, Jiaxin
> Sent: Friday, May 12, 2023 12:16 PM
> To: devel@edk2.groups.io
> Cc: Dong, Eric ; Ni, Ray ; Zeng, Star
> ; Gerd Hoffmann ; Kumar, Rahul R
> 
> Subject: [edk2-devel] [PATCH v2 2/5] UefiCpuPkg/CpuMpPei: Enable PAE page
> table if CR0.PG is not set
> 
> Some security features depends on the page table enabling. So, This patch
> is to enable the page table if page table has not been enabled during the
> transition from Temporary RAM to Permanent RAM.

2. No need to emphasize paging is not enabled during temp-ram to permanent-ram 
migration.
We can just say "Some security features depend on the page table enabling. So, 
This patch
is to enable paging if it is not enabled (32bit mode)"

3. following commit message might not be needed.

> 
> Note: If page table is not enabled before this point, which means the system
> IA-32e Mode is not activated. Because on Intel 64 processors, IA-32e Mode
> operation requires physical address extensions with 4 or 5 levels of enhanced
> paging structures (see Section 4.5, "4 - Level Paging and 5 -Level Paging"
> and Section 9.8, "Initializing IA-32e Mode"). So, just enable PAE page table
> if CR0.PG is not set.
> 

> -UINTN
> -CreatePageTable (
> +EFI_STATUS
> +EnablePaePageTable (
>VOID
>)
>  {
> -  RETURN_STATUS Status;
> -  UINTN PhysicalAddressBits;
> -  UINTN NumberOfEntries;
> -  PAGE_ATTRIBUTETopLevelPageAttr;
> -  UINTN PageTable;
> -  PAGE_ATTRIBUTEMaxMemoryPage;
> -  UINTN Index;
> -  UINT64AddressEncMask;
> -  UINT64*PageEntry;
> -  EFI_PHYSICAL_ADDRESS  PhysicalAddress;
> -
> -  TopLevelPageAttr= (PAGE_ATTRIBUTE)GetPageTableTopLevelType ();
> -  PhysicalAddressBits = GetPhysicalAddressWidth ();
> -  NumberOfEntries = (UINTN)1 << (PhysicalAddressBits -
> - 
> mPageAttributeTable[TopLevelPageAttr].AddressBitOffset);
> +  EFI_STATUS   Status;
> +  PAGING_MODE  PagingMode;
> +
> +  UINTN   PageTable;
> +  VOID*Buffer;
> +  UINTN   BufferSize;
> +  IA32_MAP_ATTRIBUTE  MapAttribute;
> +  IA32_MAP_ATTRIBUTE  MapMask;
> +
> +  PagingMode  = PagingPae;

4. No need of local variable PagingMode.

> +  PageTable   = 0;
> +  Buffer  = NULL;
> +  BufferSize  = 0;
> +  MapAttribute.Uint64 = 0;
> +  MapMask.Uint64  = MAX_UINT64;
> +  MapAttribute.Bits.Present   = 1;
> +  MapAttribute.Bits.ReadWrite = 1;
> 
> -  PageTable = (UINTN)AllocatePageTableMemory (1);
> -  if (PageTable == 0) {
> -return 0;
> +  //
> +  // Get required buffer size for the pagetable that will be created.
> +  // The Max size of LinearAddress for PAE is 2^32.

5. Let's say "1:1 map 4GB in 32bit mode." Because people might say "PAE can 
support up to 2^36 address, why 2^32 here".

> +  // Create PageTable in permanent memory.
> +  // The Max size of LinearAddress for PAE is 2^32.

6. above comments seem to be redundant.

>EFI_PEI_HOB_POINTERSHob;
> +  IA32_CR0Cr0;
> 
>//
>// Paging must be setup first. Otherwise the exception TSS setup during MP
>// initialization later will not contain paging information and then fail
>// the task switch (for the sake of stack switch).
> @@ -635,12 +575,29 @@ MemoryDiscoveredPpiNotifyCallback (
>if (IsIa32PaeSupported ()) {
>  Hob.Raw= GetFirstGuidHob ();
>  InitStackGuard = PcdGetBool (PcdCpuStackGuard);
>}
> 
> -  if (InitStackGuard || (Hob.Raw != NULL)) {
> -EnablePaging ();
> +  //
> +  // Some security features depends on the page table enabling. So, here
> +  // is to enable the page table if page table has not been enabled yet.
> +  // If page table is not enabled before this point, which means the system
> +  // IA-32e Mode is not activated. Because on Intel 64 processors, IA-32e 
> Mode
> +  // operation requires physical address extensions with 4 or 5 levels of
> +  // enhanced paging structures (see Section 4.5, "4 - Level Paging and 5 -
> +  // Level Paging" and Section 9.8, "Initializing IA-32e Mode"). So, just
> +  // enable PAE page table if CR0.PG is not set.

7. Maybe simply say " Some security features depend on the page table enabling. 
So, here
is to enable paging if it is not enabled (only in 32bit mode)"

> +  //
> +  Cr0.UintN = AsmReadCr0 ();
> +  if ((Cr0.Bits.PG == 0) && (InitStackGuard || (Hob.Raw != NULL))) {
> +ASSERT (sizeof (UINTN) == sizeof (UINT32));
> +
> +Status = EnablePaePageTable ();
> +if (EFI_ERROR (Status)) {
> +  DEBUG ((DEBUG_WARN, "MemoryDiscoveredPpiNotifyCallback: Failed to
> enable PAE page table: %r.\n", Status));
> +  ASSERT_EFI_ERROR (Status);


[edk2-devel] [edk2-redfish-client][PATCH] RedfishClientPkg/ConverterLib: Fix empty string value issue

2023-05-12 Thread Nickle Wang via groups.io
allocateDuplicateStr() will not copy input string when input
string is empty string. It returns NULL pointer and creates
assertion in application driver.

Signed-off-by: Nickle Wang 
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
---
 RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c 
b/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
index 964904a2..02fcb2b2 100644
--- a/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
+++ b/RedfishClientPkg/ConverterLib/src/RedfishCsCommon.c
@@ -223,7 +223,7 @@ allocateDuplicateStr (
 {
   RedfishCS_status  Status;
 
-  if ((Str == NULL) || (strlen (Str) == 0)) {
+  if (Str == NULL) {
 *DstBuffer = NULL;
 return RedfishCS_status_success;
   }
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104765): https://edk2.groups.io/g/devel/message/104765
Mute This Topic: https://groups.io/mt/98844375/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/5] UefiCpuPkg/SecCore: Migrate page table to permanent memory

2023-05-12 Thread Ni, Ray



> -Original Message-
> From: Wu, Jiaxin 
> Sent: Friday, May 12, 2023 12:16 PM
> To: devel@edk2.groups.io
> Cc: Dong, Eric ; Ni, Ray ; Zeng, Star
> ; Gerd Hoffmann ; Kumar, Rahul R
> 
> Subject: [PATCH v2 1/5] UefiCpuPkg/SecCore: Migrate page table to permanent
> memory
> 
> Background:
> For arch X64, system will enable the page table in SPI to cover 0-512G range
> via CR4.PAE & MSR.LME & CR0.PG & CR3 setting (see ResetVector code).
> Existing
> code doesn't cover the higher address access above 512G before memory-
> discovered
> callback. That will be potential problem if system access the higher address
> after the transition from temporary RAM to permanent MEM RAM.
> 
> Solution:
> This patch is to migrate page table to permanent memory to map entire physical
> address space if CR0.PG is set during temporary RAM Done.
> 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Zeng Star 
> Cc: Gerd Hoffmann 
> Cc: Rahul Kumar 
> Signed-off-by: Jiaxin Wu 
> ---
>  UefiCpuPkg/SecCore/SecCore.inf   |   1 +
>  UefiCpuPkg/SecCore/SecCoreNative.inf |   1 +
>  UefiCpuPkg/SecCore/SecMain.c | 152
> +++
>  UefiCpuPkg/SecCore/SecMain.h |   4 +
>  4 files changed, 158 insertions(+)
> 
> diff --git a/UefiCpuPkg/SecCore/SecCore.inf b/UefiCpuPkg/SecCore/SecCore.inf
> index 3758aded3b..cab69b8b97 100644
> --- a/UefiCpuPkg/SecCore/SecCore.inf
> +++ b/UefiCpuPkg/SecCore/SecCore.inf
> @@ -53,10 +53,11 @@
>CpuExceptionHandlerLib
>ReportStatusCodeLib
>PeiServicesLib
>PeiServicesTablePointerLib
>HobLib
> +  CpuPageTableLib
> 
>  [Ppis]
>## SOMETIMES_CONSUMES
>## PRODUCES
>gEfiSecPlatformInformationPpiGuid
> diff --git a/UefiCpuPkg/SecCore/SecCoreNative.inf
> b/UefiCpuPkg/SecCore/SecCoreNative.inf
> index 1ee6ff7d88..fa241cca94 100644
> --- a/UefiCpuPkg/SecCore/SecCoreNative.inf
> +++ b/UefiCpuPkg/SecCore/SecCoreNative.inf
> @@ -50,10 +50,11 @@
>CpuExceptionHandlerLib
>ReportStatusCodeLib
>PeiServicesLib
>PeiServicesTablePointerLib
>HobLib
> +  CpuPageTableLib
> 
>  [Ppis]
>## SOMETIMES_CONSUMES
>## PRODUCES
>gEfiSecPlatformInformationPpiGuid
> diff --git a/UefiCpuPkg/SecCore/SecMain.c b/UefiCpuPkg/SecCore/SecMain.c
> index 95375850ec..8ec0b654fb 100644
> --- a/UefiCpuPkg/SecCore/SecMain.c
> +++ b/UefiCpuPkg/SecCore/SecMain.c
> @@ -70,10 +70,139 @@ MigrateGdt (
>AsmWriteGdtr ();
> 
>return EFI_SUCCESS;
>  }
> 
> +/**
> +  Migrate page table to permanent memory mapping entire physical address
> space.
> +
> +  @retval   EFI_SUCCESS   The PageTable was migrated successfully.
> +  @retval   EFI_UNSUPPORTED   Unsupport to migrate page table to
> permanent memory if IA-32e Mode not actived.
> +  @retval   EFI_OUT_OF_RESOURCES  The PageTable could not be migrated due
> to lack of available memory.
> +
> +**/
> +EFI_STATUS
> +MigratePageTable (
> +  VOID
> +  )
> +{
> +  EFI_STATUS  Status;
> +  IA32_CR4Cr4;
> +  BOOLEAN Page5LevelSupport;
> +  UINT32  RegEax;
> +  CPUID_EXTENDED_CPU_SIG_EDX  RegEdx;
> +  BOOLEAN Page1GSupport;
> +  PAGING_MODE PagingMode;
> +  CPUID_VIR_PHY_ADDRESS_SIZE_EAX  VirPhyAddressSize;
> +  UINT32  MaxExtendedFunctionId;
> +  UINTN   PageTable;
> +  EFI_PHYSICAL_ADDRESSBuffer;
> +  UINTN   BufferSize;
> +  IA32_MAP_ATTRIBUTE  MapAttribute;
> +  IA32_MAP_ATTRIBUTE  MapMask;
> +
> +  VirPhyAddressSize.Uint32= 0;
> +  PageTable   = 0;
> +  BufferSize  = 0;
> +  MapAttribute.Uint64 = 0;
> +  MapMask.Uint64  = MAX_UINT64;
> +  MapAttribute.Bits.Present   = 1;
> +  MapAttribute.Bits.ReadWrite = 1;
> +
> +  //
> +  // Check Page5Level Support or not.
> +  //
> +  Cr4.UintN = AsmReadCr4 ();
> +  Page5LevelSupport = (Cr4.Bits.LA57 ? TRUE : FALSE);

1. "Cr4.Bits.LA57 != 0", to be consistent with other code in your patch.

> +
> +  //
> +  // Check Page1G Support or not.
> +  //
> +  Page1GSupport = FALSE;
> +  AsmCpuid (CPUID_EXTENDED_FUNCTION, , NULL, NULL, NULL);
> +  if (RegEax >= CPUID_EXTENDED_CPU_SIG) {
> +AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL,
> &(RegEdx.Uint32));

2.  No need for the bracket.

> +if ((RegEdx.Bits.Page1GB) != 0) {
3. No need for the bracket.

> +  //
> +  Cr0.UintN = AsmReadCr0 ();
> +  if (Cr0.Bits.PG != 0) {
> +//
> +// CR4.PAE must be enabled.
> +//
> +ASSERT ((AsmReadCr4 () & BIT5) != 0);

4. No need to check PAE bit because 64bit long mode should set PAE bit.

> +
> +//
> +// Assume CPU runs in 64bit mode if paging is enabled.
> +//
> +ASSERT (sizeof (UINTN) == sizeof (UINT64));
> +
> +Status = MigratePageTable ();
> +if (EFI_ERROR (Status)) {
> +  DEBUG ((DEBUG_WARN, "SecTemporaryRamDone: