public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [Patch V2 0/5] Use MpService2Ppi to wakeup CPU in Smm CpuS3
@ 2023-08-21  2:09 duntan
  2023-08-21  2:09 ` [edk2-devel] [Patch V2 1/5] MdeModulePkg: add MpService2Ppi field in SMM_S3_RESUME_STATE duntan
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: duntan @ 2023-08-21  2:09 UTC (permalink / raw)
  To: devel

In V2 patch set:
1.Put MpService2Ppi together with other Return*** fields as they are a group of fields initialized in S3 boot path.
2.Use %lx print format for MpService2Ppi
3.Implemente InitializeAp and InitializeBsp as a single function InitializeCpuProcedure because they are doing almost the same thing

*** BLURB HERE ***

Dun Tan (5):
  MdeModulePkg: add MpService2Ppi field in SMM_S3_RESUME_STATE
  UefiCpuPkg/S3Resume2Pei: prepare MpService2Ppi in S3Resume
  UefiCpuPkg/S3Resume2Pei: assert for invalid excution mode combo
  UefiCpuPkg/PiSmmCpuDxe: code refinement for CpuS3.c
  UefiCpuPkg/PiSmmCpuDxe: use MpService2Ppi to wakeup AP in s3

 MdeModulePkg/Include/Guid/AcpiS3Context.h               |   3 ++-
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c                       | 298 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------------------
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c       |  25 ++++++++++++++++++++++++-
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf |   3 ++-
 4 files changed, 191 insertions(+), 138 deletions(-)

-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107900): https://edk2.groups.io/g/devel/message/107900
Mute This Topic: https://groups.io/mt/100866127/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [edk2-devel] [Patch V2 1/5] MdeModulePkg: add MpService2Ppi field in SMM_S3_RESUME_STATE
  2023-08-21  2:09 [edk2-devel] [Patch V2 0/5] Use MpService2Ppi to wakeup CPU in Smm CpuS3 duntan
@ 2023-08-21  2:09 ` duntan
  2023-08-21  2:09 ` [edk2-devel] [Patch V2 2/5] UefiCpuPkg/S3Resume2Pei: prepare MpService2Ppi in S3Resume duntan
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: duntan @ 2023-08-21  2:09 UTC (permalink / raw)
  To: devel; +Cc: Ray Ni, Jian J Wang, Liming Gao

Add MpService2Ppi field in SMM_S3_RESUME_STATE of
AcpiS3Context.h. It will be used to wakeup AP to do the CPU
initialization during smm s3 boot flow in following patches.
With this field, we can avoid sending InitSipiSipi to wakeup
AP.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
---
 MdeModulePkg/Include/Guid/AcpiS3Context.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Include/Guid/AcpiS3Context.h b/MdeModulePkg/Include/Guid/AcpiS3Context.h
index 645496d191..72d173c4fd 100644
--- a/MdeModulePkg/Include/Guid/AcpiS3Context.h
+++ b/MdeModulePkg/Include/Guid/AcpiS3Context.h
@@ -1,7 +1,7 @@
 /** @file
   Definitions for data structures used in S3 resume.
 
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2023, Intel Corporation. All rights reserved.<BR>
 
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -30,6 +30,7 @@ typedef struct {
   EFI_PHYSICAL_ADDRESS    ReturnContext1;
   EFI_PHYSICAL_ADDRESS    ReturnContext2;
   EFI_PHYSICAL_ADDRESS    ReturnStackPointer;
+  EFI_PHYSICAL_ADDRESS    MpService2Ppi;
   EFI_PHYSICAL_ADDRESS    Smst;
 } SMM_S3_RESUME_STATE;
 
-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107901): https://edk2.groups.io/g/devel/message/107901
Mute This Topic: https://groups.io/mt/100866128/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [edk2-devel] [Patch V2 2/5] UefiCpuPkg/S3Resume2Pei: prepare MpService2Ppi in S3Resume
  2023-08-21  2:09 [edk2-devel] [Patch V2 0/5] Use MpService2Ppi to wakeup CPU in Smm CpuS3 duntan
  2023-08-21  2:09 ` [edk2-devel] [Patch V2 1/5] MdeModulePkg: add MpService2Ppi field in SMM_S3_RESUME_STATE duntan
