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.43, mailfrom: eric.dong@intel.com) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by groups.io with SMTP; Sun, 29 Sep 2019 17:44:52 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Sep 2019 17:44:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,565,1559545200"; d="scan'208";a="391898970" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga006.fm.intel.com with ESMTP; 29 Sep 2019 17:44:51 -0700 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 29 Sep 2019 17:44:51 -0700 Received: from shsmsx106.ccr.corp.intel.com (10.239.4.159) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 29 Sep 2019 17:44:50 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.176]) by SHSMSX106.ccr.corp.intel.com ([169.254.10.119]) with mapi id 14.03.0439.000; Mon, 30 Sep 2019 08:44:49 +0800 From: "Dong, Eric" To: "devel@edk2.groups.io" , "Chiu, Chasel" CC: "Wu, Hao A" , "Desimone, Nathaniel L" , "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: AQHVdQhcOrVPGjrl/kK5ecfaadJfZqdDZl5Q Date: Mon, 30 Sep 2019 00:44:48 +0000 Message-ID: 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: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: eric.dong@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Eric Dong > -----Original Message----- > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Ch= iu, > Chasel > Sent: Friday, September 27, 2019 3:51 PM > To: devel@edk2.groups.io > Cc: Wu, Hao A ; Dong, Eric ; > Desimone, Nathaniel L ; Gao, Liming > ; Laszlo Ersek > Subject: [edk2-devel] [PATCH v3] MdeModulePkg: Enable/Disable S3BootScri= pt > dynamically. >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2212 >=20 > 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. >=20 > To support this usage model below PCD is used to skip > S3BootScript functions when PCD set to FALSE: > gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable >=20 > Test: Verified on internal platform and S3BootScript > functions can be skipped by PCD during boot time. >=20 > 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(-) >=20 > 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 reserved. >=20 > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @@ -124,6 +124,7 @@ VOID *mRegistrationSmmRe= adyToLock > =3D NULL; > BOOLEAN mS3BootScriptTableAllocated =3D FALSE; > BOOLEAN mS3BootScriptTableSmmAllocated =3D FAL= SE; > EFI_SMM_SYSTEM_TABLE2 *mBootScriptSmst =3D NULL; > +BOOLEAN mAcpiS3Enable =3D TRUE; >=20 > /** > This is an internal function to add a terminate node the entry, recal= culate 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(PcdS3BootScriptTablePriv > ateDataPtr); > // > // The Boot script private data is not be initialized. create it > @@ -562,6 +569,10 @@ S3BootScriptLibDeinitialize ( > { > EFI_STATUS Status; >=20 > + if (!mAcpiS3Enable) { > + return RETURN_SUCCESS; > + } > + > DEBUG ((EFI_D_INFO, "%a() in %a module\n", __FUNCTION__, > gEfiCallerBaseName)); >=20 > if (mEventDxeSmmReadyToLock !=3D NULL) { > @@ -810,6 +821,10 @@ S3BootScriptGetEntryAddAddress ( > { > UINT8* NewEntryPtr; >=20 > + if (!mAcpiS3Enable) { > + return NULL; > + } > + > if (mS3BootScriptTablePtr->SmmLocked) { > // > // We need check InSmm, because after SmmReadyToLock, only SMM driv= er > 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 reserved. > # > # SPDX-License-Identifier: BSD-2-Clause-Patent > # > @@ -65,4 +65,4 @@ > ## SOMETIMES_PRODUCES >=20 > gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptTablePrivateSmmDataPtr >=20 > gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptRuntimeTableReservePag > eNumber ## CONSUMES > - > + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable = ## > CONSUMES > -- > 2.13.3.windows.1 >=20 >=20 >=20