public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 0/3] Add S3SmmInitDone point
@ 2018-03-02  5:15 Star Zeng
  2018-03-02  5:15 ` [PATCH 1/3] MdeModulePkg: Add S3SmmInitDone definition Star Zeng
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Star Zeng @ 2018-03-02  5:15 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng

Add gEdkiiS3SmmInitDoneGuid, after S3 SMM initialization is done and
before S3 boot script is executed, this GUID is installed as PPI in
PEI and protocol in SMM environment. It allows for PEIMs or SMM
drivers to hook this point and do the required tasks.

S3Resume will install the PPI and signal to SMM by communication,
and then PiSmmCore will install the protocol.

Star Zeng (3):
  MdeModulePkg: Add S3SmmInitDone definition
  MdeModulePkg PiSmmCore: Register SMI handler to install S3SmmInitDone
  UefiCpuPkg S3ResumePei: Signal S3SmmInitDone

 MdeModulePkg/Core/PiSmmCore/PiSmmCore.c            | 62 +++++++++++++++++++++-
 MdeModulePkg/Core/PiSmmCore/PiSmmCore.h            | 26 ++++++++-
 MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf          |  3 +-
 MdeModulePkg/Include/Guid/S3SmmInitDone.h          | 27 ++++++++++
 MdeModulePkg/MdeModulePkg.dec                      |  3 ++
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c  | 42 ++++++++++-----
 .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf   |  3 ++
 7 files changed, 151 insertions(+), 15 deletions(-)
 create mode 100644 MdeModulePkg/Include/Guid/S3SmmInitDone.h

-- 
2.7.0.windows.1



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

* [PATCH 1/3] MdeModulePkg: Add S3SmmInitDone definition
  2018-03-02  5:15 [PATCH 0/3] Add S3SmmInitDone point Star Zeng
@ 2018-03-02  5:15 ` Star Zeng
  2018-03-02  5:59   ` Yao, Jiewen
  2018-03-02  5:15 ` [PATCH 2/3] MdeModulePkg PiSmmCore: Register SMI handler to install S3SmmInitDone Star Zeng
  2018-03-02  5:15 ` [PATCH 3/3] UefiCpuPkg S3ResumePei: Signal S3SmmInitDone Star Zeng
  2 siblings, 1 reply; 8+ messages in thread
From: Star Zeng @ 2018-03-02  5:15 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Jiewen Yao

Add gEdkiiS3SmmInitDoneGuid, after S3 SMM initialization is done and
before S3 boot script is executed, this GUID is installed as PPI in
PEI and protocol in SMM environment. It allows for PEIMs or SMM
drivers to hook this point and do the required tasks.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
 MdeModulePkg/Include/Guid/S3SmmInitDone.h | 27 +++++++++++++++++++++++++++
 MdeModulePkg/MdeModulePkg.dec             |  3 +++
 2 files changed, 30 insertions(+)
 create mode 100644 MdeModulePkg/Include/Guid/S3SmmInitDone.h

diff --git a/MdeModulePkg/Include/Guid/S3SmmInitDone.h b/MdeModulePkg/Include/Guid/S3SmmInitDone.h
new file mode 100644
index 000000000000..53fef8ed19ef
--- /dev/null
+++ b/MdeModulePkg/Include/Guid/S3SmmInitDone.h
@@ -0,0 +1,27 @@
+/** @file
+  After S3 SMM initialization is done and before S3 boot script is executed,
+  this GUID is installed as PPI in PEI and protocol in SMM environment. 
+  It allows for PEIMs or SMM drivers to hook this point and do the required tasks.
+
+  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+  This program and the accompanying materials                          
+  are licensed and made available under the terms and conditions of the BSD License         
+  which accompanies this distribution.  The full text of the license may be found at        
+  http://opensource.org/licenses/bsd-license.php                                            
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             
+
+**/
+
+#ifndef __S3_SMM_INIT_DONE_H__
+#define __S3_SMM_INIT_DONE_H__
+
+#define EDKII_S3_SMM_INIT_DONE_GUID \
+  { \
+    0x8f9d4825, 0x797d, 0x48fc, { 0x84, 0x71, 0x84, 0x50, 0x25, 0x79, 0x2e, 0xf6 } \
+  }
+
+extern EFI_GUID gEdkiiS3SmmInitDoneGuid;
+
+#endif
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 455979386e3f..2b24ba506832 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -406,6 +406,9 @@ [Guids]
   ## Include/Guid/EndofS3Resume.h
   gEdkiiEndOfS3ResumeGuid = { 0x96f5296d, 0x05f7, 0x4f3c, {0x84, 0x67, 0xe4, 0x56, 0x89, 0x0e, 0x0c, 0xb5 } }
 
+  ## Include/Guid/S3SmmInitDone.h
+  gEdkiiS3SmmInitDoneGuid = { 0x8f9d4825, 0x797d, 0x48fc, { 0x84, 0x71, 0x84, 0x50, 0x25, 0x79, 0x2e, 0xf6 } }
+
 [Ppis]
   ## Include/Ppi/AtaController.h
   gPeiAtaControllerPpiGuid       = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 0x7a, 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
-- 
2.7.0.windows.1



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

* [PATCH 2/3] MdeModulePkg PiSmmCore: Register SMI handler to install S3SmmInitDone
  2018-03-02  5:15 [PATCH 0/3] Add S3SmmInitDone point Star Zeng
  2018-03-02  5:15 ` [PATCH 1/3] MdeModulePkg: Add S3SmmInitDone definition Star Zeng