@ 2023-08-21  2:09 ` duntan
  2023-09-06  3:11   ` Ni, Ray
  2023-08-21  2:09 ` [edk2-devel] [Patch V2 3/5] UefiCpuPkg/S3Resume2Pei: assert for invalid excution mode combo duntan
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: duntan @ 2023-08-21  2:09 UTC (permalink / raw)
  To: devel; +Cc: Eric Dong, Ray Ni, Rahul Kumar

Prepare MpService2Ppi in S3Resume when PEI and SMM env run
in the same execution mode. Then smm s3 code can use Mp
Service to wakeup AP instead of only sending InitSipiSipi.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Dun Tan <dun.tan@intel.com>
---
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c       | 18 +++++++++++++++++-
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf |  3 ++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
index 9ea5f6f4e5..1fd5670c7f 100644
--- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
+++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
@@ -4,7 +4,7 @@
   This module will execute the boot script saved during last boot and after that,
   control is passed to OS waking up handler.
 
-  Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.<BR>
   Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -23,6 +23,7 @@
 #include <Ppi/PostBootScriptTable.h>
 #include <Ppi/EndOfPeiPhase.h>
 #include <Ppi/SmmCommunication.h>
+#include <Ppi/MpServices2.h>
 
 #include <Library/DebugLib.h>
 #include <Library/BaseLib.h>
@@ -988,6 +989,7 @@ S3RestoreConfig2 (
   BOOLEAN                        Build4GPageTableOnly;
   BOOLEAN                        InterruptStatus;
   IA32_CR0                       Cr0;
+  EDKII_PEI_MP_SERVICES2_PPI     *MpService2Ppi;
 
   TempAcpiS3Context                 = 0;
   TempEfiBootScriptExecutorVariable = 0;
@@ -1088,6 +1090,7 @@ S3RestoreConfig2 (
     SmmS3ResumeState->ReturnContext1     = (EFI_PHYSICAL_ADDRESS)(UINTN)AcpiS3Context;
     SmmS3ResumeState->ReturnContext2     = (EFI_PHYSICAL_ADDRESS)(UINTN)EfiBootScriptExecutorVariable;
     SmmS3ResumeState->ReturnStackPointer = (EFI_PHYSICAL_ADDRESS)STACK_ALIGN_DOWN (&Status);
+    SmmS3ResumeState->MpService2Ppi      = 0;
 
     DEBUG ((DEBUG_INFO, "SMM S3 Signature                = %x\n", SmmS3ResumeState->Signature));
     DEBUG ((DEBUG_INFO, "SMM S3 Stack Base               = %x\n", SmmS3ResumeState->SmmS3StackBase));
@@ -1109,6 +1112,19 @@ S3RestoreConfig2 (
     if (((SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_32) && (sizeof (UINTN) == sizeof (UINT32))) ||
         ((SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_64) && (sizeof (UINTN) == sizeof (UINT64))))
     {
+      //
+      // Get MP Services2 Ppi to pass it to Smm S3.
+      //
+      Status = PeiServicesLocatePpi (
+                 &gEdkiiPeiMpServices2PpiGuid,
+                 0,
+                 NULL,
+                 (VOID **)&MpService2Ppi
+                 );
+      ASSERT_EFI_ERROR (Status);
+      SmmS3ResumeState->MpService2Ppi = (EFI_PHYSICAL_ADDRESS)(UINTN)MpService2Ppi;
+      DEBUG ((DEBUG_INFO, "SMM S3 MpService2Ppi Point = %lx\n", SmmS3ResumeState->MpService2Ppi));
+
       SwitchStack (
         (SWITCH_STACK_ENTRY_POINT)(UINTN)SmmS3ResumeState->SmmS3ResumeEntryPoint,
         (VOID *)AcpiS3Context,
diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
index aae984d138..9c9b6f3db3 100644
--- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
+++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
@@ -5,7 +5,7 @@
 # This module will excute the boot script saved during last boot and after that,
 # control is passed to OS waking up handler.
 #
-# Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2010 - 2023, Intel Corporation. All rights reserved.<BR>
 # Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -86,6 +86,7 @@
   gPeiPostScriptTablePpiGuid                    ## SOMETIMES_PRODUCES
   gEfiEndOfPeiSignalPpiGuid                     ## SOMETIMES_PRODUCES
   gEfiPeiSmmCommunicationPpiGuid                ## SOMETIMES_CONSUMES
+  gEdkiiPeiMpServices2PpiGuid                   ## SOMETIMES_CONSUMES
 
 [FeaturePcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode         ## CONSUMES
-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107902): https://edk2.groups.io/g/devel/message/107902
Mute This Topic: https://groups.io/mt/100866130/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [edk2-devel] [Patch V2 3/5] UefiCpuPkg/S3Resume2Pei: assert for invalid excution mode combo
  2023-08-21  2:09 [edk2-devel] [Patch V2 0/5] Use MpService2Ppi to wakeup CPU in Smm CpuS3 duntan
  2023-08-21  2:09 ` [edk2-devel] [Patch V2 1/5] MdeModulePkg: add MpService2Ppi field in SMM_S3_RESUME_STATE duntan
  2023-08-21  2:09 ` [edk2-devel] [Patch V2 2/5] UefiCpuPkg/S3Resume2Pei: prepare MpService2Ppi in S3Resume duntan
@ 2023-08-21  2:09 ` duntan
  2023-09-06  3:11   ` Ni, Ray
  2023-08-21  2:09 ` [edk2-devel] [Patch V2 4/5] UefiCpuPkg/PiSmmCpuDxe: code refinement for CpuS3.c duntan
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: duntan @ 2023-08-21  2:09 UTC (permalink / raw)
  To: devel; +Cc: Eric Dong, Ray Ni, Rahul Kumar

Add assert for invalid excution mode combination of 64bit PEI +
32bit DXE.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
---
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
index 1fd5670c7f..4cf676fb3e 100644
--- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
+++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
@@ -1106,6 +1106,13 @@ S3RestoreConfig2 (
     DEBUG ((DEBUG_INFO, "SMM S3 Return Stack Pointer     = %x\n", SmmS3ResumeState->ReturnStackPointer));
     DEBUG ((DEBUG_INFO, "SMM S3 Smst                     = %x\n", SmmS3ResumeState->Smst));
 
+    //
+    // 64bit PEI and 32bit DXE is not a supported combination.
+    //
+    if (SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_32) {
+      ASSERT (sizeof (UINTN) == sizeof (UINT32));
+    }
+
     //
     // Directly do the switch stack when PEI and SMM env run in the same execution mode.
     //
-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107903): https://edk2.groups.io/g/devel/message/107903
Mute This Topic: https://groups.io/mt/100866132/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [edk2-devel] [Patch V2 4/5] UefiCpuPkg/PiSmmCpuDxe: code refinement for CpuS3.c
  2023-08-21  2:09 [edk2-devel] [Patch V2 0/5] Use MpService2Ppi to wakeup CPU in Smm CpuS3 duntan
                   ` (2 preceding siblings ...)
  2023-08-21  2:09 ` [edk2-devel] [Patch V2 3/5] UefiCpuPkg/S3Resume2Pei: assert for invalid excution mode combo duntan
