From nobody Thu Apr 25 01:06:35 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+101913+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+101913+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1679887044; cv=none; d=zohomail.com; s=zohoarc; b=nVO/WqEl9YhBGnX9ORrzA/k+go3BQfQDy/rIrNVliWAVO0KjxBaQCO7K7+u6D5iGUOvg02r1hc27Xz82KIEGLR7cX4WhT2ovr3n1R5F8STJWi4Iszmb57K3PBGdRPZ2lBqHoXRkkkqCOoZmfb1O3wQv1Eq4f6eUQJ/BTSgqwIVQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679887044; 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=HCPJhnl0MkgWDQfT+84QT77DSwCy47q1YWL58W2aH2M=; b=R/FlQGq0Z4DXJ44ZABAydkYioAHV1CoXEiNHwIxmLGCd+1LepJsl4Tm82aZnOpDVvzT16qN8tkvi+HbCCLTc094GVrBV5EWAR4KYbeK5QmGrr1NDI/YgLCFyG5cwWIv2y1Lgt0zmStlBAzDRIBJehmEI96CPCWr0o1GJ46J3It8= 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+101913+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 1679887044218264.63660033217; Sun, 26 Mar 2023 20:17:24 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id zcapYY1788612xJLYOedbeyC; Sun, 26 Mar 2023 20:17:23 -0700 X-Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web10.26627.1679887040165897366 for ; Sun, 26 Mar 2023 20:17:23 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10661"; a="367910202" X-IronPort-AV: E=Sophos;i="5.98,293,1673942400"; d="scan'208";a="367910202" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Mar 2023 20:17:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10661"; a="747836744" X-IronPort-AV: E=Sophos;i="5.98,293,1673942400"; d="scan'208";a="747836744" X-Received: from xieyuanh-mobl.ccr.corp.intel.com ([10.238.0.208]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Mar 2023 20:17:21 -0700 From: "Yuanhao Xie" To: devel@edk2.groups.io Cc: Guo Dong , Ray Ni , Sean Rhodes , James Lu , Gua Guo Subject: [edk2-devel] [PATCH 1/2] UefiCpuPkg: Add SendStartupIpiAllExcludingSelf Date: Mon, 27 Mar 2023 11:17:10 +0800 Message-Id: <20230327031711.1575-2-yuanhao.xie@intel.com> In-Reply-To: <20230327031711.1575-1-yuanhao.xie@intel.com> References: <20230327031711.1575-1-yuanhao.xie@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,yuanhao.xie@intel.com X-Gm-Message-State: SJfud32LY7CTMqWqTAxO3J6sx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679887043; bh=lnzs5pmFfp21wcOBhXKsmCw5GmpNd+OV/BckMvDm9IM=; h=Cc:Date:From:Reply-To:Subject:To; b=OID4Av9arSq4ua/WsXdg6Bgr/OX+Lnz2HTpYLb+03f8tGl30xwxAnJ3SHBTszBqRF/h LOayucV6KX9S8rIEvphvAxgC1n4yW1mnX8d5L9ZOK2fad+ATWf+DMzTyb/AsMRkNL1MLJ xIgPSk8eF0caJBUHTxnWoqFXISeN9vEcyug= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679887045845100001 Content-Type: text/plain; charset="utf-8" Add new API SendStartupIpiAllExcludingSelf(), and modify SendInitSipiSipiAllExcludingSelf() by let it call the new API. Cc: Guo Dong Cc: Ray Ni Cc: Sean Rhodes Cc: James Lu Cc: Gua Guo Signed-off-by: Yuanhao Xie --- UefiCpuPkg/Include/Library/LocalApicLib.h | 17 +++++++- .../Library/BaseXApicLib/BaseXApicLib.c | 43 +++++++++++++------ .../BaseXApicX2ApicLib/BaseXApicX2ApicLib.c | 43 +++++++++++++------ 3 files changed, 76 insertions(+), 27 deletions(-) diff --git a/UefiCpuPkg/Include/Library/LocalApicLib.h b/UefiCpuPkg/Include= /Library/LocalApicLib.h index b55d88b0f5..d7c2ad3f70 100644 --- a/UefiCpuPkg/Include/Library/LocalApicLib.h +++ b/UefiCpuPkg/Include/Library/LocalApicLib.h @@ -4,7 +4,7 @@ Local APIC library assumes local APIC is enabled. It does not handles cases where local APIC is disabled. =20 - Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2023, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -185,6 +185,21 @@ SendInitIpiAllExcludingSelf ( VOID ); =20 +/** + Send a Start-up IPI to all processors excluding self. + This function returns after the IPI has been accepted by the target proc= essors. + if StartupRoutine >=3D 1M, then ASSERT. + if StartupRoutine is not multiple of 4K, then ASSERT. + @param StartupRoutine Points to a start-up routine which is below 1M p= hysical + address and 4K aligned. +**/ + +VOID +EFIAPI +SendStartupIpiAllExcludingSelf ( + IN UINT32 StartupRoutine + ); + /** Send an INIT-Start-up-Start-up IPI sequence to a specified target proces= sor. =20 diff --git a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c b/UefiCpuPkg/Li= brary/BaseXApicLib/BaseXApicLib.c index 008b8a070b..d56c6275cc 100644 --- a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c +++ b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c @@ -3,7 +3,7 @@ =20 This local APIC library instance supports xAPIC mode only. =20 - Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2023, Intel Corporation. All rights reserved.
Copyright (c) 2017 - 2020, AMD Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -497,6 +497,33 @@ SendInitIpiAllExcludingSelf ( SendIpi (IcrLow.Uint32, 0); } =20 +/** + Send a Start-up IPI to all processors excluding self. + This function returns after the IPI has been accepted by the target proc= essors. + if StartupRoutine >=3D 1M, then ASSERT. + if StartupRoutine is not multiple of 4K, then ASSERT. + @param StartupRoutine Points to a start-up routine which is below 1M p= hysical + address and 4K aligned. +**/ +VOID +EFIAPI +SendStartupIpiAllExcludingSelf ( + IN UINT32 StartupRoutine + ) +{ + LOCAL_APIC_ICR_LOW IcrLow; + + ASSERT (StartupRoutine < 0x100000); + ASSERT ((StartupRoutine & 0xfff) =3D=3D 0); + + IcrLow.Uint32 =3D 0; + IcrLow.Bits.Vector =3D (StartupRoutine >> 12); + IcrLow.Bits.DeliveryMode =3D LOCAL_APIC_DELIVERY_MODE_STARTUP; + IcrLow.Bits.Level =3D 1; + IcrLow.Bits.DestinationShorthand =3D LOCAL_APIC_DESTINATION_SHORTHAND_AL= L_EXCLUDING_SELF; + SendIpi (IcrLow.Uint32, 0); +} + /** Send an INIT-Start-up-Start-up IPI sequence to a specified target proces= sor. =20 @@ -551,22 +578,12 @@ SendInitSipiSipiAllExcludingSelf ( IN UINT32 StartupRoutine ) { - LOCAL_APIC_ICR_LOW IcrLow; - - ASSERT (StartupRoutine < 0x100000); - ASSERT ((StartupRoutine & 0xfff) =3D=3D 0); - SendInitIpiAllExcludingSelf (); MicroSecondDelay (PcdGet32 (PcdCpuInitIpiDelayInMicroSeconds)); - IcrLow.Uint32 =3D 0; - IcrLow.Bits.Vector =3D (StartupRoutine >> 12); - IcrLow.Bits.DeliveryMode =3D LOCAL_APIC_DELIVERY_MODE_STARTUP; - IcrLow.Bits.Level =3D 1; - IcrLow.Bits.DestinationShorthand =3D LOCAL_APIC_DESTINATION_SHORTHAND_AL= L_EXCLUDING_SELF; - SendIpi (IcrLow.Uint32, 0); + SendStartupIpiAllExcludingSelf (StartupRoutine); if (!StandardSignatureIsAuthenticAMD ()) { MicroSecondDelay (200); - SendIpi (IcrLow.Uint32, 0); + SendStartupIpiAllExcludingSelf (StartupRoutine); } } =20 diff --git a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c b/U= efiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c index 0ba0499631..aa4eb11181 100644 --- a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c +++ b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c @@ -4,7 +4,7 @@ This local APIC library instance supports x2APIC capable processors which have xAPIC and x2APIC modes. =20 - Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2010 - 2023, Intel Corporation. All rights reserved.
Copyright (c) 2017 - 2020, AMD Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -736,6 +736,33 @@ SendInitIpiAllExcludingSelf ( SendIpi (IcrLow.Uint32, 0); } =20 +/** + Send a Start-up IPI to all processors excluding self. + This function returns after the IPI has been accepted by the target proc= essors. + if StartupRoutine >=3D 1M, then ASSERT. + if StartupRoutine is not multiple of 4K, then ASSERT. + @param StartupRoutine Points to a start-up routine which is below 1M p= hysical + address and 4K aligned. +**/ +VOID +EFIAPI +SendStartupIpiAllExcludingSelf ( + IN UINT32 StartupRoutine + ) +{ + LOCAL_APIC_ICR_LOW IcrLow; + + ASSERT (StartupRoutine < 0x100000); + ASSERT ((StartupRoutine & 0xfff) =3D=3D 0); + + IcrLow.Uint32 =3D 0; + IcrLow.Bits.Vector =3D (StartupRoutine >> 12); + IcrLow.Bits.DeliveryMode =3D LOCAL_APIC_DELIVERY_MODE_STARTUP; + IcrLow.Bits.Level =3D 1; + IcrLow.Bits.DestinationShorthand =3D LOCAL_APIC_DESTINATION_SHORTHAND_AL= L_EXCLUDING_SELF; + SendIpi (IcrLow.Uint32, 0); +} + /** Send an INIT-Start-up-Start-up IPI sequence to a specified target proces= sor. =20 @@ -790,22 +817,12 @@ SendInitSipiSipiAllExcludingSelf ( IN UINT32 StartupRoutine ) { - LOCAL_APIC_ICR_LOW IcrLow; - - ASSERT (StartupRoutine < 0x100000); - ASSERT ((StartupRoutine & 0xfff) =3D=3D 0); - SendInitIpiAllExcludingSelf (); MicroSecondDelay (PcdGet32 (PcdCpuInitIpiDelayInMicroSeconds)); - IcrLow.Uint32 =3D 0; - IcrLow.Bits.Vector =3D (StartupRoutine >> 12); - IcrLow.Bits.DeliveryMode =3D LOCAL_APIC_DELIVERY_MODE_STARTUP; - IcrLow.Bits.Level =3D 1; - IcrLow.Bits.DestinationShorthand =3D LOCAL_APIC_DESTINATION_SHORTHAND_AL= L_EXCLUDING_SELF; - SendIpi (IcrLow.Uint32, 0); + SendStartupIpiAllExcludingSelf (StartupRoutine); if (!StandardSignatureIsAuthenticAMD ()) { MicroSecondDelay (200); - SendIpi (IcrLow.Uint32, 0); + SendStartupIpiAllExcludingSelf (StartupRoutine); } } =20 --=20 2.36.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 (#101913): https://edk2.groups.io/g/devel/message/101913 Mute This Topic: https://groups.io/mt/97874902/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 Thu Apr 25 01:06:35 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+101914+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+101914+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1679887051; cv=none; d=zohomail.com; s=zohoarc; b=CtjZjp+f3zOvZl6qey9ZzoYiymNEGA6ia5HKX914ws0ppF7vcotXvbc4AZBIyf40RVyS3gDTrJLM5Ydd01zwO2A3RrbAGORHaqBGQ3b2u/uAUOjs/qpTTtk5H//IVDrg0NQ9FpoKSfmtdMH0iNeQ6Y2R8rFn05kKEQGqyO1jwYE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679887051; h=Content-Type: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=NEC713L/tI4y+jX/PBe5z6qMab/UDBYTPCtLaUygQrU=; b=QfKglThItG9RXWRcSEJ6pdKs9PN69vO0pZmVuW8oQg4Rhe9rowoIsU8vuuWb4ILpkc+SsQkTvys+kQ6jRvHDEK2qjjyvEb86/keXxcJ5/Hjv20rtDFpxqHPuwvWx8aCQsK1dy9zW3jCaq+ehrXg24SWnP/H/G+qg++E7W9ioCoA= 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+101914+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 1679887051549447.7567146481914; Sun, 26 Mar 2023 20:17:31 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 5wqAYY1788612xvynvncGhS5; Sun, 26 Mar 2023 20:17:31 -0700 X-Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web11.26668.1679887050505740187 for ; Sun, 26 Mar 2023 20:17:30 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10661"; a="367910223" X-IronPort-AV: E=Sophos;i="5.98,293,1673942400"; d="scan'208";a="367910223" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Mar 2023 20:17:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10661"; a="747836755" X-IronPort-AV: E=Sophos;i="5.98,293,1673942400"; d="scan'208";a="747836755" X-Received: from xieyuanh-mobl.ccr.corp.intel.com ([10.238.0.208]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Mar 2023 20:17:28 -0700 From: "Yuanhao Xie" To: devel@edk2.groups.io Cc: Guo Dong , Ray Ni , Sean Rhodes , James Lu , Gua Guo Subject: [edk2-devel] [PATCH 2/2] UefiCpuPkg: After reset, wake up APs by SIPI. Date: Mon, 27 Mar 2023 11:17:11 +0800 Message-Id: <20230327031711.1575-3-yuanhao.xie@intel.com> In-Reply-To: <20230327031711.1575-1-yuanhao.xie@intel.com> References: <20230327031711.1575-1-yuanhao.xie@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,yuanhao.xie@intel.com X-Gm-Message-State: 4SCuCv4Gtd1NG3fQH6dDNyawx1787277AA= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679887051; bh=nUiZi7Dys44R4qS8i0ZV0lGpE3vA0iIzNLw4eSRTUn0=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=ZZ4mQyEslcADij1lSUWJueAXmy1e0V63QvmL0ecJrdFE7kSOCoia49E8Z7ZbjjbEEUo cdB8vscMcuCpKjk4olzY/u1bOGIbxZvbznYKmNmMQPguQFSzCVbotkM1hKR3/253ITV91 dYnOlgmYJQkA/2sxBQ9tNhMCHMo7V2gWDPs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679887051872100001 Following a power-up or RESET, since all APs are already in the =E2=80=9Cwait-for-SIPI state,=E2=80=9D the BSP can broadcast just a single = SIPI IPI to the APs to wake them up and initialize them. Cc: Guo Dong Cc: Ray Ni Cc: Sean Rhodes Cc: James Lu Cc: Gua Guo Signed-off-by: Yuanhao Xie --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/MpLib.c index e5dc852ed9..a540b3fe3d 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -1233,7 +1233,14 @@ WakeUpAP ( if (CpuMpData->SevSnpIsEnabled && (CpuMpData->InitFlag !=3D ApInitCo= nfig)) { SevSnpCreateAP (CpuMpData, -1); } else { - SendInitSipiSipiAllExcludingSelf ((UINT32)ExchangeInfo->BufferStar= t); + if (CpuMpData->InitFlag =3D=3D ApInitConfig) { + // + // SIPI can be used for the first time wake up after reset to re= duce boot time. + // + SendStartupIpiAllExcludingSelf ((UINT32)ExchangeInfo->BufferStar= t); + } else { + SendInitSipiSipiAllExcludingSelf ((UINT32)ExchangeInfo->BufferSt= art); + } } } =20 --=20 2.36.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 (#101914): https://edk2.groups.io/g/devel/message/101914 Mute This Topic: https://groups.io/mt/97874904/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-