From nobody Wed May 15 22:53:13 2024 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+107901+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+107901+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1692583807; cv=none; d=zohomail.com; s=zohoarc; b=n1QM3/GgcmshhHJCkXsDjCODP6+WlfjxxzE/aCYgrih73s91YrskWBRYLFkagQDIC1kQ3TIyDxie/Q6w/6nBPxOiO+kWAbbHUyzgmXFkkcG7VMzg0RkdwLZ6kLifmowdUXm9cUpXUGf6Omx9sa/OaYFBQrrRI35bAJXA8ZZPcr8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692583807; 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=Qj7HvAvQMWbXq3VY9h/UYUi6FQTNi7kpnoSl7DQCvog=; b=CGMRKocHvjOLVv+buqVOW+vNy3LU/KwXVmmGCujrt34cDmJ96RaD99CNBD3HoX6Qp61jSJIqp22qlas6IVtaQMgRopMkJhxd0N34V8U7zs1QSdrBAJbUHNAwCrs59BjwKhnjClqGUkb8tDmh50yKvjafhxnDfJwiqEfZhWNyKQA= 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+107901+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 1692583807077454.88187177376244; Sun, 20 Aug 2023 19:10:07 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=LgOvw1iL6/rM2w5S8+iTlWGCr/ZsiJ9waOKwXgXbdfI=; 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=1692583806; v=1; b=iNaH3vmTemk+QJY9Wc3Q/7n4LBG1OW3deDCi6BY/hgI0TRhSRplUVvBLZvgKLeaOtSnFLK3g Sp2N5dErkTXyXiP89ZIzeEP4S9vw8co3pYmG+tDfwifEUaNQRL0Daj1j5FWtlqmw8pQWN/a1Svs EQb5gL3mfokGQHgvFx4+SQGM= X-Received: by 127.0.0.2 with SMTP id MJySYY1788612xx8UZiojNGL; Sun, 20 Aug 2023 19:10:06 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web10.2394.1692583803192993573 for ; Sun, 20 Aug 2023 19:10:06 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10808"; a="377212472" X-IronPort-AV: E=Sophos;i="6.01,189,1684825200"; d="scan'208";a="377212472" 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:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10808"; a="909521891" X-IronPort-AV: E=Sophos;i="6.01,189,1684825200"; d="scan'208";a="909521891" 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:04 -0700 From: "duntan" To: devel@edk2.groups.io Cc: Ray Ni , Jian J Wang , Liming Gao Subject: [edk2-devel] [Patch V2 1/5] MdeModulePkg: add MpService2Ppi field in SMM_S3_RESUME_STATE Date: Mon, 21 Aug 2023 10:09:43 +0800 Message-Id: <20230821020947.346-2-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: ie7DPJxAmEpXCW6OjjnlH5wIx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1692583808246100002 Content-Type: text/plain; charset="utf-8" Add MpService2Ppi field in SMM_S3_RESUME_STATE of AcpiS3Context.h. It will be used to wakeup AP to do the CPU initialization during smm s3 boot flow in following patches. With this field, we can avoid sending InitSipiSipi to wakeup AP. Signed-off-by: Dun Tan Cc: Ray Ni Cc: Jian J Wang Cc: Liming Gao --- MdeModulePkg/Include/Guid/AcpiS3Context.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Include/Guid/AcpiS3Context.h b/MdeModulePkg/Inclu= de/Guid/AcpiS3Context.h index 645496d191..72d173c4fd 100644 --- a/MdeModulePkg/Include/Guid/AcpiS3Context.h +++ b/MdeModulePkg/Include/Guid/AcpiS3Context.h @@ -1,7 +1,7 @@ /** @file Definitions for data structures used in S3 resume. =20 -Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2011 - 2023, Intel Corporation. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -30,6 +30,7 @@ typedef struct { EFI_PHYSICAL_ADDRESS ReturnContext1; EFI_PHYSICAL_ADDRESS ReturnContext2; EFI_PHYSICAL_ADDRESS ReturnStackPointer; + EFI_PHYSICAL_ADDRESS MpService2Ppi; EFI_PHYSICAL_ADDRESS Smst; } SMM_S3_RESUME_STATE; =20 --=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 (#107901): https://edk2.groups.io/g/devel/message/107901 Mute This Topic: https://groups.io/mt/100866128/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- From nobody Wed May 15 22:53:13 2024 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+107902+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+107902+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1692583810; cv=none; d=zohomail.com; s=zohoarc; b=WxYxy4jSjodkRP/2tClqkuHEyJViznBqoap4LLGt33k9G+/fepv9kbeejk7t5u86eYyUcGjwnYUrHeHuy3umeBJ/aQuSJt6XasUYZjmFuWfVWXbvY7AHy7WwjE0zkOruafGl00KprZKMlr0eZhYFEC1mgsP33RM5Aspq7qwV/oA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692583810; 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=zx/g1hGnGD4d55UeojOL6SXQ+8iA44uNoVFp7x/L1/8=; b=cEYBMIkMpAAEHXdBVmc7iP4+C4TeqRglkKHVz2aSTKlT54OtBqcSMgY9p+IYkeXSMY52ow1jiKQh4ormuhh+YhkADYeTxSOhh4rNVj2lTCbnDe0rj5CbuM1bWWdEIUzmBkOvyMzVA22fHShCw77arSEhmv60yahXMtQUl3Xzq8o= 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+107902+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 1692583810318724.3789668818602; Sun, 20 Aug 2023 19:10:10 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=FPB1rq9bcx9Z9brU0rlRq02B1ObEBpARW63LowmonD4=; 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=1692583810; v=1; b=EfExa8AlkSrBxoKqesbPBALVPySdkpXbvu24SvBU7haT+qI4nj/4RFvghBiYObwLIjn+eYz7 fDMDSfv9eefKaLKPMO7CMgWAh83QkakPxJqyRQXn0kCmqfr5/r6UziRukdncwmQDnvF4Ih1x/Y5 uo+UVdJHzowXEv45Fc/irGDc= X-Received: by 127.0.0.2 with SMTP id RXcZYY1788612xJkWaLNub0n; Sun, 20 Aug 2023 19:10:10 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web10.2394.1692583803192993573 for ; Sun, 20 Aug 2023 19:10:09 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10808"; a="377212498" X-IronPort-AV: E=Sophos;i="6.01,189,1684825200"; d="scan'208";a="377212498" 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:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10808"; a="909521904" X-IronPort-AV: E=Sophos;i="6.01,189,1684825200"; d="scan'208";a="909521904" 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:07 -0700 From: "duntan" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar Subject: [edk2-devel] [Patch V2 2/5] UefiCpuPkg/S3Resume2Pei: prepare MpService2Ppi in S3Resume Date: Mon, 21 Aug 2023 10:09:44 +0800 Message-Id: <20230821020947.346-3-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: 7uk48nCcfVNUkAPu0roLvudmx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1692583810779100001 Content-Type: text/plain; charset="utf-8" Prepare MpService2Ppi in S3Resume when PEI and SMM env run in the same execution mode. Then smm s3 code can use Mp Service to wakeup AP instead of only sending InitSipiSipi. Signed-off-by: Dun Tan Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Signed-off-by: Dun Tan Reviewed-by: Ray Ni --- UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 18 +++++++++++++= ++++- UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf | 3 ++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg= /Universal/Acpi/S3Resume2Pei/S3Resume.c index 9ea5f6f4e5..1fd5670c7f 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 afte= r that, control is passed to OS waking up handler. =20 - Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.
Copyright (c) 2017, AMD Incorporated. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -23,6 +23,7 @@ #include #include #include +#include =20 #include #include @@ -988,6 +989,7 @@ S3RestoreConfig2 ( BOOLEAN Build4GPageTableOnly; BOOLEAN InterruptStatus; IA32_CR0 Cr0; + EDKII_PEI_MP_SERVICES2_PPI *MpService2Ppi; =20 TempAcpiS3Context =3D 0; TempEfiBootScriptExecutorVariable =3D 0; @@ -1088,6 +1090,7 @@ S3RestoreConfig2 ( SmmS3ResumeState->ReturnContext1 =3D (EFI_PHYSICAL_ADDRESS)(UINTN)= AcpiS3Context; SmmS3ResumeState->ReturnContext2 =3D (EFI_PHYSICAL_ADDRESS)(UINTN)= EfiBootScriptExecutorVariable; SmmS3ResumeState->ReturnStackPointer =3D (EFI_PHYSICAL_ADDRESS)STACK_A= LIGN_DOWN (&Status); + SmmS3ResumeState->MpService2Ppi =3D 0; =20 DEBUG ((DEBUG_INFO, "SMM S3 Signature =3D %x\n", SmmS3R= esumeState->Signature)); DEBUG ((DEBUG_INFO, "SMM S3 Stack Base =3D %x\n", SmmS3R= esumeState->SmmS3StackBase)); @@ -1109,6 +1112,19 @@ S3RestoreConfig2 ( if (((SmmS3ResumeState->Signature =3D=3D SMM_S3_RESUME_SMM_32) && (siz= eof (UINTN) =3D=3D sizeof (UINT32))) || ((SmmS3ResumeState->Signature =3D=3D SMM_S3_RESUME_SMM_64) && (siz= eof (UINTN) =3D=3D sizeof (UINT64)))) { + // + // Get MP Services2 Ppi to pass it to Smm S3. + // + Status =3D PeiServicesLocatePpi ( + &gEdkiiPeiMpServices2PpiGuid, + 0, + NULL, + (VOID **)&MpService2Ppi + ); + ASSERT_EFI_ERROR (Status); + SmmS3ResumeState->MpService2Ppi =3D (EFI_PHYSICAL_ADDRESS)(UINTN)MpS= ervice2Ppi; + DEBUG ((DEBUG_INFO, "SMM S3 MpService2Ppi Point =3D %lx\n", SmmS3Res= umeState->MpService2Ppi)); + SwitchStack ( (SWITCH_STACK_ENTRY_POINT)(UINTN)SmmS3ResumeState->SmmS3ResumeEntr= yPoint, (VOID *)AcpiS3Context, diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf b/Uefi= CpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf index aae984d138..9c9b6f3db3 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 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2010 - 2023, Intel Corporation. All rights reserved.
# Copyright (c) 2017, AMD Incorporated. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent @@ -86,6 +86,7 @@ gPeiPostScriptTablePpiGuid ## SOMETIMES_PRODUCES gEfiEndOfPeiSignalPpiGuid ## SOMETIMES_PRODUCES gEfiPeiSmmCommunicationPpiGuid ## SOMETIMES_CONSUMES + gEdkiiPeiMpServices2PpiGuid ## SOMETIMES_CONSUMES =20 [FeaturePcd] gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode ## CONS= UMES --=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 (#107902): https://edk2.groups.io/g/devel/message/107902 Mute This Topic: https://groups.io/mt/100866130/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- From nobody Wed May 15 22:53:13 2024 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+107903+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+107903+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1692583813; cv=none; d=zohomail.com; s=zohoarc; b=VEoawsxMZS6AMWaN8KB/oL44ydbqPHF0mT0U0eXN5o9RjxYNoft+wlBSVoidpRHiQRDme4b9FPTHPmcLTVLb7JSIR+oTSgXpiqlRn0tvy8DuOHDUbnG2pIEYgw+IyIEpAANTYpRN3pcv+1vTf4dCLbkLCoEbWBT2XEIqooacGKo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692583813; 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=0J4SLyhkdx9qmdu1td84rJlKQKvz9l4wFcVzkBxSp70=; b=EGgN/4yTl/t1XB1B75v/+WcJOtJYR8VlwmV3Mt3PrKIt4Wn3LjFvtSzs3ez/F1csSgbXhuaEsH5+WWIf52+znIN6fcJdo4QGZ42mVbO5VgtY3JzChCb7ZrMs+NX1XjKMsu5PdZUj7L6PdwuGbo5wBljc6D6lIE74Lt/t04hzBy0= 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+107903+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 169258381325679.67115594807638; Sun, 20 Aug 2023 19:10:13 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=saonGnMXdU8riCyMrW6C86Ptz6UAgt4jyR4+vW5jw20=; 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=1692583812; v=1; b=f8HujhKkvsoax7+8/g58sH9FKXsUABvhrbp2+ScniJ2xHnBmdHxbnuzGhvDtka4wT9oZB/NU fsMt04vvZCd0iRD5S0MRmOUCavQp71fqgTqA908UOs+dCxnMNpUrqtKILkusjaugGPqaHSe7wEh 6gSb+qDxS4ZIzatZF89xpQKw= X-Received: by 127.0.0.2 with SMTP id RKigYY1788612xzn7cPFS9xM; Sun, 20 Aug 2023 19:10:12 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web10.2394.1692583803192993573 for ; Sun, 20 Aug 2023 19:10:12 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10808"; a="377212506" X-IronPort-AV: E=Sophos;i="6.01,189,1684825200"; d="scan'208";a="377212506" 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:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10808"; a="909521908" X-IronPort-AV: E=Sophos;i="6.01,189,1684825200"; d="scan'208";a="909521908" 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:10 -0700 From: "duntan" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar Subject: [edk2-devel] [Patch V2 3/5] UefiCpuPkg/S3Resume2Pei: assert for invalid excution mode combo Date: Mon, 21 Aug 2023 10:09:45 +0800 Message-Id: <20230821020947.346-4-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: 0Y0xfQTv8z1TgNwOchnoor2hx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1692583814094100005 Content-Type: text/plain; charset="utf-8" Add assert for invalid excution mode combination of 64bit PEI + 32bit DXE. Signed-off-by: Dun Tan Cc: Eric Dong Reviewed-by: Ray Ni Cc: Rahul Kumar --- UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg= /Universal/Acpi/S3Resume2Pei/S3Resume.c index 1fd5670c7f..4cf676fb3e 100644 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c @@ -1106,6 +1106,13 @@ S3RestoreConfig2 ( DEBUG ((DEBUG_INFO, "SMM S3 Return Stack Pointer =3D %x\n", SmmS3R= esumeState->ReturnStackPointer)); DEBUG ((DEBUG_INFO, "SMM S3 Smst =3D %x\n", SmmS3R= esumeState->Smst)); =20 + // + // 64bit PEI and 32bit DXE is not a supported combination. + // + if (SmmS3ResumeState->Signature =3D=3D SMM_S3_RESUME_SMM_32) { + ASSERT (sizeof (UINTN) =3D=3D sizeof (UINT32)); + } + // // Directly do the switch stack when PEI and SMM env run in the same e= xecution mode. // --=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 (#107903): https://edk2.groups.io/g/devel/message/107903 Mute This Topic: https://groups.io/mt/100866132/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- From nobody Wed May 15 22:53:14 2024 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+107904+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+107904+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1692583814; cv=none; d=zohomail.com; s=zohoarc; b=VtSYYSeB79hdRLY6NwbY9UzQOWLt/QQZ4nN2qAtEDTfbvXLKE1AhuNSdD7GlmuU97cSyu9tuy03toXwXwzTUG9kw6VdaZ0hs5j+5yO3l76klUpOY49FwLJBy0R0p3DJBUGj5fpYwVwWYveS3If1QJZKBnoXai0candKbEhGzMUU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692583814; 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=R9hVUaElsLa+smfRr4CX7UGPvaLTFjzYOGH9aW4DAqE=; b=gLu8prsgrC47ykxHi+IG39z/mfx3/m1/R3hIXQuFWJa0zYibj6bBy+BS3xJh7RzRg74V15iF9O72Bsw0gFTCHmMTb7w501Np8Yp8cOqMPiwD4mJUAU8WexNjl0h7/75iEgk4Umh1Mu2KEdHLW5/77ZBPnvHOnz9vOvggbP8XRB0= 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+107904+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 1692583814945916.3986924539951; Sun, 20 Aug 2023 19:10:14 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=MI23GYkAKKchZWOZaE0ii+/vLzmCVuTe5c2bRIZHv9Q=; 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=1692583814; v=1; b=wq2nakivuAauV0ftySD6UMbUd3FM2/w2cRN1LoFHExlvVWWwL8d1EoE/8shidshMoQlptOz9 ktuROtCSICehWHI1n0Ic5zo52EPf7dbyf2mnBJ/UQE/pueiHml3CIW2UEVB4xHEuvRdLJd1R0VW mNSY+ORWhORl/AQQ90K1TQwE= X-Received: by 127.0.0.2 with SMTP id Hq5bYY1788612xNsfPjhuBqu; Sun, 20 Aug 2023 19:10:14 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web10.2394.1692583803192993573 for ; Sun, 20 Aug 2023 19:10:14 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10808"; a="377212521" X-IronPort-AV: E=Sophos;i="6.01,189,1684825200"; d="scan'208";a="377212521" 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:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10808"; a="909521917" X-IronPort-AV: E=Sophos;i="6.01,189,1684825200"; d="scan'208";a="909521917" 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:12 -0700 From: "duntan" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar Subject: [edk2-devel] [Patch V2 4/5] UefiCpuPkg/PiSmmCpuDxe: code refinement for CpuS3.c Date: Mon, 21 Aug 2023 10:09:46 +0800 Message-Id: <20230821020947.346-5-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: 9GkkRlYQ9LTJHq9M7A1fVlOkx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1692583816138100009 Content-Type: text/plain; charset="utf-8" This commit is code logic refinement for s3 boot flow in CpuS3.c. It doesn't change any code functionality. This commit implementes InitializeAp and InitializeBsp as a single function since they are doing almost the same thing. Then both BSP and AP will execute the same function InitializeCpuProcedure to do CPU initialization. This can make the code logic easier to understand. Signed-off-by: Dun Tan Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar --- UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 272 ++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++----------------------------------------= ---------------------------------------------------------------------------= ------------- 1 file changed, 144 insertions(+), 128 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c b/UefiCpuPkg/PiSmmCpuDxeSmm/= CpuS3.c index 0f7ee0372d..a6adf46af7 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c @@ -539,44 +539,155 @@ SetRegister ( } =20 /** - AP initialization before then after SMBASE relocation in the S3 boot pat= h. + The function is invoked before SMBASE relocation in S3 path to restores = CPU status. + + The function is invoked before SMBASE relocation in S3 path. It does fir= st time microcode load + and restores MTRRs for both BSP and APs. + + @param IsBsp The CPU this function executes on is BSP or not. + **/ VOID -InitializeAp ( - VOID +InitializeCpuBeforeRebase ( + IN BOOLEAN IsBsp ) { - UINTN TopOfStack; - UINT8 Stack[128]; - LoadMtrrData (mAcpiCpuData.MtrrTable); =20 SetRegister (TRUE); =20 + ProgramVirtualWireMode (); // // Count down the number with lock mechanism. // InterlockedDecrement (&mNumberToFinish); =20 + if (IsBsp) { + // + // Bsp wait here till all AP finish the initialization before rebase + // + while (mNumberToFinish > 0) { + CpuPause (); + } + } else { + // + // AP Wait for BSP to signal SMM Base relocation done. + // + while (!mInitApsAfterSmmBaseReloc) { + CpuPause (); + } + } +} + +/** + The function is invoked after SMBASE relocation in S3 path to restores C= PU status. + + The function is invoked after SMBASE relocation in S3 path. It restores = configuration according to + data saved by normal boot path for both BSP and APs. + + @param IsBsp The CPU this function executes on is BSP or not. + +**/ +VOID +InitializeCpuAfterRebase ( + IN BOOLEAN IsBsp + ) +{ + UINTN TopOfStack; + UINT8 Stack[128]; + + if (IsBsp) { + mNumberToFinish =3D (UINT32)(mNumberOfCpus - 1); + + // + // Signal that SMM base relocation is complete and to continue initial= ization for all APs. + // + mInitApsAfterSmmBaseReloc =3D TRUE; + + // + // Must begin set register after all APs have continue their initializ= ation. + // This is a requirement to support semaphore mechanism in register ta= ble. + // Because if semaphore's dependence type is package type, semaphore w= ill wait + // for all Aps in one package finishing their tasks before set next re= gister + // for all APs. If the Aps not begin its task during BSP doing its tas= k, the + // BSP thread will hang because it is waiting for other Aps in the same + // package finishing their task. + // + SetRegister (FALSE); + + while (mNumberToFinish > 0) { + CpuPause (); + } + } else { + DisableLvtInterrupts (); + + SetRegister (FALSE); + + // + // 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); + } +} + +/** + Cpu initialization procedure. + + @param[in,out] Buffer The pointer to private data buffer. + +**/ +VOID +EFIAPI +InitializeCpuProcedure ( + IN OUT VOID *Buffer + ) +{ + BOOLEAN IsBsp; + + IsBsp =3D (BOOLEAN)(mBspApicId =3D=3D GetApicId ()); + // - // Wait for BSP to signal SMM Base relocation done. + // Skip initialization if mAcpiCpuData is not valid // - while (!mInitApsAfterSmmBaseReloc) { - CpuPause (); + if (mAcpiCpuData.NumberOfCpus > 0) { + // + // First time microcode load and restore MTRRs + // + InitializeCpuBeforeRebase (IsBsp); } =20 - ProgramVirtualWireMode (); - DisableLvtInterrupts (); + if (IsBsp) { + DEBUG ((DEBUG_INFO, "SmmRestoreCpu: mSmmRelocated is %d\n", mSmmReloca= ted)); =20 - SetRegister (FALSE); + // + // Check whether Smm Relocation is done or not. + // If not, will do the SmmBases Relocation here!!! + // + if (!mSmmRelocated) { + // + // Restore SMBASE for BSP and all APs + // + SmmRelocateBases (); + } else { + // + // Issue SMI IPI (All Excluding Self SMM IPI + BSP SMM IPI) to exec= ute first SMI init. + // + ExecuteFirstSmiInit (); + } + } =20 // - // Place AP into the safe code, count down the number with lock mechanis= m in the safe code. + // Skip initialization if mAcpiCpuData is not valid // - 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)&mNumbe= rToFinish); + if (mAcpiCpuData.NumberOfCpus > 0) { + // + // Restore MSRs for BSP and all APs + // + InitializeCpuAfterRebase (IsBsp); + } } =20 /** @@ -627,91 +738,7 @@ PrepareApStartupVector ( mExchangeInfo->BufferStart =3D (UINT32)StartupVe= ctor; mExchangeInfo->Cr3 =3D (UINT32)(AsmReadC= r3 ()); mExchangeInfo->InitializeFloatingPointUnitsAddress =3D (UINTN)Initialize= FloatingPointUnits; -} - -/** - The function is invoked before SMBASE relocation in S3 path to restores = CPU status. - - The function is invoked before SMBASE relocation in S3 path. It does fir= st time microcode load - and restores MTRRs for both BSP and APs. - -**/ -VOID -InitializeCpuBeforeRebase ( - VOID - ) -{ - LoadMtrrData (mAcpiCpuData.MtrrTable); - - SetRegister (TRUE); - - ProgramVirtualWireMode (); - - PrepareApStartupVector (mAcpiCpuData.StartupVector); - - if (FeaturePcdGet (PcdCpuHotPlugSupport)) { - ASSERT (mNumberOfCpus <=3D mAcpiCpuData.NumberOfCpus); - } else { - ASSERT (mNumberOfCpus =3D=3D mAcpiCpuData.NumberOfCpus); - } - - mNumberToFinish =3D (UINT32)(mNumberOfCpus - 1); - mExchangeInfo->ApFunction =3D (VOID *)(UINTN)InitializeAp; - - // - // Execute code for before SmmBaseReloc. Note: This flag is maintained a= cross S3 boots. - // - mInitApsAfterSmmBaseReloc =3D FALSE; - - // - // Send INIT IPI - SIPI to all APs - // - SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector); - - while (mNumberToFinish > 0) { - CpuPause (); - } -} - -/** - The function is invoked after SMBASE relocation in S3 path to restores C= PU status. - - The function is invoked after SMBASE relocation in S3 path. It restores = configuration according to - data saved by normal boot path for both BSP and APs. - -**/ -VOID -InitializeCpuAfterRebase ( - VOID - ) -{ - if (FeaturePcdGet (PcdCpuHotPlugSupport)) { - ASSERT (mNumberOfCpus <=3D mAcpiCpuData.NumberOfCpus); - } else { - ASSERT (mNumberOfCpus =3D=3D mAcpiCpuData.NumberOfCpus); - } - - mNumberToFinish =3D (UINT32)(mNumberOfCpus - 1); - - // - // Signal that SMM base relocation is complete and to continue initializ= ation for all APs. - // - mInitApsAfterSmmBaseReloc =3D TRUE; - - // - // Must begin set register after all APs have continue their initializat= ion. - // This is a requirement to support semaphore mechanism in register tabl= e. - // Because if semaphore's dependence type is package type, semaphore wil= l wait - // for all Aps in one package finishing their tasks before set next regi= ster - // for all APs. If the Aps not begin its task during BSP doing its task,= the - // BSP thread will hang because it is waiting for other Aps in the same - // package finishing their task. - // - SetRegister (FALSE); - - while (mNumberToFinish > 0) { - CpuPause (); - } + mExchangeInfo->ApFunction =3D (VOID *)(UINTN)In= itializeCpuProcedure; } =20 /** @@ -813,44 +840,33 @@ SmmRestoreCpu ( InitializeDebugAgent (DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64, (VOID *)&I= a32Idtr, NULL); } =20 + mBspApicId =3D GetApicId (); // - // Skip initialization if mAcpiCpuData is not valid + // Skip AP initialization if mAcpiCpuData is not valid // if (mAcpiCpuData.NumberOfCpus > 0) { - // - // First time microcode load and restore MTRRs - // - InitializeCpuBeforeRebase (); - } + if (FeaturePcdGet (PcdCpuHotPlugSupport)) { + ASSERT (mNumberOfCpus <=3D mAcpiCpuData.NumberOfCpus); + } else { + ASSERT (mNumberOfCpus =3D=3D mAcpiCpuData.NumberOfCpus); + } =20 - DEBUG ((DEBUG_INFO, "SmmRestoreCpu: mSmmRelocated is %d\n", mSmmRelocate= d)); + mNumberToFinish =3D (UINT32)mNumberOfCpus; =20 - // - // Check whether Smm Relocation is done or not. - // If not, will do the SmmBases Relocation here!!! - // - if (!mSmmRelocated) { // - // Restore SMBASE for BSP and all APs + // Execute code for before SmmBaseReloc. Note: This flag is maintained= across S3 boots. // - SmmRelocateBases (); - } else { - // - // Issue SMI IPI (All Excluding Self SMM IPI + BSP SMM IPI) to execut= e first SMI init. - // - ExecuteFirstSmiInit (); - } + mInitApsAfterSmmBaseReloc =3D FALSE; =20 - // - // Skip initialization if mAcpiCpuData is not valid - // - if (mAcpiCpuData.NumberOfCpus > 0) { + PrepareApStartupVector (mAcpiCpuData.StartupVector); // - // Restore MSRs for BSP and all APs + // Send INIT IPI - SIPI to all APs // - InitializeCpuAfterRebase (); + SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector); } =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 (#107904): https://edk2.groups.io/g/devel/message/107904 Mute This Topic: https://groups.io/mt/100866133/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- From nobody Wed May 15 22:53:14 2024 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-