@ 2023-08-21  2:09 ` duntan
  2023-08-21  2:09 ` [edk2-devel] [Patch V2 5/5] UefiCpuPkg/PiSmmCpuDxe: use MpService2Ppi to wakeup AP in s3 duntan
       [not found] ` <177D440115CF68CB.15959@groups.io>
  5 siblings, 0 replies; 11+ messages in thread
From: duntan @ 2023-08-21  2:09 UTC (permalink / raw)
  To: devel; +Cc: Eric Dong, Ray Ni, Rahul Kumar

This commit is code logic refinement for s3 boot flow
in CpuS3.c. It doesn't change any code functionality.
This commit implementes InitializeAp and InitializeBsp
as a single function since they are doing almost the
same thing. Then both BSP and AP will execute the same
function InitializeCpuProcedure to do CPU initialization.
This can make the code logic easier to understand.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 272 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------
 1 file changed, 144 insertions(+), 128 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index 0f7ee0372d..a6adf46af7 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -539,44 +539,155 @@ SetRegister (
 }
 
 /**
-  AP initialization before then after SMBASE relocation in the S3 boot path.
+  The function is invoked before SMBASE relocation in S3 path to restores CPU status.
+
+  The function is invoked before SMBASE relocation in S3 path. It does first time microcode load
+  and restores MTRRs for both BSP and APs.
+
+  @param   IsBsp   The CPU this function executes on is BSP or not.
+
 **/
 VOID
-InitializeAp (
-  VOID
+InitializeCpuBeforeRebase (
+  IN BOOLEAN  IsBsp
   )
 {
-  UINTN  TopOfStack;
-  UINT8  Stack[128];
-
   LoadMtrrData (mAcpiCpuData.MtrrTable);
 
   SetRegister (TRUE);
 
+  ProgramVirtualWireMode ();
   //
   // Count down the number with lock mechanism.
   //
   InterlockedDecrement (&mNumberToFinish);
 
+  if (IsBsp) {
+    //
+    // Bsp wait here till all AP finish the initialization before rebase
+    //
+    while (mNumberToFinish > 0) {
+      CpuPause ();
+    }
+  } else {
+    //
+    // AP Wait for BSP to signal SMM Base relocation done.
+    //
+    while (!mInitApsAfterSmmBaseReloc) {
+      CpuPause ();
+    }
+  }
+}
+
+/**
+  The function is invoked after SMBASE relocation in S3 path to restores CPU status.
+
+  The function is invoked after SMBASE relocation in S3 path. It restores configuration according to
+  data saved by normal boot path for both BSP and APs.
+
+  @param   IsBsp   The CPU this function executes on is BSP or not.
+
+**/
+VOID
+InitializeCpuAfterRebase (
+  IN BOOLEAN  IsBsp
+  )
+{
+  UINTN  TopOfStack;
+  UINT8  Stack[128];
+
+  if (IsBsp) {
+    mNumberToFinish = (UINT32)(mNumberOfCpus - 1);
+
+    //
+    // Signal that SMM base relocation is complete and to continue initialization for all APs.
+    //
+    mInitApsAfterSmmBaseReloc = TRUE;
+
+    //
+    // Must begin set register after all APs have continue their initialization.
+    // This is a requirement to support semaphore mechanism in register table.
+    // Because if semaphore's dependence type is package type, semaphore will wait
+    // for all Aps in one package finishing their tasks before set next register
+    // for all APs. If the Aps not begin its task during BSP doing its task, the
+    // BSP thread will hang because it is waiting for other Aps in the same
+    // package finishing their task.
+    //
+    SetRegister (FALSE);
+
+    while (mNumberToFinish > 0) {
+      CpuPause ();
+    }
+  } else {
+    DisableLvtInterrupts ();
+
+    SetRegister (FALSE);
+
+    //
+    // Place AP into the safe code, count down the number with lock mechanism in the safe code.
+    //
+    TopOfStack  = (UINTN)Stack + sizeof (Stack);
+    TopOfStack &= ~(UINTN)(CPU_STACK_ALIGNMENT - 1);
+    CopyMem ((VOID *)(UINTN)mApHltLoopCode, mApHltLoopCodeTemplate, sizeof (mApHltLoopCodeTemplate));
+    TransferApToSafeState ((UINTN)mApHltLoopCode, TopOfStack, (UINTN)&mNumberToFinish);
+  }
+}
+
+/**
+  Cpu initialization procedure.
+
+  @param[in,out] Buffer  The pointer to private data buffer.
+
+**/
+VOID
+EFIAPI
+InitializeCpuProcedure (
+  IN OUT VOID  *Buffer
+  )
+{
+  BOOLEAN  IsBsp;
+
+  IsBsp =  (BOOLEAN)(mBspApicId == GetApicId ());
+
   //
-  // Wait for BSP to signal SMM Base relocation done.
+  // Skip initialization if mAcpiCpuData is not valid
   //
-  while (!mInitApsAfterSmmBaseReloc) {
-    CpuPause ();
+  if (mAcpiCpuData.NumberOfCpus > 0) {
+    //
+    // First time microcode load and restore MTRRs
+    //
+    InitializeCpuBeforeRebase (IsBsp);
   }
 
-  ProgramVirtualWireMode ();
-  DisableLvtInterrupts ();
+  if (IsBsp) {
+    DEBUG ((DEBUG_INFO, "SmmRestoreCpu: mSmmRelocated is %d\n", mSmmRelocated));
 
-  SetRegister (FALSE);
+    //
+    // Check whether Smm Relocation is done or not.
+    // If not, will do the SmmBases Relocation here!!!
+    //
+    if (!mSmmRelocated) {
+      //
+      // Restore SMBASE for BSP and all APs
+      //
+      SmmRelocateBases ();
+    } else {
+      //
+      // Issue SMI IPI (All Excluding  Self SMM IPI + BSP SMM IPI) to execute first SMI init.
+      //
+      ExecuteFirstSmiInit ();
+    }
+  }
 
   //
-  // Place AP into the safe code, count down the number with lock mechanism in the safe code.
+  // Skip initialization if mAcpiCpuData is not valid
   //
-  TopOfStack  = (UINTN)Stack + sizeof (Stack);
-  TopOfStack &= ~(UINTN)(CPU_STACK_ALIGNMENT - 1);
-  CopyMem ((VOID *)(UINTN)mApHltLoopCode, mApHltLoopCodeTemplate, sizeof (mApHltLoopCodeTemplate));
-  TransferApToSafeState ((UINTN)mApHltLoopCode, TopOfStack, (UINTN)&mNumberToFinish);
+  if (mAcpiCpuData.NumberOfCpus > 0) {
+    //
+    // Restore MSRs for BSP and all APs
+    //
+    InitializeCpuAfterRebase (IsBsp);
+  }
 }
 
 /**
@@ -627,91 +738,7 @@ PrepareApStartupVector (
   mExchangeInfo->BufferStart                         = (UINT32)StartupVector;
   mExchangeInfo->Cr3                                 = (UINT32)(AsmReadCr3 ());
   mExchangeInfo->InitializeFloatingPointUnitsAddress = (UINTN)InitializeFloatingPointUnits;
-}
-
-/**
-  The function is invoked before SMBASE relocation in S3 path to restores CPU status.
-
-  The function is invoked before SMBASE relocation in S3 path. It does first time microcode load
-  and restores MTRRs for both BSP and APs.
-
-**/
-VOID
-InitializeCpuBeforeRebase (
-  VOID
-  )
-{
-  LoadMtrrData (mAcpiCpuData.MtrrTable);
-
-  SetRegister (TRUE);
-
-  ProgramVirtualWireMode ();
-
-  PrepareApStartupVector (mAcpiCpuData.StartupVector);
-
-  if (FeaturePcdGet (PcdCpuHotPlugSupport)) {
-    ASSERT (mNumberOfCpus <= mAcpiCpuData.NumberOfCpus);
-  } else {
-    ASSERT (mNumberOfCpus == mAcpiCpuData.NumberOfCpus);
-  }
-
-  mNumberToFinish           = (UINT32)(mNumberOfCpus - 1);
-  mExchangeInfo->ApFunction = (VOID *)(UINTN)InitializeAp;
-
-  //
-  // Execute code for before SmmBaseReloc. Note: This flag is maintained across S3 boots.
-  //
-  mInitApsAfterSmmBaseReloc = FALSE;
-
-  //
-  // Send INIT IPI - SIPI to all APs
-  //
-  SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector);
-
-  while (mNumberToFinish > 0) {
-    CpuPause ();
-  }
-}
-
-/**
-  The function is invoked after SMBASE relocation in S3 path to restores CPU status.
-
-  The function is invoked after SMBASE relocation in S3 path. It restores configuration according to
-  data saved by normal boot path for both BSP and APs.
-
-**/
-VOID
-InitializeCpuAfterRebase (
-  VOID
-  )
-{
-  if (FeaturePcdGet (PcdCpuHotPlugSupport)) {
-    ASSERT (mNumberOfCpus <= mAcpiCpuData.NumberOfCpus);
-  } else {
-    ASSERT (mNumberOfCpus == mAcpiCpuData.NumberOfCpus);
-  }
-
-  mNumberToFinish = (UINT32)(mNumberOfCpus - 1);
-
-  //
-  // Signal that SMM base relocation is complete and to continue initialization for all APs.
-  //
-  mInitApsAfterSmmBaseReloc = TRUE;
-
-  //
-  // Must begin set register after all APs have continue their initialization.
-  // This is a requirement to support semaphore mechanism in register table.
-  // Because if semaphore's dependence type is package type, semaphore will wait
-  // for all Aps in one package finishing their tasks before set next register
-  // for all APs. If the Aps not begin its task during BSP doing its task, the
-  // BSP thread will hang because it is waiting for other Aps in the same
-  // package finishing their task.
-  //
-  SetRegister (FALSE);
-
-  while (mNumberToFinish > 0) {
-    CpuPause ();
-  }
+  mExchangeInfo->ApFunction                          = (VOID *)(UINTN)InitializeCpuProcedure;
 }
 
 /**
@@ -813,44 +840,33 @@ SmmRestoreCpu (
     InitializeDebugAgent (DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64, (VOID *)&Ia32Idtr, NULL);
   }
 
+  mBspApicId = GetApicId ();
   //
-  // Skip initialization if mAcpiCpuData is not valid
+  // Skip AP initialization if mAcpiCpuData is not valid
   //
   if (mAcpiCpuData.NumberOfCpus > 0) {
-    //
-    // First time microcode load and restore MTRRs
-    //
-    InitializeCpuBeforeRebase ();
-  }
+    if (FeaturePcdGet (PcdCpuHotPlugSupport)) {
+      ASSERT (mNumberOfCpus <= mAcpiCpuData.NumberOfCpus);
+    } else {
+      ASSERT (mNumberOfCpus == mAcpiCpuData.NumberOfCpus);
+    }
 
-  DEBUG ((DEBUG_INFO, "SmmRestoreCpu: mSmmRelocated is %d\n", mSmmRelocated));
+    mNumberToFinish = (UINT32)mNumberOfCpus;
 
-  //
-  // Check whether Smm Relocation is done or not.
-  // If not, will do the SmmBases Relocation here!!!
-  //
-  if (!mSmmRelocated) {
     //
-    // Restore SMBASE for BSP and all APs
+    // Execute code for before SmmBaseReloc. Note: This flag is maintained across S3 boots.
     //
-    SmmRelocateBases ();
-  } else {
-    //
-    // Issue SMI IPI (All Excluding  Self SMM IPI + BSP SMM IPI) to execute first SMI init.
-    //
-    ExecuteFirstSmiInit ();
-  }
+    mInitApsAfterSmmBaseReloc = FALSE;
 
-  //
-  // Skip initialization if mAcpiCpuData is not valid
-  //
-  if (mAcpiCpuData.NumberOfCpus > 0) {
+    PrepareApStartupVector (mAcpiCpuData.StartupVector);
     //
-    // Restore MSRs for BSP and all APs
+    // Send INIT IPI - SIPI to all APs
     //
-    InitializeCpuAfterRebase ();
+    SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector);
   }
 
+  InitializeCpuProcedure (NULL);
+
   //
   // Set a flag to restore SMM configuration in S3 path.
   //
-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107904): https://edk2.groups.io/g/devel/message/107904
Mute This Topic: https://groups.io/mt/100866133/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [edk2-devel] [Patch V2 5/5] UefiCpuPkg/PiSmmCpuDxe: use MpService2Ppi to wakeup AP in s3
  2023-08-21  2:09 [edk2-devel] [Patch V2 0/5] Use MpService2Ppi to wakeup CPU in Smm CpuS3 duntan
                   ` (3 preceding siblings ...)
  2023-08-21  2:09 ` [edk2-devel] [Patch V2 4/5] UefiCpuPkg/PiSmmCpuDxe: code refinement for CpuS3.c duntan
@ 2023-08-21  2:09 ` duntan
       [not found] ` <177D440115CF68CB.15959@groups.io>
  5 siblings, 0 replies; 11+ messages in thread
From: duntan @ 2023-08-21  2:09 UTC (permalink / raw)
  To: devel; +Cc: Eric Dong, Ray Ni, Rahul Kumar

Use MpService2Ppi to wakeup AP in s3 boot flow during initializing
CPU. If mSmmS3ResumeState->MpService2Ppi is not 0, then BSP will
use MpService2Ppi->StartupAllCPUs to do CPU initialization for both
BSP and AP instead of only sending InitSipiSipi for AP.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Dun Tan <dun.tan@intel.com>
---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 56 ++++++++++++++++++++++++++++++++++----------------------
 1 file changed, 34 insertions(+), 22 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index a6adf46af7..56b1edff7a 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -7,6 +7,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
 #include "PiSmmCpuDxeSmm.h"
+#include <PiPei.h>
+#include <Ppi/MpServices2.h>
 
 #pragma pack(1)
 typedef struct {
@@ -614,22 +616,25 @@ InitializeCpuAfterRebase (
     // package finishing their task.
     //
     SetRegister (FALSE);
-
-    while (mNumberToFinish > 0) {
-      CpuPause ();
+    if (mSmmS3ResumeState->MpService2Ppi == 0) {
+      while (mNumberToFinish > 0) {
+        CpuPause ();
+      }
     }
   } else {
     DisableLvtInterrupts ();
 
     SetRegister (FALSE);
 
-    //
-    // Place AP into the safe code, count down the number with lock mechanism in the safe code.
-    //
-    TopOfStack  = (UINTN)Stack + sizeof (Stack);
-    TopOfStack &= ~(UINTN)(CPU_STACK_ALIGNMENT - 1);
-    CopyMem ((VOID *)(UINTN)mApHltLoopCode, mApHltLoopCodeTemplate, sizeof (mApHltLoopCodeTemplate));
-    TransferApToSafeState ((UINTN)mApHltLoopCode, TopOfStack, (UINTN)&mNumberToFinish);
+    if (mSmmS3ResumeState->MpService2Ppi == 0) {
+      //
+      // Place AP into the safe code, count down the number with lock mechanism in the safe code.
+      //
+      TopOfStack  = (UINTN)Stack + sizeof (Stack);
+      TopOfStack &= ~(UINTN)(CPU_STACK_ALIGNMENT - 1);
+      CopyMem ((VOID *)(UINTN)mApHltLoopCode, mApHltLoopCodeTemplate, sizeof (mApHltLoopCodeTemplate));
+      TransferApToSafeState ((UINTN)mApHltLoopCode, TopOfStack, (UINTN)&mNumberToFinish);
+    }
   }
 }
 
@@ -789,11 +794,12 @@ SmmRestoreCpu (
   VOID
   )
 {
-  SMM_S3_RESUME_STATE       *SmmS3ResumeState;
-  IA32_DESCRIPTOR           Ia32Idtr;
-  IA32_DESCRIPTOR           X64Idtr;
-  IA32_IDT_GATE_DESCRIPTOR  IdtEntryTable[EXCEPTION_VECTOR_NUMBER];
-  EFI_STATUS                Status;
+  SMM_S3_RESUME_STATE         *SmmS3ResumeState;
+  IA32_DESCRIPTOR             Ia32Idtr;
+  IA32_DESCRIPTOR             X64Idtr;
+  IA32_IDT_GATE_DESCRIPTOR    IdtEntryTable[EXCEPTION_VECTOR_NUMBER];
+  EFI_STATUS                  Status;
+  EDKII_PEI_MP_SERVICES2_PPI  *Mp2ServicePpi;
 
   DEBUG ((DEBUG_INFO, "SmmRestoreCpu()\n"));
 
@@ -858,15 +864,21 @@ SmmRestoreCpu (
     //
     mInitApsAfterSmmBaseReloc = FALSE;
 
-    PrepareApStartupVector (mAcpiCpuData.StartupVector);
-    //
-    // Send INIT IPI - SIPI to all APs
-    //
-    SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector);
+    if (mSmmS3ResumeState->MpService2Ppi != 0) {
+      Mp2ServicePpi = (EDKII_PEI_MP_SERVICES2_PPI *)(UINTN)mSmmS3ResumeState->MpService2Ppi;
+      Mp2ServicePpi->StartupAllCPUs (Mp2ServicePpi, (EFI_AP_PROCEDURE)InitializeCpuProcedure, 0, NULL);
+    } else {
+      PrepareApStartupVector (mAcpiCpuData.StartupVector);
+      //
+      // Send INIT IPI - SIPI to all APs
+      //
+      SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector);
+      InitializeCpuProcedure (NULL);
+    }
+  } else {
+    InitializeCpuProcedure (NULL);
   }
 
-  InitializeCpuProcedure (NULL);
-
   //
   // Set a flag to restore SMM configuration in S3 path.
   //
-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107905): https://edk2.groups.io/g/devel/message/107905
Mute This Topic: https://groups.io/mt/100866135/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [edk2-devel] [Patch V2 2/5] UefiCpuPkg/S3Resume2Pei: prepare MpService2Ppi in S3Resume
  2023-08-21  2:09 ` [edk2-devel] [Patch V2 2/5] UefiCpuPkg/S3Resume2Pei: prepare MpService2Ppi in S3Resume duntan
