[edk2-devel] [PATCH v2 5/5] UefiPayloadPkg: Add CpuPageTableLib required by SecCore & CpuMpPei

2023-05-11 Thread Wu, Jiaxin
Add CpuPageTableLib required by SecCore & CpuMpPei in UefiPayloadPkg.

Cc: Guo Dong 
Cc: Sean Rhodes 
Cc: James Lu 
Cc: Gua Guo 
Cc: Ray Ni 
Cc: Zeng Star 
Signed-off-by: Jiaxin Wu 
---
 UefiPayloadPkg/UefiPayloadPkg.dsc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc 
b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 998d222909..615c5b4c6d 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -240,10 +240,11 @@
   # CPU
   #
   MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
   LocalApicLib|UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf
   MicrocodeLib|UefiCpuPkg/Library/MicrocodeLib/MicrocodeLib.inf
+  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
 
   #
   # Platform
   #
 !if $(CPU_TIMER_LIB_ENABLE) == TRUE && $(UNIVERSAL_PAYLOAD) == TRUE
@@ -343,11 +344,10 @@
   
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
 !if $(SOURCE_DEBUG_ENABLE)
   DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
 !endif
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
-  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
   MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
 !if $(PERFORMANCE_MEASUREMENT_ENABLE)
   PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
 !endif
 
-- 
2.16.2.windows.1



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




[edk2-devel] [PATCH v2 4/5] OvmfPkg: Add CpuPageTableLib required by SecCore & CpuMpPei

2023-05-11 Thread Wu, Jiaxin
Add CpuPageTableLib required by SecCore & CpuMpPei in OvmfPkg.

Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Gerd Hoffmann 
Cc: Ray Ni 
Cc: Zeng Star 
Signed-off-by: Jiaxin Wu 
---
 OvmfPkg/AmdSev/AmdSevX64.dsc | 2 +-
 OvmfPkg/CloudHv/CloudHvX64.dsc   | 2 +-
 OvmfPkg/IntelTdx/IntelTdxX64.dsc | 3 +--
 OvmfPkg/Microvm/MicrovmX64.dsc   | 2 +-
 OvmfPkg/OvmfPkgIa32.dsc  | 1 +
 OvmfPkg/OvmfPkgIa32X64.dsc   | 2 +-
 OvmfPkg/OvmfPkgX64.dsc   | 3 +--
 OvmfPkg/OvmfXen.dsc  | 2 +-
 8 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc
index b32049194d..dfcef0efca 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.dsc
+++ b/OvmfPkg/AmdSev/AmdSevX64.dsc
@@ -145,10 +145,11 @@
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf
   
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
   SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf
   MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
   MicrocodeLib|UefiCpuPkg/Library/MicrocodeLib/MicrocodeLib.inf
+  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
   UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
   
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
   
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
   
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
   
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
@@ -347,11 +348,10 @@
   LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf
 !if $(SOURCE_DEBUG_ENABLE) == TRUE
   DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
 !endif
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
-  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
   MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
   
NestedInterruptTplLib|OvmfPkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf
   QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf
   
QemuLoadImageLib|OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.inf
 
diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc
index 2a1139daaa..d4f86f8b71 100644
--- a/OvmfPkg/CloudHv/CloudHvX64.dsc
+++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
@@ -162,10 +162,11 @@
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf
   
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
   SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf
   MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
   MicrocodeLib|UefiCpuPkg/Library/MicrocodeLib/MicrocodeLib.inf
+  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
   UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
   
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
   
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
   
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
   
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
@@ -388,11 +389,10 @@
 !endif
 !if $(SOURCE_DEBUG_ENABLE) == TRUE
   DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
 !endif
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
-  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
   MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
   
NestedInterruptTplLib|OvmfPkg/Library/NestedInterruptTplLib/NestedInterruptTplLib.inf
   QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf
   QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf
 
diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
index d4403f11a7..0c21a713fc 100644
--- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc
+++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
@@ -149,10 +149,11 @@
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf
   
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
   SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf
   MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
   MicrocodeLib|UefiCpuPkg/Library/MicrocodeLib/MicrocodeLib.inf
+  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
   UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
   
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
   
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
   
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
   

[edk2-devel] [PATCH v2 3/5] MdeModulePkg/DxeIpl: Align Page table Level setting with previous level.

2023-05-11 Thread Wu, Jiaxin
System paging 5 level enabled or not can be checked via CR4.LA57, system
preferred Page table Level (PcdUse5LevelPageTable) must align with previous
level for 64bit long mode.

This patch is to do the wise check:
If cpu has already runned in 64bit long mode PEI, Page table Level in DXE
must align with previous level.
If cpu runs in 32bit protected mode PEI, Page table Level in DXE is decided
by PCD and feature capability.

Cc: Dandan Bi 
Cc: Liming Gao 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Zeng Star 
Cc: Gerd Hoffmann 
Cc: Rahul Kumar 
Signed-off-by: Jiaxin Wu 
---
 MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 39 
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c 
b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
index 18b121d768..a8e46eacc3 100644
--- a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
+++ b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c
@@ -737,22 +737,37 @@ CreateIdentityMappingPageTables (
 } else {
   PhysicalAddressBits = 36;
 }
   }
 
-  Page5LevelSupport = FALSE;
-  if (PcdGetBool (PcdUse5LevelPageTable)) {
-AsmCpuidEx (
-  CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS,
-  CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO,
-  NULL,
-  NULL,
-  ,
-  NULL
-  );
-if (EcxFlags.Bits.FiveLevelPage != 0) {
-  Page5LevelSupport = TRUE;
+  //
+  // Check cpu runs in 64bit long mode or 32bit protected mode.
+  //
+  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.
+//
+Cr4.UintN = AsmReadCr4 ();
+Page5LevelSupport = Cr4.Bits.LA57 ? TRUE : FALSE;
+ASSERT (PcdGetBool (PcdUse5LevelPageTable) == Page5LevelSupport);
+  } else {
+//
+// If cpu runs in 32bit protected mode PEI, Page table Level in DXE is 
decided by PCD and feature capability.
+//
+Page5LevelSupport = FALSE;
+if (PcdGetBool (PcdUse5LevelPageTable)) {
+  AsmCpuidEx (
+CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS,
+CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO,
+NULL,
+NULL,
+,
+NULL
+);
+  if (EcxFlags.Bits.FiveLevelPage != 0) {
+Page5LevelSupport = TRUE;
+  }
 }
   }
 
   DEBUG ((DEBUG_INFO, "AddressBits=%u 5LevelPaging=%u 1GPage=%u\n", 
PhysicalAddressBits, Page5LevelSupport, Page1GSupport));
 
-- 
2.16.2.windows.1



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




[edk2-devel] [PATCH v2 2/5] UefiCpuPkg/CpuMpPei: Enable PAE page table if CR0.PG is not set

2023-05-11 Thread Wu, Jiaxin
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.

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.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Zeng Star 
Cc: Gerd Hoffmann 
Cc: Rahul Kumar 
Signed-off-by: Jiaxin Wu 
---
 UefiCpuPkg/CpuMpPei/CpuMpPei.h   |   1 +
 UefiCpuPkg/CpuMpPei/CpuMpPei.inf |   1 +
 UefiCpuPkg/CpuMpPei/CpuPaging.c  | 215 ---
 3 files changed, 88 insertions(+), 129 deletions(-)

diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
index 0649c48d14..1b9a94e18f 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.h
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
@@ -26,10 +26,11 @@
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 extern EFI_PEI_PPI_DESCRIPTOR  mPeiCpuMpPpiDesc;
 
 /**
   This service retrieves the number of logical processor in the platform
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
index 7444bdb968..865be5627e 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
@@ -44,10 +44,11 @@
   CpuExceptionHandlerLib
   MpInitLib
   BaseMemoryLib
   CpuLib
   MemoryAllocationLib
+  CpuPageTableLib
 
 [Guids]
   gEdkiiMigratedFvInfoGuid ## 
SOMETIMES_CONSUMES ## HOB
 
 [Ppis]
diff --git a/UefiCpuPkg/CpuMpPei/CpuPaging.c b/UefiCpuPkg/CpuMpPei/CpuPaging.c
index a471f089c8..b282e1cf14 100644
--- a/UefiCpuPkg/CpuMpPei/CpuPaging.c
+++ b/UefiCpuPkg/CpuMpPei/CpuPaging.c
@@ -115,42 +115,10 @@ AllocatePageTableMemory (
   }
 
   return Address;
 }
 
-/**
-  Get the address width supported by current processor.
-
-  @retval 32  If processor is in 32-bit mode.
-  @retval 36-48   If processor is in 64-bit mode.
-
-**/
-UINTN
-GetPhysicalAddressWidth (
-  VOID
-  )
-{
-  UINT32  RegEax;
-
-  if (sizeof (UINTN) == 4) {
-return 32;
-  }
-
-  AsmCpuid (CPUID_EXTENDED_FUNCTION, , NULL, NULL, NULL);
-  if (RegEax >= CPUID_VIR_PHY_ADDRESS_SIZE) {
-AsmCpuid (CPUID_VIR_PHY_ADDRESS_SIZE, , NULL, NULL, NULL);
-RegEax &= 0xFF;
-if (RegEax > 48) {
-  return 48;
-}
-
-return (UINTN)RegEax;
-  }
-
-  return 36;
-}
-
 /**
   Get the type of top level page table.
 
   @retval Page512G  PML4 paging.
   @retval Page1GPAE paging.
@@ -381,120 +349,91 @@ ConvertMemoryPageAttributes (
 
   return RETURN_SUCCESS;
 }
 
 /**
-  Get maximum size of page memory supported by current processor.
-
-  @param[in]   TopLevelType The type of top level page entry.
+  Enable PAE Page Table.
 
-  @retval Page1G If processor supports 1G page and PML4.
-  @retval Page2M For all other situations.
+  @retval   EFI_SUCCESS   The PAE Page Table was enabled successfully.
+  @retval   EFI_OUT_OF_RESOURCES  The PAE Page Table could not be enabled due 
to lack of available memory.
 
 **/
-PAGE_ATTRIBUTE
-GetMaxMemoryPage (
-  IN  PAGE_ATTRIBUTE  TopLevelType
-  )
-{
-  UINT32  RegEax;
-  UINT32  RegEdx;
-
-  if (TopLevelType == Page512G) {
-AsmCpuid (CPUID_EXTENDED_FUNCTION, , NULL, NULL, NULL);
-if (RegEax >= CPUID_EXTENDED_CPU_SIG) {
-  AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, );
-  if ((RegEdx & BIT26) != 0) {
-return Page1G;
-  }
-}
-  }
-
-  return Page2M;
-}
-
-/**
-  Create PML4 or PAE page table.
-
-  @return The address of page table.
-
-**/
-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;
+  PageTable   = 0;
+  Buffer  = NULL;
+  BufferSize  = 0;
+  MapAttribute.Uint64 = 

[edk2-devel] [PATCH v2 1/5] UefiCpuPkg/SecCore: Migrate page table to permanent memory

2023-05-11 Thread Wu, Jiaxin
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);
+
+  //
+  // 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));
+if ((RegEdx.Bits.Page1GB) != 0) {
+  Page1GSupport = TRUE;
+}
+  }
+
+  //
+  // Decide Paging Mode according Page5LevelSupport & Page1GSupport.
+  //
+  if (Page5LevelSupport) {
+PagingMode = Page1GSupport ? Paging5Level1GB : Paging5Level;
+  } else {
+PagingMode = Page1GSupport ? Paging4Level1GB : Paging4Level;
+  }
+
+  //
+  // Get Maximum Physical Address Bits
+  // Get the number of address lines; Maximum Physical Address is 
2^PhysicalAddressBits - 1.
+  // If CPUID does not supported, then use a max value of 36 as per SDM 3A, 
4.1.4.
+  //
+  AsmCpuid (CPUID_EXTENDED_FUNCTION, , NULL, NULL, NULL);
+  if (MaxExtendedFunctionId >= CPUID_VIR_PHY_ADDRESS_SIZE) {
+AsmCpuid (CPUID_VIR_PHY_ADDRESS_SIZE, , NULL, 
NULL, NULL);
+  } else {
+VirPhyAddressSize.Bits.PhysicalAddressBits = 36;
+  }
+
+  if ((PagingMode == Paging4Level1GB) || (PagingMode == Paging4Level)) {
+//
+// The max lineaddress bits is 48 for 4 level page table.
+//
+VirPhyAddressSize.Bits.PhysicalAddressBits = MIN 
(VirPhyAddressSize.Bits.PhysicalAddressBits, 48);
+  }
+
+  //
+  // Get required buffer size for the pagetable that will be created.
+  //
+  Status = PageTableMap 

[edk2-devel] [PATCH v2 0/5] Target to enable paging from temporary RAM Done

2023-05-11 Thread Wu, Jiaxin
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. Existing code doesn't
cover the higher address access above 512G before memory-discovered
callback. This series patches provide the solution to enable paging from
temporary RAM Done.

Jiaxin Wu (5):
  UefiCpuPkg/SecCore: Migrate page table to permanent memory
  UefiCpuPkg/CpuMpPei: Enable PAE page table if CR0.PG is not set
  MdeModulePkg/DxeIpl: Align Page table Level setting with previous
level.
  OvmfPkg: Add CpuPageTableLib required by SecCore & CpuMpPei
  UefiPayloadPkg: Add CpuPageTableLib required by SecCore & CpuMpPei

 MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c |  39 ++--
 OvmfPkg/AmdSev/AmdSevX64.dsc |   2 +-
 OvmfPkg/CloudHv/CloudHvX64.dsc   |   2 +-
 OvmfPkg/IntelTdx/IntelTdxX64.dsc |   3 +-
 OvmfPkg/Microvm/MicrovmX64.dsc   |   2 +-
 OvmfPkg/OvmfPkgIa32.dsc  |   1 +
 OvmfPkg/OvmfPkgIa32X64.dsc   |   2 +-
 OvmfPkg/OvmfPkgX64.dsc   |   3 +-
 OvmfPkg/OvmfXen.dsc  |   2 +-
 UefiCpuPkg/CpuMpPei/CpuMpPei.h   |   1 +
 UefiCpuPkg/CpuMpPei/CpuMpPei.inf |   1 +
 UefiCpuPkg/CpuMpPei/CpuPaging.c  | 215 +--
 UefiCpuPkg/SecCore/SecCore.inf   |   1 +
 UefiCpuPkg/SecCore/SecCoreNative.inf |   1 +
 UefiCpuPkg/SecCore/SecMain.c | 152 
 UefiCpuPkg/SecCore/SecMain.h |   4 +
 UefiPayloadPkg/UefiPayloadPkg.dsc|   2 +-
 17 files changed, 282 insertions(+), 151 deletions(-)

-- 
2.16.2.windows.1



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




Re: [edk2-devel] [edk2-redfish-client][PATCH 4/4] RedfishClientPkg: Reduce the header file dependency.

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

Reviewed-by: Abner Chang 

> -Original Message-
> From: Nickle Wang 
> Sent: Friday, May 12, 2023 11:47 AM
> To: devel@edk2.groups.io
> Cc: Chang, Abner ; Igor Kulchytskyy
> 
> Subject: [edk2-redfish-client][PATCH 4/4] RedfishClientPkg: Reduce the
> header file dependency.
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> Move REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG and
> REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST from
> RedfishFeatureUtilityLib.h to EdkIIRedfishInterchangeData.h. Also, remove
> unnecessary jansson.h in RedfishDataTypeDef.h.
> 
> Signed-off-by: Simon Wang 
> Cc: Nickle Wang 
> Cc: Abner Chang 
> Cc: Igor Kulchytskyy 
> ---
>  .../ConverterLib/include/RedfishDataTypeDef.h   |  3 +--
>  .../Include/Library/RedfishFeatureUtilityLib.h  | 17 +
>  .../Protocol/EdkIIRedfishInterchangeData.h  | 17 -
>  3 files changed, 18 insertions(+), 19 deletions(-)
> 
> diff --git a/RedfishClientPkg/ConverterLib/include/RedfishDataTypeDef.h
> b/RedfishClientPkg/ConverterLib/include/RedfishDataTypeDef.h
> index 96eebc66..c759428a 100644
> --- a/RedfishClientPkg/ConverterLib/include/RedfishDataTypeDef.h
> +++ b/RedfishClientPkg/ConverterLib/include/RedfishDataTypeDef.h
> @@ -1,6 +1,7 @@
>  /** @file
> 
>(C) Copyright 2018-2021 Hewlett Packard Enterprise Development LP
> +  Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
> 
>SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -12,8 +13,6 @@
>  #ifndef REDFISH_CS_DATA_TYPE_H_
>  #define REDFISH_CS_DATA_TYPE_H_
> 
> -#include 
> -
>  typedef charRedfishCS_char;
>  typedef int RedfishCS_bool;
>  typedef signed char RedfishCS_int8;
> diff --git a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h
> b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h
> index 14296432..e2f728b2 100644
> --- a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h
> +++ b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h
> @@ -13,26 +13,11 @@
> 
>  #include 
>  #include 
> +#include 
>  #include 
> 
>  #define REDFISH_ENABLE_SYSTEM_REBOOT()
> PcdSetBoolS(PcdRedfishSystemRebootRequired, TRUE)
> 
> -//
> -// Definition of REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG
> -//
> -typedef struct {
> -  UINTN Index;
> -  EFI_STRINGConfigureLang;
> -} REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG;
> -
> -//
> -// Definition of REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST
> -//
> -typedef struct {
> -  UINTN Count;
> -  REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG*List;
> -} REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST;
> -
>  /**
> 
>Read redfish resource by given resource URI.
> diff --git
> a/RedfishClientPkg/Include/Protocol/EdkIIRedfishInterchangeData.h
> b/RedfishClientPkg/Include/Protocol/EdkIIRedfishInterchangeData.h
> index b2841b66..89708eb8 100644
> --- a/RedfishClientPkg/Include/Protocol/EdkIIRedfishInterchangeData.h
> +++ b/RedfishClientPkg/Include/Protocol/EdkIIRedfishInterchangeData.h
> @@ -2,6 +2,7 @@
>This file defines the
> EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL interface.
> 
>(C) Copyright 2022 Hewlett Packard Enterprise Development LP
> +  Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
> 
>SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -10,7 +11,21 @@
>  #ifndef EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_H_
>  #define EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_H_
> 
> -#include 
> +//
> +// Definition of REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG
> +//
> +typedef struct {
> +  UINTN Index;
> +  EFI_STRINGConfigureLang;
> +} REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG;
> +
> +//
> +// Definition of REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST
> +//
> +typedef struct {
> +  UINTN Count;
> +  REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG*List;
> +} REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST;
> 
>  typedef struct _EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL
> EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL;
> 
> --
> 2.17.1


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




Re: [edk2-devel] [edk2-redfish-client][PATCH 3/4] RedfishClientPkg: Add mechanism to reboot system if config is changed

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

Reviewed-by: Abner Chang 

> -Original Message-
> From: Nickle Wang 
> Sent: Friday, May 12, 2023 11:47 AM
> To: devel@edk2.groups.io
> Cc: Chang, Abner ; Igor Kulchytskyy
> 
> Subject: [edk2-redfish-client][PATCH 3/4] RedfishClientPkg: Add mechanism
> to reboot system if config is changed
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> When system configuration is updated from RESTful interface, we need a
> system reboot so that the changes can be applied. Introduce PCD
> "PcdSystemRebootRequired" to RedfishClientPkg. RedfishFeatureUtility
> library will enable this flag when system config is updated.
> RedfishFeatureCore driver will check this flag and perform cold reboot after
> all Redfish operations are finished. PCD "PcdSystemRebootTimeout"
> is used to specify how many second BIOS will wait before reboot system.
> 
> Signed-off-by: Nickle Wang 
> Cc: Abner Chang 
> Cc: Igor Kulchytskyy 
> ---
>  RedfishClientPkg/RedfishClientPkg.dec |  8 ++-
>  .../RedfishFeatureUtilityLib.inf  |  3 +
>  .../RedfishFeatureCoreDxe.inf |  5 ++
>  .../Library/RedfishFeatureUtilityLib.h|  3 +
>  .../RedfishFeatureCoreDxe.h   |  3 +
>  .../RedfishFeatureUtilityLib.c| 65 ---
>  .../RedfishFeatureCoreDxe.c   | 40 +---
>  7 files changed, 106 insertions(+), 21 deletions(-)
> 
> diff --git a/RedfishClientPkg/RedfishClientPkg.dec
> b/RedfishClientPkg/RedfishClientPkg.dec
> index d3c97ecf..c0ab30ab 100644
> --- a/RedfishClientPkg/RedfishClientPkg.dec
> +++ b/RedfishClientPkg/RedfishClientPkg.dec
> @@ -2,7 +2,7 @@
>  # Redfish Client Package
>  #
>  # (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
> -# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights
> reserved.
> +# Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights
> reserved.
>  #
>  # SPDX-License-Identifier: BSD-2-Clause-Patent  ## @@ -65,3 +65,9 @@
> 
> gEfiRedfishClientPkgTokenSpaceGuid.PcdEdkIIRedfishFeatureDriverStartupE
> ventGuid|{0xB3, 0x8F, 0xE8, 0x7C, 0xD7, 0x4B, 0x79, 0x46, 0x87, 0xA8, 0xA8,
> 0xD8, 0xDE, 0xE5, 0x0D, 0x2B}|VOID*|0x1003
>## Default Redfish version string
> 
> gEfiRedfishClientPkgTokenSpaceGuid.PcdDefaultRedfishVersion|L"v1"|VOID
> *|0x1004
> +  ## The number of seconds that the firmware will wait before system
> + reboot
> +
> +
> gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishSystemRebootTimeout|5|
> UIN
> + T16|0x2002
> +
> +[PcdsDynamicEx]
> +  ## The flag used to indicate that system reboot is required due to
> +system configuration change
> +
> +gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishSystemRebootRequired|F
> ALSE
> +|BOOLEAN|0x2001
> diff --git
> a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib
> .inf
> b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib
> .inf
> index 84f338e6..66d5dce6 100644
> ---
> a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib
> .inf
> +++ b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUt
> +++ ilityLib.inf
> @@ -1,6 +1,8 @@
>  ## @file
> +#  INF for Redfish feature utility library.
>  #
>  #  (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  # @@ -49,6 +51,7 @@
>gEdkIIRedfishConfigLangMapProtocolGuid  ## CONSUMED ##
> 
>  [Pcd]
> +  gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishSystemRebootRequired
> 
>  [Guids]
> 
> diff --git
> a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf
> b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf
> index ddcf9910..c67525ee 100644
> --- a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf
> +++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf
> @@ -4,6 +4,8 @@
>  #  drivers for the registration.
>  #
>  #  (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  #  ## @@ -40,6 +42,7 @@
>RedfishFeatureUtilityLib
>UefiBootServicesTableLib
>UefiDriverEntryPoint
> +  UefiRuntimeServicesTableLib
>UefiLib
> 
>  [Protocols]
> @@ -47,6 +50,8 @@
> 
>  [Pcd]
> 
> gEfiRedfishClientPkgTokenSpaceGuid.PcdEdkIIRedfishFeatureDriverStartupE
> ventGuid
> +  gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishSystemRebootRequired
> +  gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishSystemRebootTimeout
> 
>  [Depex]
>TRUE
> diff --git a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h
> b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h
> index d2733476..14296432 100644
> --- 

Re: [edk2-devel] [edk2-redfish-client][PATCH 2/4] RedfishClientPkg: Add Redfish.Settings support

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

Reviewed-by: Abner Chang 

> -Original Message-
> From: Nickle Wang 
> Sent: Friday, May 12, 2023 11:47 AM
> To: devel@edk2.groups.io
> Cc: Chang, Abner ; Igor Kulchytskyy
> 
> Subject: [edk2-redfish-client][PATCH 2/4] RedfishClientPkg: Add
> Redfish.Settings support
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> BIOS feature driver cannot recognize "@Redfish.Settings", decode it and get
> pending setting URI. So BIOS feature driver can consume pending setting
> from correct place.
> 
> Signed-off-by: Simon Wang 
> Cc: Nickle Wang 
> Cc: Abner Chang 
> Cc: Igor Kulchytskyy 
> ---
>  .../Features/Bios/v1_0_9/Dxe/BiosDxe.c| 65 ---
>  1 file changed, 57 insertions(+), 8 deletions(-)
> 
> diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> index 15ec208d..125e4eda 100644
> --- a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> +++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> @@ -2,6 +2,7 @@
>Redfish feature driver implementation - Bios
> 
>(C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
> +  Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
> 
>SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -101,7 +102,13 @@ RedfishResourceConsumeResource (
>REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
>EFI_STATUS   Status;
>REDFISH_RESPONSE Response;
> +  REDFISH_RESPONSE *ExpectedResponse;
> +  REDFISH_RESPONSE RedfishSettingsResponse;
>CHAR8*Etag;
> +  UINTNIndex;
> +  EDKII_JSON_VALUE JsonValue;
> +  EFI_STRING   RedfishSettingsUri;
> +  CONST CHAR8  *RedfishSettingsUriKeys[] =
> { "@Redfish.Settings", "SettingsObject", "@odata.id" };
> 
>if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
>  return EFI_INVALID_PARAMETER;
> @@ -119,8 +126,38 @@ RedfishResourceConsumeResource (
>  return Status;
>}
> 
> +  ExpectedResponse   = 
> +  RedfishSettingsUri = NULL;
> +  JsonValue  = RedfishJsonInPayload (Response.Payload);
> +
> +  //
> +  // Seeking RedfishSettings URI link.
> +  //
> +  for (Index = 0; Index < sizeof (RedfishSettingsUriKeys) / sizeof
> (*RedfishSettingsUriKeys); Index++) {
> +if (JsonValue == NULL) {
> +  break;
> +}
> +
> +JsonValue = JsonObjectGetValue (JsonValueGetObject (JsonValue),
> + RedfishSettingsUriKeys[Index]);  }
> +
> +  if (JsonValue != NULL) {
> +//
> +// Verify RedfishSettings URI link is valid to retrieve resource or not.
> +//
> +RedfishSettingsUri = JsonValueGetUnicodeString (JsonValue);
> +
> +Status = GetResourceByUri (Private->RedfishService, RedfishSettingsUri,
> );
> +if (EFI_ERROR (Status)) {
> +  DEBUG ((DEBUG_ERROR, "%a, @Redfish.Settings exists, get resource
> from: %s failed\n", __FUNCTION__, RedfishSettingsUri));
> +} else {
> +  Uri  = RedfishSettingsUri;
> +  ExpectedResponse = 
> +}
> +  }
> +
>Private->Uri = Uri;
> -  Private->Payload = Response.Payload;
> +  Private->Payload = ExpectedResponse->Payload;
>ASSERT (Private->Payload != NULL);
> 
>Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload),
> EDKII_JSON_COMPACT); @@ -130,7 +167,7 @@
> RedfishResourceConsumeResource (
>// Find etag in HTTP response header
>//
>Etag   = NULL;
> -  Status = GetEtagAndLocation (, , NULL);
> +  Status = GetEtagAndLocation (ExpectedResponse, , NULL);
>if (EFI_ERROR (Status)) {
>  DEBUG ((DEBUG_ERROR, "%a, failed to get ETag from HTTP header\n",
> __FUNCTION__));
>}
> @@ -153,12 +190,24 @@ RedfishResourceConsumeResource (
>// Release resource
>//
>if (Private->Payload != NULL) {
> -RedfishFreeResponse (
> -  Response.StatusCode,
> -  Response.HeaderCount,
> -  Response.Headers,
> -  Response.Payload
> -  );
> +if (Response.Payload != NULL) {
> +  RedfishFreeResponse (
> +Response.StatusCode,
> +Response.HeaderCount,
> +Response.Headers,
> +Response.Payload
> +);
> +}
> +
> +if (RedfishSettingsResponse.Payload != NULL) {
> +  RedfishFreeResponse (
> +RedfishSettingsResponse.StatusCode,
> +RedfishSettingsResponse.HeaderCount,
> +RedfishSettingsResponse.Headers,
> +RedfishSettingsResponse.Payload
> +);
> +}
> +
>  Private->Payload = NULL;
>}
> 
> --
> 2.17.1


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

Re: [edk2-devel] [edk2-redfish-client][PATCH 1/4] RedfishClientPkg: Fix GCC build error

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

Reviewed-by: Abner Chang 

> -Original Message-
> From: Nickle Wang 
> Sent: Friday, May 12, 2023 11:47 AM
> To: devel@edk2.groups.io
> Cc: Chang, Abner ; Igor Kulchytskyy
> 
> Subject: [edk2-redfish-client][PATCH 1/4] RedfishClientPkg: Fix GCC build
> error
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> Fix below GCC build error:
> 1) "Head" dereference issue.
> 2) "BooleanArrayBuffer" uninitialized variable issue.
> 3) Multiple definition of mRedfishVariableGuid.
> 4) Multiple definition of medfishResourceConfigProtocolHandle.
> 
> Signed-off-by: Nickle Wang 
> Cc: Abner Chang 
> Cc: Igor Kulchytskyy 
> ---
>  RedfishClientPkg/RedfishClientPkg.dec |  4 
>  .../RedfishConfigLangMapDxe.inf   |  2 ++
>  RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.inf|  2 ++
>  RedfishClientPkg/Include/RedfishBase.h|  4 ++--
>  .../EdkIIRedfishResourceConfigLib.c   | 11 ++-
>  .../RedfishFeatureUtilityLib.c|  5 +++--
>  .../RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.c |  9 +
>  RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.c  |  9 +
>  8 files changed, 29 insertions(+), 17 deletions(-)
> 
> diff --git a/RedfishClientPkg/RedfishClientPkg.dec
> b/RedfishClientPkg/RedfishClientPkg.dec
> index 67929341..d3c97ecf 100644
> --- a/RedfishClientPkg/RedfishClientPkg.dec
> +++ b/RedfishClientPkg/RedfishClientPkg.dec
> @@ -2,6 +2,7 @@
>  # Redfish Client Package
>  #
>  # (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
> +# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights
> reserved.
>  #
>  # SPDX-License-Identifier: BSD-2-Clause-Patent  ## @@ -51,6 +52,9 @@
>gEfiRedfishClientFeatureReadyToProvisioningGuid = { 0x77E4FC1C, 0x2428,
> 0x47EE, { 0x9E, 0xEC, 0x8B, 0x77, 0xEF, 0x9D, 0x4E, 0xF0 } }
>gEfiRedfishClientFeatureAfterProvisioningGuid   = { 0xE547CB6F, 0x306F,
> 0x4226, { 0xAB, 0x70, 0xA0, 0x6E, 0x26, 0xF1, 0x2E, 0xD0 } }
> 
> +  ## Include/RedfishBase.h
> +  gEfiRedfishClientVariableGuid   = { 0x91c46a3d, 0xed1a, 
> 0x477b,
> { 0xa5, 0x33, 0x87, 0x2d, 0xcd, 0xb0, 0xfc, 0xc1 } }
> +
>  [PcdsFixedAtBuild]
> 
> gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize|32|
> UINT32|0x1001
> 
> gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize|8|
> UINT32|0x1002
> diff --git
> a/RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.i
> nf
> b/RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.i
> nf
> index 9f195338..821f0552 100644
> ---
> a/RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.i
> nf
> +++
> b/RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.i
> +++ nf
> @@ -1,6 +1,7 @@
>  ## @file
>  #
>  #  (C) Copyright 2022 Hewlett Packard Enterprise Development LP
> +#  Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights
> reserved.
>  #
>  #  SPDX-License-Identifier: BSD-2-Clause-Patent  # @@ -41,6 +42,7 @@
> 
>  [Guids]
>gEfiEventExitBootServicesGuid  ## CONSUMED ##
> +  gEfiRedfishClientVariableGuid  ## CONSUMED ##
> 
>  [Depex]
>TRUE
> diff --git a/RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.inf
> b/RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.inf
> index e29a1045..4aecdb41 100644
> --- a/RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.inf
> +++ b/RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.inf
> @@ -1,6 +1,7 @@
>  ## @file
>  #
>  #  (C) Copyright 2021 Hewlett Packard Enterprise Development LP
> +#  Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights
> reserved.
>  #
>  #  SPDX-License-Identifier: BSD-2-Clause-Patent  # @@ -40,6 +41,7 @@
> 
>  [Guids]
>gEfiEventExitBootServicesGuid   ## CONSUMES ## Event
> +  gEfiRedfishClientVariableGuid   ## CONSUMED ##
> 
>  [Depex]
>TRUE
> diff --git a/RedfishClientPkg/Include/RedfishBase.h
> b/RedfishClientPkg/Include/RedfishBase.h
> index 1abe9517..753e9ed2 100644
> --- a/RedfishClientPkg/Include/RedfishBase.h
> +++ b/RedfishClientPkg/Include/RedfishBase.h
> @@ -2,6 +2,7 @@
>Redfish base header file.
> 
>(C) Copyright 2022 Hewlett Packard Enterprise Development LP
> +  Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
> 
>SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -16,7 +17,6 @@
>  ///
>  /// This GUID is used for an EFI Variable that stores the Redfish data.
>  ///
> -EFI_GUID  mRedfishVariableGuid = { 0x91c46a3d, 0xed1a, 0x477b, { 0xa5,
> 0x33, 0x87, 0x2d, 0xcd, 0xb0, 0xfc, 0xc1 } -};
> +extern EFI_GUID  gEfiRedfishClientVariableGuid;
> 
>  #endif
> diff --git
> a/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishReso
> urceConfigLib.c
> b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishRes
> 

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

2023-05-11 Thread Chang, Abner via groups.io
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|BOOLEAN|0x1004
   
gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeMctpEnable|FALSE|BOOLEAN|0x1005
   
gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxePldmSmbiosTransferEnable|FALSE|BOOLEAN|0x1006
+  
gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiOsWdt|FALSE|BOOLEAN|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.PcdManageabilityDxePldmSmbiosTransferEnable|TRUE
+  gManageabilityPkgTokenSpaceGuid.PcdManageabilityDxeIpmiOsWdt   
|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..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 (#104753): https://edk2.groups.io/g/devel/message/104753
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]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [edk2-platforms][PATCH 1/2] ManageabilityPkg/IpmiOsWdt: IPMI OS Watchdog timer Driver

2023-05-11 Thread Chang, Abner via groups.io
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 EFI_SUCCESS   Protocol successfully started and installed.
+  @retval EFI_OUT_OF_RESOURCES  The event could not be allocated.
+
+--*/
+EFI_STATUS
+EFIAPI
+DriverInit (
+  IN EFI_HANDLEImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  EFI_STATUS  Status;
+
+  Status = gBS->CreateEvent (
+  EVT_SIGNAL_EXIT_BOOT_SERVICES,
+  TPL_NOTIFY,
+  EnableEfiOsBootWdtHandler,
+  NULL,
+  
+  );
+
+  return Status;
+}
-- 
2.37.1.windows.1



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

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

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

