From 058196bbb3451a1a342ca9e8679b3c3218b28538 Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Wed, 27 Apr 2016 19:28:44 +0200 Subject: MdeModulePkg: PiDxeS3BootScriptLib: honor PcdAcpiS3Enable In the edk2 tree, there are currently four drivers that consume PcdAcpiS3Enable: IntelFrameworkModulePkg/Universal/Acpi/AcpiS3SaveDxe/AcpiS3SaveDxe.inf MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.inf From these, AcpiS3SaveDxe is the only one that isn't also a client of the S3BootScriptLib class; all the others (BootScriptExecutorDxe, S3SaveStateDxe, SmmS3SaveState) are clients of the S3BootScriptLib class. In turn, the edk2 tree contains only one non-Null instance of the S3BootScriptLib class: MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf Therefore we can safely state that BootScriptExecutorDxe, S3SaveStateDxe, and SmmS3SaveState are all linked against PiDxeS3BootScriptLib. Now, if PcdAcpiS3Enable is FALSE when either of BootScriptExecutorDxe, SmmS3SaveState, or SmmS3SaveState is dispatched, then the following happens: - The constructor of PiDxeS3BootScriptLib, function S3BootScriptLibInitialize(), registers a protocol installation callback for gEfiDxeSmmReadyToLockProtocolGuid. Namely, the function S3BootScriptEventCallBack(). - The driver immediately exits with EFI_UNSUPPORTED from its entry point function, upon seeing PcdAcpiS3Enable == FALSE. (See commits 800c02fbe2da6, 125e093876414, and d2d38610603f6.) - This leaves a dangling callback pointer in the DXE core. - When Platform BDS installs gEfiDxeSmmReadyToLockProtocolGuid (which is a valid thing to do for locking down SMM, even in the absence of S3 support!), things blow up. Fix this issue by returning immediately from S3BootScriptLibInitialize() if PcdAcpiS3Enable is FALSE -- it is useless to initialize the library instance if the containing driver module exits first thing in its entry point. Cc: Feng Tian Cc: Jiewen Yao Cc: Jordan Justen Cc: Ruiyu Ni Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek Reviewed-by: Jaben Carsey Reviewed-by: Jiewen Yao Reviewed-by: Star Zeng --- MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c | 4 ++++ MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf | 1 + 2 files changed, 5 insertions(+) (limited to 'MdeModulePkg/Library') diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c index e7d2a24..d954503 100644 --- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c +++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c @@ -437,6 +437,10 @@ S3BootScriptLibInitialize ( EFI_PHYSICAL_ADDRESS Buffer; EFI_EVENT Event; + if (!PcdGetBool (PcdAcpiS3Enable)) { + return RETURN_SUCCESS; + } + S3TablePtr = (SCRIPT_TABLE_PRIVATE_DATA*)(UINTN)PcdGet64(PcdS3BootScriptTablePrivateDataPtr); // // The Boot script private data is not be initialized. create it diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf b/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf index 6b7540a..4e0919e 100644 --- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf +++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf @@ -70,4 +70,5 @@ ## SOMETIMES_PRODUCES gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptTablePrivateSmmDataPtr gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptRuntimeTableReservePageNumber ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable ## CONSUMES -- cgit v1.1