@ 2023-09-06  3:11   ` Ni, Ray
  0 siblings, 0 replies; 11+ messages in thread
From: Ni, Ray @ 2023-09-06  3:11 UTC (permalink / raw)
  To: Tan, Dun, devel@edk2.groups.io; +Cc: Dong, Eric, Kumar, Rahul R

[-- Attachment #1: Type: text/plain, Size: 5261 bytes --]

Reviewed-by: Ray Ni <ray.ni@intel.com>

Thanks,
Ray
________________________________
From: Tan, Dun <dun.tan@intel.com>
Sent: Monday, August 21, 2023 10:09 AM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Dong, Eric <eric.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Kumar, Rahul R <rahul.r.kumar@intel.com>
Subject: [Patch V2 2/5] UefiCpuPkg/S3Resume2Pei: prepare MpService2Ppi in S3Resume

Prepare MpService2Ppi in S3Resume when PEI and SMM env run
in the same execution mode. Then smm s3 code can use Mp
Service to wakeup AP instead of only sending InitSipiSipi.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Dun Tan <dun.tan@intel.com>
---
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c       | 18 +++++++++++++++++-
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf |  3 ++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
index 9ea5f6f4e5..1fd5670c7f 100644
--- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
+++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
@@ -4,7 +4,7 @@
   This module will execute the boot script saved during last boot and after that,
   control is passed to OS waking up handler.

-  Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.<BR>
   Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>

   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -23,6 +23,7 @@
 #include <Ppi/PostBootScriptTable.h>
 #include <Ppi/EndOfPeiPhase.h>
 #include <Ppi/SmmCommunication.h>
+#include <Ppi/MpServices2.h>

 #include <Library/DebugLib.h>
 #include <Library/BaseLib.h>
@@ -988,6 +989,7 @@ S3RestoreConfig2 (
   BOOLEAN                        Build4GPageTableOnly;
   BOOLEAN                        InterruptStatus;
   IA32_CR0                       Cr0;
+  EDKII_PEI_MP_SERVICES2_PPI     *MpService2Ppi;

   TempAcpiS3Context                 = 0;
   TempEfiBootScriptExecutorVariable = 0;
@@ -1088,6 +1090,7 @@ S3RestoreConfig2 (
     SmmS3ResumeState->ReturnContext1     = (EFI_PHYSICAL_ADDRESS)(UINTN)AcpiS3Context;
     SmmS3ResumeState->ReturnContext2     = (EFI_PHYSICAL_ADDRESS)(UINTN)EfiBootScriptExecutorVariable;
     SmmS3ResumeState->ReturnStackPointer = (EFI_PHYSICAL_ADDRESS)STACK_ALIGN_DOWN (&Status);
+    SmmS3ResumeState->MpService2Ppi      = 0;

     DEBUG ((DEBUG_INFO, "SMM S3 Signature                = %x\n", SmmS3ResumeState->Signature));
     DEBUG ((DEBUG_INFO, "SMM S3 Stack Base               = %x\n", SmmS3ResumeState->SmmS3StackBase));
@@ -1109,6 +1112,19 @@ S3RestoreConfig2 (
     if (((SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_32) && (sizeof (UINTN) == sizeof (UINT32))) ||
         ((SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_64) && (sizeof (UINTN) == sizeof (UINT64))))
     {
+      //
+      // Get MP Services2 Ppi to pass it to Smm S3.
+      //
+      Status = PeiServicesLocatePpi (
+                 &gEdkiiPeiMpServices2PpiGuid,
+                 0,
+                 NULL,
+                 (VOID **)&MpService2Ppi
+                 );
+      ASSERT_EFI_ERROR (Status);
+      SmmS3ResumeState->MpService2Ppi = (EFI_PHYSICAL_ADDRESS)(UINTN)MpService2Ppi;
+      DEBUG ((DEBUG_INFO, "SMM S3 MpService2Ppi Point = %lx\n", SmmS3ResumeState->MpService2Ppi));
+
       SwitchStack (
         (SWITCH_STACK_ENTRY_POINT)(UINTN)SmmS3ResumeState->SmmS3ResumeEntryPoint,
         (VOID *)AcpiS3Context,
diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
index aae984d138..9c9b6f3db3 100644
--- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
+++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
@@ -5,7 +5,7 @@
 # This module will excute the boot script saved during last boot and after that,
 # control is passed to OS waking up handler.
 #
-# Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2010 - 2023, Intel Corporation. All rights reserved.<BR>
 # Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -86,6 +86,7 @@
   gPeiPostScriptTablePpiGuid                    ## SOMETIMES_PRODUCES
   gEfiEndOfPeiSignalPpiGuid                     ## SOMETIMES_PRODUCES
   gEfiPeiSmmCommunicationPpiGuid                ## SOMETIMES_CONSUMES
+  gEdkiiPeiMpServices2PpiGuid                   ## SOMETIMES_CONSUMES

 [FeaturePcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode         ## CONSUMES
--
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108300): https://edk2.groups.io/g/devel/message/108300
Mute This Topic: https://groups.io/mt/100866130/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 9823 bytes --]

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [edk2-devel] [Patch V2 3/5] UefiCpuPkg/S3Resume2Pei: assert for invalid excution mode combo
  2023-08-21  2:09 ` [edk2-devel] [Patch V2 3/5] UefiCpuPkg/S3Resume2Pei: assert for invalid excution mode combo duntan
