From patchwork Wed Apr 27 19:20:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 66829 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp2366696qge; Wed, 27 Apr 2016 12:20:58 -0700 (PDT) X-Received: by 10.98.81.195 with SMTP id f186mr14543192pfb.30.1461784858557; Wed, 27 Apr 2016 12:20:58 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id k13si6703981pat.240.2016.04.27.12.20.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Apr 2016 12:20:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0103F1A1F28; Wed, 27 Apr 2016 12:20:58 -0700 (PDT) X-Original-To: edk2-devel@ml01.01.org Delivered-To: edk2-devel@ml01.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id DC6841A1F25 for ; Wed, 27 Apr 2016 12:20:56 -0700 (PDT) Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 704FF4DAF8; Wed, 27 Apr 2016 19:20:56 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-113-86.phx2.redhat.com [10.3.113.86]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3RJKqTc023137; Wed, 27 Apr 2016 15:20:54 -0400 From: Laszlo Ersek To: edk2-devel-01 Date: Wed, 27 Apr 2016 21:20:47 +0200 Message-Id: <1461784849-30809-2-git-send-email-lersek@redhat.com> In-Reply-To: <1461784849-30809-1-git-send-email-lersek@redhat.com> References: <1461784849-30809-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Subject: [edk2] [PATCH 1/3] MdeModulePkg: PiDxeS3BootScriptLib: honor PcdAcpiS3Enable X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ruiyu Ni , Jordan Justen , Feng Tian , Jiewen Yao , Star Zeng MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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 --- MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf | 1 + MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c | 4 ++++ 2 files changed, 5 insertions(+) -- 1.8.3.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf b/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf index 6b7540a5eab9..4e0919ea2c79 100644 --- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf +++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf @@ -67,7 +67,8 @@ [Pcd] ## SOMETIMES_PRODUCES gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptTablePrivateDataPtr ## CONSUMES ## SOMETIMES_PRODUCES gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptTablePrivateSmmDataPtr gEfiMdeModulePkgTokenSpaceGuid.PcdS3BootScriptRuntimeTableReservePageNumber ## CONSUMES + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable ## CONSUMES diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c index e7d2a2492e84..d954503f864d 100644 --- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c +++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c @@ -434,12 +434,16 @@ S3BootScriptLibInitialize ( EFI_SMM_BASE2_PROTOCOL *SmmBase2; BOOLEAN InSmm; EFI_SMM_SYSTEM_TABLE2 *Smst; 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 // if (S3TablePtr == 0) { Buffer = SIZE_4GB - 1;