Regards,
Nickle

> -Original Message-
> From: abner.ch...@amd.com 
> Sent: Friday, May 12, 2023 11:27 AM
> To: devel@edk2.groups.io
> Cc: Isaac Oram ; Abdul Lateef Attar
> ; Nickle Wang 
> Subject: [edk2-platforms][PATCH 2/2] ManageabilityPkg/IpmiFru: Add to
> ManageabilityPkg
> 
> External email: Use caution opening links or attachments
> 
> 
> From: Abner Chang 
> 
> Add IpmiFru 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..8e8f30b122 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.PcdManageabilityDxeIpmiFru|FALSE|BOOLE
> AN|0x1007
> 
> diff --git a/Features/ManageabilityPkg/Include/Manageability.dsc
> b/Features/ManageabilityPkg/Include/Manageability.dsc
> index a432b0ff26..337c1fb9cc 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.PcdManageabilityDxeIpmiFru == TRUE
> +  ManageabilityPkg/Universal/IpmiFru/IpmiFru.inf
> +!endif
> diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dsc
> b/Features/ManageabilityPkg/ManageabilityPkg.dsc
> index e3baf27f2a..6074e9d904 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.PcdManageabilityDxeIpmiFru
> |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..2d7be8cc31 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.PcdManageabilityDxeIpmiFru == TRUE
> +  INF ManageabilityPkg/Universal/IpmiFru/IpmiFru.inf
> +!endif
> --
> 2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104751): https://edk2.groups.io/g/devel/message/104751
Mute This Topic: https://groups.io/mt/98842634/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-11 Thread Nickle Wang via groups.io
Reviewed-by: Nickle Wang 

Regards,
Nickle

> -Original Message-
> From: abner.ch...@amd.com 
> Sent: Friday, May 12, 2023 11:27 AM
> To: devel@edk2.groups.io
> Cc: Isaac Oram ; Abdul Lateef Attar
> ; Nickle Wang ; Tinh Nguyen
> 
> Subject: [edk2-platforms][PATCH 1/2] ManageabilityPkg/IpmiFru: IPMI FRU
> Driver
> 
> External email: Use caution opening links or attachments
> 
> 
> 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;
> +}
> --
> 2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104750): https://edk2.groups.io/g/devel/message/104750
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]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [edk2-redfish-client][PATCH 4/4] RedfishClientPkg: Reduce the header file dependency.

2023-05-11 Thread Nickle Wang via groups.io
Move REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG and
REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST from
RedfishFeatureUtilityLib.h to
EdkIIRedfishInterchangeData.h. Also, remove
unnecessary jansson.h in RedfishDataTypeDef.h.

Signed-off-by: Simon Wang 
Cc: Nickle Wang 
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
---
 .../ConverterLib/include/RedfishDataTypeDef.h   |  3 +--
 .../Include/Library/RedfishFeatureUtilityLib.h  | 17 +
 .../Protocol/EdkIIRedfishInterchangeData.h  | 17 -
 3 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/RedfishClientPkg/ConverterLib/include/RedfishDataTypeDef.h 