@ 2023-09-06  3:11   ` Ni, Ray
  0 siblings, 0 replies; 11+ messages in thread
From: Ni, Ray @ 2023-09-06  3:11 UTC (permalink / raw)
  To: Tan, Dun, devel@edk2.groups.io; +Cc: Dong, Eric, Kumar, Rahul R

[-- Attachment #1: Type: text/plain, Size: 2023 bytes --]

Reviewed-by: Ray Ni <ray.ni@intel.com>



Thanks,
Ray
________________________________
From: Tan, Dun <dun.tan@intel.com>
Sent: Monday, August 21, 2023 10:09 AM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Dong, Eric <eric.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Kumar, Rahul R <rahul.r.kumar@intel.com>
Subject: [Patch V2 3/5] UefiCpuPkg/S3Resume2Pei: assert for invalid excution mode combo

Add assert for invalid excution mode combination of 64bit PEI +
32bit DXE.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
---
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
index 1fd5670c7f..4cf676fb3e 100644
--- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
+++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
@@ -1106,6 +1106,13 @@ S3RestoreConfig2 (
     DEBUG ((DEBUG_INFO, "SMM S3 Return Stack Pointer     = %x\n", SmmS3ResumeState->ReturnStackPointer));
     DEBUG ((DEBUG_INFO, "SMM S3 Smst                     = %x\n", SmmS3ResumeState->Smst));

+    //
+    // 64bit PEI and 32bit DXE is not a supported combination.
+    //
+    if (SmmS3ResumeState->Signature == SMM_S3_RESUME_SMM_32) {
+      ASSERT (sizeof (UINTN) == sizeof (UINT32));
+    }
+
     //
     // Directly do the switch stack when PEI and SMM env run in the same execution mode.
     //
--
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108301): https://edk2.groups.io/g/devel/message/108301
Mute This Topic: https://groups.io/mt/100866132/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 4485 bytes --]

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [edk2-devel] [Patch V2 1/5] MdeModulePkg: add MpService2Ppi field in SMM_S3_RESUME_STATE
       [not found] ` <177D440115CF68CB.15959@groups.io>