@ 2018-03-02  5:15 ` Star Zeng
  2018-03-02  6:00   ` Yao, Jiewen
  2018-03-02  5:15 ` [PATCH 3/3] UefiCpuPkg S3ResumePei: Signal S3SmmInitDone Star Zeng
  2 siblings, 1 reply; 8+ messages in thread
From: Star Zeng @ 2018-03-02  5:15 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Jiewen Yao

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
 MdeModulePkg/Core/PiSmmCore/PiSmmCore.c   | 62 ++++++++++++++++++++++++++++++-
 MdeModulePkg/Core/PiSmmCore/PiSmmCore.h   | 26 ++++++++++++-
 MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf |  3 +-
 3 files changed, 88 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
index d2f0207b5c83..686b9b45a556 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
@@ -1,7 +1,7 @@
 /** @file
   SMM Core Main Entry Point
 
-  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials are licensed and made available 
   under the terms and conditions of the BSD License which accompanies this 
   distribution.  The full text of the license may be found at        
@@ -87,6 +87,7 @@ SMM_CORE_SMI_HANDLERS  mSmmCoreSmiHandlers[] = {
   { SmmExitBootServicesHandler, &gEfiEventExitBootServicesGuid,      NULL, FALSE },
   { SmmReadyToBootHandler,      &gEfiEventReadyToBootGuid,           NULL, FALSE },
   { SmmEndOfDxeHandler,         &gEfiEndOfDxeEventGroupGuid,         NULL, TRUE },
+  { SmmS3SmmInitDoneHandler,    &gEdkiiS3SmmInitDoneGuid,            NULL, FALSE },
   { SmmEndOfS3ResumeHandler,    &gEdkiiEndOfS3ResumeGuid,            NULL, FALSE },
   { NULL,                       NULL,                                NULL, FALSE }
 };
@@ -472,6 +473,65 @@ SmmEndOfDxeHandler (
 }
 
 /**
+  Software SMI handler that is called when the S3SmmInitDone signal is triggered.
+  This function installs the SMM S3SmmInitDone Protocol so SMM Drivers are informed that
+  S3 SMM initialization has been done.
+
+  @param  DispatchHandle  The unique handle assigned to this handler by SmiHandlerRegister().
+  @param  Context         Points to an optional handler context which was specified when the handler was registered.
+  @param  CommBuffer      A pointer to a collection of data in memory that will
+                          be conveyed from a non-SMM environment into an SMM environment.
+  @param  CommBufferSize  The size of the CommBuffer.
+
+  @return Status Code
+
+**/
+EFI_STATUS
+EFIAPI
+SmmS3SmmInitDoneHandler (
+  IN     EFI_HANDLE  DispatchHandle,
+  IN     CONST VOID  *Context,        OPTIONAL
+  IN OUT VOID        *CommBuffer,     OPTIONAL
+  IN OUT UINTN       *CommBufferSize  OPTIONAL
+  )
+{
+  EFI_STATUS  Status;
+  EFI_HANDLE  SmmHandle;
+
+  DEBUG ((DEBUG_INFO, "SmmS3SmmInitDoneHandler\n"));
+
+  if (!mDuringS3Resume) {
+    DEBUG ((DEBUG_ERROR, "It is not during S3 resume\n"));
+    return EFI_SUCCESS;
+  }
+
+  //
+  // Install SMM S3SmmInitDone protocol
+  //
+  SmmHandle = NULL;
+  Status = SmmInstallProtocolInterface (
+             &SmmHandle,
+             &gEdkiiS3SmmInitDoneGuid,
+             EFI_NATIVE_INTERFACE,
+             NULL
+             );
+  ASSERT_EFI_ERROR (Status);
+
+  //
+  // Uninstall the protocol here because the comsumer just hook the
+  // installation event.
+  //
+  Status = SmmUninstallProtocolInterface (
+           SmmHandle,
+           &gEdkiiS3SmmInitDoneGuid,
+           NULL
+           );
+  ASSERT_EFI_ERROR (Status);
+
+  return Status;
+}
+
+/**
   Software SMI handler that is called when the EndOfS3Resume signal is triggered.
   This function installs the SMM EndOfS3Resume Protocol so SMM Drivers are informed that
   S3 resume has finished.
diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
index 8c10d833e2ae..2f6032646f46 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
@@ -2,7 +2,7 @@
   The internal header file includes the common header files, defines
   internal structure and functions used by SmmCore module.
 
-  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials are licensed and made available 
   under the terms and conditions of the BSD License which accompanies this 
   distribution.  The full text of the license may be found at        
@@ -42,6 +42,7 @@
 #include <Guid/LoadModuleAtFixedAddress.h>
 #include <Guid/SmiHandlerProfile.h>
 #include <Guid/EndOfS3Resume.h>
+#include <Guid/S3SmmInitDone.h>
 
 #include <Library/BaseLib.h>
 #include <Library/BaseMemoryLib.h>
@@ -811,6 +812,29 @@ SmmReadyToBootHandler (
   );
 
 /**
+  Software SMI handler that is called when the S3SmmInitDone signal is triggered.
+  This function installs the SMM S3SmmInitDone Protocol so SMM Drivers are informed that
+  S3 SMM initialization has been done.
+
+  @param  DispatchHandle  The unique handle assigned to this handler by SmiHandlerRegister().
+  @param  Context         Points to an optional handler context which was specified when the handler was registered.
+  @param  CommBuffer      A pointer to a collection of data in memory that will
+                          be conveyed from a non-SMM environment into an SMM environment.
+  @param  CommBufferSize  The size of the CommBuffer.
+
+  @return Status Code
+
+**/
+EFI_STATUS
+EFIAPI
+SmmS3SmmInitDoneHandler (
+  IN     EFI_HANDLE  DispatchHandle,
+  IN     CONST VOID  *Context,        OPTIONAL
+  IN OUT VOID        *CommBuffer,     OPTIONAL
+  IN OUT UINTN       *CommBufferSize  OPTIONAL
+  );
+
+/**
   Software SMI handler that is called when the EndOfS3Resume event is trigged.
   This function installs the SMM EndOfS3Resume Protocol so SMM Drivers are informed that
   S3 resume has finished.
diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
index 5c04e851f94b..09cffb879e6f 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
@@ -1,7 +1,7 @@
 ## @file
 # This module provide an SMM CIS compliant implementation of SMM Core.
 #
-# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
 #
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD License
@@ -124,6 +124,7 @@ [Guids]
   ## SOMETIMES_PRODUCES   ## GUID # SmiHandlerRegister
   gSmiHandlerProfileGuid
   gEdkiiEndOfS3ResumeGuid ## SOMETIMES_PRODUCES ## GUID # Install protocol
+  gEdkiiS3SmmInitDoneGuid ## SOMETIMES_PRODUCES ## GUID # Install protocol
 
 [UserExtensions.TianoCore."ExtraFiles"]
   PiSmmCoreExtra.uni
-- 
2.7.0.windows.1



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

* [PATCH 3/3] UefiCpuPkg S3ResumePei: Signal S3SmmInitDone
  2018-03-02  5:15 [PATCH 0/3] Add S3SmmInitDone point Star Zeng
  2018-03-02  5:15 ` [PATCH 1/3] MdeModulePkg: Add S3SmmInitDone definition Star Zeng
  2018-03-02  5:15 ` [PATCH 2/3] MdeModulePkg PiSmmCore: Register SMI handler to install S3SmmInitDone Star Zeng
@ 2018-03-02  5:15 ` Star Zeng
  2018-03-02  6:01   ` Yao, Jiewen
  2018-03-02 14:56   ` Laszlo Ersek
  2 siblings, 2 replies; 8+ messages in thread