b/RedfishClientPkg/ConverterLib/include/RedfishDataTypeDef.h
index 96eebc66..c759428a 100644
--- a/RedfishClientPkg/ConverterLib/include/RedfishDataTypeDef.h
+++ b/RedfishClientPkg/ConverterLib/include/RedfishDataTypeDef.h
@@ -1,6 +1,7 @@
 /** @file
 
   (C) Copyright 2018-2021 Hewlett Packard Enterprise Development LP
+  Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -12,8 +13,6 @@
 #ifndef REDFISH_CS_DATA_TYPE_H_
 #define REDFISH_CS_DATA_TYPE_H_
 
-#include 
-
 typedef charRedfishCS_char;
 typedef int RedfishCS_bool;
 typedef signed char RedfishCS_int8;
diff --git a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h 
b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h
index 14296432..e2f728b2 100644
--- a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h
+++ b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h
@@ -13,26 +13,11 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #define REDFISH_ENABLE_SYSTEM_REBOOT()  
PcdSetBoolS(PcdRedfishSystemRebootRequired, TRUE)
 
-//
-// Definition of REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG
-//
-typedef struct {
-  UINTN Index;
-  EFI_STRINGConfigureLang;
-} REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG;
-
-//
-// Definition of REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST
-//
-typedef struct {
-  UINTN Count;
-  REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG*List;
-} REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST;
-
 /**
 
   Read redfish resource by given resource URI.
diff --git a/RedfishClientPkg/Include/Protocol/EdkIIRedfishInterchangeData.h 
b/RedfishClientPkg/Include/Protocol/EdkIIRedfishInterchangeData.h
index b2841b66..89708eb8 100644
--- a/RedfishClientPkg/Include/Protocol/EdkIIRedfishInterchangeData.h
+++ b/RedfishClientPkg/Include/Protocol/EdkIIRedfishInterchangeData.h
@@ -2,6 +2,7 @@
   This file defines the EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL 
interface.
 
   (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+  Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -10,7 +11,21 @@
 #ifndef EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_H_
 #define EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_H_
 
-#include 
+//
+// Definition of REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG
+//
+typedef struct {
+  UINTN Index;
+  EFI_STRINGConfigureLang;
+} REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG;
+
+//
+// Definition of REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST
+//
+typedef struct {
+  UINTN Count;
+  REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG*List;
+} REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST;
 
 typedef struct _EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL 
EDKII_REDFISH_FEATURE_INTERCHANGE_DATA_PROTOCOL;
 
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104749): https://edk2.groups.io/g/devel/message/104749
Mute This Topic: https://groups.io/mt/98842844/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 3/4] RedfishClientPkg: Add mechanism to reboot system if config is changed

2023-05-11 Thread Nickle Wang via groups.io
When system configuration is updated from RESTful interface, we need a
system reboot so that the changes can be applied. Introduce PCD
"PcdSystemRebootRequired" to RedfishClientPkg. RedfishFeatureUtility
library will enable this flag when system config is updated.
RedfishFeatureCore driver will check this flag and perform cold reboot
after all Redfish operations are finished. PCD "PcdSystemRebootTimeout"
is used to specify how many second BIOS will wait before reboot system.

Signed-off-by: Nickle Wang 
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
---
 RedfishClientPkg/RedfishClientPkg.dec |  8 ++-
 .../RedfishFeatureUtilityLib.inf  |  3 +
 .../RedfishFeatureCoreDxe.inf |  5 ++
 .../Library/RedfishFeatureUtilityLib.h|  3 +
 .../RedfishFeatureCoreDxe.h   |  3 +
 .../RedfishFeatureUtilityLib.c| 65 ---
 .../RedfishFeatureCoreDxe.c   | 40 +---
 7 files changed, 106 insertions(+), 21 deletions(-)

diff --git a/RedfishClientPkg/RedfishClientPkg.dec 
b/RedfishClientPkg/RedfishClientPkg.dec
index d3c97ecf..c0ab30ab 100644
--- a/RedfishClientPkg/RedfishClientPkg.dec
+++ b/RedfishClientPkg/RedfishClientPkg.dec
@@ -2,7 +2,7 @@
 # Redfish Client Package
 #
 # (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
-# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights 
reserved.
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 ##
@@ -65,3 +65,9 @@
   
gEfiRedfishClientPkgTokenSpaceGuid.PcdEdkIIRedfishFeatureDriverStartupEventGuid|{0xB3,
 0x8F, 0xE8, 0x7C, 0xD7, 0x4B, 0x79, 0x46, 0x87, 0xA8, 0xA8, 0xD8, 0xDE, 0xE5, 
0x0D, 0x2B}|VOID*|0x1003
   ## Default Redfish version string
   
gEfiRedfishClientPkgTokenSpaceGuid.PcdDefaultRedfishVersion|L"v1"|VOID*|0x1004
+  ## The number of seconds that the firmware will wait before system reboot
+  
gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishSystemRebootTimeout|5|UINT16|0x2002
+
+[PcdsDynamicEx]
+  ## The flag used to indicate that system reboot is required due to system 
configuration change
+  
gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishSystemRebootRequired|FALSE|BOOLEAN|0x2001
diff --git 
a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf
 
b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf
index 84f338e6..66d5dce6 100644
--- 
a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf
+++ 
b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.inf
@@ -1,6 +1,8 @@
 ## @file
+#  INF for Redfish feature utility library.
 #
 #  (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
 #
@@ -49,6 +51,7 @@
   gEdkIIRedfishConfigLangMapProtocolGuid  ## CONSUMED ##
 
 [Pcd]
+  gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishSystemRebootRequired
 
 [Guids]
 
diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf 
b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf
index ddcf9910..c67525ee 100644
--- a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf
+++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf
@@ -4,6 +4,8 @@
 #  drivers for the registration.
 #
 #  (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
 #
 ##
@@ -40,6 +42,7 @@
   RedfishFeatureUtilityLib
   UefiBootServicesTableLib
   UefiDriverEntryPoint
+  UefiRuntimeServicesTableLib
   UefiLib
 
 [Protocols]
@@ -47,6 +50,8 @@
 
 [Pcd]
   
gEfiRedfishClientPkgTokenSpaceGuid.PcdEdkIIRedfishFeatureDriverStartupEventGuid
+  gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishSystemRebootRequired
+  gEfiRedfishClientPkgTokenSpaceGuid.PcdRedfishSystemRebootTimeout
 
 [Depex]
   TRUE
diff --git a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h 
b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h
index d2733476..14296432 100644
--- a/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h
+++ b/RedfishClientPkg/Include/Library/RedfishFeatureUtilityLib.h
@@ -2,6 +2,7 @@
   This file defines the Redfish Feature Utility Library interface.
 
   (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
 
@@ -14,6 +15,8 @@
 #include 
 #include 
 
+#define REDFISH_ENABLE_SYSTEM_REBOOT()  
PcdSetBoolS(PcdRedfishSystemRebootRequired, TRUE)
+
 //
 // Definition of REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG
 //
diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h 

[edk2-devel] [edk2-redfish-client][PATCH 2/4] RedfishClientPkg: Add Redfish.Settings support

2023-05-11 Thread Nickle Wang via groups.io
BIOS feature driver cannot recognize "@Redfish.Settings",
decode it and get pending setting URI. So BIOS feature
driver can consume pending setting from correct place.

Signed-off-by: Simon Wang 
Cc: Nickle Wang 
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
---
 .../Features/Bios/v1_0_9/Dxe/BiosDxe.c| 65 ---
 1 file changed, 57 insertions(+), 8 deletions(-)

diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c 
b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
index 15ec208d..125e4eda 100644
--- a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
+++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
@@ -2,6 +2,7 @@
   Redfish feature driver implementation - Bios
 
   (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
+  Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -101,7 +102,13 @@ RedfishResourceConsumeResource (
   REDFISH_RESOURCE_COMMON_PRIVATE  *Private;
   EFI_STATUS   Status;
   REDFISH_RESPONSE Response;
+  REDFISH_RESPONSE *ExpectedResponse;
+  REDFISH_RESPONSE RedfishSettingsResponse;
   CHAR8*Etag;
+  UINTNIndex;
+  EDKII_JSON_VALUE JsonValue;
+  EFI_STRING   RedfishSettingsUri;
+  CONST CHAR8  *RedfishSettingsUriKeys[] = { 
"@Redfish.Settings", "SettingsObject", "@odata.id" };
 
   if ((This == NULL) || IS_EMPTY_STRING (Uri)) {
 return EFI_INVALID_PARAMETER;
@@ -119,8 +126,38 @@ RedfishResourceConsumeResource (
 return Status;
   }
 
+  ExpectedResponse   = 
+  RedfishSettingsUri = NULL;
+  JsonValue  = RedfishJsonInPayload (Response.Payload);
+
+  //
+  // Seeking RedfishSettings URI link.
+  //
+  for (Index = 0; Index < sizeof (RedfishSettingsUriKeys) / sizeof 
(*RedfishSettingsUriKeys); Index++) {
+if (JsonValue == NULL) {
+  break;
+}
+
+JsonValue = JsonObjectGetValue (JsonValueGetObject (JsonValue), 
RedfishSettingsUriKeys[Index]);
+  }
+
+  if (JsonValue != NULL) {
+//
+// Verify RedfishSettings URI link is valid to retrieve resource or not.
+//
+RedfishSettingsUri = JsonValueGetUnicodeString (JsonValue);
+
+Status = GetResourceByUri (Private->RedfishService, RedfishSettingsUri, 
);
+if (EFI_ERROR (Status)) {
+  DEBUG ((DEBUG_ERROR, "%a, @Redfish.Settings exists, get resource from: 
%s failed\n", __FUNCTION__, RedfishSettingsUri));
+} else {
+  Uri  = RedfishSettingsUri;
+  ExpectedResponse = 
+}
+  }
+
   Private->Uri = Uri;
-  Private->Payload = Response.Payload;
+  Private->Payload = ExpectedResponse->Payload;
   ASSERT (Private->Payload != NULL);
 
   Private->Json = JsonDumpString (RedfishJsonInPayload (Private->Payload), 
EDKII_JSON_COMPACT);
@@ -130,7 +167,7 @@ RedfishResourceConsumeResource (
   // Find etag in HTTP response header
   //
   Etag   = NULL;
-  Status = GetEtagAndLocation (, , NULL);
+  Status = GetEtagAndLocation (ExpectedResponse, , NULL);
   if (EFI_ERROR (Status)) {
 DEBUG ((DEBUG_ERROR, "%a, failed to get ETag from HTTP header\n", 
__FUNCTION__));
   }
@@ -153,12 +190,24 @@ RedfishResourceConsumeResource (
   // Release resource
   //
   if (Private->Payload != NULL) {
-RedfishFreeResponse (
-  Response.StatusCode,
-  Response.HeaderCount,
-  Response.Headers,
-  Response.Payload
-  );
+if (Response.Payload != NULL) {
+  RedfishFreeResponse (
+Response.StatusCode,
+Response.HeaderCount,
+Response.Headers,
+Response.Payload
+);
+}
+
+if (RedfishSettingsResponse.Payload != NULL) {
+  RedfishFreeResponse (
+RedfishSettingsResponse.StatusCode,
+RedfishSettingsResponse.HeaderCount,
+RedfishSettingsResponse.Headers,
+RedfishSettingsResponse.Payload
+);
+}
+
 Private->Payload = NULL;
   }
 
-- 
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104747): https://edk2.groups.io/g/devel/message/104747
Mute This Topic: https://groups.io/mt/98842834/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 1/4] RedfishClientPkg: Fix GCC build error

2023-05-11 Thread Nickle Wang via groups.io
Fix below GCC build error:
1) "Head" dereference issue.
2) "BooleanArrayBuffer" uninitialized variable issue.
3) Multiple definition of mRedfishVariableGuid.
4) Multiple definition of medfishResourceConfigProtocolHandle.

Signed-off-by: Nickle Wang 
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
---
 RedfishClientPkg/RedfishClientPkg.dec |  4 
 .../RedfishConfigLangMapDxe.inf   |  2 ++
 RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.inf|  2 ++
 RedfishClientPkg/Include/RedfishBase.h|  4 ++--
 .../EdkIIRedfishResourceConfigLib.c   | 11 ++-
 .../RedfishFeatureUtilityLib.c|  5 +++--
 .../RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.c |  9 +
 RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.c  |  9 +
 8 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/RedfishClientPkg/RedfishClientPkg.dec 
b/RedfishClientPkg/RedfishClientPkg.dec
index 67929341..d3c97ecf 100644
--- a/RedfishClientPkg/RedfishClientPkg.dec
+++ b/RedfishClientPkg/RedfishClientPkg.dec
@@ -2,6 +2,7 @@
 # Redfish Client Package
 #
 # (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
+# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 ##
@@ -51,6 +52,9 @@
   gEfiRedfishClientFeatureReadyToProvisioningGuid = { 0x77E4FC1C, 0x2428, 
0x47EE, { 0x9E, 0xEC, 0x8B, 0x77, 0xEF, 0x9D, 0x4E, 0xF0 } }
   gEfiRedfishClientFeatureAfterProvisioningGuid   = { 0xE547CB6F, 0x306F, 
0x4226, { 0xAB, 0x70, 0xA0, 0x6E, 0x26, 0xF1, 0x2E, 0xD0 } }
 
+  ## Include/RedfishBase.h
+  gEfiRedfishClientVariableGuid   = { 0x91c46a3d, 0xed1a, 
0x477b, { 0xa5, 0x33, 0x87, 0x2d, 0xcd, 0xb0, 0xfc, 0xc1 } }
+
 [PcdsFixedAtBuild]
   
gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaStringSize|32|UINT32|0x1001
   
gEfiRedfishClientPkgTokenSpaceGuid.PcdMaxRedfishSchemaVersionSize|8|UINT32|0x1002
diff --git 
a/RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.inf 
b/RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.inf
index 9f195338..821f0552 100644
--- a/RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.inf
+++ b/RedfishClientPkg/RedfishConfigLangMapDxe/RedfishConfigLangMapDxe.inf
@@ -1,6 +1,7 @@
 ## @file
 #
 #  (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+#  Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -41,6 +42,7 @@
 
 [Guids]
   gEfiEventExitBootServicesGuid  ## CONSUMED ##
+  gEfiRedfishClientVariableGuid  ## CONSUMED ##
 
 [Depex]
   TRUE
diff --git a/RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.inf 
b/RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.inf
index e29a1045..4aecdb41 100644
--- a/RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.inf
+++ b/RedfishClientPkg/RedfishETagDxe/RedfishETagDxe.inf
@@ -1,6 +1,7 @@
 ## @file
 #
 #  (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+#  Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -40,6 +41,7 @@
 
 [Guids]
   gEfiEventExitBootServicesGuid   ## CONSUMES ## Event
+  gEfiRedfishClientVariableGuid   ## CONSUMED ##
 
 [Depex]
   TRUE
diff --git a/RedfishClientPkg/Include/RedfishBase.h 
b/RedfishClientPkg/Include/RedfishBase.h
index 1abe9517..753e9ed2 100644
--- a/RedfishClientPkg/Include/RedfishBase.h
+++ b/RedfishClientPkg/Include/RedfishBase.h
@@ -2,6 +2,7 @@
   Redfish base header file.
 
   (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+  Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -16,7 +17,6 @@
 ///
 /// This GUID is used for an EFI Variable that stores the Redfish data.
 ///
-EFI_GUID  mRedfishVariableGuid = { 0x91c46a3d, 0xed1a, 0x477b, { 0xa5, 0x33, 
0x87, 0x2d, 0xcd, 0xb0, 0xfc, 0xc1 }
-};
+extern EFI_GUID  gEfiRedfishClientVariableGuid;
 
 #endif
diff --git 
a/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigLib.c
 
b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigLib.c
index b1eaad75..521e2edb 100644
--- 
a/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigLib.c
+++ 
b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigLib.c
@@ -2,6 +2,7 @@
   Redfish resource config library implementation
 
   (C) Copyright 2022 Hewlett Packard Enterprise Development LP
+  Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -17,7 +18,7 @@
 #include 
 
 EDKII_REDFISH_RESOURCE_CONFIG_PROTOCOL   
*mRedfishResourceConfigProtocol = NULL;
-EFI_HANDLE   

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

2023-05-11 Thread Ni, Ray
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: 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| 

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

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

Add IpmiFru 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..8e8f30b122 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.PcdManageabilityDxeIpmiFru|FALSE|BOOLEAN|0x1007
 
diff --git a/Features/ManageabilityPkg/Include/Manageability.dsc 
b/Features/ManageabilityPkg/Include/Manageability.dsc
index a432b0ff26..337c1fb9cc 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.PcdManageabilityDxeIpmiFru == TRUE
+  ManageabilityPkg/Universal/IpmiFru/IpmiFru.inf
+!endif
diff --git a/Features/ManageabilityPkg/ManageabilityPkg.dsc 
b/Features/ManageabilityPkg/ManageabilityPkg.dsc
index e3baf27f2a..6074e9d904 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.PcdManageabilityDxeIpmiFru 
|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..2d7be8cc31 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.PcdManageabilityDxeIpmiFru == TRUE
+  INF ManageabilityPkg/Universal/IpmiFru/IpmiFru.inf
+!endif
-- 
2.37.1.windows.1



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

2023-05-11 Thread Chang, Abner via groups.io
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;
+}
-- 
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104743): https://edk2.groups.io/g/devel/message/104743
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 0/3] Add necessary changes for PCIe core and remove unnecessary checks for PCIe Devmap mode

2023-05-11 Thread Nhi Pham via groups.io

Hi Minh,

Thanks for this patchset. It looks good to me.

Reviewed-by: Nhi Pham 

Hi Leif, Ard - Could you please help merge this series?

Thanks,

Nhi

On 5/11/2023 2:51 PM, Minh Nguyen wrote:

These patches help to improve PCIe core for Link training sequence and
add logic to check PCIe card is present or not. One patch also removes
unnecessary checks for PCIe Devmap mode.

Minh Nguyen (2):
   AmpereAltraPkg: Remove PCIe "DevMapModeAuto" case in retrieving Devmap
 mode
   AmpereAltraPkg: Fix PCIe link training sequence

Tinh Nguyen (1):
   AmpereAltraPkg: Add retry logic when PCIe card is present

  Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/RootComplexNVParam.c |  2 +-
  Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c   | 12 

  2 files changed, 9 insertions(+), 5 deletions(-)




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




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

2023-05-11 Thread gaoliming via groups.io
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 (#104741): https://edk2.groups.io/g/devel/message/104741
Mute This Topic: https://groups.io/mt/98842139/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 V2 1/1] Platform/Loongson: Set Dxe common page size to 16k

2023-05-11 Thread xianglai
The loongarch qemu tcg code section is 16K aligned by default.
When UEFI keep 4K alignment, the code section and data section
of UEFI are loaded into the same page by qemu, and when the data
is written to the page containing the code section, it will cause
qemu to refresh TB, resulting in qemu running slowly.Therefore,
setting Dxe to 16K alignment can ensure that the code section is
loaded into a page separately, avoid qemu repeatedly refreshing TB,
and speed up the execution speed of qemu.

The following shows the impact of Dxe 4K alignment and 16K alignment
on image size:

DXE 4k alignment:
DXEFV.FV 7.2M
After compression:
FVMAIN_COMPACT.Fv 3.4M
QEMU_EFI.fd 3.7M

DXE 16k alignment:
DXEFV.FV 9.5M
After compression:
FVMAIN_COMPACT.Fv 3.4M
QEMU_EFI.fd 3.7M

Cc: Ard Biesheuvel 
Cc: Bibo Mao 
Cc: Chao Li 
Cc: Leif Lindholm 
Cc: Liming Gao 
Cc: Michael D Kinney 
Signed-off-by: xianglai li 
---
 Platform/Loongson/LoongArchQemuPkg/Loongson.dsc | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc 
b/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc
index 6875e39cc6..13b27d84b8 100644
--- a/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc
+++ b/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc
@@ -61,8 +61,13 @@
 [BuildOptions.LOONGARCH64.EDKII.SEC]
   *_*_*_CC_FLAGS =
 
+#
+# default page size is 16K for loongarch qemu tcg
+# code section separated with data section with 16K page alignment, else data
+# write operation in the same page with code section will cause qemu TB flush
+#
 
[BuildOptions.common.EDKII.DXE_CORE,BuildOptions.common.EDKII.DXE_DRIVER,BuildOptions.common.EDKII.UEFI_DRIVER,BuildOptions.common.EDKII.UEFI_APPLICATION]
-  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000
+  GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x4000
 
 [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
   GCC:*_*_LOONGARCH64_DLINK_FLAGS = -z common-page-size=0x1
-- 
2.31.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104740): https://edk2.groups.io/g/devel/message/104740
Mute This Topic: https://groups.io/mt/98842119/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 1/1] Maintainers.txt: Update reviewers and maintainers for FdtLib. Update reviewers and maintainers for FdtLib.

2023-05-11 Thread Chiu, Chasel


Reviewed-by: Chasel Chiu 

Thanks,
Chasel


> -Original Message-
> From: Guo, Gua 
> Sent: Thursday, May 11, 2023 7:11 PM
> To: devel@edk2.groups.io
> Cc: Guo, Gua ; Kinney, Michael D
> ; Andrew Fish ; Leif Lindholm
> ; Lin, Benny ; Chiu, Chasel
> ; Lu, James 
> Subject: [PATCH v1 1/1] Maintainers.txt: Update reviewers and maintainers for
> FdtLib. Update reviewers and maintainers for FdtLib.
> 
> From: Gua Guo 
> 
> Cc: Michael D Kinney 
> Cc: Andrew Fish 
> Cc: Leif Lindholm 
> Cc: Benny Lin 
> Cc: Gua Guo 
> Cc: Chasel Chiu 
> Cc: James Lu 
> Signed-off-by: Guo Gua 
> ---
>  Maintainers.txt | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/Maintainers.txt b/Maintainers.txt index 30e2d2686d..97886accd5
> 100644
> --- a/Maintainers.txt
> +++ b/Maintainers.txt
> @@ -462,6 +462,14 @@ M: Prakashan Krishnadas Veliyathuparambil
>   R: Chan Laura  [lauracha] R: K N Karthik
>  [karthikkabbigere1] +MdePkg: FDT related library
> instance+F: MdePkg/Library/BaseFdtLib/FdtLib.c+F:
> MdePkg/Include/Library/FdtLib.h+M: Benny Lin 
> [Benny3345678]+R: Gua Guo  [gguo11837463]+R: Chasel
> Chiu  [ChaselChiu]+R: James Lu 
> [jameslu8]+ NetworkPkg F: NetworkPkg/ W:
> https://github.com/tianocore/tianocore.github.io/wiki/NetworkPkg--
> 2.39.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104739): https://edk2.groups.io/g/devel/message/104739
Mute This Topic: https://groups.io/mt/98841641/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-11 Thread Chiu, Chasel


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 (#104738): https://edk2.groups.io/g/devel/message/104738
Mute This Topic: https://groups.io/mt/98841640/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-11 Thread Guo, Gua
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 (#104737): https://edk2.groups.io/g/devel/message/104737
Mute This Topic: https://groups.io/mt/98841640/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-11 Thread Chiu, Chasel


Reviewed-by: Chasel Chiu 


> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Guo, Gua
> Sent: Thursday, May 11, 2023 7:11 PM
> To: devel@edk2.groups.io
> Cc: Guo, Gua 
> Subject: [edk2-devel] [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 (#104736): https://edk2.groups.io/g/devel/message/104736
Mute This Topic: https://groups.io/mt/98841640/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 1/3] UefiCpuPkg/SecCore: Migrate page table to permanent memory

2023-05-11 Thread Wu, Jiaxin
Agree, thanks comments.

> -Original Message-
> From: Ni, Ray 
> Sent: Thursday, May 11, 2023 3:48 PM
> To: Wu, Jiaxin ; devel@edk2.groups.io;
> kra...@redhat.com
> Cc: Dong, Eric ; Zeng, Star ;
> Kumar, Rahul R 
> Subject: RE: [edk2-devel] [PATCH v1 1/3] UefiCpuPkg/SecCore: Migrate page
> table to permanent memory
> 
> Jiaxin,
> Let's keep using 48 or 57.
> We can use separate patch to clean all existing code to use 47 and 56.
> 
> Thanks,
> Ray
> 
> > -Original Message-
> > From: Wu, Jiaxin 
> > Sent: Thursday, May 11, 2023 1:08 PM
> > To: devel@edk2.groups.io; kra...@redhat.com; Ni, Ray 
> > Cc: Dong, Eric ; Zeng, Star ;
> > Kumar, Rahul R 
> > Subject: RE: [edk2-devel] [PATCH v1 1/3] UefiCpuPkg/SecCore: Migrate page
> > table to permanent memory
> >
> > What's your comments to the existing code logic for the PhysicalAddressBits
> in
> > the CreateIdentityMappingPageTables()? Looks all doesn't consider the  sign-
> > extended case? is it reasonable create the paging but not used? All system
> with
> > long mode are sign-extended?
> >
> > //
> >   // IA-32e paging translates 48-bit linear addresses to 52-bit physical
> addresses
> >   //  when 5-Level Paging is disabled,
> >   //  due to either unsupported by HW, or disabled by PCD.
> >   //
> >   ASSERT (PhysicalAddressBits <= 52);
> >   if (!Page5LevelSupport && (PhysicalAddressBits > 48)) {
> > PhysicalAddressBits = 48;
> >   }
> >
> >
> > > -Original Message-
> > > From: devel@edk2.groups.io  On Behalf Of Gerd
> > > Hoffmann
> > > Sent: Wednesday, May 10, 2023 3:48 PM
> > > To: devel@edk2.groups.io; Ni, Ray 
> > > Cc: Wu, Jiaxin ; Dong, Eric ;
> > Zeng,
> > > Star ; Kumar, Rahul R 
> > > Subject: Re: [edk2-devel] [PATCH v1 1/3] UefiCpuPkg/SecCore: Migrate
> page
> > > table to permanent memory
> > >
> > > On Wed, May 10, 2023 at 02:48:52AM +, Ni, Ray wrote:
> > > > Gerd,
> > > > My understanding is that when code dereferences memory address, the
> code
> > > itself is responsible for
> > > > supplying the sign-extended linear address.
> > > > The page table creation logic still maps the entire linear memory space
> > > supported by the CPU.
> > > >
> > > > Why do you think covering the half of the space is better?
> > >
> > > edk2 boot services operate on the assumption that everything is identity
> > > mapped, only runtime services know the concept of virtual addresses.
> > >
> > > The lower half of the address space can be identity-mapped (virtual
> > > address == physical address).  The upper half can not, so I think it's
> > > better for efi boot services to restrict themself to the lower half.
> > >
> > > take care,
> > >   Gerd
> > >
> > >
> > >
> > > 
> > >



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104735): https://edk2.groups.io/g/devel/message/104735
Mute This Topic: https://groups.io/mt/98780500/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 1/1] Maintainers.txt: Update reviewers and maintainers for FdtLib. Update reviewers and maintainers for FdtLib.

2023-05-11 Thread Benny Lin
Series Reviewed-by : Benny Lin 

-Original Message-
From: Guo, Gua  
Sent: Friday, May 12, 2023 10:11 AM
To: devel@edk2.groups.io
Cc: Guo, Gua ; Kinney, Michael D 
; Andrew Fish ; Leif Lindholm 
; Lin, Benny ; Chiu, Chasel 
; Lu, James 
Subject: [PATCH v1 1/1] Maintainers.txt: Update reviewers and maintainers for 
FdtLib. Update reviewers and maintainers for FdtLib.

From: Gua Guo 

Cc: Michael D Kinney 
Cc: Andrew Fish 
Cc: Leif Lindholm 
Cc: Benny Lin 
Cc: Gua Guo 
Cc: Chasel Chiu 
Cc: James Lu 
Signed-off-by: Guo Gua 
---
 Maintainers.txt | 8 
 1 file changed, 8 insertions(+)

diff --git a/Maintainers.txt b/Maintainers.txt index 30e2d2686d..97886accd5 
100644
--- a/Maintainers.txt
+++ b/Maintainers.txt
@@ -462,6 +462,14 @@ M: Prakashan Krishnadas Veliyathuparambil 
 [lauracha] R: K N Karthik 
 [karthikkabbigere1] +MdePkg: FDT related library 
instance+F: MdePkg/Library/BaseFdtLib/FdtLib.c+F: 
MdePkg/Include/Library/FdtLib.h+M: Benny Lin  
[Benny3345678]+R: Gua Guo  [gguo11837463]+R: Chasel Chiu 
 [ChaselChiu]+R: James Lu  
[jameslu8]+ NetworkPkg F: NetworkPkg/ W: 
https://github.com/tianocore/tianocore.github.io/wiki/NetworkPkg--
2.39.2.windows.1



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




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

2023-05-11 Thread Guo, Gua
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 (#104732): https://edk2.groups.io/g/devel/message/104732
Mute This Topic: https://groups.io/mt/98841640/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




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

2023-05-11 Thread Guo, Gua
From: Gua Guo 

Cc: Michael D Kinney 
Cc: Andrew Fish 
Cc: Leif Lindholm 
Cc: Benny Lin 
Cc: Gua Guo 
Cc: Chasel Chiu 
Cc: James Lu 
Signed-off-by: Guo Gua 
---
 Maintainers.txt | 8 
 1 file changed, 8 insertions(+)

diff --git a/Maintainers.txt b/Maintainers.txt
index 30e2d2686d..97886accd5 100644
--- a/Maintainers.txt
+++ b/Maintainers.txt
@@ -462,6 +462,14 @@ M: Prakashan Krishnadas Veliyathuparambil 
 [lauracha]
 R: K N Karthik  [karthikkabbigere1]
 
+MdePkg: FDT related library instance
+F: MdePkg/Library/BaseFdtLib/FdtLib.c
+F: MdePkg/Include/Library/FdtLib.h
+M: Benny Lin  [Benny3345678]
+R: Gua Guo  [gguo11837463]
+R: Chasel Chiu  [ChaselChiu]
+R: James Lu  [jameslu8]
+
 NetworkPkg
 F: NetworkPkg/
 W: https://github.com/tianocore/tianocore.github.io/wiki/NetworkPkg
-- 
2.39.2.windows.1



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




回复: [edk2-devel] [PATCH v5 2/3] OvmfPkg/Xen: export AcpiTable installation into AcpiPlatformLib

2023-05-11 Thread gaoliming via groups.io
Yes. Patch review and update are still as normal. But, the patch will be merged 
after the stable tag is created if this patch is not target for this stable 
tag. 

Thanks
Liming
> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 Rebecca Cran
> 发送时间: 2023年5月11日 21:48
> 收件人: devel@edk2.groups.io; a...@kernel.org; Corvin Köhne
> 
> 抄送: gre...@freebsd.org; Gerd Hoffmann ; Ard
> Biesheuvel ; Jiewen Yao
> ; Jordan Justen ;
> Anthony Perard ; Julien Grall 
> 主题: Re: [edk2-devel] [PATCH v5 2/3] OvmfPkg/Xen: export AcpiTable
> installation into AcpiPlatformLib
> 
> Liming’s email appeared to say that patch reviews could continue even if they
> aren’t for the upcoming release?
> 
> “ We enter into Soft Feature Freeze phase on 2023-05-08. In this phase,
> 
> the feature under review will not be allowed to be pushed. The feature
> passed review can still be merged.
> 
>  The patch review can continue without break in edk2 community. If the
> patch is sent before Soft Feature Freeze, and plans to catch this stable
> tag, the patch contributor need reply to his patch and notify edk2 community.
> If the patch is sent after Soft Feature Freeze, and plans to catch this 
> stable tag,
> please add edk2-stable202305 key words in the patch title and BZ, so the
> community know this patch target and give the feedback.
> 
>   To avoid the unnecessary changes to be merged in edk2 stable tag release,
> all edk2 maintainers' write access will be temporarily disabled until stable 
> tag
> is released on 05-26. That means edk2 maintainer can't set push label in pull
> request after 2023-05-08.
> 
>   If the change wants to catch this stable tag 202305, please follow above
> rules, then send the merge request to gaolim...@byosoft.com.cn or
> 
> michael.d.kin...@intel.com or miki.deme...@intel.com.
> 
> 
> 
>   We will help merge the code change in soft feature freeze and hard feature
> freeze phase.
> 
> Below is edk2-stable202305 tag planning Proposed Schedule
> 
> Date (00:00:00 UTC-8) Description
> 
> 2023-02-24  Beginning of development
> 2023-05-08  Soft Feature Freeze
> 2023-05-12  Hard Feature Freeze
> 2023-05-26  Release”
> 
> 
> On Thu, May 11, 2023, at 7:19 AM, Ard Biesheuvel wrote:
> > On Thu, 11 May 2023 at 15:16, Corvin Köhne  wrote:
> >>
> >> On Thu, 2023-05-11 at 07:04 -0600, Rebecca Cran wrote:
> >> > Could you cc me on _all_ of the patches in a series please?
> >> >
> >> > I seem to have been missed on this one, and only cc'd on 3/3.
> >> >
> >> >
> >>
> >> Sry, I've updated my cc list. So, you'll be included in my next update.
> >>
> >
> > We're in the middle of a soft freeze so please don't resend this until
> > after the release - thanks.
> >
> >
> >
> 
> 
> 
> 





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104731): https://edk2.groups.io/g/devel/message/104731
Mute This Topic: https://groups.io/mt/98841274/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-11 Thread Rebecca Cran

Reviewed-by: Rebecca Cran 


Thanks!


On 5/11/23 12:59 AM, Ard Biesheuvel wrote:

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)




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




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

2023-05-11 Thread gaoliming via groups.io
Ard: 
  This change is good to me.  Reviewed-by: Liming Gao

  
  Will it be merged for this stable tag?

Thanks
Liming
> -邮件原件-
> 发件人: 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 (#104729): https://edk2.groups.io/g/devel/message/104729
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 04/12] MdeModulePkg/SataControllerDxe: Fix up ASSERTS (Private != NULL)

2023-05-11 Thread Wu, Hao A
Reviewed-by: Hao A Wu 

Best Regards,
Hao Wu

> -Original Message-
> From: Pedro Falcato 
> Sent: Wednesday, May 10, 2023 12:32 AM
> To: devel@edk2.groups.io
> Cc: Laszlo Ersek ; Pedro Falcato
> ; Wang, Jian J ; Gao,
> Liming ; Wu, Hao A ; Ni,
> Ray ; Mike Maslenkin 
> Subject: [PATCH v2 04/12] MdeModulePkg/SataControllerDxe: Fix up ASSERTS
> (Private != NULL)
> 
> ASSERT (Private != NULL) (where Private = CR(...)) is ineffective as
> CR(Ptr, Type, Member, Sig) either returns Ptr - offsetof(Type, Member),
> or ASSERTS on the signature, so it's unlikely to ever return NULL
> (must be passed a pointer = member's offset, or in this case, 0x4).
> 
> ASSERT on This != NULL instead.
> 
> Cc: Jian J Wang 
> Cc: Liming Gao 
> Cc: Hao A Wu 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Cc: Mike Maslenkin 
> Signed-off-by: Pedro Falcato 
> ---
>  MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c | 9 -
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
> b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
> index f0ffd311d7b9..ea0116071c6a 100644
> --- a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
> +++ b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
> @@ -611,7 +611,6 @@ SataControllerStop (
>}
> 
>Private = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (IdeInit);
> -  ASSERT (Private != NULL);
> 
>//
>// Uninstall the IDE Controller Init Protocol from this instance
> @@ -745,8 +744,8 @@ IdeInitGetChannelInfo (
>  {
>EFI_SATA_CONTROLLER_PRIVATE_DATA  *Private;
> 
> +  ASSERT (This != NULL);
>Private = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This);
> -  ASSERT (Private != NULL);
> 
>if (Channel < This->ChannelCount) {
>  *Enabled= TRUE;
> @@ -845,8 +844,8 @@ IdeInitSubmitData (
>EFI_SATA_CONTROLLER_PRIVATE_DATA  *Private;
>UINTN DeviceIndex;
> 
> +  ASSERT (This != NULL);
>Private = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This);
> -  ASSERT (Private != NULL);
> 
>if ((Channel >= This->ChannelCount) || (Device >= Private->DeviceCount)) {
>  return EFI_INVALID_PARAMETER;
> @@ -924,8 +923,8 @@ IdeInitDisqualifyMode (
>EFI_SATA_CONTROLLER_PRIVATE_DATA  *Private;
>UINTN DeviceIndex;
> 
> +  ASSERT (This != NULL);
>Private = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This);
> -  ASSERT (Private != NULL);
> 
>if ((Channel >= This->ChannelCount) || (BadModes == NULL) || (Device >=
> Private->DeviceCount)) {
>  return EFI_INVALID_PARAMETER;
> @@ -1017,8 +1016,8 @@ IdeInitCalculateMode (
>EFI_STATUSStatus;
>UINTN DeviceIndex;
> 
> +  ASSERT (This != NULL);
>Private = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This);
> -  ASSERT (Private != NULL);
> 
>if ((Channel >= This->ChannelCount) || (SupportedModes == NULL) ||
> (Device >= Private->DeviceCount)) {
>  return EFI_INVALID_PARAMETER;
> --
> 2.40.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104728): https://edk2.groups.io/g/devel/message/104728
Mute This Topic: https://groups.io/mt/98787857/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 02/12] MdeModulePkg/SataControllerDxe: Log expected errors at DEBUG_INFO level

2023-05-11 Thread Wu, Hao A
Reviewed-by: Hao A Wu 

Best Regards,
Hao Wu

> -Original Message-
> From: Pedro Falcato 
> Sent: Wednesday, May 10, 2023 12:32 AM
> To: devel@edk2.groups.io
> Cc: Laszlo Ersek ; Pedro Falcato
> ; Wang, Jian J ; Gao,
> Liming ; Wu, Hao A ; Ni,
> Ray 
> Subject: [PATCH v2 02/12] MdeModulePkg/SataControllerDxe: Log expected
> errors at DEBUG_INFO level
> 
> When a UEFI_DRIVER attempts to open a protocol interface with BY_DRIVER
> attribute that it already has open with BY_DRIVER attribute,
> OpenProtocol() returns EFI_ALREADY_STARTED. This is not an error. The
> UEFI-2.7 spec currently says,
> 
> > EFI_ALREADY_STARTED -- Attributes is BY_DRIVER and there is an item on
> >the open list with an attribute of BY_DRIVER
> >whose agent handle is the same as AgentHandle.
> 
> Downgrade the log mask for this one condition to DEBUG_INFO, in
> SataControllerStart(). This will match the log mask of the other two
> informative messages in this function.
> 
> (ported from commit 5dfba97)
> 
> Cc: Jian J Wang 
> Cc: Liming Gao 
> Cc: Hao A Wu 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Signed-off-by: Pedro Falcato 
> ---
>  .../Bus/Pci/SataControllerDxe/SataController.c| 15 +--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
> b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
> index d67a3e69f649..277bc6182db6 100644
> --- a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
> +++ b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
> @@ -358,10 +358,12 @@ SataControllerStart (
>UINTN TotalCount;
>UINT64Supports;
>UINT8 MaxPortNumber;
> +  UINTN BailLogMask;
> 
>DEBUG ((DEBUG_INFO, "SataControllerStart start\n"));
> 
> -  Private = NULL;
> +  Private = NULL;
> +  BailLogMask = DEBUG_ERROR;
> 
>//
>// Now test and open PCI I/O Protocol
> @@ -375,6 +377,15 @@ SataControllerStart (
>EFI_OPEN_PROTOCOL_BY_DRIVER
>);
>if (EFI_ERROR (Status)) {
> +if (Status == EFI_ALREADY_STARTED) {
> +  //
> +  // This is an expected condition for OpenProtocol() / BY_DRIVER, in a
> +  // DriverBindingStart() member function; degrade the log mask to
> +  // DEBUG_INFO in order to reduce log pollution.
> +  //
> +  BailLogMask = DEBUG_INFO;
> +}
> +
>  goto Bail;
>}
> 
> @@ -555,7 +566,7 @@ FreeSataPrivate:
>  ClosePciIo:
>gBS->CloseProtocol (Controller, , This-
> >DriverBindingHandle, Controller);
>  Bail:
> -  DEBUG ((DEBUG_ERROR, "SataControllerStart error return status = %r\n",
> Status));
> +  DEBUG ((BailLogMask, "SataControllerStart error return status = %r\n",
> Status));
>return Status;
>  }
> 
> --
> 2.40.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104727): https://edk2.groups.io/g/devel/message/104727
Mute This Topic: https://groups.io/mt/98787855/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 01/12] MdeModulePkg/SataControllerDxe: Clean up error handling in Start()

2023-05-11 Thread Wu, Hao A
Reviewed-by: Hao A Wu 

Best Regards,
Hao Wu

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Pedro
> Falcato
> Sent: Wednesday, May 10, 2023 12:32 AM
> To: devel@edk2.groups.io
> Cc: Laszlo Ersek ; Pedro Falcato
> ; Wang, Jian J ; Gao,
> Liming ; Wu, Hao A ; Ni,
> Ray 
> Subject: [edk2-devel] [PATCH v2 01/12] MdeModulePkg/SataControllerDxe:
> Clean up error handling in Start()
> 
> Clean up error handling using cascading labels + goto.
> 
> (port of commit 379b179 + bcab714)
> 
> Cc: Jian J Wang 
> Cc: Liming Gao 
> Cc: Hao A Wu 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Signed-off-by: Pedro Falcato 
> ---
>  .../Pci/SataControllerDxe/SataController.c| 80 ---
>  1 file changed, 35 insertions(+), 45 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
> b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
> index f661efaec7e9..d67a3e69f649 100644
> --- a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
> +++ b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
> @@ -375,8 +375,7 @@ SataControllerStart (
>EFI_OPEN_PROTOCOL_BY_DRIVER
>);
>if (EFI_ERROR (Status)) {
> -DEBUG ((DEBUG_ERROR, "SataControllerStart error. return status = %r\n",
> Status));
> -return Status;
> +goto Bail;
>}
> 
>//
> @@ -385,7 +384,7 @@ SataControllerStart (
>Private = AllocateZeroPool (sizeof (EFI_SATA_CONTROLLER_PRIVATE_DATA));
>if (Private == NULL) {
>  Status = EFI_OUT_OF_RESOURCES;
> -goto Done;
> +goto ClosePciIo;
>}
> 
>//
> @@ -412,7 +411,7 @@ SataControllerStart (
>  >OriginalPciAttributes
>  );
>if (EFI_ERROR (Status)) {
> -goto Done;
> +goto FreeSataPrivate;
>}
> 
>DEBUG ((
> @@ -428,7 +427,7 @@ SataControllerStart (
>  
>  );
>if (EFI_ERROR (Status)) {
> -goto Done;
> +goto FreeSataPrivate;
>}
> 
>DEBUG ((DEBUG_INFO, "Supported PCI Attributes = 0x%llx\n", Supports));
> @@ -441,7 +440,7 @@ SataControllerStart (
> NULL
> );
>if (EFI_ERROR (Status)) {
> -goto Done;
> +goto FreeSataPrivate;
>}
> 
>DEBUG ((DEBUG_INFO, "Enabled PCI Attributes = 0x%llx\n", Supports));
> @@ -456,7 +455,7 @@ SataControllerStart (
>  );
>if (EFI_ERROR (Status)) {
>  ASSERT (FALSE);
> -goto Done;
> +goto RestorePciAttributes;
>}
> 
>if (IS_PCI_IDE ()) {
> @@ -470,7 +469,7 @@ SataControllerStart (
>  DEBUG ((DEBUG_INFO, "Ports Implemented(PI) = 0x%x\n", Data32));
>  if (Data32 == 0) {
>Status = EFI_UNSUPPORTED;
> -  goto Done;
> +  goto RestorePciAttributes;
>  }
> 
>  MaxPortNumber = 31;
> @@ -502,19 +501,19 @@ SataControllerStart (
>Private->DisqualifiedModes = AllocateZeroPool ((sizeof
> (EFI_ATA_COLLECTIVE_MODE)) * TotalCount);
>if (Private->DisqualifiedModes == NULL) {
>  Status = EFI_OUT_OF_RESOURCES;
> -goto Done;
> +goto RestorePciAttributes;
>}
> 
>Private->IdentifyData = AllocateZeroPool ((sizeof (EFI_IDENTIFY_DATA)) *
> TotalCount);
>if (Private->IdentifyData == NULL) {
>  Status = EFI_OUT_OF_RESOURCES;
> -goto Done;
> +goto FreeDisqualifiedModes;
>}
> 
>Private->IdentifyValid = AllocateZeroPool ((sizeof (BOOLEAN)) * 
> TotalCount);
>if (Private->IdentifyValid == NULL) {
>  Status = EFI_OUT_OF_RESOURCES;
> -goto Done;
> +goto FreeIdentifyData;
>}
> 
>//
> @@ -527,46 +526,37 @@ SataControllerStart (
>NULL
>);
> 
> -Done:
>if (EFI_ERROR (Status)) {
> -gBS->CloseProtocol (
> -   Controller,
> -   ,
> -   This->DriverBindingHandle,
> -   Controller
> -   );
> -if (Private != NULL) {
> -  if (Private->DisqualifiedModes != NULL) {
> -FreePool (Private->DisqualifiedModes);
> -  }
> -
> -  if (Private->IdentifyData != NULL) {
> -FreePool (Private->IdentifyData);
> -  }
> -
> -  if (Private->IdentifyValid != NULL) {
> -FreePool (Private->IdentifyValid);
> -  }
> -
> -  if (Private->PciAttributesChanged) {
> -//
> -// Restore original PCI attributes
> -//
> -PciIo->Attributes (
> - PciIo,
> - EfiPciIoAttributeOperationSet,
> - Private->OriginalPciAttributes,
> - NULL
> - );
> -  }
> -
> -  FreePool (Private);
> -}
> +goto FreeIdentifyValid;
>}
> 
>DEBUG ((DEBUG_INFO, "SataControllerStart end with %r\n", Status));
> 
>return Status;
> +
> +FreeIdentifyValid:
> +  FreePool (Private->IdentifyValid);
> +FreeIdentifyData:
> +  FreePool (Private->IdentifyData);
> +FreeDisqualifiedModes:
> +  FreePool (Private->DisqualifiedModes);
> +RestorePciAttributes:
> +  

Re: [edk2-devel] [PATCH v2 03/12] MdeModulePkg/SataControllerDxe: Remove useless null check

2023-05-11 Thread Wu, Hao A
Reviewed-by: Hao A Wu 

Best Regards,
Hao Wu

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Pedro
> Falcato
> Sent: Wednesday, May 10, 2023 12:32 AM
> To: devel@edk2.groups.io
> Cc: Laszlo Ersek ; Pedro Falcato
> ; Wang, Jian J ; Gao,
> Liming ; Wu, Hao A ; Ni,
> Ray ; Mike Maslenkin 
> Subject: [edk2-devel] [PATCH v2 03/12] MdeModulePkg/SataControllerDxe:
> Remove useless null check
> 
> ASSERT (Private != NULL) already covers this check.
> See commit 81310a6.
> 
> Cc: Jian J Wang 
> Cc: Liming Gao 
> Cc: Hao A Wu 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Cc: Mike Maslenkin 
> Signed-off-by: Pedro Falcato 
> ---
>  .../Pci/SataControllerDxe/SataController.c| 44 +--
>  1 file changed, 21 insertions(+), 23 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
> b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
> index 277bc6182db6..f0ffd311d7b9 100644
> --- a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
> +++ b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
> @@ -626,34 +626,32 @@ SataControllerStop (
>  return Status;
>}
> 
> -  if (Private != NULL) {
> -if (Private->DisqualifiedModes != NULL) {
> -  FreePool (Private->DisqualifiedModes);
> -}
> -
> -if (Private->IdentifyData != NULL) {
> -  FreePool (Private->IdentifyData);
> -}
> +  if (Private->DisqualifiedModes != NULL) {
> +FreePool (Private->DisqualifiedModes);
> +  }
> 
> -if (Private->IdentifyValid != NULL) {
> -  FreePool (Private->IdentifyValid);
> -}
> +  if (Private->IdentifyData != NULL) {
> +FreePool (Private->IdentifyData);
> +  }
> 
> -if (Private->PciAttributesChanged) {
> -  //
> -  // Restore original PCI attributes
> -  //
> -  Private->PciIo->Attributes (
> -Private->PciIo,
> -EfiPciIoAttributeOperationSet,
> -Private->OriginalPciAttributes,
> -NULL
> -);
> -}
> +  if (Private->IdentifyValid != NULL) {
> +FreePool (Private->IdentifyValid);
> +  }
> 
> -FreePool (Private);
> +  if (Private->PciAttributesChanged) {
> +//
> +// Restore original PCI attributes
> +//
> +Private->PciIo->Attributes (
> +  Private->PciIo,
> +  EfiPciIoAttributeOperationSet,
> +  Private->OriginalPciAttributes,
> +  NULL
> +  );
>}
> 
> +  FreePool (Private);
> +
>//
>// Close protocols opened by Sata Controller driver
>//
> --
> 2.40.1
> 
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104725): https://edk2.groups.io/g/devel/message/104725
Mute This Topic: https://groups.io/mt/98787856/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 0/3] RISC-V SBI-backed SerialLib

2023-05-11 Thread Andrei Warkentin
Hi Michael,

When can you or one of the MdePkg maintainers merge the SBI SerialLib patch set?

A

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Andrei
> Warkentin
> Sent: Tuesday, April 25, 2023 2:27 PM
> To: Kinney, Michael D ; devel@edk2.groups.io
> Cc: Sunil V L 
> Subject: Re: [edk2-devel] [PATCH v7 0/3] RISC-V SBI-backed SerialLib
> 
> Thanks for the review. I believe this patch set is ready for merging. Sunil 
> had
> one comment on the contents of the UNI file, which I clarified. Sunil,
> anything else you wanted from this patch set or is it good to go?
> 
> A
> 
> > -Original Message-
> > From: Kinney, Michael D 
> > Sent: Friday, April 7, 2023 5:09 PM
> > To: devel@edk2.groups.io; Warkentin, Andrei
> > 
> > Cc: Kinney, Michael D 
> > Subject: RE: [edk2-devel] [PATCH v7 0/3] RISC-V SBI-backed SerialLib
> >
> > Reviewed-by: Michael D Kinney 
> >
> >
> > > -Original Message-
> > > From: devel@edk2.groups.io  On Behalf Of
> > > Andrei Warkentin
> > > Sent: Friday, April 7, 2023 2:44 PM
> > > To: devel@edk2.groups.io
> > > Cc: Warkentin, Andrei 
> > > Subject: [edk2-devel] [PATCH v7 0/3] RISC-V SBI-backed SerialLib
> > >
> > > Hello,
> > >
> > > Here are three patches that provide a SerialLib backed by SBI console.
> > > Both legacy and DBCN mechanisms are supported in various execution
> > > environments and have been tested with UART and HTIF consoles.
> > >
> > > MdePkg reviewers: please review MdePkg.dsc changes.
> > >
> > > This is also available at
> > > https://github.com/andreiw/edk2-rv-wip/tree/patchset-2
> > >
> > > A CI run is at https://github.com/tianocore/edk2/pull/4252
> > >
> > > Compared to v6:
> > >
> > > - Unify the two SerialLib implementations under one directory and
> > >   factor out the code somewhat.
> > > - Sunil's feedback on correctness.
> > >
> > > Compared to v5:
> > >
> > > Rename components as per Michael Kinney's suggestions.
> > >
> > > Compared to v4:
> > >
> > > (not sent out). CC MdePkg maintainers, fix copyright date in SecMain.c.
> > >
> > > Compared to v3
> > >
> > > EccCheck fixes. Add MdePkg infs to DSC.
> > >
> > > Compared to v2:
> > > - Probes legacy extension as well.
> > > - Encode supported module types in the INF file. This is done using
> > LIBRARY_CLASS,
> > >   as MODULE_TYPE cannot encode multiple types, so MODULE_TYPE is
> > retained as BASE.
> > > - Update INF version and generate brand new GUIDs instead of editing
> > them.
> > > - Checked that all patches retain ^M endings.
> > >
> > > Andrei Warkentin (3):
> > >   MdePkg: BaseRiscVSbiLib: make more useful to consumers
> > >   MdePkg: add SBI-based SerialPortLib for RISC-V
> > >   OvmfPkg: RiscVVirt: Add missing SerialPortInitialize to Sec
> > >
> > >  MdePkg/MdePkg.dsc
> > >|   2 +
> > >
> >
> MdePkg/Library/BaseSerialPortLibRiscVSbiLib/BaseSerialPortLibRiscVSbiLib.in
> > f|  40 +++
> > >
> > MdePkg/Library/BaseSerialPortLibRiscVSbiLib/BaseSerialPortLibRiscVSbiL
> > ibRa
> > m.inf |  37 +++
> > >  OvmfPkg/RiscVVirt/Sec/SecMain.inf
> > >|   1 +
> > >  MdePkg/Include/Library/BaseRiscVSbiLib.h 
> > >|  40
> ++-
> > >  MdePkg/Library/BaseSerialPortLibRiscVSbiLib/Common.h
> |
> > 41 +++
> > >  OvmfPkg/RiscVVirt/Sec/SecMain.h  
> > >|   1 +
> > >  MdePkg/Library/BaseRiscVSbiLib/BaseRiscVSbiLib.c 
> > >|   3
> > +-
> > >
> > MdePkg/Library/BaseSerialPortLibRiscVSbiLib/BaseSerialPortLibRiscVSbiL
> > ib.c
> > | 208 ++
> > >
> >
> MdePkg/Library/BaseSerialPortLibRiscVSbiLib/BaseSerialPortLibRiscVSbiLibRa
> > m.c   | 289 
> > >  MdePkg/Library/BaseSerialPortLibRiscVSbiLib/Common.c
> |
> > 132 +
> > >  OvmfPkg/RiscVVirt/Sec/SecMain.c  
> > >|   4 +-
> > >
> >
> MdePkg/Library/BaseSerialPortLibRiscVSbiLib/BaseSerialPortLibRiscVSbiLib.u
> > ni|  16 ++
> > >  13 files changed, 808 insertions(+), 6 deletions(-)  create mode
> > > 100644
> > > MdePkg/Library/BaseSerialPortLibRiscVSbiLib/BaseSerialPortLibRiscVSb
> > > iL
> > > ib.inf  create mode 100644
> > > MdePkg/Library/BaseSerialPortLibRiscVSbiLib/BaseSerialPortLibRiscVSb
> > > iL
> > > ibRam.inf  create mode 100644
> > > MdePkg/Library/BaseSerialPortLibRiscVSbiLib/Common.h
> > >  create mode 100644
> > > MdePkg/Library/BaseSerialPortLibRiscVSbiLib/BaseSerialPortLibRiscVSb
> > > iL
> > > ib.c  create mode 100644
> > > MdePkg/Library/BaseSerialPortLibRiscVSbiLib/BaseSerialPortLibRiscVSb
> > > iL
> > > ibRam.c  create mode 100644
> > > MdePkg/Library/BaseSerialPortLibRiscVSbiLib/Common.c
> > >  create mode 100644
> > > MdePkg/Library/BaseSerialPortLibRiscVSbiLib/BaseSerialPortLibRiscVSb
> > > iL
> > > ib.uni
> > >
> > > --
> > > 2.25.1
> > >
> > >
> > >
> > >
> > >
> 
> 
> 
> 
> 




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

2023-05-11 Thread Mike Maslenkin
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/PlatformBootManage
> > +++ 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 Size;
> > +  UINT32AuthenticationStatus;
> > +  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
> > +  VOID  *Buffer;
> > +
> > +  Status = EFI_SUCCESS;
> > +  gBS->LocateHandleBuffer (
> > + ByProtocol,
> > + ,
> > + NULL,
> > + ,
> > + 
> > + );
> > +
> > +  for (Index = 0; Index < FvHandleCount; Index++) {
> > +Buffer = NULL;
> > +Size   = 0;
> > +gBS->HandleProtocol (
> > +   FvHandleBuffer[Index],
> > +   ,
> > +   

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

2023-05-11 Thread Guo Dong

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/PlatformBootManage
> +++ 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 Size;
> +  UINT32AuthenticationStatus;
> +  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
> +  VOID  *Buffer;
> +
> +  Status = EFI_SUCCESS;
> +  gBS->LocateHandleBuffer (
> + ByProtocol,
> + ,
> + NULL,
> + ,
> + 
> + );
> +
> +  for (Index = 0; Index < FvHandleCount; Index++) {
> +Buffer = NULL;
> +Size   = 0;
> +gBS->HandleProtocol (
> +   FvHandleBuffer[Index],
> +   ,
> +   (VOID **) 
> +   );
> +Status = Fv->ReadSection (
> +   Fv,
> +   ,
> +   EFI_SECTION_PE32,
> +   0,
> +   ,
> +   ,
> +   
> +   );
> +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 +176,12 @@ 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 +312,7 @@ PlatformBootManagerAfterConsole (
>//
>// Register UEFI Shell
>

[edk2-devel] [edk2-platforms][PATCH 1/6] AmpereAltraPkg: Add PCIe Hot Plug library

2023-05-11 Thread Minh Nguyen via groups.io
From: Vu Nguyen 

This adds PCIe Hot Plug library to support Hot Plug
feature and specific procedures for setting different
Portmap tables (GPIO pins used for PCIe reset).

Signed-off-by: Minh Nguyen 
---
 Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec|   8 
+-
 Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec|  13 +
 Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc|   1 +
 Platform/Ampere/JadePkg/Jade.dsc|  66 

 Silicon/Ampere/AmpereAltraPkg/Library/PcieHotPlugLib/PcieHotPlugLib.inf |  37 
++
 Silicon/Ampere/AmpereAltraPkg/Include/Library/PcieHotPlugLib.h  | 162 

 Silicon/Ampere/AmpereSiliconPkg/Include/Library/PcieHotPlugPortMapLib.h |  81 

 Silicon/Ampere/AmpereAltraPkg/Library/PcieHotPlugLib/PcieHotPlugLib.c   | 397 

 8 files changed, 764 insertions(+), 1 deletion(-)

diff --git a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec 
b/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec
index d795c9229691..d4881eaed692 100644
--- a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec
+++ b/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec
@@ -1,6 +1,6 @@
 ## @file
 #
-# Copyright (c) 2020-2021, Ampere Computing LLC. All rights reserved.
+# Copyright (c) 2020-2023, Ampere Computing LLC. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -49,6 +49,9 @@ [LibraryClasses]
   ##  @libraryclass  Defines a set of methods to initialize Pcie
   Ac01PcieLib|Silicon/Ampere/AmpereAltraPkg/Include/Library/Ac01PcieLib.h
 
+  ##  @libraryclass  Defines a set of methods to start Hot plug feature
+  PcieHotPlugLib|Silicon/Ampere/AmpereAltraPkg/Include/Library/PcieHotPlugLib.h
+
 [Guids]
   ## NVParam MM GUID
   gNVParamMmGuid   = { 0xE4AC5024, 0x29BE, 0x4ADC, { 0x93, 0x36, 
0x87, 0xB5, 0xA0, 0x76, 0x23, 0x2D } }
@@ -70,3 +73,6 @@ [Guids]
 
   ## Include/Guid/AcpiConfigHii.h
   gAcpiConfigFormSetGuid = { 0x0ceb6764, 0xd415, 0x4b01, { 0xa8, 0x43, 0xd1, 
0x01, 0xbc, 0xb0, 0xd8, 0x29 } }
+
+  ## PCIe Hot Plug GUID
+  gPcieHotPlugGuid = { 0x5598273c, 0x11ea, 0xa496, { 0x42, 0x02, 0x37, 0xbb, 
0x02, 0x00, 0x13, 0xac } }
diff --git a/Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec 
b/Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec
index 625a9b2b1e89..9259956c7caa 100644
--- a/Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec
+++ b/Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec
@@ -80,3 +80,16 @@ [PcdsFixedAtBuild, PcdsDynamic, PcdsDynamicEx]
   #
   # SMBIOS Type 0 - BIOS Information
   
gAmpereTokenSpaceGuid.PcdSmbiosTables0BiosReleaseDate|"MM/DD/"|VOID*|0xB002
 # Must follow this MM/DD/ SMBIOS date format
+
+  # Pcie HotPlug reset map
+  gAmpereTokenSpaceGuid.PcdPcieHotPlugGpioResetMap|0x0|UINT8|0xB00A
+
+  #
+  # Pcie HotPlug Port Map table
+  #
+  
gAmpereTokenSpaceGuid.PcdPcieHotPlugPortMapTable|{0x00}|PCIE_HOT_PLUG_PORT_MAP_TABLE|0xB00B
 {
+
+  Library/PcieHotPlugPortMapLib.h
+
+  Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec
+  }
diff --git a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc 
b/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc
index 9275e0053af6..8cb2a3fe6422 100644
--- a/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc
+++ b/Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc
@@ -81,6 +81,7 @@ [LibraryClasses.common]
   NVParamLib|Silicon/Ampere/AmpereAltraPkg/Library/NVParamLib/NVParamLib.inf
   
MailboxInterfaceLib|Silicon/Ampere/AmpereAltraPkg/Library/MailboxInterfaceLib/MailboxInterfaceLib.inf
   
SystemFirmwareInterfaceLib|Silicon/Ampere/AmpereAltraPkg/Library/SystemFirmwareInterfaceLib/SystemFirmwareInterfaceLib.inf
+  
PcieHotPlugLib|Silicon/Ampere/AmpereAltraPkg/Library/PcieHotPlugLib/PcieHotPlugLib.inf
   PciePhyLib|Silicon/Ampere/AmpereAltraBinPkg/Library/PciePhyLib/PciePhyLib.inf
   Ac01PcieLib|Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/Ac01PcieLib.inf
   
AmpereCpuLib|Silicon/Ampere/AmpereAltraPkg/Library/AmpereCpuLib/AmpereCpuLib.inf
diff --git a/Platform/Ampere/JadePkg/Jade.dsc b/Platform/Ampere/JadePkg/Jade.dsc
index f14d286cdfb8..a6b5fa3ca2d3 100644
--- a/Platform/Ampere/JadePkg/Jade.dsc
+++ b/Platform/Ampere/JadePkg/Jade.dsc
@@ -100,7 +100,73 @@ [PcdsFeatureFlag.common]
   #
   gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
 
+  #
+  # Flag to indicate option of using default or specific platform Port Map 
table
+  #
+  gAmpereTokenSpaceGuid.PcdPcieHotPlugPortMapTable.UseDefaultConfig|TRUE
+
 [PcdsFixedAtBuild]
+  gAmpereTokenSpaceGuid.PcdPcieHotPlugGpioResetMap|0x3F
+
+  #
+  # Setting Portmap table
+  #
+  #   * Elements of array:
+  # - 0:  Index of Portmap entry in Portmap table structure (Vport).
+  # - 1:  Socket number (Socket).
+  # - 2:  Root complex port for each Portmap entry (RcaPort).
+  # - 3:  Root complex sub-port for each Portmap entry (RcaSubPort).
+  # - 4:  Select 

[edk2-devel] [edk2-platforms][PATCH 3/3] AmpereAltraPkg: Add retry logic when PCIe card is present

2023-05-11 Thread Minh Nguyen via groups.io
From: Tinh Nguyen 

Add PCIe link retry logic. If the card is detected to be present,
allow a retry for 3 times.

When the link is down, check if the LTSSMEN bit is cleared.
Based on Altra PCIe IP, the LTSSMEN bit is cleared from 1 to 0
if there is a surprising link down.
This indicates that a card is present.

Signed-off-by: Minh Nguyen 
---
 Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c 
b/Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c
index d797442d9fbc..9cc059788581 100644
--- a/Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c
+++ b/Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c
@@ -1769,7 +1769,11 @@ Ac01PcieCoreUpdateLink (
   } else {
 FailedPciePtr[*FailedPcieCount] = PcieIndex;
 *FailedPcieCount += 1;
-*IsNextRoundNeeded = !(*IsNextRoundNeeded) ? 
Ac01PcieCoreCheckCardPresent (Pcie) : TRUE;
+
+if (Ac01PcieCoreCheckCardPresent (Pcie)) {
+  *IsNextRoundNeeded = TRUE;
+  DEBUG ((DEBUG_INFO, "PCIE%d.%d Link retry\n", RootComplex->ID, 
PcieIndex));
+}
   }
 }
   }
-- 
2.39.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104713): https://edk2.groups.io/g/devel/message/104713
Mute This Topic: https://groups.io/mt/98831765/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 0/6] Support NVMe Hot Plug feature for Ampere Altra and Ampere Altra Max

2023-05-11 Thread Minh Nguyen via groups.io
These patches support NVMe Hot Plug feature for Ampere Altra and Ampere Altra 
Max.

Minh Nguyen (2):
  AmpereAltraPkg: Add Hot Plug Slot Capable during PCIe port
initialization
  AmpereAltraPkg: Change PCIe Amba Link Timeout value

Vu Nguyen (4):
  AmpereAltraPkg: Add PCIe Hot Plug library
  JadePkg: Support ACPI tables for Hot Plug of Ampere Altra
  JadePkg: Support ACPI tables for Hot Plug of Ampere Altra Max
  AmpereAltraPkg: Enable NVMe Hot Plug feature

 Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dec|8 
+-
 Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec|   13 
+
 Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc|1 
+
 Platform/Ampere/JadePkg/Jade.dsc|   66 
++
 Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.inf   |3 
+-
 Silicon/Ampere/AmpereAltraPkg/Library/PcieHotPlugLib/PcieHotPlugLib.inf |   37 
+
 Silicon/Ampere/AmpereAltraPkg/Include/Library/PcieHotPlugLib.h  |  162 
+++
 Silicon/Ampere/AmpereSiliconPkg/Include/Library/PcieHotPlugPortMapLib.h |   81 
++
 Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.c |3 
+
 Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c|   13 
+-
 Silicon/Ampere/AmpereAltraPkg/Library/PcieHotPlugLib/PcieHotPlugLib.c   |  397 

 Platform/Ampere/JadePkg/Ac02AcpiTables/CommonDevices.asi|   24 
+
 Platform/Ampere/JadePkg/Ac02AcpiTables/Dsdt.asl |  511 
++
 Platform/Ampere/JadePkg/Ac02AcpiTables/MHPP.asi |   92 
++
 Platform/Ampere/JadePkg/Ac02AcpiTables/PCI-S0.asi   |  545 
++
 Platform/Ampere/JadePkg/Ac02AcpiTables/PCI-S1.asi   | 1072 
+++
 Platform/Ampere/JadePkg/AcpiTables/Dsdt.asl |  499 
-
 Platform/Ampere/JadePkg/AcpiTables/MHPP.asi |  127 
+++
 Platform/Ampere/JadePkg/AcpiTables/PCI-S0.asi   |  548 
+-
 Platform/Ampere/JadePkg/AcpiTables/PCI-S1.asi   | 1074 
+++-
 20 files changed, 5269 insertions(+), 7 deletions(-)
 create mode 100644 
Silicon/Ampere/AmpereAltraPkg/Library/PcieHotPlugLib/PcieHotPlugLib.inf
 create mode 100644 
Silicon/Ampere/AmpereAltraPkg/Include/Library/PcieHotPlugLib.h
 create mode 100644 
Silicon/Ampere/AmpereSiliconPkg/Include/Library/PcieHotPlugPortMapLib.h
 create mode 100644 
Silicon/Ampere/AmpereAltraPkg/Library/PcieHotPlugLib/PcieHotPlugLib.c
 create mode 100644 Platform/Ampere/JadePkg/Ac02AcpiTables/MHPP.asi
 create mode 100644 Platform/Ampere/JadePkg/AcpiTables/MHPP.asi

-- 
2.39.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104714): https://edk2.groups.io/g/devel/message/104714
Mute This Topic: https://groups.io/mt/98831766/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 6/6] AmpereAltraPkg: Enable NVMe Hot Plug feature

2023-05-11 Thread Minh Nguyen via groups.io
From: Vu Nguyen 

This enables NVMe Hot Plug feature after finishing
PCIe set up. This helps to detect NVMe disk when
it's removed or inserted into its slot.

Signed-off-by: Minh Nguyen 
---
 Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.inf | 3 ++-
 Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.c   | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.inf 
b/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.inf
index 32d60bec1440..f9d5c927fca3 100644
--- a/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.inf
+++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.inf
@@ -1,6 +1,6 @@
 ## @file
 #
-# Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.
+# Copyright (c) 2020 - 2023, Ampere Computing LLC. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -30,6 +30,7 @@ [LibraryClasses]
   BoardPcieLib
   DebugLib
   HobLib
+  PcieHotPlugLib
   PeimEntryPoint
   PeiServicesLib
 
diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.c 
b/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.c
index 598a2e64d02f..bf4395d48d40 100644
--- a/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.c
+++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/PcieInitPei.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -207,6 +208,8 @@ PcieInitEntry (
 
   Ac01PcieCorePostSetupRC (mRootComplexList);
 
+  PcieHotPlugStart ();
+
   //
   // Build Root Complex info Hob
   //
-- 
2.39.0



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




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

2023-05-11 Thread neiljay
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


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104721): https://edk2.groups.io/g/devel/message/104721
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] [edk2-platforms][PATCH 5/6] JadePkg: Support ACPI tables for Hot Plug of Ampere Altra Max

2023-05-11 Thread Minh Nguyen via groups.io
From: Vu Nguyen 

This adds necessary changes of ACPI tables and defines the memory
region between OS and Trusted Firmware-A for supporting Hot Plug
of Ampere Altra Max.

Signed-off-by: Minh Nguyen 
---
 Platform/Ampere/JadePkg/Ac02AcpiTables/CommonDevices.asi |   24 +
 Platform/Ampere/JadePkg/Ac02AcpiTables/Dsdt.asl  |  511 ++
 Platform/Ampere/JadePkg/Ac02AcpiTables/MHPP.asi  |   92 ++
 Platform/Ampere/JadePkg/Ac02AcpiTables/PCI-S0.asi|  545 ++
 Platform/Ampere/JadePkg/Ac02AcpiTables/PCI-S1.asi| 1072 

 5 files changed, 2244 insertions(+)

diff --git a/Platform/Ampere/JadePkg/Ac02AcpiTables/CommonDevices.asi 
b/Platform/Ampere/JadePkg/Ac02AcpiTables/CommonDevices.asi
index 17ecd52a553f..73804cab81b5 100644
--- a/Platform/Ampere/JadePkg/Ac02AcpiTables/CommonDevices.asi
+++ b/Platform/Ampere/JadePkg/Ac02AcpiTables/CommonDevices.asi
@@ -174,7 +174,16 @@ Device(GED0) {
 }
 Name(_CRS, ResourceTemplate () {
 Interrupt(ResourceConsumer, Level, ActiveHigh, Exclusive) { 84 } // 
GHES
+Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive) { 44 } // 
PCIe Hot Plug Doorbell Insertion & Ejection (DBNS4 -> GIC-IRQS44)
 })
+
+// @DBN4 agent base address for HP PCIe insertion/ejection event: 
0x1000.0054.4000
+OperationRegion(DBN4, SystemMemory, 0x10544010, 20)
+Field (DBN4, DWordAcc, NoLock, Preserve) {
+DOUT, 32, // event and PCIe port information at offset 0x10
+offset (0x10),
+STA4, 32, // interrupt status at offset 0x20
+}
 }
 
 // Shutdown button using GED.
@@ -511,3 +520,18 @@ Device(NVDR) {
  }
}
 }
+
+//
+// LED Device
+Device(LED) {
+  Name(_HID, "AMPC0008")
+  Name(_CCA, ONE)
+  Name(_STR, Unicode("Altra LED Device"))
+
+  Name (_DSD, Package () {
+ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"),
+Package () {
+  Package () { "uuid", Package (4) { 0x5598273c, 0xa49611ea, 0xbb370242, 
0xac130002 }},
+}
+  })
+}
diff --git a/Platform/Ampere/JadePkg/Ac02AcpiTables/Dsdt.asl 
b/Platform/Ampere/JadePkg/Ac02AcpiTables/Dsdt.asl
index ce12272f961d..f2977d4e58a8 100644
--- a/Platform/Ampere/JadePkg/Ac02AcpiTables/Dsdt.asl
+++ b/Platform/Ampere/JadePkg/Ac02AcpiTables/Dsdt.asl
@@ -12,8 +12,519 @@ DefinitionBlock("Dsdt.aml", "DSDT", 0x02, "Ampere", "Jade", 
1) {
   Name(\BDMD, "Altra Max Jade Board")
   Name(AERF, 0)  // PCIe AER Firmware-First
 
+  Include ("MHPP.asi")
+
   Scope(\_SB) {
+
 Include ("CommonDevices.asi")
+
+Scope(\_SB.GED0) {
+Method(_EVT, 1, Serialized) {
+  Switch (ToInteger(Arg0)) {
+Case (84) { // GHES interrupt
+  Notify (HED0, 0x80)
+}
+
+Case (44) { // doorbell notification (Insertion/ejection)
+  local0 = DOUT & 0x00FF
+  if (local0 == 0x0001) {
+local0 = STA4 & 0x
+if (local0) {
+  Store(local0, STA4) // clear interrupt
+}
+local0 = A050 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) {
+  Notify (\_SB.PCI5.P2P1, 1) // insertion action
+}
+local0 = A051 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) {
+  Notify (\_SB.PCI5.P2P2, 1) // insertion action
+}
+local0 = A052 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) {
+  Notify (\_SB.PCI5.P2P3, 1) // insertion action
+}
+local0 = A053 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) {
+  Notify (\_SB.PCI5.P2P4, 1) // insertion action
+}
+local0 = A040 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) {
+  Notify (\_SB.PCI4.P2P1, 1) // insertion action
+}
+local0 = A041 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) {
+  Notify (\_SB.PCI4.P2P2, 1) // insertion action
+}
+local0 = A042 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) {
+  Notify (\_SB.PCI4.P2P3, 1) // insertion action
+}
+local0 = A043 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) {
+  Notify (\_SB.PCI4.P2P4, 1) // insertion action
+}
+local0 = A160 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) {
+  Notify (\_SB.PCIE.P2P1, 1) // insertion action
+}
+local0 = A161 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) {
+  Notify 

[edk2-devel] [edk2-platforms][PATCH 2/3] AmpereAltraPkg: Fix PCIe link training sequence

2023-05-11 Thread Minh Nguyen via groups.io
Currently, the implementation starts link training and put device
out-of-reset right away. This make LinkStat and BlockEventStat registers
indicate that link is not up yet (LinkStat: 0x300 and BlockEventStat: 0x0).
This fix will start link training after putting device out-of-reset.
The values of LinkStat and BlockEventStat registers after this fix are
respectively 0x1103 and 0x1 (Link is up).

Signed-off-by: Minh Nguyen 
---
 Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c 
b/Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c
index f7c8defc1906..d797442d9fbc 100644
--- a/Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c
+++ b/Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c
@@ -1177,12 +1177,12 @@ Ac01PcieCoreSetupRC (
 // Assert PERST low to reset endpoint
 BoardPcieAssertPerst (RootComplex, PcieIndex, FALSE);
 
+// Complete the PERST pulse
+BoardPcieAssertPerst (RootComplex, PcieIndex, TRUE);
+
 // Start link training
 StartLinkTraining (RootComplex, PcieIndex, TRUE);
 
-// Complete the PERST pulse
-BoardPcieAssertPerst (RootComplex, PcieIndex, TRUE);
-
 // Lock programming of config space
 EnableDbiAccess  (RootComplex, PcieIndex, FALSE);
 
-- 
2.39.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104712): https://edk2.groups.io/g/devel/message/104712
Mute This Topic: https://groups.io/mt/98831764/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 4/6] JadePkg: Support ACPI tables for Hot Plug of Ampere Altra

2023-05-11 Thread Minh Nguyen via groups.io
From: Vu Nguyen 

This adds necessary changes of ACPI tables and defines the memory
region between OS and Trusted Firmware-A for supporting Hot Plug
of Ampere Altra.

Signed-off-by: Minh Nguyen 
---
 Platform/Ampere/JadePkg/AcpiTables/Dsdt.asl   |  499 -
 Platform/Ampere/JadePkg/AcpiTables/MHPP.asi   |  127 +++
 Platform/Ampere/JadePkg/AcpiTables/PCI-S0.asi |  548 +-
 Platform/Ampere/JadePkg/AcpiTables/PCI-S1.asi | 1074 +++-
 4 files changed, 2245 insertions(+), 3 deletions(-)

diff --git a/Platform/Ampere/JadePkg/AcpiTables/Dsdt.asl 
b/Platform/Ampere/JadePkg/AcpiTables/Dsdt.asl
index d7d2df8c3dce..9ee215a26a09 100644
--- a/Platform/Ampere/JadePkg/AcpiTables/Dsdt.asl
+++ b/Platform/Ampere/JadePkg/AcpiTables/Dsdt.asl
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2020 - 2021, Ampere Computing LLC. All rights reserved.
+  Copyright (c) 2020 - 2023, Ampere Computing LLC. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -11,6 +11,9 @@ DefinitionBlock("Dsdt.aml", "DSDT", 0x02, "Ampere", "Jade", 
1) {
   // Board Model
   Name(\BDMD, "Jade Board")
   Name(AERF, 0)  // PCIe AER Firmware-First
+
+  Include ("MHPP.asi")
+
   Scope(\_SB) {
 
 //
@@ -181,12 +184,506 @@ DefinitionBlock("Dsdt.aml", "DSDT", 0x02, "Ampere", 
"Jade", 1) {
 }
 Name(_CRS, ResourceTemplate () {
   Interrupt(ResourceConsumer, Level, ActiveHigh, Exclusive) { 84 } // 
GHES
+  Interrupt(ResourceConsumer, Level, ActiveHigh, Exclusive) { 44 } // 
PCIe Hot Plug Doorbell Insertion & Ejection (DBNS4 -> GIC-IRQS44)
 })
+
+// @DBN4 agent base address for HP PCIe insertion/ejection event: 
0x1000.0054.4000
+OperationRegion(DBN4, SystemMemory, 0x10544010, 20)
+Field (DBN4, DWordAcc, NoLock, Preserve) {
+  DOUT, 32, // event and PCIe port information at offset 0x10
+  offset (0x10),
+  STA4, 32, // interrupt status at offset 0x20
+}
+
 Method(_EVT, 1, Serialized) {
   Switch (ToInteger(Arg0)) {
 Case (84) { // GHES interrupt
   Notify (HED0, 0x80)
 }
+
+Case (44) { // doorbell notification (Insertion/ejection)
+  local0 = DOUT & 0x00FF
+  if (local0 == 0x0001) {
+local0 = STA4 & 0x
+if (local0) {
+  Store(local0, STA4) // clear interrupt
+}
+local0 = A120 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) {
+  Notify (\_SB.PCIA.P2P1, 1) // insertion action
+}
+local0 = A121 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) {
+  Notify (\_SB.PCIA.P2P2, 1) // insertion action
+}
+local0 = A122 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) {
+  Notify (\_SB.PCIA.P2P3, 1) // insertion action
+}
+local0 = A123 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) {
+  Notify (\_SB.PCIA.P2P4, 1) // insertion action
+}
+local0 = B000 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) {
+  Notify (\_SB.PCI4.P2P1, 1) // insertion action
+}
+local0 = B002 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) {
+  Notify (\_SB.PCI4.P2P3, 1) // insertion action
+}
+local0 = B004 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) {
+  Notify (\_SB.PCI4.P2P5, 1) // insertion action
+}
+local0 = B006 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) {
+  Notify (\_SB.PCI4.P2P7, 1) // insertion action
+}
+local0 = B010 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) {
+  Notify (\_SB.PCI5.P2P1, 1) // insertion action
+}
+local0 = B012 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) {
+  Notify (\_SB.PCI5.P2P3, 1) // insertion action
+}
+local0 = B014 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) {
+  Notify (\_SB.PCI5.P2P5, 1) // insertion action
+}
+local0 = B016 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) {
+  Notify (\_SB.PCI5.P2P7, 1) // insertion action
+}
+local0 = B104 & 0xFF00
+if ((local0 == 0x0100) || (local0 == 0x0F00)) 

[edk2-devel] [edk2-platforms][PATCH 3/6] AmpereAltraPkg: Change PCIe Amba Link Timeout value

2023-05-11 Thread Minh Nguyen via groups.io
As AMBA_LINK_TIMEOUT_OFF spec, it impacts OS Hot Plug removal delay.
The greater value the longer delay it is. Per experiments, set it 2
from beginning of Root Port initialization for stable operation.

Signed-off-by: Minh Nguyen 
---
 Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c 
b/Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c
index c5a299cca6c5..d71f56d5fcf1 100644
--- a/Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c
+++ b/Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c
@@ -1159,8 +1159,12 @@ Ac01PcieCoreSetupRC (
   }
 }
 
-// Link timeout after 1ms
-SetLinkTimeout (RootComplex, PcieIndex, 1);
+//
+// As AMBA_LINK_TIMEOUT_OFF spec, it impacts OS HP removal delay.
+// The greater value the longer delay it is. Per discussion,
+// set it 2 from beginning of RP initialization.
+//
+SetLinkTimeout (RootComplex, PcieIndex, 2);
 
 DisableCompletionTimeOut (RootComplex, PcieIndex, TRUE);
 
-- 
2.39.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104717): https://edk2.groups.io/g/devel/message/104717
Mute This Topic: https://groups.io/mt/98831769/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 2/6] AmpereAltraPkg: Add Hot Plug Slot Capable during PCIe port initialization

2023-05-11 Thread Minh Nguyen via groups.io
In order to detect the NVMe after OS boots successfully but
that NVMe's not present previously. Hot Plug Slot Capable
will help PCI Linux driver to initialize its slot iomem resource
which is used for detecting the disk when it's inserted.

Signed-off-by: Minh Nguyen 
---
 Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c 
b/Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c
index f7c8defc1906..c5a299cca6c5 100644
--- a/Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c
+++ b/Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c
@@ -1093,6 +1093,11 @@ Ac01PcieCoreSetupRC (
 // Program the power limit
 TargetAddress = CfgBase + PCIE_CAPABILITY_BASE + SLOT_CAPABILITIES_REG;
 Val = MmioRead32 (TargetAddress);
+// In order to detect the NVMe after OS boots successfully but
+// that NVMe's not present previously. Hot Plug Slot Capable
+// will help PCI Linux driver to initialize its slot iomem resource
+// which is used for detecting the disk when it's inserted.
+Val = SLOT_HPC_SET(Val, 1);
 Val = SLOT_CAP_SLOT_POWER_LIMIT_VALUE_SET (Val, SLOT_POWER_LIMIT_75W);
 MmioWrite32 (TargetAddress, Val);
 
-- 
2.39.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104716): https://edk2.groups.io/g/devel/message/104716
Mute This Topic: https://groups.io/mt/98831768/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/3] AmpereAltraPkg: Remove PCIe "DevMapModeAuto" case in retrieving Devmap mode

2023-05-11 Thread Minh Nguyen via groups.io
Because PCIe Auto bifurcation feature doesn't depend on the default
Devmap mode so that "DevMapModeAuto" is unnecessary in retrieving
the PCIe Devmap default mode.

Signed-off-by: Minh Nguyen 
---
 Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/RootComplexNVParam.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/RootComplexNVParam.c 
b/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/RootComplexNVParam.c
index a8e23015b605..199929bfdb24 100644
--- a/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/RootComplexNVParam.c
+++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/RootComplexNVParam.c
@@ -160,7 +160,7 @@ GetDefaultDevMap (
   UINT8StartIndex;
   DEV_MAP_MODE DevMapMode;
 
-  DevMapMode = MaxDevMapMode;
+  DevMapMode = DevMapMode4;
   StartIndex = IsGetDevMapLow ? PcieController0 : PcieController4;
 
   while (DevMapMode >= DevMapMode1)
-- 
2.39.0



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




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

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

Hi Michael,
Thanks for providing the inputs, I will make the necessary changes. 
Please see inline for my reply.

-Original Message-
From: Michael Kubacki 
Sent: 10 May 2023 00:42
To: devel@edk2.groups.io; Attar, AbdulLateef (Abdul Lateef) 

Cc: Grimes, Paul ; Chang, Abner ; 
Eric Dong ; Ray Ni ; Rahul Kumar 
; Gerd Hoffmann ; Michael D Kinney 
; Liming Gao ; Zhiguang 
Liu ; Ard Biesheuvel ; 
Jiewen Yao ; Jordan Justen 
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.


I haven't followed the whole thread but looking at v11, I wanted to check on 
the following.

1. The library source files (for AmdMmSaveStateLib and
IntelMmSaveStateLib) include several library headers (particularly in
MmSaveStateLib/MmSaveState.h) but do not have a [LibraryClasses] section in 
their INF files. Is there a reason?
[Attar, AbdulLateef (Abdul Lateef)]  I will make changes and submit V12 version.

2. AmdMmSaveStateLib and IntelMmSaveStateLib depend on SmmServicesTableLib. Can 
they depend on MmServicesTableLib instead?
[Attar, AbdulLateef (Abdul Lateef)] MmSaveStateLib is mainly used by 
PiSmmCpuDxeSmm driver which still uses Smm convention and preserve the 
SAVE_STATE pointed by gSmst(Instead of gMmst).
Hence I don’t think we can move to MmServicesTableLib.

3. It seems resources like the EFER register LMA bit should be defined 
somewhere agnostic to the MmSaveState.h file in MmSaveStateLib. It is 
referenced in MdePkg/Include/Register/Intel/ArchitecturalMsr.h:

https://github.com/tianocore/edk2/blob/5215cd5baf6609e54050c69909273b7f5161c59e/MdePkg/Include/Register/Intel/ArchitecturalMsr.h#L6342

In any case, can the bit be defined in one location?
[Attar, AbdulLateef (Abdul Lateef)] This AMD specific implementation, I'll move 
the MACRO definition under the AmdMmSaveStateLib.c file.

4. Your change to the SmmCpuFeaturesLib.h interface is not backward compatible 
and a build breaking change. I think that should be called out in your cover 
letter.
[Attar, AbdulLateef (Abdul Lateef)] I will update the cover letter in V12 
version.

Thanks,
Michael

On 5/6/2023 12:06 AM, Abdul Lateef Attar via groups.io wrote:
> 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: 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 |  14 +
>   .../MmSaveStateLib/AmdMmSaveStateLib.inf  |  28 +
>   .../MmSaveStateLib/IntelMmSaveStateLib.inf|  28 +
>   .../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  | 102 +++
>   UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h|  56 +-
>   

[edk2-devel] [edk2-platforms][PATCH 0/3] Add necessary changes for PCIe core and remove unnecessary checks for PCIe Devmap mode

2023-05-11 Thread Minh Nguyen via groups.io
These patches help to improve PCIe core for Link training sequence and
add logic to check PCIe card is present or not. One patch also removes
unnecessary checks for PCIe Devmap mode.

Minh Nguyen (2):
  AmpereAltraPkg: Remove PCIe "DevMapModeAuto" case in retrieving Devmap
mode
  AmpereAltraPkg: Fix PCIe link training sequence

Tinh Nguyen (1):
  AmpereAltraPkg: Add retry logic when PCIe card is present

 Silicon/Ampere/AmpereAltraPkg/Drivers/PcieInitPei/RootComplexNVParam.c |  2 +-
 Silicon/Ampere/AmpereAltraPkg/Library/Ac01PcieLib/PcieCore.c   | 12 

 2 files changed, 9 insertions(+), 5 deletions(-)

-- 
2.39.0



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




[edk2-devel] [PATCH v5 1/2] Platform/SbsaQemu: read platform version

2023-05-11 Thread Marcin Juszkiewicz
Qemu has versioning for sbsa-ref platform. TF-A reads it from provided
DeviceTree and provides as SMC.

This change adds reading platform version into EDK2.

Signed-off-by: Marcin Juszkiewicz 
---
 Platform/Qemu/SbsaQemu/SbsaQemu.dsc   |  3 +++
 .../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c | 27 +++
 .../SbsaQemuPlatformDxe.inf   |  5 
 Silicon/Qemu/SbsaQemu/SbsaQemu.dec|  3 +++
 4 files changed, 38 insertions(+)

diff --git a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc 
b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
index 9ca030cfe9a7..43798e03d33c 100644
--- a/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
+++ b/Platform/Qemu/SbsaQemu/SbsaQemu.dsc
@@ -558,6 +558,9 @@ DEFINE NETWORK_HTTP_BOOT_ENABLE   = FALSE
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisAssetTag|L"AT"
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisSKU|L"SK"
 
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor|0x0
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor|0x0
+
 

 #
 # Components Section - list of all EDK II Modules needed by this Platform
diff --git 
a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c 
b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
index b7270a07abbd..199766c7014a 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
@@ -7,15 +7,25 @@
 *
 **/
 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
