|
|
63d87e |
From 4ef57a1e6b9411e785e00e8874bd5c67235e9134 Mon Sep 17 00:00:00 2001
|
|
|
63d87e |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
63d87e |
Date: Tue, 11 Feb 2020 17:01:59 +0100
|
|
|
63d87e |
Subject: [PATCH 1/2] MdeModulePkg: Enable/Disable S3BootScript dynamically.
|
|
|
63d87e |
MIME-Version: 1.0
|
|
|
63d87e |
Content-Type: text/plain; charset=UTF-8
|
|
|
63d87e |
Content-Transfer-Encoding: 8bit
|
|
|
63d87e |
|
|
|
63d87e |
RH-Author: Laszlo Ersek <lersek@redhat.com>
|
|
|
63d87e |
Message-id: <20200211170200.12389-2-lersek@redhat.com>
|
|
|
63d87e |
Patchwork-id: 93776
|
|
|
63d87e |
O-Subject: [RHEL-8.2.0 edk2 PATCH 1/2] MdeModulePkg: Enable/Disable S3BootScript dynamically.
|
|
|
63d87e |
Bugzilla: 1801274
|
|
|
63d87e |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
63d87e |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
63d87e |
|
|
|
63d87e |
From: Chasel Chiu <chasel.chiu@intel.com>
|
|
|
63d87e |
|
|
|
63d87e |
--v-- RHEL8 note start --v--
|
|
|
63d87e |
|
|
|
63d87e |
This patch is cherry-picked from upstream as a contextual (not semantic /
|
|
|
63d87e |
functional) pre-requisite for the next patch.
|
|
|
63d87e |
|
|
|
63d87e |
Functionally, this patch makes no difference in OVMF, for two reasons:
|
|
|
63d87e |
|
|
|
63d87e |
- Downstream, we don't enable S3 anyway (per QEMU default).
|
|
|
63d87e |
|
|
|
63d87e |
- The S3-related modules that are built into OVMF (S3SaveStateDxe,
|
|
|
63d87e |
BootScriptExecutorDxe) already consider PcdAcpiS3Enable, and exit their
|
|
|
63d87e |
entry point functions with EFI_UNSUPPORTED when the PCD is FALSE. As a
|
|
|
63d87e |
consequence, the DESTRUCTOR function of the PiDxeS3BootScriptLib library
|
|
|
63d87e |
instance (which is linked into those binaries) will undo whatever the
|
|
|
63d87e |
CONSTRUCTOR function did; no resources will be leaked.
|
|
|
63d87e |
|
|
|
63d87e |
https://edk2.groups.io/g/devel/message/47996
|
|
|
63d87e |
http://mid.mail-archive.com/e43e3f56-d2db-7989-b6f1-03e1c810d908@redhat.com
|
|
|
63d87e |
|
|
|
63d87e |
--^-- RHEL8 note end --^--
|
|
|
63d87e |
|
|
|
63d87e |
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2212
|
|
|
63d87e |
|
|
|
63d87e |
In binary model the same binary may have to support both
|
|
|
63d87e |
S3 enabled and disabled scenarios, however not all DXE
|
|
|
63d87e |
drivers linking PiDxeS3BootScriptLib can return error to
|
|
|
63d87e |
invoke library DESTRUCTOR for releasing resource.
|
|
|
63d87e |
|
|
|
63d87e |
To support this usage model below PCD is used to skip
|
|
|
63d87e |
S3BootScript functions when PCD set to FALSE:
|
|
|
63d87e |
gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable
|
|
|
63d87e |
|
|
|
63d87e |
Test: Verified on internal platform and S3BootScript
|
|
|
63d87e |
functions can be skipped by PCD during boot time.
|
|
|
63d87e |
|
|
|
63d87e |
Cc: Hao A Wu <hao.a.wu@intel.com>
|
|
|
63d87e |
Cc: Eric Dong <eric.dong@intel.com>
|
|
|
63d87e |
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
|
|
|
63d87e |
Cc: Liming Gao <liming.gao@intel.com>
|
|
|
63d87e |
Cc: Laszlo Ersek <lersek@redhat.com>
|
|
|
63d87e |
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
|
|
|
63d87e |
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>
|
|
|
63d87e |
Reviewed-by: Eric Dong <eric.dong@intel.com>
|
|
|
63d87e |
Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
63d87e |
(cherry picked from commit ed9db1b91ceba7d3a24743d4d9314c6fbe11c4b3)
|
|
|
63d87e |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
63d87e |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
63d87e |
---
|
|
|
63d87e |
.../Library/PiDxeS3BootScriptLib/BootScriptSave.c | 17 ++++++++++++++++-
|
|
|
63d87e |
.../Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf | 4 ++--
|
|
|
63d87e |
2 files changed, 18 insertions(+), 3 deletions(-)
|
|
|
63d87e |
|
|
|
63d87e |
diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
|
|
|
63d87e |
index c116727..9106e7d 100644
|
|
|
63d87e |
--- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
|
|
|
63d87e |
+++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
|
|
|
63d87e |
@@ -1,7 +1,7 @@
|
|
|
63d87e |
/** @file
|
|
|
63d87e |
Save the S3 data to S3 boot script.
|
|
|
63d87e |
|
|
|
63d87e |
- Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
|
|
|
63d87e |
+ Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
|
|
|
63d87e |
|
|
|
63d87e |
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
|
63d87e |
|
|
|
63d87e |
@@ -124,6 +124,7 @@ VOID *mRegistrationSmmReadyToLock = NULL;
|
|
|
63d87e |
BOOLEAN mS3BootScriptTableAllocated = FALSE;
|
|
|
63d87e |
BOOLEAN mS3BootScriptTableSmmAllocated = FALSE;
|
|
|
63d87e |
EFI_SMM_SYSTEM_TABLE2 *mBootScriptSmst = NULL;
|
|
|
63d87e |
+BOOLEAN mAcpiS3Enable = TRUE;
|
|
|
63d87e |
|
|
|
63d87e |
/**
|
|
|
63d87e |
This is an internal function to add a terminate node the entry, recalculate the table
|
|
|
63d87e |
@@ -436,6 +437,12 @@ S3BootScriptLibInitialize (
|
|
|
63d87e |
BOOLEAN InSmm;
|
|
|
63d87e |
EFI_PHYSICAL_ADDRESS Buffer;
|
|
|
63d87e |
|
|
|
63d87e |
+ if (!PcdGetBool (PcdAcpiS3Enable)) {
|
|
|
63d87e |
+ mAcpiS3Enable = FALSE;
|
|
|
63d87e |
+ DEBUG ((DEBUG_INFO, "%a: Skip S3BootScript because ACPI S3 disabled.\n", gEfiCallerBaseName));
|
|
|
63d87e |
+ return RETURN_SUCCESS;
|
|
|
63d87e |
+ }
|
|
|
63d87e |
+
|
|
|
63d87e |
S3TablePtr = (SCRIPT_TABLE_PRIVATE_DATA*)(UINTN)PcdGet64(PcdS3BootScriptTablePrivateDataPtr);
|
|
|
63d87e |
//
|
|
|
63d87e |
// The Boot script private data is not be initialized. create it
|
|
|
63d87e |
@@ -562,6 +569,10 @@ S3BootScriptLibDeinitialize (
|
|
|
63d87e |
{
|
|
|
63d87e |
EFI_STATUS Status;
|
|
|
63d87e |
|
|
|
63d87e |
+ if (!mAcpiS3Enable) {
|
|
|
63d87e |
+ return RETURN_SUCCESS;
|
|
|
63d87e |
+ }
|
|
|
63d87e |
+
|
|
|
63d87e |
DEBUG ((EFI_D_INFO, "%a() in %a module\n", __FUNCTION__, gEfiCallerBaseName));
|
|
|
63d87e |
|
|
|
63d87e |
if (mEventDxeSmmReadyToLock != NULL) {
|
|
|
63d87e |
@@ -810,6 +821,10 @@ S3BootScriptGetEntryAddAddress (
|
|
|
63d87e |
{
|
|
|
63d87e |
UINT8* NewEntryPtr;
|
|
|
63d87e |
|
|
|
63d87e |
+ if (!mAcpiS3Enable) {
|
|
|
63d87e |
+ return NULL;
|
|
|
63d87e |
+ }
|
|
|
63d87e |
+
|
|
|
63d87e |
if (mS3BootScriptTablePtr->SmmLocked) {
|
|
|
63d87e |
//
|
|
|
63d87e |
// We need check InSmm, because after SmmReadyToLock, only SMM driver is allowed to write boot script.
|
|
|
63d87e |
diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf b/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
|
|
|
63d87e |
index 517ea69..2b894c9 100644
|
|
|
63d87e |
--- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
|
|
|
63d87e |
+++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
|
|
|
63d87e |
@@ -1,7 +1,7 @@
|
|
|
63d87e |
## @file
|
|
|
63d87e |
# DXE S3 boot script Library.
|
|
|
63d87e |
#
|
|
|
63d87e |
-# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
|
|
|
63d87e |
+# Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
|
|
|
63d87e |
#
|
|
|
63d87e |
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
|
63d87e |
#
|
|
|
63d87e |
@@ -65,4 +65,4 @@
|
|
|
63d87e |
## SOMETIMES_PRODUCES
|
|
|
63d87e |
gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptTablePrivateSmmDataPtr
|
|
|
63d87e |
gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptRuntimeTableReservePageNumber ## CONSUMES
|
|
|
63d87e |
-
|
|
|
63d87e |
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable ## CONSUMES
|
|
|
63d87e |
--
|
|
|
63d87e |
1.8.3.1
|
|
|
63d87e |
|