From nobody Mon Feb 9 00:01:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+107905+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+107905+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1692583822; cv=none; d=zohomail.com; s=zohoarc; b=KfJ5siwIzx2c21iSFW6cwU00T/q+nRAgCHqUrVDVrG+sJq+WVNCYzqNInHGaP8DlMcRSxNhOZADv5UvhjD23fOmpY5Hal2rOkV0tmlSeQWyzpatNZj973/KGLk180eKhy4LhM408TEvAE6CrFBYnBJ1L1QCd7yQIMamMqUfIuQ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692583822; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=MzPTz0H1vdrUBjEYrk6VWPs2sp3ZVxGd5gFmNYdAVsg=; b=XxglChFjfffHgYqXuTCXm0bqB1e7XmY9WHDbJyoEuV1VelVGeRfxfKLvyovGbF6aJ43eNT2qYwEfuiHIuguyXT0vVVED1Uk0KFs4infjD09qqDhUI3t2d4Ltkr0K6c5dXhBR2+EM5l6zIaCtzh0CEsHyALAhK/YDiw072gAqwX0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+107905+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1692583822571722.5098741438957; Sun, 20 Aug 2023 19:10:22 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=xqDHX0HIUZ8nBKMBLv8kd2ijZCB1BG+O86Ts1AsxyNM=; 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=mHPu++TqwnCqdEQmAK2u5xOkO2NQUlXSdTgE1v2I+L6tpRx3SMYit54a0WP3bFTth+XrlwGk jb3tkKBChOdWrYnjBY77W1VdsIFNYkjrLUPgUBZL1qsRUvG5P4ZiBP4A/LC5bSN84KmPWU4H6CU 7GYtP/m3rRoAwnFo/9mAoMSE= X-Received: by 127.0.0.2 with SMTP id K7CaYY1788612xCwP57JObIL; 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: gDh1Kka8jqa6FIINxOyMEfeux1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1692583822928100001 Content-Type: text/plain; charset="utf-8" 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 **/ =20 #include "PiSmmCpuDxeSmm.h" +#include +#include =20 #pragma pack(1) typedef struct { @@ -614,22 +616,25 @@ InitializeCpuAfterRebase ( // package finishing their task. // SetRegister (FALSE); - - while (mNumberToFinish > 0) { - CpuPause (); + if (mSmmS3ResumeState->MpService2Ppi =3D=3D 0) { + while (mNumberToFinish > 0) { + CpuPause (); + } } } else { DisableLvtInterrupts (); =20 SetRegister (FALSE); =20 - // - // Place AP into the safe code, count down the number with lock mechan= ism in the safe code. - // - TopOfStack =3D (UINTN)Stack + sizeof (Stack); - TopOfStack &=3D ~(UINTN)(CPU_STACK_ALIGNMENT - 1); - CopyMem ((VOID *)(UINTN)mApHltLoopCode, mApHltLoopCodeTemplate, sizeof= (mApHltLoopCodeTemplate)); - TransferApToSafeState ((UINTN)mApHltLoopCode, TopOfStack, (UINTN)&mNum= berToFinish); + if (mSmmS3ResumeState->MpService2Ppi =3D=3D 0) { + // + // Place AP into the safe code, count down the number with lock mech= anism in the safe code. + // + TopOfStack =3D (UINTN)Stack + sizeof (Stack); + TopOfStack &=3D ~(UINTN)(CPU_STACK_ALIGNMENT - 1); + CopyMem ((VOID *)(UINTN)mApHltLoopCode, mApHltLoopCodeTemplate, size= of (mApHltLoopCodeTemplate)); + TransferApToSafeState ((UINTN)mApHltLoopCode, TopOfStack, (UINTN)&mN= umberToFinish); + } } } =20 @@ -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; =20 DEBUG ((DEBUG_INFO, "SmmRestoreCpu()\n")); =20 @@ -858,15 +864,21 @@ SmmRestoreCpu ( // mInitApsAfterSmmBaseReloc =3D FALSE; =20 - PrepareApStartupVector (mAcpiCpuData.StartupVector); - // - // Send INIT IPI - SIPI to all APs - // - SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector); + if (mSmmS3ResumeState->MpService2Ppi !=3D 0) { + Mp2ServicePpi =3D (EDKII_PEI_MP_SERVICES2_PPI *)(UINTN)mSmmS3ResumeS= tate->MpService2Ppi; + Mp2ServicePpi->StartupAllCPUs (Mp2ServicePpi, (EFI_AP_PROCEDURE)Init= ializeCpuProcedure, 0, NULL); + } else { + PrepareApStartupVector (mAcpiCpuData.StartupVector); + // + // Send INIT IPI - SIPI to all APs + // + SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector= ); + InitializeCpuProcedure (NULL); + } + } else { + InitializeCpuProcedure (NULL); } =20 - InitializeCpuProcedure (NULL); - // // Set a flag to restore SMM configuration in S3 path. // --=20 2.31.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- 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/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-