From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id B0E6F940EAC for ; Mon, 21 Aug 2023 02:10:23 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=vatFTUWuGu9SDm+6gk2EdAARWJC9Z9DDR6jR2Ac1SUg=; 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:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1692583822; v=1; b=QJvrWgUCw4H1dF2mEPSsJh7izORTv3KGant7oIHAk8Hv+BqcxsojfR5uSxE0qGxBFCXWCQPG atLEyFOnUAA4HgR5vFoK2vbRNkUN8NU5Cj1yNCKtR3/uPgDgT3v1aAUrGOv09F1kZFQzmgAXYQA H+/4TWNSIFxCeufdLKYkL2mY= X-Received: by 127.0.0.2 with SMTP id A16AYY7687511xGX2nC43qI1; Sun, 20 Aug 2023 19:10:22 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web11.2423.1692583821454948026 for ; Sun, 20 Aug 2023 19:10:21 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10808"; a="377212592" X-IronPort-AV: E=Sophos;i="6.01,189,1684825200"; d="scan'208";a="377212592" X-Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2023 19:10:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10808"; a="909521932" X-IronPort-AV: E=Sophos;i="6.01,189,1684825200"; d="scan'208";a="909521932" X-Received: from shwdeppedeas070.ccr.corp.intel.com (HELO shwdeopenlab702.ccr.corp.intel.com) ([10.239.55.158]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2023 19:10:19 -0700 From: "duntan" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar Subject: [edk2-devel] [Patch V2 5/5] UefiCpuPkg/PiSmmCpuDxe: use MpService2Ppi to wakeup AP in s3 Date: Mon, 21 Aug 2023 10:09:47 +0800 Message-Id: <20230821020947.346-6-dun.tan@intel.com> In-Reply-To: <20230821020947.346-1-dun.tan@intel.com> References: <20230821020947.346-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 Reply-To: devel@edk2.groups.io,dun.tan@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: B19yRNX4NjQeigilVaQctpuTx7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=QJvrWgUC; 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 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Use MpService2Ppi to wakeup AP in s3 boot flow during initializing CPU. If mSmmS3ResumeState->MpService2Ppi is not 0, then BSP will use MpService2Ppi->StartupAllCPUs to do CPU initialization for both BSP and AP instead of only sending InitSipiSipi for AP. Signed-off-by: Dun Tan Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Signed-off-by: Dun Tan --- UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 56 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c index a6adf46af7..56b1edff7a 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c @@ -7,6 +7,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include "PiSmmCpuDxeSmm.h" +#include +#include #pragma pack(1) typedef struct { @@ -614,22 +616,25 @@ InitializeCpuAfterRebase ( // package finishing their task. // SetRegister (FALSE); - - while (mNumberToFinish > 0) { - CpuPause (); + if (mSmmS3ResumeState->MpService2Ppi == 0) { + while (mNumberToFinish > 0) { + CpuPause (); + } } } else { DisableLvtInterrupts (); SetRegister (FALSE); - // - // Place AP into the safe code, count down the number with lock mechanism in the safe code. - // - TopOfStack = (UINTN)Stack + sizeof (Stack); - TopOfStack &= ~(UINTN)(CPU_STACK_ALIGNMENT - 1); - CopyMem ((VOID *)(UINTN)mApHltLoopCode, mApHltLoopCodeTemplate, sizeof (mApHltLoopCodeTemplate)); - TransferApToSafeState ((UINTN)mApHltLoopCode, TopOfStack, (UINTN)&mNumberToFinish); + if (mSmmS3ResumeState->MpService2Ppi == 0) { + // + // Place AP into the safe code, count down the number with lock mechanism in the safe code. + // + TopOfStack = (UINTN)Stack + sizeof (Stack); + TopOfStack &= ~(UINTN)(CPU_STACK_ALIGNMENT - 1); + CopyMem ((VOID *)(UINTN)mApHltLoopCode, mApHltLoopCodeTemplate, sizeof (mApHltLoopCodeTemplate)); + TransferApToSafeState ((UINTN)mApHltLoopCode, TopOfStack, (UINTN)&mNumberToFinish); + } } } @@ -789,11 +794,12 @@ SmmRestoreCpu ( VOID ) { - SMM_S3_RESUME_STATE *SmmS3ResumeState; - IA32_DESCRIPTOR Ia32Idtr; - IA32_DESCRIPTOR X64Idtr; - IA32_IDT_GATE_DESCRIPTOR IdtEntryTable[EXCEPTION_VECTOR_NUMBER]; - EFI_STATUS Status; + SMM_S3_RESUME_STATE *SmmS3ResumeState; + IA32_DESCRIPTOR Ia32Idtr; + IA32_DESCRIPTOR X64Idtr; + IA32_IDT_GATE_DESCRIPTOR IdtEntryTable[EXCEPTION_VECTOR_NUMBER]; + EFI_STATUS Status; + EDKII_PEI_MP_SERVICES2_PPI *Mp2ServicePpi; DEBUG ((DEBUG_INFO, "SmmRestoreCpu()\n")); @@ -858,15 +864,21 @@ SmmRestoreCpu ( // mInitApsAfterSmmBaseReloc = FALSE; - PrepareApStartupVector (mAcpiCpuData.StartupVector); - // - // Send INIT IPI - SIPI to all APs - // - SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector); + if (mSmmS3ResumeState->MpService2Ppi != 0) { + Mp2ServicePpi = (EDKII_PEI_MP_SERVICES2_PPI *)(UINTN)mSmmS3ResumeState->MpService2Ppi; + Mp2ServicePpi->StartupAllCPUs (Mp2ServicePpi, (EFI_AP_PROCEDURE)InitializeCpuProcedure, 0, NULL); + } else { + PrepareApStartupVector (mAcpiCpuData.StartupVector); + // + // Send INIT IPI - SIPI to all APs + // + SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector); + InitializeCpuProcedure (NULL); + } + } else { + InitializeCpuProcedure (NULL); } - InitializeCpuProcedure (NULL); - // // Set a flag to restore SMM configuration in S3 path. // -- 2.31.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#107905): https://edk2.groups.io/g/devel/message/107905 Mute This Topic: https://groups.io/mt/100866135/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-