@ 2023-09-06  3:22   ` duntan
  2023-09-06  5:37     ` Ni, Ray
  2023-09-07 15:02     ` Wang, Jian J
  0 siblings, 2 replies; 11+ messages in thread
From: duntan @ 2023-09-06  3:22 UTC (permalink / raw)
  To: devel@edk2.groups.io, Tan, Dun; +Cc: Ni, Ray, Wang, Jian J, Gao, Liming

Hi Jian and Liming,

Could you please help to review this patch?

Thanks,
Dun
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of duntan
Sent: Monday, August 21, 2023 10:10 AM
To: devel@edk2.groups.io
Cc: Ni, Ray <ray.ni@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>
Subject: [edk2-devel] [Patch V2 1/5] MdeModulePkg: add MpService2Ppi field in SMM_S3_RESUME_STATE

Add MpService2Ppi field in SMM_S3_RESUME_STATE of AcpiS3Context.h. It will be used to wakeup AP to do the CPU initialization during smm s3 boot flow in following patches.
With this field, we can avoid sending InitSipiSipi to wakeup AP.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
---
 MdeModulePkg/Include/Guid/AcpiS3Context.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Include/Guid/AcpiS3Context.h b/MdeModulePkg/Include/Guid/AcpiS3Context.h
index 645496d191..72d173c4fd 100644
--- a/MdeModulePkg/Include/Guid/AcpiS3Context.h
+++ b/MdeModulePkg/Include/Guid/AcpiS3Context.h
@@ -1,7 +1,7 @@
 /** @file
   Definitions for data structures used in S3 resume.
 
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2023, Intel Corporation. All rights reserved.<BR>
 
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -30,6 +30,7 @@ typedef struct {
   EFI_PHYSICAL_ADDRESS    ReturnContext1;
   EFI_PHYSICAL_ADDRESS    ReturnContext2;
   EFI_PHYSICAL_ADDRESS    ReturnStackPointer;
+  EFI_PHYSICAL_ADDRESS    MpService2Ppi;
   EFI_PHYSICAL_ADDRESS    Smst;
 } SMM_S3_RESUME_STATE;
 
--
2.31.1.windows.1








-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108302): https://edk2.groups.io/g/devel/message/108302
Mute This Topic: https://groups.io/mt/101186185/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [edk2-devel] [Patch V2 1/5] MdeModulePkg: add MpService2Ppi field in SMM_S3_RESUME_STATE
  2023-09-06  3:22   ` [edk2-devel] [Patch V2 1/5] MdeModulePkg: add MpService2Ppi field in SMM_S3_RESUME_STATE duntan
