public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v3] MdeModulePkg: Enable/Disable S3BootScript dynamically.
@ 2019-09-27  7:51 Chiu, Chasel
  2019-09-29 18:40 ` [edk2-devel] " Nate DeSimone
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Chiu, Chasel @ 2019-09-27  7:51 UTC (permalink / raw)
  To: devel; +Cc: Hao A Wu, Eric Dong, Nate DeSimone, Liming Gao, Laszlo Ersek

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

In binary model the same binary may have to support both
S3 enabled and disabled scenarios, however not all DXE
drivers linking PiDxeS3BootScriptLib can return error to
invoke library DESTRUCTOR for releasing resource.

To support this usage model below PCD is used to skip
S3BootScript functions when PCD set to FALSE:
  gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable

Test: Verified on internal platform and S3BootScript
      functions can be skipped by PCD during boot time.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
---
 MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c       | 17 ++++++++++++++++-
 MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf |  4 ++--
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
index c116727531..9106e7d0f9 100644
--- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
+++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
@@ -1,7 +1,7 @@
 /** @file
   Save the S3 data to S3 boot script.
 
-  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -124,6 +124,7 @@ VOID                             *mRegistrationSmmReadyToLock = NULL;
 BOOLEAN                          mS3BootScriptTableAllocated = FALSE;
 BOOLEAN                          mS3BootScriptTableSmmAllocated = FALSE;
 EFI_SMM_SYSTEM_TABLE2            *mBootScriptSmst = NULL;
+BOOLEAN                          mAcpiS3Enable = TRUE;
 
 /**
   This is an internal function to add a terminate node the entry, recalculate the table
@@ -436,6 +437,12 @@ S3BootScriptLibInitialize (
   BOOLEAN                        InSmm;
   EFI_PHYSICAL_ADDRESS           Buffer;
 
+  if (!PcdGetBool (PcdAcpiS3Enable)) {
+    mAcpiS3Enable = FALSE;
+    DEBUG ((DEBUG_INFO, "%a: Skip S3BootScript because ACPI S3 disabled.\n", gEfiCallerBaseName));
+    return RETURN_SUCCESS;
+  }
+
   S3TablePtr = (SCRIPT_TABLE_PRIVATE_DATA*)(UINTN)PcdGet64(PcdS3BootScriptTablePrivateDataPtr);
   //
   // The Boot script private data is not be initialized. create it
@@ -562,6 +569,10 @@ S3BootScriptLibDeinitialize (
 {
   EFI_STATUS                Status;
 
+  if (!mAcpiS3Enable) {
+    return RETURN_SUCCESS;
+  }
+
   DEBUG ((EFI_D_INFO, "%a() in %a module\n", __FUNCTION__, gEfiCallerBaseName));
 
   if (mEventDxeSmmReadyToLock != NULL) {
@@ -810,6 +821,10 @@ S3BootScriptGetEntryAddAddress (
 {
   UINT8*                         NewEntryPtr;
 
+  if (!mAcpiS3Enable) {
+    return NULL;
+  }
+
   if (mS3BootScriptTablePtr->SmmLocked) {
     //
     // We need check InSmm, because after SmmReadyToLock, only SMM driver is allowed to write boot script.
diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf b/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
index 517ea69568..2b894c99da 100644
--- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
+++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
@@ -1,7 +1,7 @@
 ## @file
 # DXE S3 boot script Library.
 #
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -65,4 +65,4 @@
   ## SOMETIMES_PRODUCES
   gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptTablePrivateSmmDataPtr
   gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptRuntimeTableReservePageNumber   ## CONSUMES
-
+  gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable                                ## CONSUMES
-- 
2.13.3.windows.1


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

* Re: [edk2-devel] [PATCH v3] MdeModulePkg: Enable/Disable S3BootScript dynamically.
  2019-09-27  7:51 [PATCH v3] MdeModulePkg: Enable/Disable S3BootScript dynamically Chiu, Chasel
@ 2019-09-29 18:40 ` Nate DeSimone
  2019-09-30  0:44 ` Dong, Eric
  2019-09-30 23:09 ` Laszlo Ersek
  2 siblings, 0 replies; 5+ messages in thread
