From nobody Thu Apr 25 14:09:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+48206+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+48206+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1569570675; cv=none; d=zoho.com; s=zohoarc; b=MEVhTw2f3wopO8+g677ziDS71Jrn8NGXL4WSfvX+0E+RLCelK3AMYz/ukeSdeSiSp/u/Uq37mZIAgmzqs/x/Vz4tPpMrWzL5lSO1pGPiw8PSSzT9znzHPzZvlUhNaz+nHE5+9Ri9xvdZsWcgZgPms6BHb3GKABgSS4R1LUpwyAg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569570675; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=QThFKXw6i2gA98WdxLmhHrB/ULjVud3r5nuehSSKo3Q=; b=gBFGcGGVugGdIIivPWsFsXKqDy7urOaatML5EAz42p074d7f1N4uRBn0vVxEDvOy99WjSHknYGRXgCY4zbz+JitG0w6TgbGI0/D4UOYNfqj44sP/OldcWPhUq7ql7NxDOLGviq+81fd8ZObfoAiWGbK9nCkdPg4CUpUj4KjIJdk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+48206+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1569570675512983.9543798428558; Fri, 27 Sep 2019 00:51:15 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id SqScYY1788612xdYMS2CokgX; Fri, 27 Sep 2019 00:51:14 -0700 X-Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by groups.io with SMTP; Fri, 27 Sep 2019 00:51:14 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Sep 2019 00:51:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,554,1559545200"; d="scan'208";a="214749154" X-Received: from cchiu4-mobl1.gar.corp.intel.com ([10.5.215.135]) by fmsmga004.fm.intel.com with ESMTP; 27 Sep 2019 00:51:12 -0700 From: "Chiu, Chasel" To: devel@edk2.groups.io Cc: Hao A Wu , Eric Dong , Nate DeSimone , Liming Gao , Laszlo Ersek Subject: [edk2-devel] [PATCH v3] MdeModulePkg: Enable/Disable S3BootScript dynamically. Date: Fri, 27 Sep 2019 15:51:06 +0800 Message-Id: <20190927075106.1060-1-chasel.chiu@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,chasel.chiu@intel.com X-Gm-Message-State: x3aWuqPhC5XfBSq3pWX2cK4ix1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1569570674; bh=S1xRXr1HIshuNX6HeQ4g8UM7ixHSBIpI4+BHasuVdy4=; h=Cc:Date:From:Reply-To:Subject:To; b=eYKJdPlzHoO9jyHlr2snc2ZVWQboqf/WADwJquy4nEwRyZ23vhAGXpWDBJO8H/SdHYV AkaOzxWAmkx7B4rRhQJ9xMOFsDKBUqg4ynKJPYakiCI7BYEYUZ1Tep9bkkPm8GFsY1vrH yhbIgwZhq0Oq+H9MmUDJrdIxuUF7GwcmiB8= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 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 Cc: Eric Dong Cc: Nate DeSimone Cc: Liming Gao Cc: Laszlo Ersek Signed-off-by: Chasel Chiu Acked-by: Laszlo Ersek Reviewed-by: Eric Dong Reviewed-by: Nate DeSimone --- 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/M= deModulePkg/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 *mRegistrationSmmReady= ToLock =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, recalcul= ate 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(PcdS3BootScri= ptTablePrivateDataPtr); // // 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__, gEfiCallerBaseN= ame)); =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 driver = is allowed to write boot script. diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.i= nf 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 gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptTablePrivateSmmDataPtr gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptRuntimeTableReservePageNum= ber ## CONSUMES - + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable = ## CONSUMES --=20 2.13.3.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#48206): https://edk2.groups.io/g/devel/message/48206 Mute This Topic: https://groups.io/mt/34309091/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-