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 1C7C9D802AE for ; Fri, 10 May 2024 10:09:02 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=/UNj6WU0SMRTE3QHMa3aF4sHj4DUoB34reUI/lvop/M=; 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=1715335741; v=1; b=INQBowzuCpkXyRp7VEjKziOM+9BQ1+n69goHPiW49t2EqzhoLvqz0cpoaocK6JAkRT31wGbG F9ZaBwq45udMQPyboHO884CrGwvXmiymzjNuFWRJCIPeijzgcE1qOxdV8dJ+P17uOkrHWuI4VpZ UNsBpMC82aialciVWlPjpoYqu6RmqahiQ2K+CAJUOB4N4sig//XTWpdr5Hr3367eMS1CI0bV/Hm Zm1kVw6nMp1TbLNcJDbbARTWWoi+54eYV6Nl/1hrWzjW0newb74OHcnfTdmfnpKMNG6YkuNc5b1 pbSeruDkvZEi2LLvEM9VMR+MHlEE6lIgtoVcg+8wIEkJA== X-Received: by 127.0.0.2 with SMTP id YvNeYY7687511xzl8cfylgoZ; Fri, 10 May 2024 03:09:01 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) by mx.groups.io with SMTP id smtpd.web10.9485.1715335727366928454 for ; Fri, 10 May 2024 03:09:01 -0700 X-CSE-ConnectionGUID: mJ3UsEs1SBiWP3AaWBIp1Q== X-CSE-MsgGUID: zlrtZosBTG6f/NagIGBPkw== X-IronPort-AV: E=McAfee;i="6600,9927,11068"; a="28819134" X-IronPort-AV: E=Sophos;i="6.08,150,1712646000"; d="scan'208";a="28819134" X-Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2024 03:09:01 -0700 X-CSE-ConnectionGUID: EBfjNZp9R0eArOU5JpAEkQ== X-CSE-MsgGUID: zy+qJ5ONTrGN0ZRLlmb+JA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,150,1712646000"; d="scan'208";a="60424246" X-Received: from unknown (HELO shwdeopenlab702.ccr.corp.intel.com) ([10.239.55.43]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2024 03:09:00 -0700 From: "duntan" To: devel@edk2.groups.io Cc: Ray Ni , Rahul Kumar , Gerd Hoffmann , Jiaxin Wu Subject: [edk2-devel] [PATCH 05/18] UefiCpuPkg: LoadMtrrData for all cpu in S3Resume Date: Fri, 10 May 2024 18:08:14 +0800 Message-Id: <20240510100827.1903-6-dun.tan@intel.com> In-Reply-To: <20240510100827.1903-1-dun.tan@intel.com> References: <20240510100827.1903-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, 10 May 2024 03:09:01 -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: WqXTDHwdE6BHUUB6I1GzULZIx7686176AA= 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=INQBowzu; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none) 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 Cc: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann Cc: Jiaxin Wu --- UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf | 2 ++ 2 files changed, 51 insertions(+) diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c index 4cf676fb3e..3e85eab28f 100644 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c @@ -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..890c588aa8 100644 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf @@ -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 (#118797): https://edk2.groups.io/g/devel/message/118797 Mute This Topic: https://groups.io/mt/106018126/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-