From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: chasel.chiu@intel.com) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by groups.io with SMTP; Mon, 23 Sep 2019 22:58:10 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Sep 2019 22:58:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,543,1559545200"; d="scan'208";a="189263751" Received: from cchiu4-mobl1.gar.corp.intel.com ([10.5.215.135]) by fmsmga007.fm.intel.com with ESMTP; 23 Sep 2019 22:58:08 -0700 From: "Chiu, Chasel" To: devel@edk2.groups.io Cc: Hao A Wu , Eric Dong , Nate DeSimone , Liming Gao Subject: [PATCH] MdeModulePkg: Enable/Disable S3BootScript dynamically. Date: Tue, 24 Sep 2019 13:54:16 +0800 Message-Id: <20190924055416.16140-1-chasel.chiu@intel.com> X-Mailer: git-send-email 2.13.3.windows.1 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2212 Current S3BootScriptLib can only support build time opt-out but in binary model the same binary should support both enabling and disabling scenarios. To support this below PCD is expected to be used as DynamicPCD (or DynamicEx) 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 Cc: Eric Dong Cc: Nate DeSimone Cc: Liming Gao Signed-off-by: Chasel Chiu --- MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c | 13 ++++++++++++- MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf | 4 +++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c index c116727531..c5353119f7 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.
+ Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
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,11 @@ S3BootScriptLibInitialize ( BOOLEAN InSmm; EFI_PHYSICAL_ADDRESS Buffer; + if (!PcdGetBool (PcdAcpiS3Enable)) { + mAcpiS3Enable = FALSE; + return RETURN_SUCCESS; + } + S3TablePtr = (SCRIPT_TABLE_PRIVATE_DATA*)(UINTN)PcdGet64(PcdS3BootScriptTablePrivateDataPtr); // // The Boot script private data is not be initialized. create it @@ -810,6 +816,11 @@ S3BootScriptGetEntryAddAddress ( { UINT8* NewEntryPtr; + if (!mAcpiS3Enable) { + DEBUG ((DEBUG_INFO, "Skip S3BootScript because ACPI S3 disabled.\n")); + 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..fa139b03ff 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.
+# Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -65,4 +65,6 @@ ## SOMETIMES_PRODUCES gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptTablePrivateSmmDataPtr gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptRuntimeTableReservePageNumber ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable ## CONSUMES + -- 2.13.3.windows.1