From: Star Zeng @ 2018-03-02  5:15 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Jiewen Yao, Eric Dong, Laszlo Ersek

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
 UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c  | 42 +++++++++++++++-------
 .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf   |  3 ++
 2 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
index 4d776891a72d..2cb7b429e59c 100644
--- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
+++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
@@ -24,6 +24,7 @@
 #include <Guid/BootScriptExecutorVariable.h>
 #include <Guid/ExtendedFirmwarePerformance.h>
 #include <Guid/EndOfS3Resume.h>
+#include <Guid/S3SmmInitDone.h>
 #include <Ppi/ReadOnlyVariable2.h>
 #include <Ppi/S3Resume2.h>
 #include <Ppi/SmmAccess.h>
@@ -259,6 +260,12 @@ EFI_PEI_PPI_DESCRIPTOR mPpiListEndOfPeiTable = {
   0
 };
 
+EFI_PEI_PPI_DESCRIPTOR mPpiListS3SmmInitDoneTable = {
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+  &gEdkiiS3SmmInitDoneGuid,
+  0
+};
+
 //
 // Global Descriptor Table (GDT)
 //
@@ -322,13 +329,14 @@ IsLongModeWakingVector (
 }
 
 /**
-  Send EndOfS3Resume event to SmmCore through communication buffer way.
+  Signal to SMM through communication buffer way.
+
+  @param[in]  HandlerType       SMI handler type to be signaled.
 
-  @retval  EFI_SUCCESS                 Return send the event success.
 **/
