From nobody Fri Apr 26 00:49:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+48723+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+48723+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570707000; cv=none; d=zoho.com; s=zohoarc; b=dLPT4OTe3pBsC3sPSNbcIdCvCfSXTGm3Ca4H5wbLZuOr8tE42eKlarOOaqPa2+w6MFtLUTXum+lU41YisChC6FTz+rLex/bwfmgyAPXgdxbRLS9AcHG5lkIUJioXnaSjmipXKqfMxVO18otli1evYjh5hUkeIpc2E3+9yiuHf8s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570707000; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=Fk4SALRYeW7aBsxhhGE8gf8GyqsEu9FxTuVP8XNXwEI=; b=OMoZVv9Qee6C/x40jY7TLqc3XPtY1QLrmWTNWoOCNwy0MGOTX3GM0RXpW7Kd0DdCBZQeHX/5QKJjCtcXESpQ/zqeroJWNErMXGUXCYUzg+hkEkPjh5ovlN/tHkOl0INnBSVzyEBaUwpD8BJe9FYGCYY+LdoC11fEL4vtwIUQ9gs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+48723+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 157070700004581.22667155101362; Thu, 10 Oct 2019 04:30:00 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id aaaaYY1788612xaaaaaaaaaa; Thu, 10 Oct 2019 04:29:58 -0700 X-Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.groups.io with SMTP id smtpd.web11.4713.1570706998062363550 for ; Thu, 10 Oct 2019 04:29:58 -0700 X-Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BDF3F18CB8E5; Thu, 10 Oct 2019 11:29:57 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-48.rdu2.redhat.com [10.10.120.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA0115D6B2; Thu, 10 Oct 2019 11:29:56 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Eric Dong , Ray Ni Subject: [edk2-devel] [PATCH v2 1/2] UefiCpuPkg/MpInitLib: expand comment on initial AP enumeration Date: Thu, 10 Oct 2019 13:29:51 +0200 Message-Id: <20191010112952.7187-2-lersek@redhat.com> In-Reply-To: <20191010112952.7187-1-lersek@redhat.com> References: <20191010112952.7187-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.63]); Thu, 10 Oct 2019 11:29:57 +0000 (UTC) Precedence: Bulk List-Unsubscribe: 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,lersek@redhat.com X-Gm-Message-State: aaaaaaaaaaaaaaaaaaaaaaaax1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1570706998; bh=UaOAAmq4f8V5IdJ8N1s9vS7Wucrk5DwJjOaSESnJ1pg=; h=Cc:Date:From:Reply-To:Subject:To; b=TYzwVhWb1nAZgrajYVmlWCxDYkU+IWhsEUtYteOZ1T2rrE5ZvM8wN5pVXv6gRkN20+s c4BNDbCVZMBK0X2kjTRm4D6d+YULKV/rmDxGSJaCdMWr+bLLagLtUInddVdwUkFWpz4wz md5LkeR1lYbWxYGOb04a2clo+cwguA4AKPY= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Before adding another AP enumeration mode, clarify the documentation on the current logic. No functional changes. Cc: Eric Dong Cc: Ray Ni Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1515 Signed-off-by: Laszlo Ersek Reviewed-by: Ray Ni --- Notes: v2: - new patch UefiCpuPkg/Library/MpInitLib/MpLib.c | 38 +++++++++++++++----- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/MpLib.c index d6f84c6f45c0..594a035d8b92 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -1045,14 +1045,36 @@ WakeUpAP ( } if (CpuMpData->InitFlag =3D=3D ApInitConfig) { // - // Here support two methods to collect AP count through adjust - // PcdCpuApInitTimeOutInMicroSeconds values. - // - // one way is set a value to just let the first AP to start the - // initialization, then through the later while loop to wait all Aps - // finsh the initialization. - // The other way is set a value to let all APs finished the initialz= ation. - // In this case, the later while loop is useless. + // The AP enumeration algorithm below is suitable for two use cases. + // + // (1) The check-in time for an individual AP is bounded, and APs run + // through their initialization routines strongly concurrently. = In + // particular, the number of concurrently running APs + // ("NumApsExecuting") is never expected to fall to zero + // *temporarily* -- it is expected to fall to zero only when all + // APs have checked-in. + // + // In this case, the platform is supposed to set + // PcdCpuApInitTimeOutInMicroSeconds to a low-ish value (just lo= ng + // enough for one AP to start initialization). The timeout will = be + // reached soon, and remaining APs are collected by watching + // NumApsExecuting fall to zero. If NumApsExecuting falls to zero + // mid-process, while some APs have not completed initialization, + // the behavior is undefined. + // + // (2) The check-in time for an individual AP is unbounded, and/or A= Ps + // may complete their initializations widely spread out. In + // particular, some APs may finish initialization before some APs + // even start. + // + // In this case, the platform is supposed to set + // PcdCpuApInitTimeOutInMicroSeconds to a high-ish value. The AP + // enumeration will always take that long (except when the boot = CPU + // count happens to be maximal, that is, + // PcdCpuMaxLogicalProcessorNumber). All APs are expected to + // check-in before the timeout, and NumApsExecuting is assumed z= ero + // at timeout. APs that miss the time-out may cause undefined + // behavior. // TimedWaitForApFinish ( CpuMpData, --=20 2.19.1.3.g30247aa5d201 -=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 (#48723): https://edk2.groups.io/g/devel/message/48723 Mute This Topic: https://groups.io/mt/34473662/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 Fri Apr 26 00:49:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+48724+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+48724+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570707001; cv=none; d=zoho.com; s=zohoarc; b=ioaxYQFVvcZ6ZoBCvXSf6sWIscIQxidnj9wuS3GG6NoaK5GSewUt85fCjjW0ZR15MvZKPTFuEhiiMRsfi/fyHaFdiIbYjI/wYQWi6u65XHdEIzNNnOJxDix2KzAUeZOL8m2aZOqoG3bHz6xFH2KcDWlNOsK/9R7r66Mpq3rB0QM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570707001; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=5LQ155g4XI8X651Q5QGtqjQ/wHqZR4HcF071DOWSM88=; b=WjeRS2Smie9VF8RoXF3yfe6DNb0QhkdZ11PeUraxrYrczv707mx+cOxjeEt0NjDtJcuqNf2G2ODIg5pQnQmtMSqqo4kpidnhB+Qa6nOJYfOpc1eP14dlnIq3SBjr7tP0J2QMeYFzNi+vMdiWYqhUGsYpSiumQ3DjPONXtuc8Ijk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+48724+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1570707001507989.4808442355733; Thu, 10 Oct 2019 04:30:01 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id aaaaYY1788612xaaaaaaaaaa; Thu, 10 Oct 2019 04:30:00 -0700 X-Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.groups.io with SMTP id smtpd.web10.4641.1570706999510398024 for ; Thu, 10 Oct 2019 04:29:59 -0700 X-Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2A063C05686D; Thu, 10 Oct 2019 11:29:59 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-48.rdu2.redhat.com [10.10.120.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 269325D6A5; Thu, 10 Oct 2019 11:29:57 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Eric Dong , Ray Ni Subject: [edk2-devel] [PATCH v2 2/2] UefiCpuPkg/MpInitLib: honor the platform's boot CPU count in AP detection Date: Thu, 10 Oct 2019 13:29:52 +0200 Message-Id: <20191010112952.7187-3-lersek@redhat.com> In-Reply-To: <20191010112952.7187-1-lersek@redhat.com> References: <20191010112952.7187-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 10 Oct 2019 11:29:59 +0000 (UTC) Precedence: Bulk List-Unsubscribe: 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,lersek@redhat.com X-Gm-Message-State: aaaaaaaaaaaaaaaaaaaaaaaax1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1570707000; bh=P+/A7WxHZnj/OqPr7id82YVF1vqtOwHuCRvh+i1rJGU=; h=Cc:Date:From:Reply-To:Subject:To; b=YdMS1Frq5g1uy8WIdCYM5k24Dte5IUpGMDK9ckEWXwLAEZi1/4TW5vS/g2PvFYuJRoj QBmXoierXMytXf0uWzjT6siABOV3Zm5XBmYj+K/maoAdtC3jwWNqDA9ymUnnjUd0CJg9O h+cNr8FPbD1v/240Zn7B25PsRO86NQC/aDQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" - If a platform boots such that the boot CPU count is smaller than PcdCpuMaxLogicalProcessorNumber, then the platform cannot use the "fast AP detection" logic added in commit 6e1987f19af7. (Which has been documented as a subset of use case (2) in the previous patch.) Said logic depends on the boot CPU count being equal to PcdCpuMaxLogicalProcessorNumber. If the equality does not hold, the platform either has to wait too long, or risk missing APs due to an early timeout. - The platform may not be able to use the variant added in commit 0594ec417c89 either. (Which has been documented as use case (1) in the previous patch.) See commit 861218740d6d. When OVMF runs on QEMU/KVM, APs may check in with the BSP in arbitrary order, plus the individual AP may take arbitrarily long to check-in. If "NumApsExecuting" falls to zero mid-enumeration, APs will be missed. Allow platforms to specify the exact boot CPU count, independently of PcdCpuMaxLogicalProcessorNumber. In this mode, the BSP waits for all APs to check-in regardless of timeout. If at least one AP fails to check-in, then the AP enumeration hangs forever. That is the desired behavior when the exact boot CPU count is known in advance. (A hung boot is better than an AP checking-in after timeout, and executing code from released storage.) Cc: Eric Dong Cc: Ray Ni Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1515 Signed-off-by: Laszlo Ersek Reviewed-by: Ray Ni --- Notes: v2: - update commit message - update docs in DEC file - add code comments - no functional changes UefiCpuPkg/UefiCpuPkg.dec | 13 +++ UefiCpuPkg/UefiCpuPkg.uni | 4 + UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf | 1 + UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf | 3 +- UefiCpuPkg/Library/MpInitLib/MpLib.c | 99 ++++++++++++-------- 5 files changed, 80 insertions(+), 40 deletions(-) diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec index 031a2ccd680a..12f4413ea5b0 100644 --- a/UefiCpuPkg/UefiCpuPkg.dec +++ b/UefiCpuPkg/UefiCpuPkg.dec @@ -227,6 +227,19 @@ [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic,= PcdsDynamicEx] ## Specifies timeout value in microseconds for the BSP to detect all APs= for the first time. # @Prompt Timeout for the BSP to detect all APs for the first time. gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds|50000|UINT32= |0x00000004 + ## Specifies the number of Logical Processors that are available in the + # preboot environment after platform reset, including BSP and APs. Poss= ible + # values:

+ # zero (default) - PcdCpuBootLogicalProcessorNumber is ignored, and + # PcdCpuApInitTimeOutInMicroSeconds limits the initial= AP + # detection by the BSP.
+ # nonzero - PcdCpuApInitTimeOutInMicroSeconds is ignored. The in= itial + # AP detection finishes only when the detected CPU cou= nt + # (BSP plus APs) reaches the value of + # PcdCpuBootLogicalProcessorNumber, regardless of how = long + # that takes.
+ # @Prompt Number of Logical Processors available after platform reset. + gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber|0|UINT32|0x00= 000008 ## Specifies the base address of the first microcode Patch in the microc= ode Region. # @Prompt Microcode Region base address. gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress|0x0|UINT64|0x00000= 005 diff --git a/UefiCpuPkg/UefiCpuPkg.uni b/UefiCpuPkg/UefiCpuPkg.uni index fbf768072668..a7e279c5cb14 100644 --- a/UefiCpuPkg/UefiCpuPkg.uni +++ b/UefiCpuPkg/UefiCpuPkg.uni @@ -37,6 +37,10 @@ =20 #string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApInitTimeOutInMicroSeconds_HE= LP #language en-US "Specifies timeout value in microseconds for the BSP to= detect all APs for the first time." =20 +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuBootLogicalProcessorNumber_PRO= MPT #language en-US "Number of Logical Processors available after platform= reset." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuBootLogicalProcessorNumber_HEL= P #language en-US "Specifies the number of Logical Processors that are ava= ilable in the preboot environment after platform reset, including BSP and A= Ps." + #string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuMicrocodePatchAddress_PROMPT = #language en-US "Microcode Region base address." =20 #string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuMicrocodePatchAddress_HELP #l= anguage en-US "Specifies the base address of the first microcode Patch in t= he microcode Region." diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf b/UefiCpuPkg/Lib= rary/MpInitLib/DxeMpInitLib.inf index 37b3f64e578a..cd912ab0c5ee 100644 --- a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf @@ -61,6 +61,7 @@ [Guids] =20 [Pcd] gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber ## CONS= UMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber ## CONS= UMES gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds ## SOME= TIMES_CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize ## CONS= UMES gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress ## CONS= UMES diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf b/UefiCpuPkg/Lib= rary/MpInitLib/PeiMpInitLib.inf index 82b77b63ea87..1538185ef99a 100644 --- a/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf +++ b/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf @@ -53,7 +53,8 @@ [LibraryClasses] =20 [Pcd] gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber ## CONS= UMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds ## CONS= UMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber ## CONS= UMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds ## SOME= TIMES_CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize ## CONS= UMES gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress ## CONS= UMES gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchRegionSize ## CONS= UMES diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/MpLib.c index 594a035d8b92..622b70ca3c4e 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -1044,46 +1044,67 @@ WakeUpAP ( SendInitSipiSipiAllExcludingSelf ((UINT32) ExchangeInfo->BufferStart= ); } if (CpuMpData->InitFlag =3D=3D ApInitConfig) { - // - // The AP enumeration algorithm below is suitable for two use cases. - // - // (1) The check-in time for an individual AP is bounded, and APs run - // through their initialization routines strongly concurrently. = In - // particular, the number of concurrently running APs - // ("NumApsExecuting") is never expected to fall to zero - // *temporarily* -- it is expected to fall to zero only when all - // APs have checked-in. - // - // In this case, the platform is supposed to set - // PcdCpuApInitTimeOutInMicroSeconds to a low-ish value (just lo= ng - // enough for one AP to start initialization). The timeout will = be - // reached soon, and remaining APs are collected by watching - // NumApsExecuting fall to zero. If NumApsExecuting falls to zero - // mid-process, while some APs have not completed initialization, - // the behavior is undefined. - // - // (2) The check-in time for an individual AP is unbounded, and/or A= Ps - // may complete their initializations widely spread out. In - // particular, some APs may finish initialization before some APs - // even start. - // - // In this case, the platform is supposed to set - // PcdCpuApInitTimeOutInMicroSeconds to a high-ish value. The AP - // enumeration will always take that long (except when the boot = CPU - // count happens to be maximal, that is, - // PcdCpuMaxLogicalProcessorNumber). All APs are expected to - // check-in before the timeout, and NumApsExecuting is assumed z= ero - // at timeout. APs that miss the time-out may cause undefined - // behavior. - // - TimedWaitForApFinish ( - CpuMpData, - PcdGet32 (PcdCpuMaxLogicalProcessorNumber) - 1, - PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds) - ); + if (PcdGet32 (PcdCpuBootLogicalProcessorNumber) > 0) { + // + // The AP enumeration algorithm below is suitable only when the + // platform can tell us the *exact* boot CPU count in advance. + // + // The wait below finishes only when the detected AP count reaches + // (PcdCpuBootLogicalProcessorNumber - 1), regardless of how long = that + // takes. If at least one AP fails to check in (meaning a platform + // hardware bug), the detection hangs forever, by design. If the a= ctual + // boot CPU count in the system is higher than + // PcdCpuBootLogicalProcessorNumber (meaning a platform + // misconfiguration), then some APs may complete initialization af= ter + // the wait finishes, and cause undefined behavior. + // + TimedWaitForApFinish ( + CpuMpData, + PcdGet32 (PcdCpuBootLogicalProcessorNumber) - 1, + MAX_UINT32 // approx. 71 minutes + ); + } else { + // + // The AP enumeration algorithm below is suitable for two use case= s. + // + // (1) The check-in time for an individual AP is bounded, and APs = run + // through their initialization routines strongly concurrently= . In + // particular, the number of concurrently running APs + // ("NumApsExecuting") is never expected to fall to zero + // *temporarily* -- it is expected to fall to zero only when a= ll + // APs have checked-in. + // + // In this case, the platform is supposed to set + // PcdCpuApInitTimeOutInMicroSeconds to a low-ish value (just = long + // enough for one AP to start initialization). The timeout wil= l be + // reached soon, and remaining APs are collected by watching + // NumApsExecuting fall to zero. If NumApsExecuting falls to z= ero + // mid-process, while some APs have not completed initializati= on, + // the behavior is undefined. + // + // (2) The check-in time for an individual AP is unbounded, and/or= APs + // may complete their initializations widely spread out. In + // particular, some APs may finish initialization before some = APs + // even start. + // + // In this case, the platform is supposed to set + // PcdCpuApInitTimeOutInMicroSeconds to a high-ish value. The = AP + // enumeration will always take that long (except when the boo= t CPU + // count happens to be maximal, that is, + // PcdCpuMaxLogicalProcessorNumber). All APs are expected to + // check-in before the timeout, and NumApsExecuting is assumed= zero + // at timeout. APs that miss the time-out may cause undefined + // behavior. + // + TimedWaitForApFinish ( + CpuMpData, + PcdGet32 (PcdCpuMaxLogicalProcessorNumber) - 1, + PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds) + ); =20 - while (CpuMpData->MpCpuExchangeInfo->NumApsExecuting !=3D 0) { - CpuPause(); + while (CpuMpData->MpCpuExchangeInfo->NumApsExecuting !=3D 0) { + CpuPause(); + } } } else { // --=20 2.19.1.3.g30247aa5d201 -=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 (#48724): https://edk2.groups.io/g/devel/message/48724 Mute This Topic: https://groups.io/mt/34473663/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-