From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id B2620740052 for ; Fri, 17 May 2024 09:46:54 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=D15rCWTT5ca42aCAWkukeTus4xxGlqIvGbLgZ+XVyy4=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1715939213; v=1; b=AEhqd6XxTPyRNWnRTFoHySYqUnI7B2KuQwgkxIkDJ0Z7IZtForDQunfhlu2w7Lr7L4cYXBuh crM9Qdr+e6zcwSZWlsBDf+jR8dNoKo2bC4RMw/5S9y2LD1slYLg2x8Z/v5+/nt3JDanzgWjGCxS SP82XBmt2mY0VtY5Pb/kemKfPAW5yr23Ll7d8P4ayeG45Enyhsc58/FqwmSqb/wGMAUwnWh5Cx1 sujPpKz/dyJ1ESjhpX9+RoEHMKHkGgQVaR45CAm+zhZ9gZDs+9c/I4n1Fn4d2DMFkgjQleahVK9 Qd21NlACTJwyTAz+zHfZp/2WTK9DB26d4qJWQk8ml7dqA== X-Received: by 127.0.0.2 with SMTP id 42KAYY7687511x1YHKyNbbqG; Fri, 17 May 2024 02:46:53 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) by mx.groups.io with SMTP id smtpd.web10.35981.1715939207425420009 for ; Fri, 17 May 2024 02:46:47 -0700 X-CSE-ConnectionGUID: ttojdQFQQuC02g+U2JbUPw== X-CSE-MsgGUID: cRyowPERRfy5e3JoMd6/Og== X-IronPort-AV: E=McAfee;i="6600,9927,11074"; a="12318747" X-IronPort-AV: E=Sophos;i="6.08,167,1712646000"; d="scan'208";a="12318747" X-Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2024 02:46:47 -0700 X-CSE-ConnectionGUID: Li3g0d3TTS2TVvMlBRPb7w== X-CSE-MsgGUID: AMFOy409Rne/KMGed2aKcA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,167,1712646000"; d="scan'208";a="36646787" X-Received: from unknown (HELO shwdeopenlab702.ccr.corp.intel.com) ([10.239.55.43]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2024 02:46:45 -0700 From: "duntan" To: devel@edk2.groups.io Cc: Ray Ni , Rahul Kumar , Gerd Hoffmann , Jiaxin Wu Subject: [edk2-devel] [Patch V2 05/18] UefiCpuPkg: LoadMtrrData for all cpu in S3Resume Date: Fri, 17 May 2024 17:45:57 +0800 Message-Id: <20240517094610.533-6-dun.tan@intel.com> In-Reply-To: <20240517094610.533-1-dun.tan@intel.com> References: <20240517094610.533-1-dun.tan@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Fri, 17 May 2024 02:46:47 -0700 Resent-From: dun.tan@intel.com Reply-To: devel@edk2.groups.io,dun.tan@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 5WoGvhAXG4G6tQM1yuV7fjknx7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=AEhqd6Xx; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io In this commit, S3Resume.c wakeup all Aps to run LoadMtrrData for all cpu before transfer to CpuS3.c in smm cpu driver. The MtrrSetting table can be restored by gEdkiiS3MtrrSettingGuid which is saved by lockbox in PEI phase. This can avoid waking up APs in CpuS3.c. Signed-off-by: Dun Tan Reviewed-by: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann Cc: Jiaxin Wu --- UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf | 4 +++- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c index 4cf676fb3e..078ae2d72d 100644 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c @@ -4,7 +4,7 @@ This module will execute the boot script saved during last boot and after that, control is passed to OS waking up handler. - Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2024, Intel Corporation. All rights reserved.
Copyright (c) 2017, AMD Incorporated. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -938,6 +939,20 @@ S3ResumeExecuteBootScript ( CpuDeadLoop (); } +/** + Sync up the MTRR values for all processors. + + @param[in] MtrrTable Address of MTRR setting. +**/ +VOID +EFIAPI +LoadMtrrData ( + IN VOID *MtrrTable + ) +{ + MtrrSetAllMtrrs (MtrrTable); +} + /** Restores the platform to its preboot configuration for an S3 resume and jumps to the OS waking vector. @@ -990,6 +1005,7 @@ S3RestoreConfig2 ( BOOLEAN InterruptStatus; IA32_CR0 Cr0; EDKII_PEI_MP_SERVICES2_PPI *MpService2Ppi; + MTRR_SETTINGS MtrrTable; TempAcpiS3Context = 0; TempEfiBootScriptExecutorVariable = 0; @@ -1082,6 +1098,39 @@ S3RestoreConfig2 ( Status = SmmAccess->Open ((EFI_PEI_SERVICES **)GetPeiServicesTablePointer (), SmmAccess, Index); } + // + // Get MP Services2 Ppi to pass it to Smm S3. + // + Status = PeiServicesLocatePpi ( + &gEdkiiPeiMpServices2PpiGuid, + 0, + NULL, + (VOID **)&MpService2Ppi + ); + ASSERT_EFI_ERROR (Status); + + // + // Restore MTRR setting + // + VarSize = sizeof (MTRR_SETTINGS); + Status = RestoreLockBox ( + &gEdkiiS3MtrrSettingGuid, + &MtrrTable, + &VarSize + ); + ASSERT_EFI_ERROR (Status); + + // + // Sync up the MTRR values for all processors. + // + Status = MpService2Ppi->StartupAllCPUs ( + MpService2Ppi, + (EFI_AP_PROCEDURE)LoadMtrrData, + 0, + (VOID *)&MtrrTable + ); + ASSERT_EFI_ERROR (Status); + SmramDescriptor = (EFI_SMRAM_DESCRIPTOR *)GET_GUID_HOB_DATA (GuidHob); SmmS3ResumeState = (SMM_S3_RESUME_STATE *)(UINTN)SmramDescriptor->CpuStart; diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf index 9c9b6f3db3..54de8bc91f 100644 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf @@ -5,7 +5,7 @@ # This module will excute the boot script saved during last boot and after that, # control is passed to OS waking up handler. # -# Copyright (c) 2010 - 2023, Intel Corporation. All rights reserved.
+# Copyright (c) 2010 - 2024, Intel Corporation. All rights reserved.
# Copyright (c) 2017, AMD Incorporated. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent @@ -67,6 +67,7 @@ LocalApicLib ReportStatusCodeLib LockBoxLib + MtrrLib [Guids] gEfiBootScriptExecutorVariableGuid ## SOMETIMES_CONSUMES ## UNDEFINED # LockBox @@ -79,6 +80,7 @@ ## SOMETIMES_PRODUCES ## UNDEFINED # Install PPI ## SOMETIMES_CONSUMES ## UNDEFINED # Used to do smm communication gEdkiiS3SmmInitDoneGuid + gEdkiiS3MtrrSettingGuid [Ppis] gEfiPeiS3Resume2PpiGuid ## PRODUCES -- 2.31.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#119002): https://edk2.groups.io/g/devel/message/119002 Mute This Topic: https://groups.io/mt/106150763/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-