+/* those probably should go into IndustryStandard/ArmStdSmc.h */
+#define SMC_FASTCALL   0x8000
+#define SMC64_FUNCTION (SMC_FASTCALL   | 0x4000)
+#define SIP_FUNCTION   (SMC64_FUNCTION | 0x0200)
+#define SIP_FUNCTION_ID(n) (SIP_FUNCTION   | (n))
+
+#define SIP_SVC_VERSION  SIP_FUNCTION_ID(1)
+
 EFI_STATUS
 EFIAPI
 InitializeSbsaQemuPlatformDxe (
@@ -26,6 +36,9 @@ InitializeSbsaQemuPlatformDxe (
   EFI_STATUS Status;
   UINTN  Size;
   VOID*  Base;
+  UINTN  Arg0;
+  UINTN  Arg1;
+  UINTN  Result;
 
   DEBUG ((DEBUG_INFO, "%a: InitializeSbsaQemuPlatformDxe called\n", 
__FUNCTION__));
 
@@ -51,5 +64,19 @@ InitializeSbsaQemuPlatformDxe (
 return Status;
   }
 
+  Result = ArmCallSmc0 (SIP_SVC_VERSION, , , NULL);
+  if (Result == SMC_ARCH_CALL_SUCCESS)
+  {
+Result = PcdSet32S (PcdPlatformVersionMajor, Arg0);
+ASSERT_EFI_ERROR (Result);
+Result = PcdSet32S (PcdPlatformVersionMinor, Arg1);
+ASSERT_EFI_ERROR (Result);
+  }
+
+  Arg0 = PcdGet32 (PcdPlatformVersionMajor);
+  Arg1 = PcdGet32 (PcdPlatformVersionMinor);
+
+  DEBUG ((DEBUG_INFO, "Platform version: %d.%d\n", Arg0, Arg1));
+
   return EFI_SUCCESS;
 }
diff --git 
a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf 
b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
index 21d2135f6d17..1f2c8a9dd6af 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
@@ -20,6 +20,7 @@
   SbsaQemuPlatformDxe.c
 
 [Packages]
+  ArmPkg/ArmPkg.dec
   ArmVirtPkg/ArmVirtPkg.dec
   EmbeddedPkg/EmbeddedPkg.dec
   MdeModulePkg/MdeModulePkg.dec
@@ -27,6 +28,7 @@
   Silicon/Qemu/SbsaQemu/SbsaQemu.dec
 
 [LibraryClasses]
+  ArmSmcLib
   PcdLib
   DebugLib
   NonDiscoverableDeviceRegistrationLib
@@ -36,6 +38,9 @@
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciBase
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformAhciSize
 
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor
+  gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor
+
 [Depex]
   TRUE
 
diff --git a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec 
b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
index 9448852967b6..5182978cf56d 100644
--- a/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
+++ b/Silicon/Qemu/SbsaQemu/SbsaQemu.dec
@@ -67,3 +67,6 @@
   
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisManufacturer|L""|VOID*|0x011B
   
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisAssetTag|L""|VOID*|0x011C
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdChassisSKU|L""|VOID*|0x011D
+
+  
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor|0x0|UINT32|0x011E
+  
gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor|0x0|UINT32|0x011F
-- 
2.40.1



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

[edk2-devel] [PATCH v5 0/2] Platform/SbsaQemu: versioning support

2023-05-11 Thread Marcin Juszkiewicz
This changeset adds support to platform versioning for SbsaQemu
platform.

changes since v4:
- SMC variables renamed to Arg0, Arg1 as they are used for misc calls
- GIC base handling added

Patch 2/2 (GIC) does not build. No idea why.


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




[edk2-devel] [PATCH v5 2/2] Platform/SbsaQemu: read GIC base from TF-A

2023-05-11 Thread Marcin Juszkiewicz
Qemu has versioning for sbsa-ref platform. TF-A reads data from provided
DeviceTree and provides as SMC.

This change adds reading GIC base addresses into EDK2.

Signed-off-by: Marcin Juszkiewicz 
---
 .../SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c | 24 +++
 .../SbsaQemuPlatformDxe.inf   |  4 
 2 files changed, 28 insertions(+)

diff --git 
a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c 
b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
index 199766c7014a..82c349971625 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.c
@@ -25,6 +25,8 @@
 #define SIP_FUNCTION_ID(n) (SIP_FUNCTION   | (n))
 
 #define SIP_SVC_VERSION  SIP_FUNCTION_ID(1)
+#define SIP_SVC_GET_GICD SIP_FUNCTION_ID(2)
+#define SIP_SVC_GET_GICR SIP_FUNCTION_ID(3)
 
 EFI_STATUS
 EFIAPI
@@ -78,5 +80,27 @@ InitializeSbsaQemuPlatformDxe (
 
   DEBUG ((DEBUG_INFO, "Platform version: %d.%d\n", Arg0, Arg1));
 
+  Result = ArmCallSmc0 (SIP_SVC_GET_GICD, , NULL, NULL);
+  if (Result == SMC_ARCH_CALL_SUCCESS)
+  {
+Result = PcdSet32S (PcdGicDistributorBase, Arg0);
+ASSERT_EFI_ERROR (Result);
+  }
+
+  Arg0 = PcdGet32 (PcdGicDistributorBase);
+
+  DEBUG ((DEBUG_INFO, "GICD base: 0x%x\n", Arg0));
+
+  Result = ArmCallSmc0 (SIP_SVC_GET_GICR, , NULL, NULL);
+  if (Result == SMC_ARCH_CALL_SUCCESS)
+  {
+Result = PcdSet32S (PcdGicRedistributorsBase, Arg0);
+ASSERT_EFI_ERROR (Result);
+  }
+
+  Arg0 = PcdGet32 (PcdGicRedistributorsBase);
+
+  DEBUG ((DEBUG_INFO, "GICR base: 0x%x\n", Arg0));
+
   return EFI_SUCCESS;
 }
diff --git 
a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf 
b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
index 1f2c8a9dd6af..545794a8c7ff 100644
--- a/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
+++ b/Silicon/Qemu/SbsaQemu/Drivers/SbsaQemuPlatformDxe/SbsaQemuPlatformDxe.inf
@@ -41,6 +41,10 @@
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMajor
   gArmVirtSbsaQemuPlatformTokenSpaceGuid.PcdPlatformVersionMinor
 
+  gArmTokenSpaceGuid.PcdGicDistributorBase
+  gArmTokenSpaceGuid.PcdGicRedistributorsBase
+
+
 [Depex]
   TRUE
 
-- 
2.40.1



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




Re: [edk2-devel] [PATCH v5 2/3] OvmfPkg/Xen: export AcpiTable installation into AcpiPlatformLib

2023-05-11 Thread Rebecca Cran
Liming’s email appeared to say that patch reviews could continue even if they 
aren’t for the upcoming release?

“ We enter into Soft Feature Freeze phase on 2023-05-08. In this phase,

the feature under review will not be allowed to be pushed. The feature passed 
review can still be merged. 

 The patch review can continue without break in edk2 community. If the patch is 
sent before Soft Feature Freeze, and plans to catch this stable
tag, the patch contributor need reply to his patch and notify edk2 community. 
If the patch is sent after Soft Feature Freeze, and plans to catch this stable 
tag, please add edk2-stable202305 key words in the patch title and BZ, so the 
community know this patch target and give the feedback.

  To avoid the unnecessary changes to be merged in edk2 stable tag release, all 
edk2 maintainers' write access will be temporarily disabled until stable tag is 
released on 05-26. That means edk2 maintainer can't set push label in pull 
request after 2023-05-08. 

  If the change wants to catch this stable tag 202305, please follow above 
rules, then send the merge request to gaolim...@byosoft.com.cn or 

michael.d.kin...@intel.com or miki.deme...@intel.com.

 

  We will help merge the code change in soft feature freeze and hard feature 
freeze phase. 

Below is edk2-stable202305 tag planning Proposed Schedule

Date (00:00:00 UTC-8) Description

2023-02-24  Beginning of development
2023-05-08  Soft Feature Freeze
2023-05-12  Hard Feature Freeze
2023-05-26  Release”


On Thu, May 11, 2023, at 7:19 AM, Ard Biesheuvel wrote:
> On Thu, 11 May 2023 at 15:16, Corvin Köhne  wrote:
>>
>> On Thu, 2023-05-11 at 07:04 -0600, Rebecca Cran wrote:
>> > Could you cc me on _all_ of the patches in a series please?
>> >
>> > I seem to have been missed on this one, and only cc'd on 3/3.
>> >
>> >
>>
>> Sry, I've updated my cc list. So, you'll be included in my next update.
>>
>
> We're in the middle of a soft freeze so please don't resend this until
> after the release - thanks.
>
>
> 


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




Re: [edk2-devel] [PATCH v5 2/3] OvmfPkg/Xen: export AcpiTable installation into AcpiPlatformLib

2023-05-11 Thread Anthony PERARD via groups.io
On Thu, May 11, 2023 at 02:02:38PM +0200, Corvin Köhne wrote:
> This makes the function reuseable by bhyve.
> 
> Signed-off-by: Corvin Köhne 
> Acked-by: Gerd Hoffmann 

Reviewed-by: Anthony PERARD 

Thanks,

-- 
Anthony PERARD


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




Re: [edk2-devel] [PATCH v5 1/3] OvmfPkg/Xen: export search of RSDP into a library function

2023-05-11 Thread Anthony PERARD via groups.io
On Thu, May 11, 2023 at 02:02:37PM +0200, Corvin Köhne wrote:
> diff --git a/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c 
> b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c
> new file mode 100644
> index ..ce52ad31cf25
> --- /dev/null
> +++ b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c
> @@ -0,0 +1,62 @@
> +/** @file
> +  Copyright (c) 2023, Corvin Köhne 

As this new file move codes from OvmfPkg/XenAcpiPlatformDxe/Xen.c,
shouldn't you also copy the "Copyright" lines from that file as well?


Beside that, patch looks fine:
Reviewed-by: Anthony PERARD 

Thanks,

-- 
Anthony PERARD


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




Re: [edk2-devel] [PATCH v5 2/3] OvmfPkg/Xen: export AcpiTable installation into AcpiPlatformLib

2023-05-11 Thread Ard Biesheuvel
On Thu, 11 May 2023 at 15:16, Corvin Köhne  wrote:
>
> On Thu, 2023-05-11 at 07:04 -0600, Rebecca Cran wrote:
> > Could you cc me on _all_ of the patches in a series please?
> >
> > I seem to have been missed on this one, and only cc'd on 3/3.
> >
> >
>
> Sry, I've updated my cc list. So, you'll be included in my next update.
>

We're in the middle of a soft freeze so please don't resend this until
after the release - thanks.


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




Re: [edk2-devel] [PATCH v5 2/3] OvmfPkg/Xen: export AcpiTable installation into AcpiPlatformLib

2023-05-11 Thread Corvin Köhne
On Thu, 2023-05-11 at 07:04 -0600, Rebecca Cran wrote:
> Could you cc me on _all_ of the patches in a series please?
> 
> I seem to have been missed on this one, and only cc'd on 3/3.
> 
> 

Sry, I've updated my cc list. So, you'll be included in my next update.


-- 
Kind regards,
Corvin


On 5/11/23 06:02, Corvin Köhne wrote:
> This makes the function reuseable by bhyve.
>
> Signed-off-by: Corvin Köhne 
> Acked-by: Gerd Hoffmann 
> Cc: Ard Biesheuvel 
> Cc: Jiewen Yao 
> Cc: Jordan Justen 
> Cc: Anthony Perard 
> Cc: Julien Grall 
> ---
>   .../XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf |   1 -
>   OvmfPkg/Include/Library/AcpiPlatformLib.h |  25 ++
>   .../AcpiPlatformLib/DxeAcpiPlatformLib.c  | 185 +
>   OvmfPkg/XenAcpiPlatformDxe/AcpiPlatform.c |  47 +++-
>   OvmfPkg/XenAcpiPlatformDxe/Xen.c  | 257 ---
---
>   5 files changed, 254 insertions(+), 261 deletions(-)
>   delete mode 100644 OvmfPkg/XenAcpiPlatformDxe/Xen.c
>
> diff --git a/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf
b/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf
> index 65374569ddc2..be175d290f92 100644
> --- a/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf
> +++ b/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf
> @@ -25,7 +25,6 @@ [Sources]
> AcpiPlatform.c
> AcpiPlatform.h
> EntryPoint.c
> -  Xen.c
>   
>   [Packages]
> MdePkg/MdePkg.dec
> diff --git a/OvmfPkg/Include/Library/AcpiPlatformLib.h
b/OvmfPkg/Include/Library/AcpiPlatformLib.h
> index b0a3c5bd0048..73a170636032 100644
> --- a/OvmfPkg/Include/Library/AcpiPlatformLib.h
> +++ b/OvmfPkg/Include/Library/AcpiPlatformLib.h
> @@ -4,6 +4,8 @@
> SPDX-License-Identifier: BSD-2-Clause-Patent
>   **/
>   
> +#include 
> +
>   /**
> Searches and returns the address of the ACPI Root System
Description Pointer (RSDP) in system memory.
>   
> @@ -22,3 +24,26 @@ GetAcpiRsdpFromMemory (
> IN UINT64 EndAddress,
> OUT EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER  **RsdpPtr
> );
> +
> +/**
> +  Get Acpi tables from the RSDP structure. And installs ACPI tables
> +  into the RSDT/XSDT using InstallAcpiTable. Some signature of the
installed
> +  ACPI tables are: FACP, APIC, HPET, WAET, SSDT, FACS, DSDT.
> +
> +  @param  AcpiProtocol   Protocol instance pointer.
> +
> +  @return EFI_SUCCESSThe table was successfully
inserted.
> +  @return EFI_INVALID_PARAMETER  Either AcpiTableBuffer is NULL,
TableHandle is
> + NULL, or AcpiTableBufferSize and
the size
> + field embedded in the ACPI table
pointed to
> + by AcpiTableBuffer are not in sync.
> +  @return EFI_OUT_OF_RESOURCES   Insufficient resources exist to
complete the
> +request.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +InstallAcpiTablesFromRsdp (
> +  IN EFI_ACPI_TABLE_PROTOCOL   *AcpiProtocol,
> +  IN EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp
> +  );
> diff --git a/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c
b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c
> index ce52ad31cf25..06b9b88eb347 100644
> --- a/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c
> +++ b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c
> @@ -60,3 +60,188 @@ GetAcpiRsdpFromMemory (
>   
> return EFI_NOT_FOUND;
>   }
> +
> +EFI_STATUS
> +EFIAPI
> +InstallAcpiTablesFromRsdp (
> +  IN EFI_ACPI_TABLE_PROTOCOL   *AcpiProtocol,
> +  IN EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp
> +  )
> +{
> +  EFI_STATUS  Status;
> +  UINTN   TableHandle;
> +
> +  EFI_ACPI_DESCRIPTION_HEADER   *Rsdt;
> +  EFI_ACPI_DESCRIPTION_HEADER   *Xsdt;
> +  VOID  *CurrentTableEntry;
> +  UINTN CurrentTablePointer;
> +  EFI_ACPI_DESCRIPTION_HEADER   *CurrentTable;
> +  UINTN Index;
> +  UINTN
NumberOfTableEntries;
> +  EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt2Table;
> +  EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt1Table;
> +  EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE  *Facs2Table;
> +  EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE  *Facs1Table;
> +  EFI_ACPI_DESCRIPTION_HEADER   *DsdtTable;
> +
> +  Fadt2Table   = NULL;
> +  Fadt1Table   = NULL;
> +  Facs2Table   = NULL;
> +  Facs1Table   = NULL;
> +  DsdtTable= NULL;
> +  TableHandle  = 0;
> +  NumberOfTableEntries = 0;
> +
> +  //
> +  // If XSDT table is find, just install its tables.
> +  // Otherwise, try to find and install the RSDT tables.
> +  //
> +  if (Rsdp->XsdtAddress) {
> +//
> +// Retrieve the addresses of XSDT and
> +// calculate the number of its table entries.
> +//
> +Xsdt = 

Re: [edk2-devel] [PATCH v5 2/3] OvmfPkg/Xen: export AcpiTable installation into AcpiPlatformLib

2023-05-11 Thread Rebecca Cran

Could you cc me on _all_ of the patches in a series please?

I seem to have been missed on this one, and only cc'd on 3/3.


--

Rebecca Cran


On 5/11/23 06:02, Corvin Köhne wrote:

This makes the function reuseable by bhyve.

Signed-off-by: Corvin Köhne 
Acked-by: Gerd Hoffmann 
Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Anthony Perard 
Cc: Julien Grall 
---
  .../XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf |   1 -
  OvmfPkg/Include/Library/AcpiPlatformLib.h |  25 ++
  .../AcpiPlatformLib/DxeAcpiPlatformLib.c  | 185 +
  OvmfPkg/XenAcpiPlatformDxe/AcpiPlatform.c |  47 +++-
  OvmfPkg/XenAcpiPlatformDxe/Xen.c  | 257 --
  5 files changed, 254 insertions(+), 261 deletions(-)
  delete mode 100644 OvmfPkg/XenAcpiPlatformDxe/Xen.c

diff --git a/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf 
b/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf
index 65374569ddc2..be175d290f92 100644
--- a/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf
+++ b/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf
@@ -25,7 +25,6 @@ [Sources]
AcpiPlatform.c
AcpiPlatform.h
EntryPoint.c
-  Xen.c
  
  [Packages]

MdePkg/MdePkg.dec
diff --git a/OvmfPkg/Include/Library/AcpiPlatformLib.h 
b/OvmfPkg/Include/Library/AcpiPlatformLib.h
index b0a3c5bd0048..73a170636032 100644
--- a/OvmfPkg/Include/Library/AcpiPlatformLib.h
+++ b/OvmfPkg/Include/Library/AcpiPlatformLib.h
@@ -4,6 +4,8 @@
SPDX-License-Identifier: BSD-2-Clause-Patent
  **/
  
+#include 

+
  /**
Searches and returns the address of the ACPI Root System Description 
Pointer (RSDP) in system memory.
  
@@ -22,3 +24,26 @@ GetAcpiRsdpFromMemory (

IN UINT64 EndAddress,
OUT EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER  **RsdpPtr
);
+
+/**
+  Get Acpi tables from the RSDP structure. And installs ACPI tables
+  into the RSDT/XSDT using InstallAcpiTable. Some signature of the installed
+  ACPI tables are: FACP, APIC, HPET, WAET, SSDT, FACS, DSDT.
+
+  @param  AcpiProtocol   Protocol instance pointer.
+
+  @return EFI_SUCCESSThe table was successfully inserted.
+  @return EFI_INVALID_PARAMETER  Either AcpiTableBuffer is NULL, TableHandle is
+ NULL, or AcpiTableBufferSize and the size
+ field embedded in the ACPI table pointed to
+ by AcpiTableBuffer are not in sync.
+  @return EFI_OUT_OF_RESOURCES   Insufficient resources exist to complete the
+request.
+
+**/
+EFI_STATUS
+EFIAPI
+InstallAcpiTablesFromRsdp (
+  IN EFI_ACPI_TABLE_PROTOCOL   *AcpiProtocol,
+  IN EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp
+  );
diff --git a/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c 
b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c
index ce52ad31cf25..06b9b88eb347 100644
--- a/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c
+++ b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c
@@ -60,3 +60,188 @@ GetAcpiRsdpFromMemory (
  
return EFI_NOT_FOUND;

  }
+
+EFI_STATUS
+EFIAPI
+InstallAcpiTablesFromRsdp (
+  IN EFI_ACPI_TABLE_PROTOCOL   *AcpiProtocol,
+  IN EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp
+  )
+{
+  EFI_STATUS  Status;
+  UINTN   TableHandle;
+
+  EFI_ACPI_DESCRIPTION_HEADER   *Rsdt;
+  EFI_ACPI_DESCRIPTION_HEADER   *Xsdt;
+  VOID  *CurrentTableEntry;
+  UINTN CurrentTablePointer;
+  EFI_ACPI_DESCRIPTION_HEADER   *CurrentTable;
+  UINTN Index;
+  UINTN NumberOfTableEntries;
+  EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt2Table;
+  EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt1Table;
+  EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE  *Facs2Table;
+  EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE  *Facs1Table;
+  EFI_ACPI_DESCRIPTION_HEADER   *DsdtTable;
+
+  Fadt2Table   = NULL;
+  Fadt1Table   = NULL;
+  Facs2Table   = NULL;
+  Facs1Table   = NULL;
+  DsdtTable= NULL;
+  TableHandle  = 0;
+  NumberOfTableEntries = 0;
+
+  //
+  // If XSDT table is find, just install its tables.
+  // Otherwise, try to find and install the RSDT tables.
+  //
+  if (Rsdp->XsdtAddress) {
+//
+// Retrieve the addresses of XSDT and
+// calculate the number of its table entries.
+//
+Xsdt = (EFI_ACPI_DESCRIPTION_HEADER 
*)(UINTN)Rsdp->XsdtAddress;
+NumberOfTableEntries =
+  (Xsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof (UINT64);
+
+//
+// Install ACPI tables found in XSDT.
+//
+for (Index = 0; Index < NumberOfTableEntries; Index++) {
+  //
+  // Get the table entry from XSDT
+  //
+  CurrentTableEntry =
+

[edk2-devel] [PATCH v5 1/3] OvmfPkg/Xen: export search of RSDP into a library function

2023-05-11 Thread Corvin Köhne
Xen and bhyve are placing ACPI tables into system memory. So, they can
share the same code. Therefore, create a new library which searches and
installs ACPI tables from system memory.

Signed-off-by: Corvin Köhne 
Acked-by: Gerd Hoffmann 
Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Anthony Perard 
Cc: Julien Grall 
---
 OvmfPkg/OvmfPkg.dec   |   4 +
 OvmfPkg/OvmfXen.dsc   |   1 +
 .../AcpiPlatformLib/DxeAcpiPlatformLib.inf|  26 
 .../XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf |   1 +
 OvmfPkg/Include/Library/AcpiPlatformLib.h |  24 
 .../AcpiPlatformLib/DxeAcpiPlatformLib.c  |  62 +
 OvmfPkg/XenAcpiPlatformDxe/Xen.c  | 119 +-
 7 files changed, 147 insertions(+), 90 deletions(-)
 create mode 100644 OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
 create mode 100644 OvmfPkg/Include/Library/AcpiPlatformLib.h
 create mode 100644 OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c

diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
index 03ae29e7b034..7b321ba01d72 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -20,6 +20,10 @@ [Includes]
   Csm/Include
 
 [LibraryClasses]
+  ##  @libraryclass  Search and install ACPI tables.
+  #
+  AcpiPlatformLib|Include/Library/AcpiPlatformLib.h
+
   ##  @libraryclass  Access bhyve's firmware control interface.
   BhyveFwCtlLib|Include/Library/BhyveFwCtlLib.h
 
diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc
index 1f44ec86c9c7..ddcf8a36f513 100644
--- a/OvmfPkg/OvmfXen.dsc
+++ b/OvmfPkg/OvmfXen.dsc
@@ -321,6 +321,7 @@ [LibraryClasses.common.UEFI_DRIVER]
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
 
 [LibraryClasses.common.DXE_DRIVER]
+  AcpiPlatformLib|OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
diff --git a/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf 
b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
new file mode 100644
index ..dfe0e5623d32
--- /dev/null
+++ b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
@@ -0,0 +1,26 @@
+## @file
+#  ACPI Platform Library Instance.
+#
+#  Copyright (C) 2023, Corvin Köhne 
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = DxeAcpiPlatformLib
+  FILE_GUID  = 578F441A-4A4C-4D24-B9BE-F783152B46F6
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = AcpiPlatformLib
+
+[Sources]
+  DxeAcpiPlatformLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  DebugLib
diff --git a/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf 
b/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf
index d3a6353a50a6..65374569ddc2 100644
--- a/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf
+++ b/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf
@@ -32,6 +32,7 @@ [Packages]
   OvmfPkg/OvmfPkg.dec
 
 [LibraryClasses]
+  AcpiPlatformLib
   BaseLib
   DebugLib
   UefiBootServicesTableLib
diff --git a/OvmfPkg/Include/Library/AcpiPlatformLib.h 
b/OvmfPkg/Include/Library/AcpiPlatformLib.h
new file mode 100644
index ..b0a3c5bd0048
--- /dev/null
+++ b/OvmfPkg/Include/Library/AcpiPlatformLib.h
@@ -0,0 +1,24 @@
+/** @file
+  Copyright (c) 2023, Corvin Köhne 
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+/**
+  Searches and returns the address of the ACPI Root System Description Pointer 
(RSDP) in system memory.
+
+  @param  StartAddressStart address of search range.
+  @param  EndAddress  End address of search range.
+  @param  RsdpPtr Return pointer to RSDP.
+
+  @retval EFI_SUCCESS RSDP successfully found.
+  @retval EFI_NOT_FOUND   Couldn't find RSDP.
+  @retval EFI_ABORTED Invalid RSDP found.
+**/
+EFI_STATUS
+EFIAPI
+GetAcpiRsdpFromMemory (
+  IN UINT64 StartAddress,
+  IN UINT64 EndAddress,
+  OUT EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER  **RsdpPtr
+  );
diff --git a/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c 
b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c
new file mode 100644
index ..ce52ad31cf25
--- /dev/null
+++ b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c
@@ -0,0 +1,62 @@
+/** @file
+  Copyright (c) 2023, Corvin Köhne 
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include 
+#include 
+#include 
+
+EFI_STATUS
+EFIAPI
+GetAcpiRsdpFromMemory (
+  IN UINTNStartAddress,
+  IN UINTNEndAddress,
+  OUT   EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER  **RsdpPtr
+  )
+{
+  EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *RsdpStructurePtr;
+  UINT8

[edk2-devel] [PATCH v5 3/3] OvmfPkg/Bhyve: install ACPI tables from memory

2023-05-11 Thread Corvin Köhne
It's much easier to create configuration dependend ACPI tables for bhyve
than for OVMF. For this reason, don't use the statically created ACPI
tables provided by OVMF. Instead prefer the dynamically created ACPI
tables of bhyve. If bhyve provides no ACPI tables or we are unable to
detect those, fall back to OVMF tables.

Ideally, we use the qemu fwcfg interface to pass the ACPI tables from
bhyve to OVMF. bhyve will support this in the future. However, current
bhyve executables don't support passing ACPI tables by the qemu fwcfg
interface. They just copy the ACPI into main memory. For that reason,
pick up the ACPI tables from main memory.

Signed-off-by: Corvin Köhne 
Reviewed-by: Rebecca Cran 
Acked-by: Peter Grehan 
Acked-by: Gerd Hoffmann 
Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
---
 OvmfPkg/Bhyve/BhyveX64.dsc|  1 +
 .../Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf |  1 +
 OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c  | 37 ++-
 3 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
index d0d2712c5662..465b81ffcd51 100644
--- a/OvmfPkg/Bhyve/BhyveX64.dsc
+++ b/OvmfPkg/Bhyve/BhyveX64.dsc
@@ -341,6 +341,7 @@ [LibraryClasses.common.UEFI_DRIVER]
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
 
 [LibraryClasses.common.DXE_DRIVER]
+  AcpiPlatformLib|OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
diff --git a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf 
b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
index 94c65f32dcab..75ed8e4a7deb 100644
--- a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
+++ b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
@@ -35,6 +35,7 @@ [Packages]
   UefiCpuPkg/UefiCpuPkg.dec
 
 [LibraryClasses]
+  AcpiPlatformLib
   BaseLib
   BaseMemoryLib
   BhyveFwCtlLib
diff --git a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c 
b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c
index 999e9f151ebb..1e1c90614ea1 100644
--- a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c
+++ b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.c
@@ -10,6 +10,11 @@
 
 #include "AcpiPlatform.h"
 
+#include  // InstallAcpiTablesFromMemory()
+
+#define BHYVE_ACPI_PHYSICAL_ADDRESS  ((UINTN)0x000F2400)
+#define BHYVE_BIOS_PHYSICAL_END  ((UINTN)0x0010)
+
 EFI_STATUS
 EFIAPI
 InstallAcpiTable (
@@ -241,7 +246,37 @@ InstallAcpiTables (
   IN   EFI_ACPI_TABLE_PROTOCOL  *AcpiTable
   )
 {
-  EFI_STATUS  Status;
+  EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp;
+  EFI_STATUSStatus;
+
+  Status = GetAcpiRsdpFromMemory (
+ BHYVE_ACPI_PHYSICAL_ADDRESS,
+ BHYVE_BIOS_PHYSICAL_END,
+ 
+ );
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+
+  Status = InstallAcpiTablesFromRsdp (
+ AcpiTable,
+ Rsdp
+ );
+  if (!EFI_ERROR (Status)) {
+return EFI_SUCCESS;
+  }
+
+  if (Status != EFI_NOT_FOUND) {
+DEBUG (
+  (
+   DEBUG_WARN,
+   "%a: unable to install bhyve's ACPI tables (%r)\n",
+   __func__,
+   Status
+  )
+  );
+return Status;
+  }
 
   Status = InstallOvmfFvTables (AcpiTable);
 
-- 
2.40.1



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




[edk2-devel] [PATCH v5 2/3] OvmfPkg/Xen: export AcpiTable installation into AcpiPlatformLib

2023-05-11 Thread Corvin Köhne
This makes the function reuseable by bhyve.

Signed-off-by: Corvin Köhne 
Acked-by: Gerd Hoffmann 
Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Anthony Perard 
Cc: Julien Grall 
---
 .../XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf |   1 -
 OvmfPkg/Include/Library/AcpiPlatformLib.h |  25 ++
 .../AcpiPlatformLib/DxeAcpiPlatformLib.c  | 185 +
 OvmfPkg/XenAcpiPlatformDxe/AcpiPlatform.c |  47 +++-
 OvmfPkg/XenAcpiPlatformDxe/Xen.c  | 257 --
 5 files changed, 254 insertions(+), 261 deletions(-)
 delete mode 100644 OvmfPkg/XenAcpiPlatformDxe/Xen.c

diff --git a/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf 
b/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf
index 65374569ddc2..be175d290f92 100644
--- a/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf
+++ b/OvmfPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf
@@ -25,7 +25,6 @@ [Sources]
   AcpiPlatform.c
   AcpiPlatform.h
   EntryPoint.c
-  Xen.c
 
 [Packages]
   MdePkg/MdePkg.dec
diff --git a/OvmfPkg/Include/Library/AcpiPlatformLib.h 
b/OvmfPkg/Include/Library/AcpiPlatformLib.h
index b0a3c5bd0048..73a170636032 100644
--- a/OvmfPkg/Include/Library/AcpiPlatformLib.h
+++ b/OvmfPkg/Include/Library/AcpiPlatformLib.h
@@ -4,6 +4,8 @@
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
+#include 
+
 /**
   Searches and returns the address of the ACPI Root System Description Pointer 
(RSDP) in system memory.
 
@@ -22,3 +24,26 @@ GetAcpiRsdpFromMemory (
   IN UINT64 EndAddress,
   OUT EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER  **RsdpPtr
   );
+
+/**
+  Get Acpi tables from the RSDP structure. And installs ACPI tables
+  into the RSDT/XSDT using InstallAcpiTable. Some signature of the installed
+  ACPI tables are: FACP, APIC, HPET, WAET, SSDT, FACS, DSDT.
+
+  @param  AcpiProtocol   Protocol instance pointer.
+
+  @return EFI_SUCCESSThe table was successfully inserted.
+  @return EFI_INVALID_PARAMETER  Either AcpiTableBuffer is NULL, TableHandle is
+ NULL, or AcpiTableBufferSize and the size
+ field embedded in the ACPI table pointed to
+ by AcpiTableBuffer are not in sync.
+  @return EFI_OUT_OF_RESOURCES   Insufficient resources exist to complete the
+request.
+
+**/
+EFI_STATUS
+EFIAPI
+InstallAcpiTablesFromRsdp (
+  IN EFI_ACPI_TABLE_PROTOCOL   *AcpiProtocol,
+  IN EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp
+  );
diff --git a/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c 
b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c
index ce52ad31cf25..06b9b88eb347 100644
--- a/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c
+++ b/OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.c
@@ -60,3 +60,188 @@ GetAcpiRsdpFromMemory (
 
   return EFI_NOT_FOUND;
 }
+
+EFI_STATUS
+EFIAPI
+InstallAcpiTablesFromRsdp (
+  IN EFI_ACPI_TABLE_PROTOCOL   *AcpiProtocol,
+  IN EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER  *Rsdp
+  )
+{
+  EFI_STATUS  Status;
+  UINTN   TableHandle;
+
+  EFI_ACPI_DESCRIPTION_HEADER   *Rsdt;
+  EFI_ACPI_DESCRIPTION_HEADER   *Xsdt;
+  VOID  *CurrentTableEntry;
+  UINTN CurrentTablePointer;
+  EFI_ACPI_DESCRIPTION_HEADER   *CurrentTable;
+  UINTN Index;
+  UINTN NumberOfTableEntries;
+  EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt2Table;
+  EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt1Table;
+  EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE  *Facs2Table;
+  EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE  *Facs1Table;
+  EFI_ACPI_DESCRIPTION_HEADER   *DsdtTable;
+
+  Fadt2Table   = NULL;
+  Fadt1Table   = NULL;
+  Facs2Table   = NULL;
+  Facs1Table   = NULL;
+  DsdtTable= NULL;
+  TableHandle  = 0;
+  NumberOfTableEntries = 0;
+
+  //
+  // If XSDT table is find, just install its tables.
+  // Otherwise, try to find and install the RSDT tables.
+  //
+  if (Rsdp->XsdtAddress) {
+//
+// Retrieve the addresses of XSDT and
+// calculate the number of its table entries.
+//
+Xsdt = (EFI_ACPI_DESCRIPTION_HEADER 
*)(UINTN)Rsdp->XsdtAddress;
+NumberOfTableEntries =
+  (Xsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof (UINT64);
+
+//
+// Install ACPI tables found in XSDT.
+//
+for (Index = 0; Index < NumberOfTableEntries; Index++) {
+  //
+  // Get the table entry from XSDT
+  //
+  CurrentTableEntry =
+(VOID *)((UINT8 *)Xsdt + sizeof (EFI_ACPI_DESCRIPTION_HEADER) +
+ Index * sizeof (UINT64));
+  CurrentTablePointer = (UINTN)*(UINT64 *)CurrentTableEntry;
+  CurrentTable= 

Re: [edk2-devel] [PATCH v2 07/12] OvmfPkg/Bhyve: Replace the OVMF-specific SataControllerDxe

2023-05-11 Thread Corvin Köhne
On 5/9/23 18:32, Pedro Falcato wrote:
> > Replace the OVMF-specific SataControllerDxe (to be later removed)
> > with
> > the generic, MdeModulePkg one, for the Bhyve platform.
> > 
> > Cc: Ard Biesheuvel 
> > Cc: Jiewen Yao 
> > Cc: Jordan Justen 
> > Cc: Gerd Hoffmann 
> > Cc: Rebecca Cran 
> > Cc: Peter Grehan 
> > Cc: Corvin Köhne 
> > Signed-off-by: Pedro Falcato 
> > ---
> >  OvmfPkg/Bhyve/BhyveX64.dsc | 2 +-
> >  OvmfPkg/Bhyve/BhyveX64.fdf | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc
> > b/OvmfPkg/Bhyve/BhyveX64.dsc
> > index d0d2712c5662..bb317a50e6af 100644
> > --- a/OvmfPkg/Bhyve/BhyveX64.dsc
> > +++ b/OvmfPkg/Bhyve/BhyveX64.dsc
> > @@ -698,7 +698,7 @@
> >    MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
> >    MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
> >    MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
> > -  OvmfPkg/SataControllerDxe/SataControllerDxe.inf
> > +  MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
> >    MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
> >    MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
> >    MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
> > diff --git a/OvmfPkg/Bhyve/BhyveX64.fdf
> > b/OvmfPkg/Bhyve/BhyveX64.fdf
> > index 153b3cfeba55..3f6270c048cc 100644
> > --- a/OvmfPkg/Bhyve/BhyveX64.fdf
> > +++ b/OvmfPkg/Bhyve/BhyveX64.fdf
> > @@ -239,7 +239,7 @@ INF 
> > MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf
> >  INF 
> > MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.
> > inf
> >  INF  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
> >  INF  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
> > -INF  OvmfPkg/SataControllerDxe/SataControllerDxe.inf
> > +INF  MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf
> >  INF  MdeModulePkg/Bus/Ata/AtaAtapiPassThru/AtaAtapiPassThru.inf
> >  INF  MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBusDxe.inf
> >  INF  MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf

Acked-by: Corvin Köhne 



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




signature.asc
Description: This is a digitally signed message part


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

2023-05-11 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 v12 7/8] UefiCpuPkg: Removes SmmCpuFeaturesReadSaveStateRegister

2023-05-11 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 
---
 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 Devices, Inc. All rights 

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

2023-05-11 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 ..fcf6514443d1
--- /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  = SmmCpuFeaturesLib
+  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 read

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

2023-05-11 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 
---
 .../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 EFI_SUCCESS   The 

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

2023-05-11 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 |   4 +
 .../MmSaveStateLib/IntelMmSaveStateLib.inf|  34 ++
 .../Library/MmSaveStateLib/IntelMmSaveState.c | 413 ++
 3 files changed, 451 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..401550209af9 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
@@ -168,12 +169,14 @@ [Components.IA32, Components.X64]
   FILE_GUID = D1D74FE9-7A4E-41D3-A0B3-67F13AD34D94
 
   
SmmCpuFeaturesLib|UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf
+  MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveStateLib.inf
   }
   UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
 
   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 +194,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 ..d7e31af5275a
--- /dev/null
+++ b/UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveState.c
@@ -0,0 +1,413 @@
+/** @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 MM_SAVE_STATE_REGISTER_SMMREVID_INDEX1
+#define MM_SAVE_STATE_REGISTER_IOMISC_INDEX  2
+#define MM_SAVE_STATE_REGISTER_IOMEMADDR_INDEX   3
+#define INTEL_SMM_SAVE_STATE_REGISTER_MAX_INDEX  4
+
+///
+/// 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 

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

2023-05-11 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 
---
 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 (#104690): https://edk2.groups.io/g/devel/message/104690
Mute This Topic: https://groups.io/mt/98825550/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




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

2023-05-11 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 v12 3/8] UefiCpuPkg: Implements MmSaveStateLib library instance

2023-05-11 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  |  99 ++
 .../Library/MmSaveStateLib/AmdMmSaveState.c   | 311 ++
 .../MmSaveStateLib/MmSaveStateCommon.c| 132 
 5 files changed, 579 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 ..246429fe44fc
--- /dev/null
+++ b/UefiCpuPkg/Library/MmSaveStateLib/MmSaveState.h
@@ -0,0 +1,99 @@
+/** @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 }
+
+#define MM_SAVE_STATE_REGISTER_MAX_INDEX  2
+
+// 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.
+
+  @param[in]  CpuIndex  Specifies the zero-based index of the CPU save state.
+
+  @retval UINT8 returns LMA bit value.
+**/
+UINT8
+EFIAPI
+MmSaveStateGetRegisterLma (
+  IN UINTN  CpuIndex
+  );
+
+/**

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

2023-05-11 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/4387

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 |  14 +
 .../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  |  99 +++
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h|  56 +-
 .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 767 --
 .../Library/MmSaveStateLib/AmdMmSaveState.c   | 311 +++
 .../Library/MmSaveStateLib/IntelMmSaveState.c | 413 ++
 .../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, 1817 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 (#104687): https://edk2.groups.io/g/devel/message/104687
Mute This Topic: https://groups.io/mt/98825543/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




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

2023-05-11 Thread VincentX Ke
Hi, Ray

Thanks for the correction and those suggestion in previous patches.
As your suggestion, the best way is keep following the logic of ACPI spec 
definition.
[Patch V7] updated with https://edk2.groups.io/g/devel/message/104685
I apologize for those flaws in previous patches.

Sincerely,
Vincent
-Original Message-
From: Ni, Ray  
Sent: Thursday, May 11, 2023 11:42 AM
To: devel@edk2.groups.io; Ke, VincentX 
Cc: Chiu, Chasel ; Desimone, Nathaniel L 
; Oram, Isaac W ; Gao, 
Liming ; Dong, Eric ; Sinha, 
Ankit 
Subject: RE: [edk2-devel] [PATCH v6] MinPlatformPkg: Update HWSignature filed 
in FACS

Vincent,
ACPI spec contains following:
  The XSDT provides identical functionality to the RSDT but accommodates 
physical addresses of DESCRIPTION
  HEADERs that are larger than 32 bits. Notice that both the XSDT and the RSDT 
can be pointed to by the RSDP
  structure. An ACPI-compatible OS must use the XSDT if present.

Which means, XSDT is used over RSDT when it exists.
But your code measures both XSDT and RSDT. It's not right.

This change is not a simple change. I suggest you review the ACPI spec in 
detail and close the opens within your team before sending another version of 
patches.

Thanks,
Ray

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of 
> VincentX Ke
> Sent: Wednesday, May 10, 2023 5:58 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 v6] 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   | 271
> +++-
>  Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.inf |   1 +
>  2 files changed, 209 insertions(+), 63 deletions(-)
> 
> diff --git 
> a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
> b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
> index e967031a3b..bb0f4a1f04 100644
> --- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
> +++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
> @@ -1191,98 +1191,243 @@ 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 (, 

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

2023-05-11 Thread VincentX Ke
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) {
+  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));
+  if (Fadt.FirmwareCtrl || Fadt.XFirmwareCtrl) {
+TableCount++;
+  }
+
+  if (Fadt.Dsdt || Fadt.XDsdt) {
+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 HandleCount;
-  EFI_HANDLE*HandleBuffer;
-  EFI_PCI_IO_PROTOCOL   *PciIo;
-  UINT32CRC;
-  UINT32*HWChange;
-  UINTN HWChangeSize;
-  UINT32PciId;
-  UINTN Handle;
-  EFI_ACPI_6_3_FIRMWARE_ACPI_CONTROL_STRUCTURE *FacsPtr;
-  EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE*pFADT;
-
-  HandleCount  = 0;
-  HandleBuffer = NULL;
-
-  Status = gBS->LocateHandleBuffer (
-  ByProtocol,
-  ,
-  NULL,
-  ,
-  
-  );
-  if (EFI_ERROR (Status)) {
-return; // PciIO protocol not installed yet!
+  EFI_STATUSStatus;
+  UINTN Index;
+  UINTN AcpiTableCount;
+  UINTN EntryCount;
+  UINTN BasePtr;
+  UINT64EntryPtr;
+  UINT32

Re: [edk2-devel] [PATCH v1 1/8] UefiPayloadPkg: Remove FP Init from UPL entry

2023-05-11 Thread Guo, Gua
@Dhaval Sharma I give some feedbacks on the PR.
URL: https://github.com/tianocore/edk2/pull/4367
I think we can discuss it on the PR. And currently Edk2 code freeze so the 
change need to hold on until UPL spec 1.0 publish and Edk2 code freeze unlock 
(2023/05/26).

Thanks,
Gua

-Original Message-
From: Dhaval Sharma  
Sent: Thursday, May 11, 2023 3:09 PM
To: devel@edk2.groups.io
Cc: Dong, Guo ; Ni, Ray ; Rhodes, Sean 
; Lu, James ; Guo, Gua 

Subject: [PATCH v1 1/8] UefiPayloadPkg: Remove FP Init from UPL entry

According to UPL spec BL should initialize FP init meaning UPL does not need to 
initialize it. Besides this is arch specific init and needs to be moved out of 
UPL common flow. In order to not break current BL implementations, for now just 
moving the init to later point of time but for both x32 and x64 eventually this 
should be removed once BL impelement this logic.

Test: Verified booting  UEFI shell on coreboot on qemu.

Cc: Guo Dong 
Cc: Ray Ni 
Cc: Sean Rhodes 
Cc: James Lu 
Cc: Gua Guo 

Signed-off-by: Dhaval Sharma 

Reviewed-by: Gua Guo 
Reviewed-by: James Lu 
---

Notes:
v3:
- Added FP initialization to X64 path as well
v4:
- Updated reviewed-by tag

 UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c  | 3 +++
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c | 3 ---
 UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c   | 3 +++
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c 
b/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c
index 61a9f01ec9e7..921a38555e21 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c
@@ -268,6 +268,9 @@ HandOffToDxeCore (
   UINT32   Index;   X64_IDT_TABLE*IdtTableForX64; 
+  // Initialize floating point operating environment to be compliant with UEFI 
spec.+  InitializeFloatingPointUnits ();+   //   // Clear page 0 and mark it as 
allocated if NULL pointer detection is enabled.   //diff --git 
a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c 
b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
index f8939efe70db..8aff00142971 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
@@ -473,9 +473,6 @@ _ModuleEntryPoint (
 PrintHob (mHobList); ); -  // Initialize floating point operating 
environment to be compliant with UEFI spec.-  InitializeFloatingPointUnits ();- 
  // Build HOB based on information from Bootloader   Status = BuildHobs 
(BootloaderParameter, );   ASSERT_EFI_ERROR (Status);diff --git 
a/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c 
b/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
index 346e3feb0459..84a6112ce64a 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
@@ -40,6 +40,9 @@ HandOffToDxeCore (
   VOID   *GhcbBase;   UINTN  GhcbSize; +  // Initialize floating point 
operating environment to be compliant with UEFI spec.+  
InitializeFloatingPointUnits ();+   //   // Clear page 0 and mark it as 
allocated if NULL pointer detection is enabled.   //-- 
2.34.1



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




Re: [edk2-devel] [PATCH v3 4/4] Maintainers.txt: Update reviewers and maintainers for TraceHubDebugLib.

2023-05-11 Thread Leif Lindholm

On 2023-05-10 19:57, Michael D Kinney wrote:

Hi Leif,

The original patch series was sent by Victor in January and has Signed-off-by 
from Victor.

https://edk2.groups.io/g/devel/message/99333

Subsequent updates to the patch series based on feedback were sent by Gua.


Ah, understood.


With this background, who should be Signed-off-by and the Author in the final 
patch series?


Whoever posts patches needs to add their Signed-off-by.
Since Victor's S-o-b was on there from before, Gua could have added 
theirs next to it.

There is no need to add Victor's back though.

/
Leif



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

2023-05-11 Thread Ni, Ray
Jiaxin,
Let's keep using 48 or 57.
We can use separate patch to clean all existing code to use 47 and 56.

Thanks,
Ray

> -Original Message-
> From: Wu, Jiaxin 
> Sent: Thursday, May 11, 2023 1:08 PM
> To: devel@edk2.groups.io; kra...@redhat.com; Ni, Ray 
> Cc: Dong, Eric ; Zeng, Star ;
> Kumar, Rahul R 
> Subject: RE: [edk2-devel] [PATCH v1 1/3] UefiCpuPkg/SecCore: Migrate page
> table to permanent memory
> 
> What's your comments to the existing code logic for the PhysicalAddressBits in
> the CreateIdentityMappingPageTables()? Looks all doesn't consider the  sign-
> extended case? is it reasonable create the paging but not used? All system 
> with
> long mode are sign-extended?
> 
> //
>   // IA-32e paging translates 48-bit linear addresses to 52-bit physical 
> addresses
>   //  when 5-Level Paging is disabled,
>   //  due to either unsupported by HW, or disabled by PCD.
>   //
>   ASSERT (PhysicalAddressBits <= 52);
>   if (!Page5LevelSupport && (PhysicalAddressBits > 48)) {
> PhysicalAddressBits = 48;
>   }
> 
> 
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Gerd
> > Hoffmann
> > Sent: Wednesday, May 10, 2023 3:48 PM
> > To: devel@edk2.groups.io; Ni, Ray 
> > Cc: Wu, Jiaxin ; Dong, Eric ;
> Zeng,
> > Star ; Kumar, Rahul R 
> > Subject: Re: [edk2-devel] [PATCH v1 1/3] UefiCpuPkg/SecCore: Migrate page
> > table to permanent memory
> >
> > On Wed, May 10, 2023 at 02:48:52AM +, Ni, Ray wrote:
> > > Gerd,
> > > My understanding is that when code dereferences memory address, the code
> > itself is responsible for
> > > supplying the sign-extended linear address.
> > > The page table creation logic still maps the entire linear memory space
> > supported by the CPU.
> > >
> > > Why do you think covering the half of the space is better?
> >
> > edk2 boot services operate on the assumption that everything is identity
> > mapped, only runtime services know the concept of virtual addresses.
> >
> > The lower half of the address space can be identity-mapped (virtual
> > address == physical address).  The upper half can not, so I think it's
> > better for efi boot services to restrict themself to the lower half.
> >
> > take care,
> >   Gerd
> >
> >
> >
> > 
> >



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104682): https://edk2.groups.io/g/devel/message/104682
Mute This Topic: https://groups.io/mt/98780500/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 v1 8/8] UefiPayloadPkg: Add RV64 driver to boot to UEFI Shell

2023-05-11 Thread Dhaval Sharma
Added required Dxe and Arch Proto drivers to ensure we
are able to boot to Shell.

Test: Able to boot to UEFI Shell

Cc: Guo Dong 
Cc: Ray Ni 
Cc: Sean Rhodes 
Cc: James Lu 
Cc: Gua Guo 
Cc: Sunil V 
Signed-off-by: Dhaval Sharma 
---
 UefiPayloadPkg/UefiPayloadPkgRV64.dsc | 33 +++--
 UefiPayloadPkg/UefiPayloadPkgRV64.fdf | 51 +++-
 2 files changed, 46 insertions(+), 38 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadPkgRV64.dsc 
b/UefiPayloadPkg/UefiPayloadPkgRV64.dsc
index 8b226c483855..81a59f486837 100644
--- a/UefiPayloadPkg/UefiPayloadPkgRV64.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkgRV64.dsc
@@ -211,7 +211,7 @@ [LibraryClasses.common]
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/BaseRiscV64CpuExceptionHandlerLib/BaseRiscV64CpuExceptionHandlerLib.inf
   RiscVSbiLib|MdePkg/Library/BaseRiscVSbiLib/BaseRiscVSbiLib.inf
   
ResetSystemLib|OvmfPkg/RiscVVirt/Library/ResetSystemLib/BaseResetSystemLib.inf
-
+  TimeBaseLib|EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.inf
 
 [LibraryClasses.common.SEC]
   HobLib|UefiPayloadPkg/Library/PayloadEntryHobLib/HobLib.inf
@@ -252,7 +252,6 @@ [LibraryClasses.common.DXE_RUNTIME_DRIVER]
 !if $(PERFORMANCE_MEASUREMENT_ENABLE)
   PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
 !endif
-  ResetSystemLib|OvmfPkg/Library/ResetSystemLib/DxeResetSystemLib.inf
   UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
 
 !ifdef $(DEBUG_ON_SERIAL_PORT)
@@ -466,11 +465,25 @@ [Components]
   #
   # RISC-V Platform module
   #
-   EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
-   UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf
   #
   # Components that produce the architectural protocols
   #
+  UefiCpuPkg/CpuDxeRiscV64/CpuDxeRiscV64.inf
+  UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf
+  EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
+  MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
+  MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
+  MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
+  
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
+  EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
+
+!if $(DISABLE_RESET_SYSTEM) == FALSE
+  MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
+!endif
+!if $(EMU_VARIABLE_ENABLE) == TRUE
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
+!endif
+
 !if $(SECURITY_STUB_ENABLE) == TRUE
   MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
 !endif
@@ -488,17 +501,6 @@ [Components]
 
   
NULL|UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
   }
-  EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
-  MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
-  MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
-  MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
-  
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
-!if $(DISABLE_RESET_SYSTEM) == FALSE
-  MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
-!endif
-!if $(EMU_VARIABLE_ENABLE) == TRUE
-  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
-!endif
   #
   # Following are the DXE drivers
   #
@@ -593,7 +595,6 @@ [LibraryClasses]
   FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
   ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
   !include NetworkPkg/NetworkLibs.dsc.inc
-  TimeBaseLib|EmbeddedPkg//Library/TimeBaseLib/TimeBaseLib.inf
   
OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
 
 [Components]
diff --git a/UefiPayloadPkg/UefiPayloadPkgRV64.fdf 
b/UefiPayloadPkg/UefiPayloadPkgRV64.fdf
index 747c617b0f60..90128713f544 100644
--- a/UefiPayloadPkg/UefiPayloadPkgRV64.fdf
+++ b/UefiPayloadPkg/UefiPayloadPkgRV64.fdf
@@ -104,34 +104,13 @@ [FV.DXEFV]
 !if $(CRYPTO_PROTOCOL_SUPPORT) == TRUE
 INF CryptoPkg/Driver/CryptoDxe.inf
 !endif
-!if $(SECURITY_STUB_ENABLE) == TRUE
-INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
-!endif
 INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
 INF RuleOverride = UI MdeModulePkg/Application/UiApp/UiApp.inf
 INF MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf
-INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
 INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
-INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
-INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
-INF 
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
-
-!if $(DISABLE_RESET_SYSTEM) == FALSE
-INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
-!endif
-
-!if $(VARIABLE_SUPPORT) == "EMU"
-  INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
-!elseif $(VARIABLE_SUPPORT) == "SPI"
-  INF UefiPayloadPkg/FvbRuntimeDxe/FvbSmm.inf
-  INF 

[edk2-devel] [PATCH v1 6/8] UefiPayloadPkg: Add FirmwareContext for RV64

2023-05-11 Thread Dhaval Sharma
RV CPU driver requires access to HartID and FDT passed by BL.
Set it through FirmwareContext. In future this should be passed
as part of FDT itself to avoid any custome structures.

Cc: Guo Dong 
Cc: Ray Ni 
Cc: Sean Rhodes 
Cc: James Lu 
Cc: Gua Guo 
Cc: Sunil V 
Signed-off-by: Dhaval Sharma 
---
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf  | 2 ++
 UefiPayloadPkg/UefiPayloadEntry/RiscV64/Rv64FdtParserLib.c | 9 +
 2 files changed, 11 insertions(+)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf 
b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
index 9b21b218a657..0cc3c0994aa1 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
@@ -61,6 +61,8 @@ [LibraryClasses]
   CpuLib
   FdtLib
 
+[LibraryClasses.RISCV64]
+  RiscVSbiLib
 [Guids]
   gEfiMemoryTypeInformationGuid
   gEfiFirmwareFileSystem2Guid
diff --git a/UefiPayloadPkg/UefiPayloadEntry/RiscV64/Rv64FdtParserLib.c 
b/UefiPayloadPkg/UefiPayloadEntry/RiscV64/Rv64FdtParserLib.c
index 76f0600482f7..7be38bb742f6 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/RiscV64/Rv64FdtParserLib.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/RiscV64/Rv64FdtParserLib.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #define E820_RAM1
@@ -376,6 +377,14 @@ BuildBlHobs (
   UINTN   FdtPages;
   UINT64  *FdtHobData;
   CONST VOID  *Fdt;
+  EFI_FFS_FILE_HEADER *FileHeader;
+  EFI_FIRMWARE_VOLUME_HEADER  *DxeCoreFv;
+  EFI_STATUS  Status;
+  EFI_RISCV_FIRMWARE_CONTEXT  FirmwareContext;
+
+  FirmwareContext.BootHartId  = Param1;
+  FirmwareContext.FlattenedDeviceTree = Param2;
+  SetFirmwareContextPointer ();
 
   Fdt   = (VOID *)Param2;
   MinimalNeededSize = FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);
-- 
2.34.1



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




[edk2-devel] [PATCH v1 7/8] UefiPayloadPkg: Find DxeFV and create required FV HOB

2023-05-11 Thread Dhaval Sharma
UPL expects to have Dxe info from gUniversalPayloadExtraDataGuid HOB.
With new FDT proposal this requirement should go away. But for now
satisfying this requirement through RV hook.

Test: Able to enter DxeMain function after finding correct DxeFv.

Cc: Guo Dong 
Cc: Ray Ni 
Cc: Sean Rhodes 
Cc: James Lu 
Cc: Gua Guo 
Cc: Sunil V 
Signed-off-by: Dhaval Sharma 
---
 UefiPayloadPkg/UefiPayloadEntry/RiscV64/DxeLoadFunc.c  |  46 ++
 UefiPayloadPkg/UefiPayloadEntry/RiscV64/Rv64FdtParserLib.c | 149 
+++-
 2 files changed, 194 insertions(+), 1 deletion(-)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/RiscV64/DxeLoadFunc.c 
b/UefiPayloadPkg/UefiPayloadEntry/RiscV64/DxeLoadFunc.c
index db44b38cc7c7..ecd249337151 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/RiscV64/DxeLoadFunc.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/RiscV64/DxeLoadFunc.c
@@ -7,6 +7,16 @@
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "UefiPayloadEntry.h"
+
+#define STACK_SIZE  0x2
 
 /**
Transfers control to DxeCore.
@@ -25,4 +35,40 @@ HandOffToDxeCore (
   IN EFI_PEI_HOB_POINTERS  HobList
   )
 {
+  VOID  *BaseOfStack;
+  VOID  *TopOfStack;
+
+  //
+  //
+  // Allocate 128KB for the Stack
+  //
+  BaseOfStack = AllocatePages (EFI_SIZE_TO_PAGES (STACK_SIZE));
+  if (BaseOfStack == NULL) {
+DEBUG ((DEBUG_ERROR, "%a: Can't allocate memory for stack.", __func__));
+ASSERT (FALSE);
+  }
+
+  //
+  // Compute the top of the stack we were allocated. Pre-allocate a UINTN
+  // for safety.
+  //
+  TopOfStack = (VOID *)((UINTN)BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * 
EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);
+  TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
+
+  //
+  // Update the contents of BSP stack HOB to reflect the real stack info 
passed to DxeCore.
+  //
+  UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN)BaseOfStack, STACK_SIZE);
+
+  DEBUG ((DEBUG_INFO, "DXE Core new stack at %x, stack pointer at %x\n", 
BaseOfStack, TopOfStack));
+
+  //
+  // Transfer the control to the entry point of DxeCore.
+  //
+  SwitchStack (
+(SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,
+HobList.Raw,
+NULL,
+TopOfStack
+);
 }
diff --git a/UefiPayloadPkg/UefiPayloadEntry/RiscV64/Rv64FdtParserLib.c 
b/UefiPayloadPkg/UefiPayloadEntry/RiscV64/Rv64FdtParserLib.c
index 7be38bb742f6..b1251a83a236 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/RiscV64/Rv64FdtParserLib.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/RiscV64/Rv64FdtParserLib.c
@@ -41,6 +41,8 @@
 #define E820_DISABLED   6
 #define E820_PMEM   7
 #define E820_UNDEFINED  8
+#define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
+  ((ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & 
((Alignment) - 1)))
 
 /**
   Auto-generated function that calls the library constructors for all of the 
module's
@@ -341,6 +343,138 @@ BuildSerialHobFromFDT (
   return TRUE;
 }
 
+/**
+  This function searchs a given file type with a given Guid within a valid FV.
+  If input Guid is NULL, will locate the first section having the given file 
type
+
+  @param FvHeaderA pointer to firmware volume header that contains the 
set of files
+ to be searched.
+  @param FileTypeFile type to be searched.
+  @param GuidWill ignore if it is NULL.
+  @param FileHeader  A pointer to the discovered file, if successful.
+
+  @retval EFI_SUCCESSSuccessfully found FileType
+  @retval EFI_NOT_FOUND  File type can't be found.
+**/
+STATIC EFI_STATUS
+FvFindFileByTypeGuid (
+  IN  EFI_FIRMWARE_VOLUME_HEADER  *FvHeader,
+  IN  EFI_FV_FILETYPE FileType,
+  IN  EFI_GUID*Guid  OPTIONAL,
+  OUT EFI_FFS_FILE_HEADER **FileHeader
+  )
+{
+  EFI_PHYSICAL_ADDRESS  CurrentAddress;
+  EFI_PHYSICAL_ADDRESS  EndOfFirmwareVolume;
+  EFI_FFS_FILE_HEADER   *File;
+  UINT32Size;
+  EFI_PHYSICAL_ADDRESS  EndOfFile;
+
+  CurrentAddress  = (EFI_PHYSICAL_ADDRESS)(UINTN)FvHeader;
+  EndOfFirmwareVolume = CurrentAddress + FvHeader->FvLength;
+
+  //
+  // Loop through the FFS files
+  //
+  for (EndOfFile = CurrentAddress + FvHeader->HeaderLength; ; ) {
+CurrentAddress = (EndOfFile + 7) & 0xfff8ULL;
+if (CurrentAddress > EndOfFirmwareVolume) {
+  break;
+}
+
+File = (EFI_FFS_FILE_HEADER *)(UINTN)CurrentAddress;
+if (IS_FFS_FILE2 (File)) {
+  Size = FFS_FILE2_SIZE (File);
+  if (Size <= 0x00FF) {
+break;
+  }
+} else {
+  Size = FFS_FILE_SIZE (File);
+  if (Size < sizeof (EFI_FFS_FILE_HEADER)) {
+break;
+  }
+}
+
+EndOfFile = CurrentAddress + Size;
+if (EndOfFile > EndOfFirmwareVolume) {
+  break;
+}
+
+//
+// Look for file type
+//
+if (File->Type == FileType) {
+  if ((Guid == NULL) || CompareGuid (>Name, Guid)) {
+*FileHeader = File;
+return 

[edk2-devel] [PATCH v1 3/8] UefiPayloadPkg: Basic Infra To Enable RV64 UPL Support

2023-05-11 Thread Dhaval Sharma
Add support for RiscV64 Arch for UPL. The Patch primarily
allows one to compile UPL with RV64 GCC tools.
It builds on top of earlier patches submitted for UPL
boot flow modifications where arch specific initialization
was removed. Follow up patches will be added to further the
boot flow.

Test: Tested that code compiles UPL Pkg with RV64 GCC5

Cc: Guo Dong 
Cc: Ray Ni 
Cc: Sean Rhodes 
Cc: James Lu 
Cc: Gua Guo 
Cc: Sunil V 

Signed-off-by: Dhaval Sharma 
---
 UefiPayloadPkg/UefiPayloadPkgRV64.dsc | 637 

 UefiPayloadPkg/UefiPayloadPkgRV64.fdf | 318 ++
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf |   4 +-
 UefiPayloadPkg/UefiPayloadEntry/RiscV64/DxeLoadFunc.c |  28 +
 4 files changed, 986 insertions(+), 1 deletion(-)

diff --git a/UefiPayloadPkg/UefiPayloadPkgRV64.dsc 
b/UefiPayloadPkg/UefiPayloadPkgRV64.dsc
new file mode 100644
index ..8b226c483855
--- /dev/null
+++ b/UefiPayloadPkg/UefiPayloadPkgRV64.dsc
@@ -0,0 +1,637 @@
+## @file
+# Bootloader Payload Package
+#
+# Provides drivers and definitions to create uefi payload for bootloaders.
+#
+# Copyright (c) 2023, Rivos Inc
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+
+#
+# Defines Section - statements that will be processed to create a Makefile.
+#
+
+[Defines]
+  PLATFORM_NAME   = UefiPayloadPkg
+  PLATFORM_GUID   = F71608AB-D63D-4491-B744-A8C8CD96
+  PLATFORM_VERSION= 0.1
+  DSC_SPECIFICATION   = 0x00010005
+  SUPPORTED_ARCHITECTURES = RISCV64
+  BUILD_TARGETS   = DEBUG|RELEASE|NOOPT
+  SKUID_IDENTIFIER= DEFAULT
+  OUTPUT_DIRECTORY= Build/UefiPayloadPkgRV64
+  FLASH_DEFINITION= UefiPayloadPkg/UefiPayloadPkgRV64.fdf
+  PCD_DYNAMIC_AS_DYNAMICEX= TRUE
+
+  DEFINE SECURITY_STUB_ENABLE = TRUE
+  DEFINE PLATFORM_BOOT_TIMEOUT= 3
+  DEFINE UNIVERSAL_PAYLOAD= TRUE
+  DEFINE DEBUG_ON_SERIAL_PORT = TRUE
+  #
+  # CPU options
+  #
+  DEFINE MAX_LOGICAL_PROCESSORS   = 256
+
+  #
+  # PCI options
+  #
+  DEFINE PCIE_BASE_SUPPORT= TRUE
+
+  #
+  # Serial port set up
+  #
+  DEFINE BAUD_RATE= 115200
+  DEFINE SERIAL_CLOCK_RATE= 1843200
+  DEFINE SERIAL_LINE_CONTROL  = 3 # 8-bits, no parity
+  DEFINE SERIAL_HARDWARE_FLOW_CONTROL = FALSE
+  DEFINE SERIAL_DETECT_CABLE  = FALSE
+  DEFINE SERIAL_FIFO_CONTROL  = 7 # Enable FIFO
+  DEFINE UART_DEFAULT_BAUD_RATE   = $(BAUD_RATE)
+  DEFINE UART_DEFAULT_DATA_BITS   = 8
+  DEFINE UART_DEFAULT_PARITY  = 1
+  DEFINE UART_DEFAULT_STOP_BITS   = 1
+  DEFINE DEFAULT_TERMINAL_TYPE= 0
+
+  # Enabling the serial terminal will slow down the boot menu redering!
+  DEFINE DISABLE_SERIAL_TERMINAL  = FALSE
+
+  #   [Vendor]   [Device]  
[ClockRate---]  [Offset---] [Bar] [Stride] [RxFifo] 
[TxFifo]   [Rsvd]   [Vendor]
+  DEFINE PCI_SERIAL_PARAMETERS= {0xff,0xff, 0x00,0x00, 
0x0,0x20,0x1c,0x00, 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x00,0x01, 0x0,0x0, 
0x0,0x0, 0x0,0x0, 0xff,0xff}
+
+  #
+  # Shell options: [BUILD_SHELL, MIN_BIN, NONE, UEFI_BIN]
+  #
+  DEFINE SHELL_TYPE   = BUILD_SHELL
+
+  #
+  # EMU:  UEFI payload with EMU variable
+  # SPI:  UEFI payload with SPI NV variable support
+  # NONE: UEFI payload with no variable modules
+  #
+  DEFINE VARIABLE_SUPPORT  = EMU
+
+  DEFINE SERIAL_DRIVER_ENABLE = TRUE
+
+  # For recent X86 CPU, 0x15 CPUID instruction will return Time Stamp Counter 
Frequence.
+  # This is how BaseCpuTimerLib works, and a recommended way to get Frequence, 
so set the default value as TRUE.
+  # Note: for emulation platform such as QEMU, this may not work and should 
set it as FALSE
+  DEFINE CPU_TIMER_LIB_ENABLE  = TRUE
+
+[BuildOptions]
+  *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
+  GCC:RELEASE_*_*_CC_FLAGS   = -DMDEPKG_NDEBUG
+  INTEL:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG
+
+[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
+  GCC:*_*_*_DLINK_FLAGS  = -z common-page-size=0x1000
+  XCODE:*_*_*_DLINK_FLAGS= -seg1addr 0x1000 -segalign 0x1000
+  XCODE:*_*_*_MTOC_FLAGS = -align 0x1000
+  CLANGPDB:*_*_*_DLINK_FLAGS = /ALIGN:4096
+
+
+#
+# SKU Identification section - list of all SKU IDs supported by this Platform.
+#
+
+[SkuIds]
+  0|DEFAULT
+
+
+#
+# 

[edk2-devel] [PATCH v1 5/8] UefiPayloadPkg: Hook to parse IN params as per UPL spec

2023-05-11 Thread Dhaval Sharma
Provide an arch specific hook which will consume IN params
to UPL and populate FDT variable properly. Each Arch has its
own ABI and accordingly input param changes. First part, This
hook will ensure correct input param is used to populate FDT
value. Second part, after finding proper FDT, it uses FDT to
create HOBs that are later consumed by UPL.New implementation
may remove HOB creation as per latest spec. First part will
still be relevant.

Test: Able to parse FDT, create HOBs and get serial debug logs.

Cc: Guo Dong 
Cc: Ray Ni 
Cc: Sean Rhodes 
Cc: James Lu 
Cc: Gua Guo 
Cc: Sunil V 

Signed-off-by: Dhaval Sharma 
---
 UefiPayloadPkg/UefiPayloadPkg.dsc  |   2 +-
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf  |   6 +
 UefiPayloadPkg/UefiPayloadEntry/Ia32/Ia32FdtParserLib.c|  33 ++
 UefiPayloadPkg/UefiPayloadEntry/RiscV64/Rv64FdtParserLib.c | 469 

 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c|  13 +-
 UefiPayloadPkg/UefiPayloadEntry/X64/X64FdtParserLib.c  |  33 ++
 6 files changed, 553 insertions(+), 3 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc 
b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 998d22290922..e5eac44d06b2 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -305,7 +305,7 @@ [LibraryClasses]
   
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
   CcExitLib|UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.inf
   
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
-
+  FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
 [LibraryClasses.common]
 !if $(BOOTSPLASH_IMAGE)
   SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf 
b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
index 14d072e1198f..9b21b218a657 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
@@ -32,19 +32,23 @@ [Sources.Ia32]
   X64/VirtualMemory.c
   Ia32/DxeLoadFunc.c
   Ia32/IdtVectorAsm.nasm
+  Ia32/Ia32FdtParserLib.c
 
 [Sources.X64]
   X64/VirtualMemory.h
   X64/VirtualMemory.c
   X64/DxeLoadFunc.c
+  X64/X64FdtParserLib.c
 
 [Sources.RISCV64]
   RiscV64/DxeLoadFunc.c
+  RiscV64/Rv64FdtParserLib.c
 [Packages]
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
   UefiCpuPkg/UefiCpuPkg.dec
   UefiPayloadPkg/UefiPayloadPkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
 
 [LibraryClasses]
   BaseMemoryLib
@@ -55,6 +59,7 @@ [LibraryClasses]
   HobLib
   PeCoffLib
   CpuLib
+  FdtLib
 
 [Guids]
   gEfiMemoryTypeInformationGuid
@@ -72,6 +77,7 @@ [Guids]
   gUniversalPayloadPciRootBridgeInfoGuid
   gUniversalPayloadSmbios3TableGuid
   gEdkiiBootManagerMenuFileGuid
+  gFdtHobGuid
 
 [FeaturePcd.IA32]
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode  ## CONSUMES
diff --git a/UefiPayloadPkg/UefiPayloadEntry/Ia32/Ia32FdtParserLib.c 
b/UefiPayloadPkg/UefiPayloadEntry/Ia32/Ia32FdtParserLib.c
new file mode 100644
index ..ec35834a782b
--- /dev/null
+++ b/UefiPayloadPkg/UefiPayloadEntry/Ia32/Ia32FdtParserLib.c
@@ -0,0 +1,33 @@
+/** @file
+  This library will parse the coreboot table in memory and extract those 
required
+  information.
+
+  Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+EFI_STATUS
+BuildBlHobs (
+  IN  UINTN   Param1,
+  IN  UINTN   Param2,
+  OUT EFI_FIRMWARE_VOLUME_HEADER  **DxeFv
+  );
+
+/**
+  It will build HOBs based on information from bootloaders.
+
+  @param[in]  Param1   Hard ID
+  @param[in]  Param2   FDT blob pointer
+  @param[out] DxeFvThe pointer to the DXE FV in memory.
+
+  @retval EFI_SUCCESSIf it completed successfully.
+**/
+EFI_STATUS
+BuildBlHobs (
+  IN  UINTN   Param1,
+  IN  UINTN   Param2,
+  OUT EFI_FIRMWARE_VOLUME_HEADER  **DxeFv
+  )
+{
+  return EFI_SUCCESS;
+}
diff --git a/UefiPayloadPkg/UefiPayloadEntry/RiscV64/Rv64FdtParserLib.c 
b/UefiPayloadPkg/UefiPayloadEntry/RiscV64/Rv64FdtParserLib.c
new file mode 100644
index ..76f0600482f7
--- /dev/null
+++ b/UefiPayloadPkg/UefiPayloadEntry/RiscV64/Rv64FdtParserLib.c
@@ -0,0 +1,469 @@
+/** @file
+  This library will parse the coreboot table in memory and extract those 
required
+  information.
+
+  Copyright (c) 2014 - 2021, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define E820_RAM1
+#define E820_RESERVED   2
+#define E820_ACPI   3
+#define 

[edk2-devel] [PATCH v1 4/8] UefiPayloadPkg: Update input params as per latest UPL spec

2023-05-11 Thread Dhaval Sharma
According to UPL spec for various archs ABIs we have different
input passing arguments. We provide Arch specific hooks to
ensure FDT is populated from the correct argument following the
spec. TODO: Will have to create one parser per arch.

Cc: Guo Dong 
Cc: Ray Ni 
Cc: Sean Rhodes 
Cc: James Lu 
Cc: Gua Guo 
Cc: Sunil V 
Signed-off-by: Dhaval Sharma 
---
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c 
b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
index 3f7f72ea7f06..59cb4d56e314 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
@@ -450,16 +450,15 @@ BuildHobs (
 EFI_STATUS
 EFIAPI
 _ModuleEntryPoint (
-  IN UINTN  BootloaderParameter
+  IN UINTN  Param1,
+  IN UINTN  Param2
   )
 {
   EFI_STATUS  Status;
   PHYSICAL_ADDRESSDxeCoreEntryPoint;
   EFI_PEI_HOB_POINTERSHob;
-  EFI_FIRMWARE_VOLUME_HEADER  *DxeFv;
+  EFI_FIRMWARE_VOLUME_HEADER  *DxeFv = NULL;
 
-  mHobList = (VOID *)BootloaderParameter;
-  DxeFv= NULL;
   // Call constructor for all libraries
   ProcessLibraryConstructorList ();
 
@@ -473,10 +472,6 @@ _ModuleEntryPoint (
 PrintHob (mHobList);
 );
 
-  // Build HOB based on information from Bootloader
-  Status = BuildHobs (BootloaderParameter, );
-  ASSERT_EFI_ERROR (Status);
-
   FixUpPcdDatabase (DxeFv);
   Status = UniversalLoadDxeCore (DxeFv, );
   ASSERT_EFI_ERROR (Status);
-- 
2.34.1



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




[edk2-devel] [PATCH v1 2/8] UefiPayloadPkg: Move INT prog outside common flow

2023-05-11 Thread Dhaval Sharma
8259 is very arch specific programming. It needs to be moved out to
the respective arch flow. Added in both x64 and x32 paths

Test: Able to boot UEFI shell with Coreboot Tianocore payload on
x86 qemu

Cc: Guo Dong 
Cc: Ray Ni 
Cc: Sean Rhodes 
Cc: James Lu 
Cc: Gua Guo 

Signed-off-by: Dhaval Sharma 

Reviewed-by: Gua Guo 
Reviewed-by: James Lu 
---

Notes:
v3:
- Added legacy INT intialization to X64 path as well
v4:
- Updated reviewed-by tag

 UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c  | 6 ++
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c | 6 --
 UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c   | 6 ++
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c 
b/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c
index 921a38555e21..695d751bbb50 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c
@@ -271,6 +271,12 @@ HandOffToDxeCore (
   // Initialize floating point operating environment to be compliant with UEFI 
spec.
   InitializeFloatingPointUnits ();
 
+  //
+  // Mask off all legacy 8259 interrupt sources
+  //
+  IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF);
+  IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF);
+
   //
   // Clear page 0 and mark it as allocated if NULL pointer detection is 
enabled.
   //
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c 
b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
index 8aff00142971..3f7f72ea7f06 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
@@ -481,12 +481,6 @@ _ModuleEntryPoint (
   Status = UniversalLoadDxeCore (DxeFv, );
   ASSERT_EFI_ERROR (Status);
 
-  //
-  // Mask off all legacy 8259 interrupt sources
-  //
-  IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF);
-  IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF);
-
   Hob.HandoffInformationTable = (EFI_HOB_HANDOFF_INFO_TABLE *)GetFirstHob 
(EFI_HOB_TYPE_HANDOFF);
   HandOffToDxeCore (DxeCoreEntryPoint, Hob);
 
diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c 
b/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
index 84a6112ce64a..1dfb7459e85a 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
@@ -43,6 +43,12 @@ HandOffToDxeCore (
   // Initialize floating point operating environment to be compliant with UEFI 
spec.
   InitializeFloatingPointUnits ();
 
+  //
+  // Mask off all legacy 8259 interrupt sources
+  //
+  IoWrite8 (LEGACY_8259_MASK_REGISTER_MASTER, 0xFF);
+  IoWrite8 (LEGACY_8259_MASK_REGISTER_SLAVE, 0xFF);
+
   //
   // Clear page 0 and mark it as allocated if NULL pointer detection is 
enabled.
   //
-- 
2.34.1



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




[edk2-devel] [PATCH v1 1/8] UefiPayloadPkg: Remove FP Init from UPL entry

2023-05-11 Thread Dhaval Sharma
According to UPL spec BL should initialize FP init meaning UPL
does not need to initialize it. Besides this is arch specific init
and needs to be moved out of UPL common flow. In order to not break
current BL implementations, for now just moving the init to later
point of time but for both x32 and x64 eventually this should be
removed once BL impelement this logic.

Test: Verified booting  UEFI shell on coreboot on qemu.

Cc: Guo Dong 
Cc: Ray Ni 
Cc: Sean Rhodes 
Cc: James Lu 
Cc: Gua Guo 

Signed-off-by: Dhaval Sharma 

Reviewed-by: Gua Guo 
Reviewed-by: James Lu 
---

Notes:
v3:
- Added FP initialization to X64 path as well
v4:
- Updated reviewed-by tag

 UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c  | 3 +++
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c | 3 ---
 UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c   | 3 +++
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c 
b/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c
index 61a9f01ec9e7..921a38555e21 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c
@@ -268,6 +268,9 @@ HandOffToDxeCore (
   UINT32   Index;
   X64_IDT_TABLE*IdtTableForX64;
 
+  // Initialize floating point operating environment to be compliant with UEFI 
spec.
+  InitializeFloatingPointUnits ();
+
   //
   // Clear page 0 and mark it as allocated if NULL pointer detection is 
enabled.
   //
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c 
b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
index f8939efe70db..8aff00142971 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
@@ -473,9 +473,6 @@ _ModuleEntryPoint (
 PrintHob (mHobList);
 );
 
-  // Initialize floating point operating environment to be compliant with UEFI 
spec.
-  InitializeFloatingPointUnits ();
-
   // Build HOB based on information from Bootloader
   Status = BuildHobs (BootloaderParameter, );
   ASSERT_EFI_ERROR (Status);
diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c 
b/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
index 346e3feb0459..84a6112ce64a 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
@@ -40,6 +40,9 @@ HandOffToDxeCore (
   VOID   *GhcbBase;
   UINTN  GhcbSize;
 
+  // Initialize floating point operating environment to be compliant with UEFI 
spec.
+  InitializeFloatingPointUnits ();
+
   //
   // Clear page 0 and mark it as allocated if NULL pointer detection is 
enabled.
   //
-- 
2.34.1



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




[edk2-devel] DRAFT: [PATCH v1 0/8] RiscV64 Support In UPL

2023-05-11 Thread Dhaval Sharma
This patchset contains modifications required in UPL boot flow to
enable RiscV64 support. Squashing earlier series of patches
related to arch specific removal from UPL boot path to this release such
that all chnages can be viewed in the entirety.
1. Add required infra to support RiscV64
2. New UPL proposal supports multiple Archs and accordingly ABI
   is also different. This is a proposal to accomodate these changes.
   This patch adds a hook to parse RiscV64 specific IN params and extract
   FDT from the same.
3. Take FDT received from BL and parse it to create required HOBs that
   are later consumed by UPL.
4. Add FirmwareContext structure which is specific to RV and used by RV
   CPU driver.
5. Add required modifications to extrace DxeFv from overall UPL FD.
6. Add required RV drivers to boot to UEFI Shell

P.S. This patch is review only at this point as it is tested in a limited
fashion for RV to get to early debug logs from FDT described serial device.
It will require modifications to work on other Archs.

Branch https://github.com/rivosinc/edk2/tree/upl-rv64-enable-compilation-v1

Dhaval Sharma (8):
  UefiPayloadPkg: Remove FP Init from UPL entry
  UefiPayloadPkg: Move INT prog outside common flow
  UefiPayloadPkg: Basic Infra To Enable RV64 UPL Support
  UefiPayloadPkg: Update input params as per latest UPL spec
  UefiPayloadPkg: Hook to parse IN params as per UPL spec
  UefiPayloadPkg: Add FirmwareContext for RV64
  UefiPayloadPkg: Find DxeFV and create required FV HOB
  UefiPayloadPkg: Add RV64 driver to boot to UEFI Shell

 UefiPayloadPkg/UefiPayloadPkg.dsc  |   2 +-
 UefiPayloadPkg/{UefiPayloadPkg.dsc => UefiPayloadPkgRV64.dsc}  | 448 
+++---
 UefiPayloadPkg/UefiPayloadPkgRV64.fdf  | 325 ++
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf  |  12 +-
 UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c |   9 +
 UefiPayloadPkg/UefiPayloadEntry/Ia32/Ia32FdtParserLib.c|  33 ++
 UefiPayloadPkg/UefiPayloadEntry/{X64 => RiscV64}/DxeLoadFunc.c |  62 +-
 UefiPayloadPkg/UefiPayloadEntry/RiscV64/Rv64FdtParserLib.c | 625 

 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c|  29 +-
 UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c  |   9 +
 UefiPayloadPkg/UefiPayloadEntry/X64/X64FdtParserLib.c  |  33 ++
 11 files changed, 1166 insertions(+), 421 deletions(-)
 copy UefiPayloadPkg/{UefiPayloadPkg.dsc => UefiPayloadPkgRV64.dsc} (63%)
 create mode 100644 UefiPayloadPkg/UefiPayloadPkgRV64.fdf
 create mode 100644 UefiPayloadPkg/UefiPayloadEntry/Ia32/Ia32FdtParserLib.c
 copy UefiPayloadPkg/UefiPayloadEntry/{X64 => RiscV64}/DxeLoadFunc.c (51%)
 create mode 100644 UefiPayloadPkg/UefiPayloadEntry/RiscV64/Rv64FdtParserLib.c
 create mode 100644 UefiPayloadPkg/UefiPayloadEntry/X64/X64FdtParserLib.c

-- 
2.34.1



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




[edk2-devel] [PATCH v1 1/8] UefiPayloadPkg: Remove FP Init from UPL entry

2023-05-11 Thread Dhaval Sharma
According to UPL spec BL should initialize FP init meaning UPL
does not need to initialize it. Besides this is arch specific init
and needs to be moved out of UPL common flow. In order to not break
current BL implementations, for now just moving the init to later
point of time but for both x32 and x64 eventually this should be
removed once BL impelement this logic.

Test: Verified booting  UEFI shell on coreboot on qemu.

Cc: Guo Dong 
Cc: Ray Ni 
Cc: Sean Rhodes 
Cc: James Lu 
Cc: Gua Guo 

Signed-off-by: Dhaval Sharma 

Reviewed-by: Gua Guo 
Reviewed-by: James Lu 
---

Notes:
v3:
- Added FP initialization to X64 path as well
v4:
- Updated reviewed-by tag

 UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c  | 3 +++
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c | 3 ---
 UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c   | 3 +++
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c 
b/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c
index 61a9f01ec9e7..921a38555e21 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c
@@ -268,6 +268,9 @@ HandOffToDxeCore (
   UINT32   Index;
   X64_IDT_TABLE*IdtTableForX64;
 
+  // Initialize floating point operating environment to be compliant with UEFI 
spec.
+  InitializeFloatingPointUnits ();
+
   //
   // Clear page 0 and mark it as allocated if NULL pointer detection is 
enabled.
   //
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c 
b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
index f8939efe70db..8aff00142971 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
@@ -473,9 +473,6 @@ _ModuleEntryPoint (
 PrintHob (mHobList);
 );
 
-  // Initialize floating point operating environment to be compliant with UEFI 
spec.
-  InitializeFloatingPointUnits ();
-
   // Build HOB based on information from Bootloader
   Status = BuildHobs (BootloaderParameter, );
   ASSERT_EFI_ERROR (Status);
diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c 
b/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
index 346e3feb0459..84a6112ce64a 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c
@@ -40,6 +40,9 @@ HandOffToDxeCore (
   VOID   *GhcbBase;
   UINTN  GhcbSize;
 
+  // Initialize floating point operating environment to be compliant with UEFI 
spec.
+  InitializeFloatingPointUnits ();
+
   //
   // Clear page 0 and mark it as allocated if NULL pointer detection is 
enabled.
   //
-- 
2.34.1



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




[edk2-devel] DRAFT: [PATCH v1 0/8] RiscV64 Support In UPL

2023-05-11 Thread Dhaval Sharma
This patchset contains modifications required in UPL boot flow to
enable RiscV64 support. Squashing earlier series of patches
related to arch specific removal from UPL boot path to this release such
that all chnages can be viewed in the entirety.
1. Add required infra to support RiscV64
2. New UPL proposal supports multiple Archs and accordingly ABI
   is also different. This is a proposal to accomodate these changes.
   This patch adds a hook to parse RiscV64 specific IN params and extract
   FDT from the same.
3. Take FDT received from BL and parse it to create required HOBs that
   are later consumed by UPL.
4. Add FirmwareContext structure which is specific to RV and used by RV
   CPU driver.
5. Add required modifications to extrace DxeFv from overall UPL FD.
6. Add required RV drivers to boot to UEFI Shell

P.S. This patch is review only at this point as it is tested in a limited
fashion for RV to get to early debug logs from FDT described serial device.
It will require modifications to work on other Archs.

Branch https://github.com/rivosinc/edk2/tree/upl-rv64-enable-compilation-v1

Dhaval Sharma (8):
  UefiPayloadPkg: Remove FP Init from UPL entry
  UefiPayloadPkg: Move INT prog outside common flow
  UefiPayloadPkg: Basic Infra To Enable RV64 UPL Support
  UefiPayloadPkg: Update input params as per latest UPL spec
  UefiPayloadPkg: Hook to parse IN params as per UPL spec
  UefiPayloadPkg: Add FirmwareContext for RV64
  UefiPayloadPkg: Find DxeFV and create required FV HOB
  UefiPayloadPkg: Add RV64 driver to boot to UEFI Shell

 UefiPayloadPkg/UefiPayloadPkg.dsc  |   2 +-
 UefiPayloadPkg/{UefiPayloadPkg.dsc => UefiPayloadPkgRV64.dsc}  | 448 
+++---
 UefiPayloadPkg/UefiPayloadPkgRV64.fdf  | 325 ++
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf  |  12 +-
 UefiPayloadPkg/UefiPayloadEntry/Ia32/DxeLoadFunc.c |   9 +
 UefiPayloadPkg/UefiPayloadEntry/Ia32/Ia32FdtParserLib.c|  33 ++
 UefiPayloadPkg/UefiPayloadEntry/{X64 => RiscV64}/DxeLoadFunc.c |  62 +-
 UefiPayloadPkg/UefiPayloadEntry/RiscV64/Rv64FdtParserLib.c | 625 

 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c|  29 +-
 UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c  |   9 +
 UefiPayloadPkg/UefiPayloadEntry/X64/X64FdtParserLib.c  |  33 ++
 11 files changed, 1166 insertions(+), 421 deletions(-)
 copy UefiPayloadPkg/{UefiPayloadPkg.dsc => UefiPayloadPkgRV64.dsc} (63%)
 create mode 100644 UefiPayloadPkg/UefiPayloadPkgRV64.fdf
 create mode 100644 UefiPayloadPkg/UefiPayloadEntry/Ia32/Ia32FdtParserLib.c
 copy UefiPayloadPkg/UefiPayloadEntry/{X64 => RiscV64}/DxeLoadFunc.c (51%)
 create mode 100644 UefiPayloadPkg/UefiPayloadEntry/RiscV64/Rv64FdtParserLib.c
 create mode 100644 UefiPayloadPkg/UefiPayloadEntry/X64/X64FdtParserLib.c

-- 
2.34.1



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




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

2023-05-11 Thread Ard Biesheuvel
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 (#104670): https://edk2.groups.io/g/devel/message/104670
Mute This Topic: https://groups.io/mt/98822561/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




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

2023-05-11 Thread Ni, Ray
>   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.
2. MmSaveStateGetRegisterLma() doesn't need to carry "CpuIndex" as parameter. 
Can you please remove the parameter?
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.)

> 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.

@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: 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 |  14 +
>  .../MmSaveStateLib/AmdMmSaveStateLib.inf  |  28 +
>  .../MmSaveStateLib/IntelMmSaveStateLib.inf|  28 +
>  .../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  | 102 +++
>  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h|  56 +-
>  .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 767 --
>  .../Library/MmSaveStateLib/AmdMmSaveState.c   | 309 +++
>  .../Library/MmSaveStateLib/IntelMmSaveState.c | 413 ++
>  .../MmSaveStateLib/MmSaveStateCommon.c| 138 
>  .../SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c  | 387 +
>  .../IntelSmmCpuFeaturesLib.c  |  70 ++
>  .../SmmCpuFeaturesLibCommon.c | 128 ---
>