From: Nate DeSimone @ 2019-09-29 18:40 UTC (permalink / raw)
  To: devel@edk2.groups.io, Chiu, Chasel
  Cc: Wu, Hao A, Dong, Eric, Gao, Liming, Laszlo Ersek

Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chiu, Chasel
Sent: Friday, September 27, 2019 12:51 AM
To: devel@edk2.groups.io
Cc: Wu, Hao A <hao.a.wu@intel.com>; Dong, Eric <eric.dong@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Gao, Liming <liming.gao@intel.com>; Laszlo Ersek <lersek@redhat.com>
Subject: [edk2-devel] [PATCH v3] MdeModulePkg: Enable/Disable S3BootScript dynamically.

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

In binary model the same binary may have to support both
S3 enabled and disabled scenarios, however not all DXE drivers linking PiDxeS3BootScriptLib can return error to invoke library DESTRUCTOR for releasing resource.

To support this usage model below PCD is used to skip S3BootScript functions when PCD set to FALSE:
  gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable

Test: Verified on internal platform and S3BootScript
      functions can be skipped by PCD during boot time.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
---
 MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c       | 17 ++++++++++++++++-
 MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf |  4 ++--
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
index c116727531..9106e7d0f9 100644
--- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
+++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
@@ -1,7 +1,7 @@
 /** @file
   Save the S3 data to S3 boot script.
 
-  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights 
+ reserved.<BR>
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -124,6 +124,7 @@ VOID                             *mRegistrationSmmReadyToLock = NULL;
 BOOLEAN                          mS3BootScriptTableAllocated = FALSE;
 BOOLEAN                          mS3BootScriptTableSmmAllocated = FALSE;
 EFI_SMM_SYSTEM_TABLE2            *mBootScriptSmst = NULL;
+BOOLEAN                          mAcpiS3Enable = TRUE;
 
 /**
   This is an internal function to add a terminate node the entry, recalculate the table @@ -436,6 +437,12 @@ S3BootScriptLibInitialize (
   BOOLEAN                        InSmm;
   EFI_PHYSICAL_ADDRESS           Buffer;
 
+  if (!PcdGetBool (PcdAcpiS3Enable)) {
+    mAcpiS3Enable = FALSE;
+    DEBUG ((DEBUG_INFO, "%a: Skip S3BootScript because ACPI S3 disabled.\n", gEfiCallerBaseName));
+    return RETURN_SUCCESS;
+  }
+
   S3TablePtr = (SCRIPT_TABLE_PRIVATE_DATA*)(UINTN)PcdGet64(PcdS3BootScriptTablePrivateDataPtr);
   //
   // The Boot script private data is not be initialized. create it @@ -562,6 +569,10 @@ S3BootScriptLibDeinitialize (  {
   EFI_STATUS                Status;
 
+  if (!mAcpiS3Enable) {
+    return RETURN_SUCCESS;
+  }
+
   DEBUG ((EFI_D_INFO, "%a() in %a module\n", __FUNCTION__, gEfiCallerBaseName));
 
   if (mEventDxeSmmReadyToLock != NULL) { @@ -810,6 +821,10 @@ S3BootScriptGetEntryAddAddress (  {
   UINT8*                         NewEntryPtr;
 
+  if (!mAcpiS3Enable) {
+    return NULL;
+  }
+
   if (mS3BootScriptTablePtr->SmmLocked) {
     //
     // We need check InSmm, because after SmmReadyToLock, only SMM driver is allowed to write boot script.
diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf b/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
index 517ea69568..2b894c99da 100644
--- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
+++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
@@ -1,7 +1,7 @@
 ## @file
 # DXE S3 boot script Library.
 #
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2019, Intel Corporation. All rights 
+reserved.<BR>
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent  # @@ -65,4 +65,4 @@
   ## SOMETIMES_PRODUCES
   gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptTablePrivateSmmDataPtr
   gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptRuntimeTableReservePageNumber   ## CONSUMES
-
+  gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable                                ## CONSUMES
--
2.13.3.windows.1





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

* Re: [edk2-devel] [PATCH v3] MdeModulePkg: Enable/Disable S3BootScript dynamically.
  2019-09-27  7:51 [PATCH v3] MdeModulePkg: Enable/Disable S3BootScript dynamically Chiu, Chasel
  2019-09-29 18:40 ` [edk2-devel] " Nate DeSimone
@ 2019-09-30  0:44 ` Dong, Eric
  2019-09-30 23:09 ` Laszlo Ersek
  2 siblings, 0 replies; 5+ messages in thread
From: Dong, Eric @ 2019-09-30  0:44 UTC (permalink / raw)
  To: devel@edk2.groups.io, Chiu, Chasel
  Cc: Wu, Hao A, Desimone, Nathaniel L, Gao, Liming, Laszlo Ersek

Reviewed-by: Eric Dong <eric.dong@intel.com>

> -----Original Message-----
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Chiu,
> Chasel
> Sent: Friday, September 27, 2019 3:51 PM
> To: devel@edk2.groups.io
> Cc: Wu, Hao A <hao.a.wu@intel.com>; Dong, Eric <eric.dong@intel.com>;
> Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Gao, Liming
> <liming.gao@intel.com>; Laszlo Ersek <lersek@redhat.com>
> Subject: [edk2-devel] [PATCH v3] MdeModulePkg: Enable/Disable S3BootScript
> dynamically.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2212
> 
> In binary model the same binary may have to support both
> S3 enabled and disabled scenarios, however not all DXE
> drivers linking PiDxeS3BootScriptLib can return error to
> invoke library DESTRUCTOR for releasing resource.
> 
> To support this usage model below PCD is used to skip
> S3BootScript functions when PCD set to FALSE:
>   gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable
> 
> Test: Verified on internal platform and S3BootScript
>       functions can be skipped by PCD during boot time.
> 
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
> ---
>  MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c       | 17
> ++++++++++++++++-
>  MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf |  4 ++--
>  2 files changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
> b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
> index c116727531..9106e7d0f9 100644
> --- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
> +++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
> @@ -1,7 +1,7 @@
>  /** @file
>    Save the S3 data to S3 boot script.
> 
> -  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
> 
>    SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -124,6 +124,7 @@ VOID                             *mRegistrationSmmReadyToLock
> = NULL;
>  BOOLEAN                          mS3BootScriptTableAllocated = FALSE;
>  BOOLEAN                          mS3BootScriptTableSmmAllocated = FALSE;
>  EFI_SMM_SYSTEM_TABLE2            *mBootScriptSmst = NULL;
> +BOOLEAN                          mAcpiS3Enable = TRUE;
> 
>  /**
>    This is an internal function to add a terminate node the entry, recalculate the
> table
> @@ -436,6 +437,12 @@ S3BootScriptLibInitialize (
>    BOOLEAN                        InSmm;
>    EFI_PHYSICAL_ADDRESS           Buffer;
> 
> +  if (!PcdGetBool (PcdAcpiS3Enable)) {
> +    mAcpiS3Enable = FALSE;
> +    DEBUG ((DEBUG_INFO, "%a: Skip S3BootScript because ACPI S3
> disabled.\n", gEfiCallerBaseName));
> +    return RETURN_SUCCESS;
> +  }
> +
>    S3TablePtr =
> (SCRIPT_TABLE_PRIVATE_DATA*)(UINTN)PcdGet64(PcdS3BootScriptTablePriv
> ateDataPtr);
>    //
>    // The Boot script private data is not be initialized. create it
> @@ -562,6 +569,10 @@ S3BootScriptLibDeinitialize (
>  {
>    EFI_STATUS                Status;
> 
> +  if (!mAcpiS3Enable) {
> +    return RETURN_SUCCESS;
> +  }
> +
>    DEBUG ((EFI_D_INFO, "%a() in %a module\n", __FUNCTION__,
> gEfiCallerBaseName));
> 
>    if (mEventDxeSmmReadyToLock != NULL) {
> @@ -810,6 +821,10 @@ S3BootScriptGetEntryAddAddress (
>  {
>    UINT8*                         NewEntryPtr;
> 
> +  if (!mAcpiS3Enable) {
> +    return NULL;
> +  }
> +
>    if (mS3BootScriptTablePtr->SmmLocked) {
>      //
>      // We need check InSmm, because after SmmReadyToLock, only SMM driver
> is allowed to write boot script.
> diff --git
> a/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
> b/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
> index 517ea69568..2b894c99da 100644
> --- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
> +++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
> @@ -1,7 +1,7 @@
>  ## @file
>  # DXE S3 boot script Library.
>  #
> -# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
> +# Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
>  #
>  # SPDX-License-Identifier: BSD-2-Clause-Patent
>  #
> @@ -65,4 +65,4 @@
>    ## SOMETIMES_PRODUCES
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptTablePrivateSmmDataPtr
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptRuntimeTableReservePag
> eNumber   ## CONSUMES
> -
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable                                ##
> CONSUMES
> --
> 2.13.3.windows.1
> 
> 
> 


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

* Re: [PATCH v3] MdeModulePkg: Enable/Disable S3BootScript dynamically.
  2019-09-27  7:51 [PATCH v3] MdeModulePkg: Enable/Disable S3BootScript dynamically Chiu, Chasel
  2019-09-29 18:40 ` [edk2-devel] " Nate DeSimone
  2019-09-30  0:44 ` Dong, Eric
@ 2019-09-30 23:09 ` Laszlo Ersek
  2 siblings, 0 replies; 5+ messages in thread
From: Laszlo Ersek @ 2019-09-30 23:09 UTC (permalink / raw)
  To: Chasel Chiu, devel; +Cc: Hao A Wu, Eric Dong, Nate DeSimone, Liming Gao

On 09/27/19 09:51, Chasel Chiu wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2212
> 
> In binary model the same binary may have to support both
> S3 enabled and disabled scenarios, however not all DXE
> drivers linking PiDxeS3BootScriptLib can return error to
> invoke library DESTRUCTOR for releasing resource.
> 
> To support this usage model below PCD is used to skip
> S3BootScript functions when PCD set to FALSE:
>   gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable
> 
> Test: Verified on internal platform and S3BootScript
>       functions can be skipped by PCD during boot time.
> 
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
> ---
>  MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c       | 17 ++++++++++++++++-
>  MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf |  4 ++--
>  2 files changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
> index c116727531..9106e7d0f9 100644
> --- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
> +++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
> @@ -1,7 +1,7 @@
>  /** @file
>    Save the S3 data to S3 boot script.
>  
> -  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
>  
>    SPDX-License-Identifier: BSD-2-Clause-Patent
>  
> @@ -124,6 +124,7 @@ VOID                             *mRegistrationSmmReadyToLock = NULL;
>  BOOLEAN                          mS3BootScriptTableAllocated = FALSE;
>  BOOLEAN                          mS3BootScriptTableSmmAllocated = FALSE;
>  EFI_SMM_SYSTEM_TABLE2            *mBootScriptSmst = NULL;
> +BOOLEAN                          mAcpiS3Enable = TRUE;
>  
>  /**
>    This is an internal function to add a terminate node the entry, recalculate the table
> @@ -436,6 +437,12 @@ S3BootScriptLibInitialize (
>    BOOLEAN                        InSmm;
>    EFI_PHYSICAL_ADDRESS           Buffer;
>  
> +  if (!PcdGetBool (PcdAcpiS3Enable)) {
> +    mAcpiS3Enable = FALSE;
> +    DEBUG ((DEBUG_INFO, "%a: Skip S3BootScript because ACPI S3 disabled.\n", gEfiCallerBaseName));
> +    return RETURN_SUCCESS;
> +  }
> +
>    S3TablePtr = (SCRIPT_TABLE_PRIVATE_DATA*)(UINTN)PcdGet64(PcdS3BootScriptTablePrivateDataPtr);
>    //
>    // The Boot script private data is not be initialized. create it
> @@ -562,6 +569,10 @@ S3BootScriptLibDeinitialize (
>  {
>    EFI_STATUS                Status;
>  
> +  if (!mAcpiS3Enable) {
> +    return RETURN_SUCCESS;
> +  }
> +
>    DEBUG ((EFI_D_INFO, "%a() in %a module\n", __FUNCTION__, gEfiCallerBaseName));
>  
>    if (mEventDxeSmmReadyToLock != NULL) {
> @@ -810,6 +821,10 @@ S3BootScriptGetEntryAddAddress (
>  {
>    UINT8*                         NewEntryPtr;
>  
> +  if (!mAcpiS3Enable) {
> +    return NULL;
> +  }
> +
>    if (mS3BootScriptTablePtr->SmmLocked) {
>      //
>      // We need check InSmm, because after SmmReadyToLock, only SMM driver is allowed to write boot script.
> diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf b/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
> index 517ea69568..2b894c99da 100644
> --- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
> +++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
> @@ -1,7 +1,7 @@
>  ## @file
>  # DXE S3 boot script Library.
>  #
> -# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
> +# Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
>  #
>  # SPDX-License-Identifier: BSD-2-Clause-Patent
>  #
> @@ -65,4 +65,4 @@
>    ## SOMETIMES_PRODUCES
>    gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptTablePrivateSmmDataPtr
>    gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptRuntimeTableReservePageNumber   ## CONSUMES
> -
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable                                ## CONSUMES
> 

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

Thanks!
Laszlo

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

* Re: [edk2-devel] [PATCH v3] MdeModulePkg: Enable/Disable S3BootScript dynamically.
       [not found] <15C83C366689EC81.3061@groups.io>
@ 2019-10-01  0:19 ` Chiu, Chasel
  0 siblings, 0 replies; 5+ messages in thread
From: Chiu, Chasel @ 2019-10-01  0:19 UTC (permalink / raw)
  To: devel@edk2.groups.io
  Cc: Wu, Hao A, Dong, Eric, Desimone, Nathaniel L, Gao, Liming,
	Laszlo Ersek, Chiu, Chasel


Change pushed: ed9db1b91ceba7d3a24743d4d9314c6fbe11c4b3

Thanks!
Chasel


> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Chiu,
> Chasel
> Sent: Friday, September 27, 2019 3:51 PM
> To: devel@edk2.groups.io
> Cc: Wu, Hao A <hao.a.wu@intel.com>; Dong, Eric <eric.dong@intel.com>;
> Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Gao, Liming
> <liming.gao@intel.com>; Laszlo Ersek <lersek@redhat.com>
> Subject: [edk2-devel] [PATCH v3] MdeModulePkg: Enable/Disable
> S3BootScript dynamically.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2212
> 
> In binary model the same binary may have to support both
> S3 enabled and disabled scenarios, however not all DXE drivers linking
> PiDxeS3BootScriptLib can return error to invoke library DESTRUCTOR for
> releasing resource.
> 
> To support this usage model below PCD is used to skip S3BootScript
> functions when PCD set to FALSE:
>   gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable
> 
> Test: Verified on internal platform and S3BootScript
>       functions can be skipped by PCD during boot time.
> 
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
> ---
>  MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c       | 17
> ++++++++++++++++-
>  MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf |  4
> ++--
>  2 files changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
> b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
> index c116727531..9106e7d0f9 100644
> --- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
> +++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
> @@ -1,7 +1,7 @@
>  /** @file
>    Save the S3 data to S3 boot script.
> 
> -  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) 2006 - 2019, Intel Corporation. All rights
> + reserved.<BR>
> 
>    SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -124,6 +124,7 @@ VOID
> *mRegistrationSmmReadyToLock = NULL;
>  BOOLEAN                          mS3BootScriptTableAllocated =
> FALSE;
>  BOOLEAN                          mS3BootScriptTableSmmAllocated
> = FALSE;
>  EFI_SMM_SYSTEM_TABLE2            *mBootScriptSmst = NULL;
> +BOOLEAN                          mAcpiS3Enable = TRUE;
> 
>  /**
>    This is an internal function to add a terminate node the entry, recalculate
> the table @@ -436,6 +437,12 @@ S3BootScriptLibInitialize (
>    BOOLEAN                        InSmm;
>    EFI_PHYSICAL_ADDRESS           Buffer;
> 
> +  if (!PcdGetBool (PcdAcpiS3Enable)) {
> +    mAcpiS3Enable = FALSE;
> +    DEBUG ((DEBUG_INFO, "%a: Skip S3BootScript because ACPI S3
> disabled.\n", gEfiCallerBaseName));
> +    return RETURN_SUCCESS;
> +  }
> +
>    S3TablePtr =
> (SCRIPT_TABLE_PRIVATE_DATA*)(UINTN)PcdGet64(PcdS3BootScriptTablePrivat
> eDataPtr);
>    //
>    // The Boot script private data is not be initialized. create it @@ -562,6
> +569,10 @@ S3BootScriptLibDeinitialize (  {
>    EFI_STATUS                Status;
> 
> +  if (!mAcpiS3Enable) {
> +    return RETURN_SUCCESS;
> +  }
> +
>    DEBUG ((EFI_D_INFO, "%a() in %a module\n", __FUNCTION__,
> gEfiCallerBaseName));
> 
>    if (mEventDxeSmmReadyToLock != NULL) { @@ -810,6 +821,10 @@
> S3BootScriptGetEntryAddAddress (  {
>    UINT8*                         NewEntryPtr;
> 
> +  if (!mAcpiS3Enable) {
> +    return NULL;
> +  }
> +
>    if (mS3BootScriptTablePtr->SmmLocked) {
>      //
>      // We need check InSmm, because after SmmReadyToLock, only SMM
> driver is allowed to write boot script.
> diff --git
> a/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
> b/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
> index 517ea69568..2b894c99da 100644
> --- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
> +++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
> @@ -1,7 +1,7 @@
>  ## @file
>  # DXE S3 boot script Library.
>  #
> -# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
> +# Copyright (c) 2006 - 2019, Intel Corporation. All rights
> +reserved.<BR>
>  #
>  # SPDX-License-Identifier: BSD-2-Clause-Patent  # @@ -65,4 +65,4 @@
>    ## SOMETIMES_PRODUCES
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptTablePrivateSmmDataPtr
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptRuntimeTableReservePa
> geNumber   ## CONSUMES
> -
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable
> ## CONSUMES
> --
> 2.13.3.windows.1
> 
> 
> 


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

end of thread, other threads:[~2019-10-01  0:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-27  7:51 [PATCH v3] MdeModulePkg: Enable/Disable S3BootScript dynamically Chiu, Chasel
2019-09-29 18:40 ` [edk2-devel] " Nate DeSimone
2019-09-30  0:44 ` Dong, Eric
2019-09-30 23:09 ` Laszlo Ersek
     [not found] <15C83C366689EC81.3061@groups.io>
2019-10-01  0:19 ` [edk2-devel] " Chiu, Chasel

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