-EFI_STATUS
-SignalEndOfS3Resume (
-  VOID
+VOID
+SignalToSmmByCommunication (
+  IN EFI_GUID   *HandlerType
   )
 {
   EFI_STATUS                         Status;
@@ -338,7 +346,7 @@ SignalEndOfS3Resume (
   SMM_COMMUNICATE_HEADER_64          Header64;
   VOID                               *CommBuffer;
 
-  DEBUG ((DEBUG_INFO, "SignalEndOfS3Resume - Enter\n"));
+  DEBUG ((DEBUG_INFO, "Signal %g to SMM - Enter\n", HandlerType));
 
   //
   // This buffer consumed in DXE phase, so base on DXE mode to prepare communicate buffer.
@@ -355,7 +363,7 @@ SignalEndOfS3Resume (
     Header32.MessageLength = 0;
     CommSize = OFFSET_OF (SMM_COMMUNICATE_HEADER_32, Data);
   }
-  CopyGuid (CommBuffer, &gEdkiiEndOfS3ResumeGuid);
+  CopyGuid (CommBuffer, HandlerType);
 
   Status = PeiServicesLocatePpi (
              &gEfiPeiSmmCommunicationPpiGuid,
@@ -365,7 +373,7 @@ SignalEndOfS3Resume (
              );
   if (EFI_ERROR (Status)) {
     DEBUG ((DEBUG_ERROR, "Locate Smm Communicate Ppi failed (%r)!\n", Status));
-    return Status;
+    return;
   }
 
   Status = SmmCommunicationPpi->Communicate (
@@ -377,8 +385,8 @@ SignalEndOfS3Resume (
     DEBUG ((DEBUG_ERROR, "SmmCommunicationPpi->Communicate return failure (%r)!\n", Status));
   }
 
-  DEBUG ((DEBUG_INFO, "SignalEndOfS3Resume - Exit (%r)\n", Status));
-  return Status;
+  DEBUG ((DEBUG_INFO, "Signal %g to SMM - Exit (%r)\n", HandlerType, Status));
+  return;
 }
 
 /**
@@ -464,11 +472,11 @@ S3ResumeBootOs (
   PERF_END_EX (NULL, "EndOfPeiPpi", NULL, 0, PERF_INMODULE_END_ID);
 
   //
-  // Signal EndOfS3Resume event.
+  // Signal EndOfS3Resume to SMM.
   //
   PERF_START_EX (NULL, "EndOfS3Resume", NULL, 0, PERF_INMODULE_START_ID);
 
-  SignalEndOfS3Resume ();
+  SignalToSmmByCommunication (&gEdkiiEndOfS3ResumeGuid);
 
   PERF_END_EX (NULL, "EndOfS3Resume", NULL, 0, PERF_INMODULE_END_ID);
 
@@ -787,6 +795,16 @@ S3ResumeExecuteBootScript (
         Status = SmmAccess->Lock ((EFI_PEI_SERVICES **)GetPeiServicesTablePointer (), SmmAccess, Index);
       }
     }
+
+    //
+    // Install S3SmmInitDone PPI.
+    //
+    Status = PeiServicesInstallPpi (&mPpiListS3SmmInitDoneTable);
+    ASSERT_EFI_ERROR (Status);
+    //
+    // Signal S3SmmInitDone to SMM.
+    //
+    SignalToSmmByCommunication (&gEdkiiS3SmmInitDoneGuid);
   }
 
   if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) {
diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
index 9522ede726f4..47fecd7d6d80 100644
--- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
+++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
@@ -78,6 +78,9 @@ [Guids]
   gEfiAcpiVariableGuid
   gEfiAcpiS3ContextGuid                         ## SOMETIMES_CONSUMES ## UNDEFINED # LockBox
   gEdkiiEndOfS3ResumeGuid                       ## SOMETIMES_CONSUMES ## UNDEFINED # Used to do smm communication
+  ## SOMETIMES_PRODUCES ## UNDEFINED # Install PPI
+  ## SOMETIMES_CONSUMES ## UNDEFINED # Used to do smm communication
+  gEdkiiS3SmmInitDoneGuid
 
 [Ppis]
   gEfiPeiReadOnlyVariable2PpiGuid               ## CONSUMES
-- 
2.7.0.windows.1



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

* Re: [PATCH 1/3] MdeModulePkg: Add S3SmmInitDone definition
  2018-03-02  5:15 ` [PATCH 1/3] MdeModulePkg: Add S3SmmInitDone definition Star Zeng
@ 2018-03-02  5:59   ` Yao, Jiewen
  0 siblings, 0 replies; 8+ messages in thread
From: Yao, Jiewen @ 2018-03-02  5:59 UTC (permalink / raw)
  To: Zeng, Star, edk2-devel@lists.01.org

Reviewed-by: Jiewen.yao@intel.com

> -----Original Message-----
> From: Zeng, Star
> Sent: Friday, March 2, 2018 1:16 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star <star.zeng@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> Subject: [PATCH 1/3] MdeModulePkg: Add S3SmmInitDone definition
> 
> Add gEdkiiS3SmmInitDoneGuid, after S3 SMM initialization is done and
> before S3 boot script is executed, this GUID is installed as PPI in
> PEI and protocol in SMM environment. It allows for PEIMs or SMM
> drivers to hook this point and do the required tasks.
> 
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng <star.zeng@intel.com>
> ---
>  MdeModulePkg/Include/Guid/S3SmmInitDone.h | 27
> +++++++++++++++++++++++++++
>  MdeModulePkg/MdeModulePkg.dec             |  3 +++
>  2 files changed, 30 insertions(+)
>  create mode 100644 MdeModulePkg/Include/Guid/S3SmmInitDone.h
> 
> diff --git a/MdeModulePkg/Include/Guid/S3SmmInitDone.h
> b/MdeModulePkg/Include/Guid/S3SmmInitDone.h
> new file mode 100644
> index 000000000000..53fef8ed19ef
> --- /dev/null
> +++ b/MdeModulePkg/Include/Guid/S3SmmInitDone.h
> @@ -0,0 +1,27 @@
> +/** @file
> +  After S3 SMM initialization is done and before S3 boot script is executed,
> +  this GUID is installed as PPI in PEI and protocol in SMM environment.
> +  It allows for PEIMs or SMM drivers to hook this point and do the required
> tasks.
> +
> +  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
> +  This program and the accompanying materials
> +  are licensed and made available under the terms and conditions of the BSD
> License
> +  which accompanies this distribution.  The full text of the license may be
> found at
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#ifndef __S3_SMM_INIT_DONE_H__
> +#define __S3_SMM_INIT_DONE_H__
> +
> +#define EDKII_S3_SMM_INIT_DONE_GUID \
> +  { \
> +    0x8f9d4825, 0x797d, 0x48fc, { 0x84, 0x71, 0x84, 0x50, 0x25, 0x79, 0x2e,
> 0xf6 } \
> +  }
> +
> +extern EFI_GUID gEdkiiS3SmmInitDoneGuid;
> +
> +#endif
> diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec
> index 455979386e3f..2b24ba506832 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -406,6 +406,9 @@ [Guids]
>    ## Include/Guid/EndofS3Resume.h
>    gEdkiiEndOfS3ResumeGuid = { 0x96f5296d, 0x05f7, 0x4f3c, {0x84, 0x67,
> 0xe4, 0x56, 0x89, 0x0e, 0x0c, 0xb5 } }
> 
> +  ## Include/Guid/S3SmmInitDone.h
> +  gEdkiiS3SmmInitDoneGuid = { 0x8f9d4825, 0x797d, 0x48fc, { 0x84, 0x71,
> 0x84, 0x50, 0x25, 0x79, 0x2e, 0xf6 } }
> +
>  [Ppis]
>    ## Include/Ppi/AtaController.h
>    gPeiAtaControllerPpiGuid       = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0,
> 0x7a, 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
> --
> 2.7.0.windows.1



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

* Re: [PATCH 2/3] MdeModulePkg PiSmmCore: Register SMI handler to install S3SmmInitDone
  2018-03-02  5:15 ` [PATCH 2/3] MdeModulePkg PiSmmCore: Register SMI handler to install S3SmmInitDone Star Zeng
@ 2018-03-02  6:00   ` Yao, Jiewen
  0 siblings, 0 replies; 8+ messages in thread
From: Yao, Jiewen @ 2018-03-02  6:00 UTC (permalink / raw)
  To: Zeng, Star, edk2-devel@lists.01.org

Reviewed-by: Jiewen.yao@intel.com

> -----Original Message-----
> From: Zeng, Star
> Sent: Friday, March 2, 2018 1:16 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star <star.zeng@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>
> Subject: [PATCH 2/3] MdeModulePkg PiSmmCore: Register SMI handler to install
> S3SmmInitDone
> 
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng <star.zeng@intel.com>
> ---
>  MdeModulePkg/Core/PiSmmCore/PiSmmCore.c   | 62
> ++++++++++++++++++++++++++++++-
>  MdeModulePkg/Core/PiSmmCore/PiSmmCore.h   | 26 ++++++++++++-
>  MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf |  3 +-
>  3 files changed, 88 insertions(+), 3 deletions(-)
> 
> diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
> b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
> index d2f0207b5c83..686b9b45a556 100644
> --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
> +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
> @@ -1,7 +1,7 @@
>  /** @file
>    SMM Core Main Entry Point
> 
> -  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
>    This program and the accompanying materials are licensed and made
> available
>    under the terms and conditions of the BSD License which accompanies this
>    distribution.  The full text of the license may be found at
> @@ -87,6 +87,7 @@ SMM_CORE_SMI_HANDLERS  mSmmCoreSmiHandlers[]
> = {
>    { SmmExitBootServicesHandler, &gEfiEventExitBootServicesGuid,      NULL,
> FALSE },
>    { SmmReadyToBootHandler,      &gEfiEventReadyToBootGuid,
> NULL, FALSE },
>    { SmmEndOfDxeHandler,         &gEfiEndOfDxeEventGroupGuid,
> NULL, TRUE },
> +  { SmmS3SmmInitDoneHandler,    &gEdkiiS3SmmInitDoneGuid,
> NULL, FALSE },
>    { SmmEndOfS3ResumeHandler,    &gEdkiiEndOfS3ResumeGuid,
> NULL, FALSE },
>    { NULL,                       NULL,
> NULL, FALSE }
>  };
> @@ -472,6 +473,65 @@ SmmEndOfDxeHandler (
>  }
> 
>  /**
> +  Software SMI handler that is called when the S3SmmInitDone signal is
> triggered.
> +  This function installs the SMM S3SmmInitDone Protocol so SMM Drivers are
> informed that
> +  S3 SMM initialization has been done.
> +
> +  @param  DispatchHandle  The unique handle assigned to this handler by
> SmiHandlerRegister().
> +  @param  Context         Points to an optional handler context which
> was specified when the handler was registered.
> +  @param  CommBuffer      A pointer to a collection of data in memory
> that will
> +                          be conveyed from a non-SMM environment into
> an SMM environment.
> +  @param  CommBufferSize  The size of the CommBuffer.
> +
> +  @return Status Code
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +SmmS3SmmInitDoneHandler (
> +  IN     EFI_HANDLE  DispatchHandle,
> +  IN     CONST VOID  *Context,        OPTIONAL
> +  IN OUT VOID        *CommBuffer,     OPTIONAL
> +  IN OUT UINTN       *CommBufferSize  OPTIONAL
> +  )
> +{
> +  EFI_STATUS  Status;
> +  EFI_HANDLE  SmmHandle;
> +
> +  DEBUG ((DEBUG_INFO, "SmmS3SmmInitDoneHandler\n"));
> +
> +  if (!mDuringS3Resume) {
> +    DEBUG ((DEBUG_ERROR, "It is not during S3 resume\n"));
> +    return EFI_SUCCESS;
> +  }
> +
> +  //
> +  // Install SMM S3SmmInitDone protocol
> +  //
> +  SmmHandle = NULL;
> +  Status = SmmInstallProtocolInterface (
> +             &SmmHandle,
> +             &gEdkiiS3SmmInitDoneGuid,
> +             EFI_NATIVE_INTERFACE,
> +             NULL
> +             );
> +  ASSERT_EFI_ERROR (Status);
> +
> +  //
> +  // Uninstall the protocol here because the comsumer just hook the
> +  // installation event.
> +  //
> +  Status = SmmUninstallProtocolInterface (
> +           SmmHandle,
> +           &gEdkiiS3SmmInitDoneGuid,
> +           NULL
> +           );
> +  ASSERT_EFI_ERROR (Status);
> +
> +  return Status;
> +}
> +
> +/**
>    Software SMI handler that is called when the EndOfS3Resume signal is
> triggered.
>    This function installs the SMM EndOfS3Resume Protocol so SMM Drivers are
> informed that
>    S3 resume has finished.
> diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
> b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
> index 8c10d833e2ae..2f6032646f46 100644
> --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
> +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
> @@ -2,7 +2,7 @@
>    The internal header file includes the common header files, defines
>    internal structure and functions used by SmmCore module.
> 
> -  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
>    This program and the accompanying materials are licensed and made
> available
>    under the terms and conditions of the BSD License which accompanies this
>    distribution.  The full text of the license may be found at
> @@ -42,6 +42,7 @@
>  #include <Guid/LoadModuleAtFixedAddress.h>
>  #include <Guid/SmiHandlerProfile.h>
>  #include <Guid/EndOfS3Resume.h>
> +#include <Guid/S3SmmInitDone.h>
> 
>  #include <Library/BaseLib.h>
>  #include <Library/BaseMemoryLib.h>
> @@ -811,6 +812,29 @@ SmmReadyToBootHandler (
>    );
> 
>  /**
> +  Software SMI handler that is called when the S3SmmInitDone signal is
> triggered.
> +  This function installs the SMM S3SmmInitDone Protocol so SMM Drivers are
> informed that
> +  S3 SMM initialization has been done.
> +
> +  @param  DispatchHandle  The unique handle assigned to this handler by
> SmiHandlerRegister().
> +  @param  Context         Points to an optional handler context which
> was specified when the handler was registered.
> +  @param  CommBuffer      A pointer to a collection of data in memory
> that will
> +                          be conveyed from a non-SMM environment into
> an SMM environment.
> +  @param  CommBufferSize  The size of the CommBuffer.
> +
> +  @return Status Code
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +SmmS3SmmInitDoneHandler (
> +  IN     EFI_HANDLE  DispatchHandle,
> +  IN     CONST VOID  *Context,        OPTIONAL
> +  IN OUT VOID        *CommBuffer,     OPTIONAL
> +  IN OUT UINTN       *CommBufferSize  OPTIONAL
> +  );
> +
> +/**
>    Software SMI handler that is called when the EndOfS3Resume event is
> trigged.
>    This function installs the SMM EndOfS3Resume Protocol so SMM Drivers are
> informed that
>    S3 resume has finished.
> diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
> b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
> index 5c04e851f94b..09cffb879e6f 100644
> --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
> +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
> @@ -1,7 +1,7 @@
>  ## @file
>  # This module provide an SMM CIS compliant implementation of SMM Core.
>  #
> -# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
> +# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
>  #
>  # This program and the accompanying materials
>  # are licensed and made available under the terms and conditions of the BSD
> License
> @@ -124,6 +124,7 @@ [Guids]
>    ## SOMETIMES_PRODUCES   ## GUID # SmiHandlerRegister
>    gSmiHandlerProfileGuid
>    gEdkiiEndOfS3ResumeGuid ## SOMETIMES_PRODUCES ## GUID # Install
> protocol
> +  gEdkiiS3SmmInitDoneGuid ## SOMETIMES_PRODUCES ## GUID # Install
> protocol
> 
>  [UserExtensions.TianoCore."ExtraFiles"]
>    PiSmmCoreExtra.uni
> --
> 2.7.0.windows.1



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

* Re: [PATCH 3/3] UefiCpuPkg S3ResumePei: Signal S3SmmInitDone
  2018-03-02  5:15 ` [PATCH 3/3] UefiCpuPkg S3ResumePei: Signal S3SmmInitDone Star Zeng
@ 2018-03-02  6:01   ` Yao, Jiewen
  2018-03-02 14:56   ` Laszlo Ersek
  1 sibling, 0 replies; 8+ messages in thread
From: Yao, Jiewen @ 2018-03-02  6:01 UTC (permalink / raw)
  To: Zeng, Star, edk2-devel@lists.01.org; +Cc: Dong, Eric, Laszlo Ersek

Hi Star
Can we keep the human readable debug message?

-  DEBUG ((DEBUG_INFO, "SignalEndOfS3Resume - Enter\n"));
+  DEBUG ((DEBUG_INFO, "Signal %g to SMM - Enter\n", HandlerType));

Other update is good to me.
Reviewed-by: Jiewen.yao@intel.com


Thank you
Yao Jiewen


> -----Original Message-----
> From: Zeng, Star
> Sent: Friday, March 2, 2018 1:16 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star <star.zeng@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>;
> Dong, Eric <eric.dong@intel.com>; Laszlo Ersek <lersek@redhat.com>
> Subject: [PATCH 3/3] UefiCpuPkg S3ResumePei: Signal S3SmmInitDone
> 
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng <star.zeng@intel.com>
> ---
>  UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c  | 42
> +++++++++++++++-------
>  .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf   |  3 ++
>  2 files changed, 33 insertions(+), 12 deletions(-)
> 
> diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
> b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
> index 4d776891a72d..2cb7b429e59c 100644
> --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
> +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
> @@ -24,6 +24,7 @@
>  #include <Guid/BootScriptExecutorVariable.h>
>  #include <Guid/ExtendedFirmwarePerformance.h>
>  #include <Guid/EndOfS3Resume.h>
> +#include <Guid/S3SmmInitDone.h>
>  #include <Ppi/ReadOnlyVariable2.h>
>  #include <Ppi/S3Resume2.h>
>  #include <Ppi/SmmAccess.h>
> @@ -259,6 +260,12 @@ EFI_PEI_PPI_DESCRIPTOR mPpiListEndOfPeiTable = {
>    0
>  };
> 
> +EFI_PEI_PPI_DESCRIPTOR mPpiListS3SmmInitDoneTable = {
> +  (EFI_PEI_PPI_DESCRIPTOR_PPI |
> EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
> +  &gEdkiiS3SmmInitDoneGuid,
> +  0
> +};
> +
>  //
>  // Global Descriptor Table (GDT)
>  //
> @@ -322,13 +329,14 @@ IsLongModeWakingVector (
>  }
> 
>  /**
> -  Send EndOfS3Resume event to SmmCore through communication buffer
> way.
> +  Signal to SMM through communication buffer way.
> +
> +  @param[in]  HandlerType       SMI handler type to be signaled.
> 
> -  @retval  EFI_SUCCESS                 Return send the event success.
>  **/
> -EFI_STATUS
> -SignalEndOfS3Resume (
> -  VOID
> +VOID
> +SignalToSmmByCommunication (
> +  IN EFI_GUID   *HandlerType
>    )
>  {
>    EFI_STATUS                         Status;
> @@ -338,7 +346,7 @@ SignalEndOfS3Resume (
>    SMM_COMMUNICATE_HEADER_64          Header64;
>    VOID                               *CommBuffer;
> 
> -  DEBUG ((DEBUG_INFO, "SignalEndOfS3Resume - Enter\n"));
> +  DEBUG ((DEBUG_INFO, "Signal %g to SMM - Enter\n", HandlerType));
> 
>    //
>    // This buffer consumed in DXE phase, so base on DXE mode to prepare
> communicate buffer.
> @@ -355,7 +363,7 @@ SignalEndOfS3Resume (
>      Header32.MessageLength = 0;
>      CommSize = OFFSET_OF (SMM_COMMUNICATE_HEADER_32, Data);
>    }
> -  CopyGuid (CommBuffer, &gEdkiiEndOfS3ResumeGuid);
> +  CopyGuid (CommBuffer, HandlerType);
> 
>    Status = PeiServicesLocatePpi (
>               &gEfiPeiSmmCommunicationPpiGuid,
> @@ -365,7 +373,7 @@ SignalEndOfS3Resume (
>               );
>    if (EFI_ERROR (Status)) {
>      DEBUG ((DEBUG_ERROR, "Locate Smm Communicate Ppi failed (%r)!\n",
> Status));
> -    return Status;
> +    return;
>    }
> 
>    Status = SmmCommunicationPpi->Communicate (
> @@ -377,8 +385,8 @@ SignalEndOfS3Resume (
>      DEBUG ((DEBUG_ERROR, "SmmCommunicationPpi->Communicate return
> failure (%r)!\n", Status));
>    }
> 
> -  DEBUG ((DEBUG_INFO, "SignalEndOfS3Resume - Exit (%r)\n", Status));
> -  return Status;
> +  DEBUG ((DEBUG_INFO, "Signal %g to SMM - Exit (%r)\n", HandlerType,
> Status));
> +  return;
>  }
> 
>  /**
> @@ -464,11 +472,11 @@ S3ResumeBootOs (
>    PERF_END_EX (NULL, "EndOfPeiPpi", NULL, 0, PERF_INMODULE_END_ID);
> 
>    //
> -  // Signal EndOfS3Resume event.
> +  // Signal EndOfS3Resume to SMM.
>    //
>    PERF_START_EX (NULL, "EndOfS3Resume", NULL, 0,
> PERF_INMODULE_START_ID);
> 
> -  SignalEndOfS3Resume ();
> +  SignalToSmmByCommunication (&gEdkiiEndOfS3ResumeGuid);
> 
>    PERF_END_EX (NULL, "EndOfS3Resume", NULL, 0,
> PERF_INMODULE_END_ID);
> 
> @@ -787,6 +795,16 @@ S3ResumeExecuteBootScript (
>          Status = SmmAccess->Lock ((EFI_PEI_SERVICES
> **)GetPeiServicesTablePointer (), SmmAccess, Index);
>        }
>      }
> +
> +    //
> +    // Install S3SmmInitDone PPI.
> +    //
> +    Status = PeiServicesInstallPpi (&mPpiListS3SmmInitDoneTable);
> +    ASSERT_EFI_ERROR (Status);
> +    //
> +    // Signal S3SmmInitDone to SMM.
> +    //
> +    SignalToSmmByCommunication (&gEdkiiS3SmmInitDoneGuid);
>    }
> 
>    if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) {
> diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
> b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
> index 9522ede726f4..47fecd7d6d80 100644
> --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
> +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
> @@ -78,6 +78,9 @@ [Guids]
>    gEfiAcpiVariableGuid
>    gEfiAcpiS3ContextGuid                         ##
> SOMETIMES_CONSUMES ## UNDEFINED # LockBox
>    gEdkiiEndOfS3ResumeGuid                       ##
> SOMETIMES_CONSUMES ## UNDEFINED # Used to do smm communication
> +  ## SOMETIMES_PRODUCES ## UNDEFINED # Install PPI
> +  ## SOMETIMES_CONSUMES ## UNDEFINED # Used to do smm
> communication
> +  gEdkiiS3SmmInitDoneGuid
> 
>  [Ppis]
>    gEfiPeiReadOnlyVariable2PpiGuid               ## CONSUMES
> --
> 2.7.0.windows.1



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

* Re: [PATCH 3/3] UefiCpuPkg S3ResumePei: Signal S3SmmInitDone
  2018-03-02  5:15 ` [PATCH 3/3] UefiCpuPkg S3ResumePei: Signal S3SmmInitDone Star Zeng
  2018-03-02  6:01   ` Yao, Jiewen
@ 2018-03-02 14:56   ` Laszlo Ersek
  1 sibling, 0 replies; 8+ messages in thread
From: Laszlo Ersek @ 2018-03-02 14:56 UTC (permalink / raw)
  To: Star Zeng, edk2-devel; +Cc: Jiewen Yao, Eric Dong

On 03/02/18 06:15, Star Zeng wrote:
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Star Zeng <star.zeng@intel.com>
> ---
>  UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c  | 42 +++++++++++++++-------
>  .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf   |  3 ++
>  2 files changed, 33 insertions(+), 12 deletions(-)
> 
> diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
> index 4d776891a72d..2cb7b429e59c 100644
> --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
> +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c
> @@ -24,6 +24,7 @@
>  #include <Guid/BootScriptExecutorVariable.h>
>  #include <Guid/ExtendedFirmwarePerformance.h>
>  #include <Guid/EndOfS3Resume.h>
> +#include <Guid/S3SmmInitDone.h>
>  #include <Ppi/ReadOnlyVariable2.h>
>  #include <Ppi/S3Resume2.h>
>  #include <Ppi/SmmAccess.h>
> @@ -259,6 +260,12 @@ EFI_PEI_PPI_DESCRIPTOR mPpiListEndOfPeiTable = {
>    0
>  };
>  
> +EFI_PEI_PPI_DESCRIPTOR mPpiListS3SmmInitDoneTable = {
> +  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
> +  &gEdkiiS3SmmInitDoneGuid,
> +  0
> +};
> +
>  //
>  // Global Descriptor Table (GDT)
>  //
> @@ -322,13 +329,14 @@ IsLongModeWakingVector (
>  }
>  
>  /**
> -  Send EndOfS3Resume event to SmmCore through communication buffer way.
> +  Signal to SMM through communication buffer way.
> +
> +  @param[in]  HandlerType       SMI handler type to be signaled.
>  
> -  @retval  EFI_SUCCESS                 Return send the event success.
>  **/
> -EFI_STATUS
> -SignalEndOfS3Resume (
> -  VOID
> +VOID
> +SignalToSmmByCommunication (
> +  IN EFI_GUID   *HandlerType
>    )
>  {
>    EFI_STATUS                         Status;
> @@ -338,7 +346,7 @@ SignalEndOfS3Resume (
>    SMM_COMMUNICATE_HEADER_64          Header64;
>    VOID                               *CommBuffer;
>  
> -  DEBUG ((DEBUG_INFO, "SignalEndOfS3Resume - Enter\n"));
> +  DEBUG ((DEBUG_INFO, "Signal %g to SMM - Enter\n", HandlerType));
>  
>    //
>    // This buffer consumed in DXE phase, so base on DXE mode to prepare communicate buffer.
> @@ -355,7 +363,7 @@ SignalEndOfS3Resume (
>      Header32.MessageLength = 0;
>      CommSize = OFFSET_OF (SMM_COMMUNICATE_HEADER_32, Data);
>    }
> -  CopyGuid (CommBuffer, &gEdkiiEndOfS3ResumeGuid);
> +  CopyGuid (CommBuffer, HandlerType);
>  
>    Status = PeiServicesLocatePpi (
>               &gEfiPeiSmmCommunicationPpiGuid,
> @@ -365,7 +373,7 @@ SignalEndOfS3Resume (
>               );
>    if (EFI_ERROR (Status)) {
>      DEBUG ((DEBUG_ERROR, "Locate Smm Communicate Ppi failed (%r)!\n", Status));
> -    return Status;
> +    return;
>    }
>  
>    Status = SmmCommunicationPpi->Communicate (
> @@ -377,8 +385,8 @@ SignalEndOfS3Resume (
>      DEBUG ((DEBUG_ERROR, "SmmCommunicationPpi->Communicate return failure (%r)!\n", Status));
>    }
>  
> -  DEBUG ((DEBUG_INFO, "SignalEndOfS3Resume - Exit (%r)\n", Status));
> -  return Status;
> +  DEBUG ((DEBUG_INFO, "Signal %g to SMM - Exit (%r)\n", HandlerType, Status));
> +  return;
>  }
>  
>  /**
> @@ -464,11 +472,11 @@ S3ResumeBootOs (
>    PERF_END_EX (NULL, "EndOfPeiPpi", NULL, 0, PERF_INMODULE_END_ID);
>  
>    //
> -  // Signal EndOfS3Resume event.
> +  // Signal EndOfS3Resume to SMM.
>    //
>    PERF_START_EX (NULL, "EndOfS3Resume", NULL, 0, PERF_INMODULE_START_ID);
>  
> -  SignalEndOfS3Resume ();
> +  SignalToSmmByCommunication (&gEdkiiEndOfS3ResumeGuid);
>  
>    PERF_END_EX (NULL, "EndOfS3Resume", NULL, 0, PERF_INMODULE_END_ID);
>  
> @@ -787,6 +795,16 @@ S3ResumeExecuteBootScript (
>          Status = SmmAccess->Lock ((EFI_PEI_SERVICES **)GetPeiServicesTablePointer (), SmmAccess, Index);
>        }
>      }
> +
> +    //
> +    // Install S3SmmInitDone PPI.
> +    //
> +    Status = PeiServicesInstallPpi (&mPpiListS3SmmInitDoneTable);
> +    ASSERT_EFI_ERROR (Status);
> +    //
> +    // Signal S3SmmInitDone to SMM.
> +    //
> +    SignalToSmmByCommunication (&gEdkiiS3SmmInitDoneGuid);
>    }
>  
>    if (FeaturePcdGet (PcdDxeIplSwitchToLongMode)) {
> diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
> index 9522ede726f4..47fecd7d6d80 100644
> --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
> +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
> @@ -78,6 +78,9 @@ [Guids]
>    gEfiAcpiVariableGuid
>    gEfiAcpiS3ContextGuid                         ## SOMETIMES_CONSUMES ## UNDEFINED # LockBox
>    gEdkiiEndOfS3ResumeGuid                       ## SOMETIMES_CONSUMES ## UNDEFINED # Used to do smm communication
> +  ## SOMETIMES_PRODUCES ## UNDEFINED # Install PPI
> +  ## SOMETIMES_CONSUMES ## UNDEFINED # Used to do smm communication
> +  gEdkiiS3SmmInitDoneGuid
>  
>  [Ppis]
>    gEfiPeiReadOnlyVariable2PpiGuid               ## CONSUMES
> 

OK, this patch seems to preserve the current behavior that the SMM
communication PPI is optional.

Acked-by: Laszlo Ersek <lersek@redhat.com>

Thanks
Laszlo


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

end of thread, other threads:[~2018-03-02 14:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-02  5:15 [PATCH 0/3] Add S3SmmInitDone point Star Zeng
2018-03-02  5:15 ` [PATCH 1/3] MdeModulePkg: Add S3SmmInitDone definition Star Zeng
2018-03-02  5:59   ` Yao, Jiewen
2018-03-02  5:15 ` [PATCH 2/3] MdeModulePkg PiSmmCore: Register SMI handler to install S3SmmInitDone Star Zeng
2018-03-02  6:00   ` Yao, Jiewen
2018-03-02  5:15 ` [PATCH 3/3] UefiCpuPkg S3ResumePei: Signal S3SmmInitDone Star Zeng
2018-03-02  6:01   ` Yao, Jiewen
2018-03-02 14:56   ` Laszlo Ersek

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