From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: nathaniel.l.desimone@intel.com) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by groups.io with SMTP; Sun, 29 Sep 2019 11:40:26 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Sep 2019 11:40:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,563,1559545200"; d="scan'208";a="190049902" Received: from orsmsx101.amr.corp.intel.com ([10.22.225.128]) by fmsmga008.fm.intel.com with ESMTP; 29 Sep 2019 11:40:26 -0700 Received: from orsmsx155.amr.corp.intel.com (10.22.240.21) by ORSMSX101.amr.corp.intel.com (10.22.225.128) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 29 Sep 2019 11:40:26 -0700 Received: from orsmsx114.amr.corp.intel.com ([169.254.8.55]) by ORSMSX155.amr.corp.intel.com ([169.254.7.185]) with mapi id 14.03.0439.000; Sun, 29 Sep 2019 11:40:25 -0700 From: "Nate DeSimone" To: "devel@edk2.groups.io" , "Chiu, Chasel" CC: "Wu, Hao A" , "Dong, Eric" , "Gao, Liming" , Laszlo Ersek Subject: Re: [edk2-devel] [PATCH v3] MdeModulePkg: Enable/Disable S3BootScript dynamically. Thread-Topic: [edk2-devel] [PATCH v3] MdeModulePkg: Enable/Disable S3BootScript dynamically. Thread-Index: AQHVdQhZANe8znUECEypbFtH1RnEI6dDAHNg Date: Sun, 29 Sep 2019 18:40:25 +0000 Message-ID: <02A34F284D1DA44BB705E61F7180EF0AAEF20CD7@ORSMSX114.amr.corp.intel.com> References: <20190927075106.1060-1-chasel.chiu@intel.com> In-Reply-To: <20190927075106.1060-1-chasel.chiu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNDExYjIxMjUtNmFhNi00NmE3LTgzYWQtMmUwYmJmZjc3NWY5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiR2NyNnp3aVwvUk1IU1YycFR4UktkOHpaMTZXTnpqU1NCbFlKY0FlSUZCM0ZEZjd5Q0U5Vjk3NnMyejhpc3BkcnIifQ== x-ctpclassification: CTP_NT x-originating-ip: [10.22.254.139] MIME-Version: 1.0 Return-Path: nathaniel.l.desimone@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Nate DeSimone -----Original Message----- From: devel@edk2.groups.io On Behalf Of Chiu, Chase= l Sent: Friday, September 27, 2019 12:51 AM To: devel@edk2.groups.io Cc: Wu, Hao A ; Dong, Eric ; Desi= mone, Nathaniel L ; Gao, Liming ; Laszlo Ersek Subject: [edk2-devel] [PATCH v3] MdeModulePkg: Enable/Disable S3BootScript= dynamically. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2212 In binary model the same binary may have to support both S3 enabled and disabled scenarios, however not all DXE drivers linking PiD= xeS3BootScriptLib can return error to invoke library DESTRUCTOR for releasi= ng resource. To support this usage model below PCD is used to skip S3BootScript functio= ns 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 Cc: Laszlo Ersek Signed-off-by: Chasel Chiu --- 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. =20 - Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2019, Intel Corporation. All rights=20 + reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -124,6 +124,7 @@ VOID *mRegistrationSmmRead= yToLock =3D NULL; BOOLEAN mS3BootScriptTableAllocated =3D FALSE; BOOLEAN mS3BootScriptTableSmmAllocated =3D FALSE= ; EFI_SMM_SYSTEM_TABLE2 *mBootScriptSmst =3D NULL; +BOOLEAN mAcpiS3Enable =3D TRUE; =20 /** This is an internal function to add a terminate node the entry, recalcu= late the table @@ -436,6 +437,12 @@ S3BootScriptLibInitialize ( BOOLEAN InSmm; EFI_PHYSICAL_ADDRESS Buffer; =20 + if (!PcdGetBool (PcdAcpiS3Enable)) { + mAcpiS3Enable =3D FALSE; + DEBUG ((DEBUG_INFO, "%a: Skip S3BootScript because ACPI S3 disabled.\= n", gEfiCallerBaseName)); + return RETURN_SUCCESS; + } + S3TablePtr =3D (SCRIPT_TABLE_PRIVATE_DATA*)(UINTN)PcdGet64(PcdS3BootScr= iptTablePrivateDataPtr); // // The Boot script private data is not be initialized. create it @@ -56= 2,6 +569,10 @@ S3BootScriptLibDeinitialize ( { EFI_STATUS Status; =20 + if (!mAcpiS3Enable) { + return RETURN_SUCCESS; + } + DEBUG ((EFI_D_INFO, "%a() in %a module\n", __FUNCTION__, gEfiCallerBase= Name)); =20 if (mEventDxeSmmReadyToLock !=3D NULL) { @@ -810,6 +821,10 @@ S3BootScr= iptGetEntryAddAddress ( { UINT8* NewEntryPtr; =20 + 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.
+# Copyright (c) 2006 - 2019, Intel Corporation. All rights=20 +reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -65,4 +65,4 @@ ## SOMETIMES_PRODUCES gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptTablePrivateSmmDataPtr gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptRuntimeTableReservePageNu= mber ## CONSUMES - + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable = ## CONSUMES -- 2.13.3.windows.1