@ 2023-09-06  5:37     ` Ni, Ray
  2023-09-07 15:02     ` Wang, Jian J
  1 sibling, 0 replies; 11+ messages in thread
From: Ni, Ray @ 2023-09-06  5:37 UTC (permalink / raw)
  To: Tan, Dun, devel@edk2.groups.io; +Cc: Wang, Jian J, Gao, Liming

[-- Attachment #1: Type: text/plain, Size: 2660 bytes --]

Reviewed-by: Ray Ni <ray.ni@intel.com>

Thanks,
Ray
________________________________
From: Tan, Dun <dun.tan@intel.com>
Sent: Wednesday, September 6, 2023 11:22 AM
To: devel@edk2.groups.io <devel@edk2.groups.io>; Tan, Dun <dun.tan@intel.com>
Cc: Ni, Ray <ray.ni@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>
Subject: RE: [edk2-devel] [Patch V2 1/5] MdeModulePkg: add MpService2Ppi field in SMM_S3_RESUME_STATE

Hi Jian and Liming,

Could you please help to review this patch?

Thanks,
Dun
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of duntan
Sent: Monday, August 21, 2023 10:10 AM
To: devel@edk2.groups.io
Cc: Ni, Ray <ray.ni@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>
Subject: [edk2-devel] [Patch V2 1/5] MdeModulePkg: add MpService2Ppi field in SMM_S3_RESUME_STATE

Add MpService2Ppi field in SMM_S3_RESUME_STATE of AcpiS3Context.h. It will be used to wakeup AP to do the CPU initialization during smm s3 boot flow in following patches.
With this field, we can avoid sending InitSipiSipi to wakeup AP.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
---
 MdeModulePkg/Include/Guid/AcpiS3Context.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Include/Guid/AcpiS3Context.h b/MdeModulePkg/Include/Guid/AcpiS3Context.h
index 645496d191..72d173c4fd 100644
--- a/MdeModulePkg/Include/Guid/AcpiS3Context.h
+++ b/MdeModulePkg/Include/Guid/AcpiS3Context.h
@@ -1,7 +1,7 @@
 /** @file
   Definitions for data structures used in S3 resume.

-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2023, Intel Corporation. All rights reserved.<BR>

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

@@ -30,6 +30,7 @@ typedef struct {
   EFI_PHYSICAL_ADDRESS    ReturnContext1;
   EFI_PHYSICAL_ADDRESS    ReturnContext2;
   EFI_PHYSICAL_ADDRESS    ReturnStackPointer;
+  EFI_PHYSICAL_ADDRESS    MpService2Ppi;
   EFI_PHYSICAL_ADDRESS    Smst;
 } SMM_S3_RESUME_STATE;

--
2.31.1.windows.1








-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108305): https://edk2.groups.io/g/devel/message/108305
Mute This Topic: https://groups.io/mt/101186185/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 4879 bytes --]

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [edk2-devel] [Patch V2 1/5] MdeModulePkg: add MpService2Ppi field in SMM_S3_RESUME_STATE
  2023-09-06  3:22   ` [edk2-devel] [Patch V2 1/5] MdeModulePkg: add MpService2Ppi field in SMM_S3_RESUME_STATE duntan
  2023-09-06  5:37     ` Ni, Ray
@ 2023-09-07 15:02     ` Wang, Jian J
  1 sibling, 0 replies; 11+ messages in thread
From: Wang, Jian J @ 2023-09-07 15:02 UTC (permalink / raw)
  To: Tan, Dun, devel@edk2.groups.io; +Cc: Ni, Ray, Gao, Liming

Reviewed-by: Jian J Wang <jian.j.wang@intel.com>

Regards,
Jian



> -----Original Message-----
> From: Tan, Dun <dun.tan@intel.com>
> Sent: Wednesday, September 06, 2023 11:22 AM
> To: devel@edk2.groups.io; Tan, Dun <dun.tan@intel.com>
> Cc: Ni, Ray <ray.ni@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Gao,
> Liming <gaoliming@byosoft.com.cn>
> Subject: RE: [edk2-devel] [Patch V2 1/5] MdeModulePkg: add MpService2Ppi
> field in SMM_S3_RESUME_STATE
> 
> Hi Jian and Liming,
> 
> Could you please help to review this patch?
> 
> Thanks,
> Dun
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of duntan
> Sent: Monday, August 21, 2023 10:10 AM
> To: devel@edk2.groups.io
> Cc: Ni, Ray <ray.ni@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Gao,
> Liming <gaoliming@byosoft.com.cn>
> Subject: [edk2-devel] [Patch V2 1/5] MdeModulePkg: add MpService2Ppi field in
> SMM_S3_RESUME_STATE
> 
> Add MpService2Ppi field in SMM_S3_RESUME_STATE of AcpiS3Context.h. It will
> be used to wakeup AP to do the CPU initialization during smm s3 boot flow in
> following patches.
> With this field, we can avoid sending InitSipiSipi to wakeup AP.
> 
> Signed-off-by: Dun Tan <dun.tan@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> ---
>  MdeModulePkg/Include/Guid/AcpiS3Context.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Include/Guid/AcpiS3Context.h
> b/MdeModulePkg/Include/Guid/AcpiS3Context.h
> index 645496d191..72d173c4fd 100644
> --- a/MdeModulePkg/Include/Guid/AcpiS3Context.h
> +++ b/MdeModulePkg/Include/Guid/AcpiS3Context.h
> @@ -1,7 +1,7 @@
>  /** @file
>    Definitions for data structures used in S3 resume.
> 
> -Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2011 - 2023, Intel Corporation. All rights reserved.<BR>
> 
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -30,6 +30,7 @@ typedef struct {
>    EFI_PHYSICAL_ADDRESS    ReturnContext1;
>    EFI_PHYSICAL_ADDRESS    ReturnContext2;
>    EFI_PHYSICAL_ADDRESS    ReturnStackPointer;
> +  EFI_PHYSICAL_ADDRESS    MpService2Ppi;
>    EFI_PHYSICAL_ADDRESS    Smst;
>  } SMM_S3_RESUME_STATE;
> 
> --
> 2.31.1.windows.1
> 
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108399): https://edk2.groups.io/g/devel/message/108399
Mute This Topic: https://groups.io/mt/101186185/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-09-07 15:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-21  2:09 [edk2-devel] [Patch V2 0/5] Use MpService2Ppi to wakeup CPU in Smm CpuS3 duntan
2023-08-21  2:09 ` [edk2-devel] [Patch V2 1/5] MdeModulePkg: add MpService2Ppi field in SMM_S3_RESUME_STATE duntan
2023-08-21  2:09 ` [edk2-devel] [Patch V2 2/5] UefiCpuPkg/S3Resume2Pei: prepare MpService2Ppi in S3Resume duntan
2023-09-06  3:11   ` Ni, Ray
2023-08-21  2:09 ` [edk2-devel] [Patch V2 3/5] UefiCpuPkg/S3Resume2Pei: assert for invalid excution mode combo duntan
2023-09-06  3:11   ` Ni, Ray
2023-08-21  2:09 ` [edk2-devel] [Patch V2 4/5] UefiCpuPkg/PiSmmCpuDxe: code refinement for CpuS3.c duntan
2023-08-21  2:09 ` [edk2-devel] [Patch V2 5/5] UefiCpuPkg/PiSmmCpuDxe: use MpService2Ppi to wakeup AP in s3 duntan
     [not found] ` <177D440115CF68CB.15959@groups.io>
2023-09-06  3:22   ` [edk2-devel] [Patch V2 1/5] MdeModulePkg: add MpService2Ppi field in SMM_S3_RESUME_STATE duntan
2023-09-06  5:37     ` Ni, Ray
2023-09-07 15:02     ` Wang, Jian J

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox