From nobody Fri Mar 29 14:09:47 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+48563+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+48563+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570534041; cv=none; d=zoho.com; s=zohoarc; b=NMCZPYDWFEw5HN0MFnKGzBEaG0C9j8Myf8kebieU6RA2MVcyaz2GcOwzbKk5iLHN5TX45ER27m1CVRP09PMygDlVdCmnTj1Q2hNP8ouVhg7TBjOWbMjgoztvvorf+ql5wnv/SxjLZRCBwNsyNdLXYIp/ADt2qc7Vmzs5Gd7I0R0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570534041; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=gK+CFKBPun5uKaRQfOFmx3NiUFptLfiIrb6JTfHUCqA=; b=RwiIJ6sf5TTygBzrXQCEhRHITpsB9MeWeC0diftRXZc7S2jcBTnXJ47Z2gWqC07tUfWCFpCCJLyZ3nI6K2qXmQg3ndITUB2H3gYGdIItcwyaNDVp1nG4FRf4uuOqu2yha5sp1hyY0FftBmC13RpUyvdtAB195wGJJXlOEfjdB+0= 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+48563+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 1570534041160224.29592238585474; Tue, 8 Oct 2019 04:27:21 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id y5JGYY1788612xHyTeK6pOiO; Tue, 08 Oct 2019 04:27:20 -0700 X-Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 08 Oct 2019 04:27:20 -0700 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 26E6585A03; Tue, 8 Oct 2019 11:27:20 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-109.rdu2.redhat.com [10.10.120.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 041B3600CE; Tue, 8 Oct 2019 11:27:18 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Eric Dong , Igor Mammedov , Ray Ni Subject: [edk2-devel] [PATCH 1/4] UefiCpuPkg/MpInitLib: honor the platform's boot CPU count in AP detection Date: Tue, 8 Oct 2019 13:27:11 +0200 Message-Id: <20191008112714.6215-2-lersek@redhat.com> In-Reply-To: <20191008112714.6215-1-lersek@redhat.com> References: <20191008112714.6215-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 08 Oct 2019 11:27:20 +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: WCNctKdruBSyrJJBgmMaOASgx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1570534040; bh=wSq41rFinz9/aTqmKVqW2DmovdG8BfjDLcCQPT3v8nw=; h=Cc:Date:From:Reply-To:Subject:To; b=u9bwYqJyAkYaCUuOIfTsKlE1dFqvw9+vaKmisimmar7/KyawqTQUtuIm9+pmj9mNTXQ TLlftLSPplymx3Po53Y1ZCPNEKQmJdEWaQuk/e2CXoATxAUnhTxe7DDwvzqjFFXTnRt1e 4DWb2lMeTUKj3e7U+A/jMixJwQP0DYVeY3E= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" If a platform boots with a CPU topology that is not fully populated (that is, the boot CPU count is smaller than PcdCpuMaxLogicalProcessorNumber), then the platform cannot use the "fast AP detection" logic added in commit 6e1987f19af7. Said logic depends on the boot CPU count being equal to PcdCpuMaxLogicalProcessorNumber. The platform may not be able to use the variant added in commit 0594ec417c89 either, for different reasons; see for example commit 861218740d6d. Allow platforms to specify the exact boot CPU count, independently of PcdCpuMaxLogicalProcessorNumber. Cc: Eric Dong Cc: Igor Mammedov Cc: Ray Ni Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1515 Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel --- UefiCpuPkg/UefiCpuPkg.dec | 11 +++++ UefiCpuPkg/UefiCpuPkg.uni | 4 ++ UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf | 1 + UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf | 3 +- UefiCpuPkg/Library/MpInitLib/MpLib.c | 42 ++++++++++++-------- 5 files changed, 43 insertions(+), 18 deletions(-) diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec index 031a2ccd680a..d6b33fd9b465 100644 --- a/UefiCpuPkg/UefiCpuPkg.dec +++ b/UefiCpuPkg/UefiCpuPkg.dec @@ -227,6 +227,17 @@ [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) - This PCD is ignored, and + # PcdCpuApInitTimeOutInMicroSeconds limits the initial= AP + # detection by the BSP.
+ # nonzero - PcdCpuApInitTimeOutInMicroSeconds is ignored. The in= itial + # AP detection finishes when the detected CPU count (B= SP + # plus APs) reaches the value of this PCD.
+ # @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 d6f84c6f45c0..f1bf8a7ba7cf 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -1044,24 +1044,32 @@ WakeUpAP ( SendInitSipiSipiAllExcludingSelf ((UINT32) ExchangeInfo->BufferStart= ); } 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. - // - TimedWaitForApFinish ( - CpuMpData, - PcdGet32 (PcdCpuMaxLogicalProcessorNumber) - 1, - PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds) - ); + if (PcdGet32 (PcdCpuBootLogicalProcessorNumber) > 0) { + TimedWaitForApFinish ( + CpuMpData, + PcdGet32 (PcdCpuBootLogicalProcessorNumber) - 1, + MAX_UINT32 // approx. 71 minutes + ); + } else { + // + // 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 A= ps + // finsh the initialization. + // The other way is set a value to let all APs finished the + // initialzation. In this case, the later while loop is useless. + // + 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 (#48563): https://edk2.groups.io/g/devel/message/48563 Mute This Topic: https://groups.io/mt/34441228/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 Mar 29 14:09:47 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+48564+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+48564+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570534043; cv=none; d=zoho.com; s=zohoarc; b=lG7j+DPswoeS32kMucriAwh3J0uwFSvOB8UXp2jpzX6fqqqBj5/J+56qXK93m0Y3nluRkvZ6dM83hXdvdmEpz1K/ivEQGXpZK7PUXcYKI/fHcB9lvrTdyveucw500TwljQkMpkl98ANlACfwveOYUGiAxNzcTe6oq4WcWQXXcVk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570534043; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=DTTDfJdSHIjSlnRVfAqnyJoS4cEJRSikbk+wrYfK6lU=; b=D0zzNbK/0zKABate6gKPhmjORcx3vygATbvaBkhEeaPwlW1cqdzEhz8lgOLlqm3URO3feUA/f/S0RarAGpDq5lCEOMYeOiZu1b3TZhC9wFYm+R4yce2CfrNBC7GDZ7nftgkfzo1dCkUNsRgOamy5z/2sDbKbHjo0Lnmhj+khofU= 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+48564+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 1570534043442436.44016702393196; Tue, 8 Oct 2019 04:27:23 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id arrMYY1788612xwa0SZyEeok; Tue, 08 Oct 2019 04:27:22 -0700 X-Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 08 Oct 2019 04:27:22 -0700 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 08B2318CB8FE; Tue, 8 Oct 2019 11:27:22 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-109.rdu2.redhat.com [10.10.120.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7CE49600CE; Tue, 8 Oct 2019 11:27:20 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Anthony Perard , Ard Biesheuvel , Igor Mammedov , Jordan Justen , Julien Grall Subject: [edk2-devel] [PATCH 2/4] OvmfPkg/OvmfXen.dsc: remove PcdCpu* dynamic defaults Date: Tue, 8 Oct 2019 13:27:12 +0200 Message-Id: <20191008112714.6215-3-lersek@redhat.com> In-Reply-To: <20191008112714.6215-1-lersek@redhat.com> References: <20191008112714.6215-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.63]); Tue, 08 Oct 2019 11:27:22 +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: Q6i8Xvtv942QUYZkxTcsF7R5x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1570534042; bh=wZEa8RcbH2AuD1U+CAo98Fofh7fYu5A6PhdMmDI3VyU=; h=Cc:Date:From:Reply-To:Subject:To; b=dAQLpGKd0bW2peqwYXsPPL3GT7xMuGE3sd8XU35CXNPS7o9nS5pBNvZjVXD5MXwb9yA fJGRq7P0UxN2Xt43/EhO8wxCQwXq5GYF8HcSXPleSv3JKwmsFlBbLe9/jWwQhyJGbjrQG IZPmttP7Zt3gK43TtTUE1VldvqwfzjkGjBM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" PcdCpuMaxLogicalProcessorNumber and PcdCpuApInitTimeOutInMicroSeconds are only referenced in "OvmfPkg/PlatformPei/PlatformPei.inf", and OvmfXen does not include that module. Remove the unnecessary dynamic PCD defaults from "OvmfXen.dsc". Cc: Anthony Perard Cc: Ard Biesheuvel Cc: Igor Mammedov Cc: Jordan Justen Cc: Julien Grall Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1515 Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel Reviewed-by: Philippe Mathieu-Daude --- OvmfPkg/OvmfXen.dsc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc index 5a31f75f05d0..6deafea034c0 100644 --- a/OvmfPkg/OvmfXen.dsc +++ b/OvmfPkg/OvmfXen.dsc @@ -481,10 +481,6 @@ [PcdsDynamicDefault] gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|FALSE gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|FALSE =20 - # UefiCpuPkg PCDs related to initial AP bringup and general AP managemen= t. - gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|64 - gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds|50000 - # Set memory encryption mask gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0 =20 --=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 (#48564): https://edk2.groups.io/g/devel/message/48564 Mute This Topic: https://groups.io/mt/34441229/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 Mar 29 14:09:47 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+48565+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+48565+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570534044; cv=none; d=zoho.com; s=zohoarc; b=cnugygX57TB63HUYN6YTDdg8Imqy119HEcPdGx5qcsjvTry3YGNMb4LBxufuXKhqWXXOqo1tb0wGg89LHu+MZIYdgSidFnrTQCBDVuupKZB8pAI3fcCg031R1o08ihclrY46DVrxOPavB4d3UU1LcevegxXq133/IrgP5dSYPmI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570534044; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=l1UIsCz+/JYNQd7LeKKpBkc3yRG28czjKHUEXGaMopI=; b=FMWfju97kiZRGB0rJzPdaNv9jlMokIM23xx1CBTjS+ERtUFdIYc0oNc0ujjwQ510jcZgx7E599Xof30XdfUcR4qEdlGtnpf8ItshPCsw31ApmDRvDP5QAieDixyLH662HPdAPbnRJOnd91Uq80+WGmv1AQfLvef6UvKRGo1bgns= 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+48565+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 1570534044769144.32381034450327; Tue, 8 Oct 2019 04:27:24 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id AsTnYY1788612xeDUT9ncPJt; Tue, 08 Oct 2019 04:27:24 -0700 X-Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 08 Oct 2019 04:27:23 -0700 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8167D87633; Tue, 8 Oct 2019 11:27:23 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-109.rdu2.redhat.com [10.10.120.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D871600CE; Tue, 8 Oct 2019 11:27:22 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Ard Biesheuvel , Igor Mammedov , Jordan Justen Subject: [edk2-devel] [PATCH 3/4] OvmfPkg/IndustryStandard: define FW_CFG_X86_TOPOLOGY structure type Date: Tue, 8 Oct 2019 13:27:13 +0200 Message-Id: <20191008112714.6215-4-lersek@redhat.com> In-Reply-To: <20191008112714.6215-1-lersek@redhat.com> References: <20191008112714.6215-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 08 Oct 2019 11:27:23 +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: gK0MmG3PmUQAyMA3K5nQAPUBx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1570534044; bh=rdssITTH953k3eD6qI+Uq0vryF20Ra/PC+F+7NILo4A=; h=Cc:Date:From:Reply-To:Subject:To; b=KgEjcxegUK0yXNAQRFmY8oyh5SNN8mmNyybytwHwhqM9p2EBCFEqYQQesyR4C+XPxJC qpDlF3dI5QvPBJwKd1hksFUnqrKyJvLzFq14Ka56Xg4CkAkcWDdVB8FqiYU6e970/jzmt 2HASR1MhSIglEymIQxMvgU8WG6BnuxjheEc= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" pc-q35-4.2+ and pc-i440fx-4.2+ machine types report CPU topology info in the "etc/x86-smp-topology" fw_cfg file. Add a structure type for parsing this blob. Cc: Ard Biesheuvel Cc: Igor Mammedov Cc: Jordan Justen Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1515 Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel --- OvmfPkg/Include/IndustryStandard/QemuFwCfg.h | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/OvmfPkg/Include/IndustryStandard/QemuFwCfg.h b/OvmfPkg/Include= /IndustryStandard/QemuFwCfg.h index 7969aba3ca61..fe410d4a3fc2 100644 --- a/OvmfPkg/Include/IndustryStandard/QemuFwCfg.h +++ b/OvmfPkg/Include/IndustryStandard/QemuFwCfg.h @@ -95,4 +95,26 @@ typedef struct { } FW_CFG_DMA_ACCESS; #pragma pack () =20 +// +// Structure describing the VCPU topology on IA32 and X64, in the fw_cfg f= ile +// named "etc/x86-smp-topology". +// +// All fields are little endian. +// +// The number of sockets (aka packages) can be calculated by dividing +// MaxLogicalProcessors by (DiesPerSocket * CoresPerDie * ThreadsPerCore),= and +// rounding up the quotient. +// +// APIC ID field widths and offsets can be derived with the standard method +// described in "Intel(R) 64 Architecture Processor Topology Enumeration" +// . +// +#pragma pack (1) +typedef struct { + UINT32 DiesPerSocket; + UINT32 CoresPerDie; + UINT32 ThreadsPerCore; + UINT32 MaxLogicalProcessors; +} FW_CFG_X86_TOPOLOGY; +#pragma pack () #endif --=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 (#48565): https://edk2.groups.io/g/devel/message/48565 Mute This Topic: https://groups.io/mt/34441230/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 Mar 29 14:09:47 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+48566+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+48566+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1570534047; cv=none; d=zoho.com; s=zohoarc; b=NbJRDPj0QzaVdj5mint+M5NVjoxsev/h6bPN3aYDAr+Ylvhnjk+v2EfHefmrlei4eQUyxSwCB7YjWFJ+POuWVlFS5E6LSHPvqOiOfmCDF3jdnQeq7YDg3wHPoeQqzJue9FyIz7qE6l7qBXADKhbo2D22ouIzhb4oiBTQc91rQR4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570534047; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=gGO0iQmsinxEd9nJ7kzjijI2Y6+pdP5xCwvzEwLf08I=; b=F5YB9BDBI9a53HgBogIgdSMd30lzoMuYJyd5mtDhPzLiDhso+rADzFTEvdI7iOl37RYrLt6rs2D8MZ203mf+jj+011kRLlVyB6v0E2iEdyZF8sD+/sUP4fSaI93ylqZtRuIfay0R+xNs/MZHjFFP9REkh26b9Vcyh58hKuV/KLw= 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+48566+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 1570534047499377.54032528407913; Tue, 8 Oct 2019 04:27:27 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id XzJJYY1788612xrMjKZx2e9h; Tue, 08 Oct 2019 04:27:26 -0700 X-Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 08 Oct 2019 04:27:26 -0700 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BC2433B77; Tue, 8 Oct 2019 11:27:25 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-109.rdu2.redhat.com [10.10.120.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id D6333600CE; Tue, 8 Oct 2019 11:27:23 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Anthony Perard , Ard Biesheuvel , Eric Dong , Igor Mammedov , Jordan Justen , Julien Grall , Ray Ni Subject: [edk2-devel] [PATCH 4/4] OvmfPkg/PlatformPei: rewrite MaxCpuCountInitialization() for CPU hotplug Date: Tue, 8 Oct 2019 13:27:14 +0200 Message-Id: <20191008112714.6215-5-lersek@redhat.com> In-Reply-To: <20191008112714.6215-1-lersek@redhat.com> References: <20191008112714.6215-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 08 Oct 2019 11:27:25 +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: IZjCkTM8NHzj4LT5y9YEobKLx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1570534046; bh=c6cLx1iO/IUKqAihjxQ3Rr/DAR1bGt5syRsPHUF9X0I=; h=Cc:Date:From:Reply-To:Subject:To; b=fe2VMsn0sAZ/TGfJKTwUhcWMtf1/gGL+dZwkzNnhNvhKGZAoIY9GXLN1nsIFspLW3YJ y1427n3sS2qGosQ9owas1jpoiq8dH8w2d/SqFFbHvAPaHS9aso8+WW0WhrO8C/zHN3OZI jdtpg6IvqF3rJPpRFbaTSlV1PndKjHYpJ/g= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" MaxCpuCountInitialization() currently handles the following options: (1) QEMU does not report the boot CPU count. In this case, PlatformPei makes MpInitLib enumerate APs up to the default PcdCpuMaxLogicalProcessorNumber value (64) minus 1, or until the default PcdCpuApInitTimeOutInMicroSeconds (50,000) elapses. (Whichever is reached first.) Time-limited AP enumeration had never been reliable on QEMU/KVM, which is why commit 45a70db3c3a5 strated handling case (2) below, in OVMF. (2) QEMU reports the boot CPU count. In this case, PlatformPei sets PcdCpuMaxLogicalProcessorNumber to the reported boot CPU count, and PcdCpuApInitTimeOutInMicroSeconds to practically "infinity" (MAX_UINT32, ~71 minutes). That causes MpInitLib to enumerate exactly the available (boot) APs. With CPU hotplug in mind, this method is not good enough. While UefiCpuPkg expects PcdCpuMaxLogicalProcessorNumber to include both boot (i.e., cold-plugged), and all *potentially* hot-plugged, logical processors, the boot CPU count reported by QEMU does not cover the second category. Rewrite MaxCpuCountInitialization() for handling the following cases: (1) The behavior of case (1) does not change. (No UefiCpuPkg PCDs are set to values different from the defaults.) (2) QEMU reports the boot CPU count, but not the potential maximum CPU count. In this case, the behavior remains unchanged. The way MpInitLib is instructed to do the same differs however: we now set the new PcdCpuBootLogicalProcessorNumber to the boot CPU count (together with PcdCpuMaxLogicalProcessorNumber). PcdCpuApInitTimeOutInMicroSeconds is irrelevant. (3) QEMU reports both the boot CPU count, and the potential maximum CPU count. We tell UefiCpuPkg about the potential maximum through PcdCpuMaxLogicalProcessorNumber. We also tell MpInitLib the boot CPU count for precise and quick AP enumeration, via PcdCpuBootLogicalProcessorNumber. PcdCpuApInitTimeOutInMicroSeconds is irrelevant. This patch is a pre-requisite for enabling CPU hotplug with SMM_REQUIRE. As a side effect, it also enables S3 to work with CPU hotplug at once, *without* SMM_REQUIRE. Cc: Anthony Perard Cc: Ard Biesheuvel Cc: Eric Dong Cc: Igor Mammedov Cc: Jordan Justen Cc: Julien Grall Cc: Ray Ni Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1515 Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel --- OvmfPkg/OvmfPkgIa32.dsc | 2 +- OvmfPkg/OvmfPkgIa32X64.dsc | 2 +- OvmfPkg/OvmfPkgX64.dsc | 2 +- OvmfPkg/PlatformPei/PlatformPei.inf | 2 +- OvmfPkg/PlatformPei/Platform.c | 83 +++++++++++++------- 5 files changed, 60 insertions(+), 31 deletions(-) diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index 66e944436a69..89b1fc41458d 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -554,7 +554,7 @@ [PcdsDynamicDefault] =20 # UefiCpuPkg PCDs related to initial AP bringup and general AP managemen= t. gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|64 - gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds|50000 + gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber|0 =20 # Set memory encryption mask gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0 diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 51c2bfb44f14..f978d27a0b55 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -566,7 +566,7 @@ [PcdsDynamicDefault] =20 # UefiCpuPkg PCDs related to initial AP bringup and general AP managemen= t. gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|64 - gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds|50000 + gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber|0 =20 # Set memory encryption mask gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0 diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index ba7a75884490..04604ed6b35b 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -565,7 +565,7 @@ [PcdsDynamicDefault] =20 # UefiCpuPkg PCDs related to initial AP bringup and general AP managemen= t. gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|64 - gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds|50000 + gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber|0 =20 # Set memory encryption mask gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0 diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/Plat= formPei.inf index d9fd9c8f05b3..30eaebdfae63 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -98,7 +98,7 @@ [Pcd] gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber - gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds + gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize =20 [FixedPcd] diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index 3ba2459872d9..12cec1d60ec1 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -564,43 +564,72 @@ S3Verification ( =20 =20 /** - Fetch the number of boot CPUs from QEMU and expose it to UefiCpuPkg modu= les. - Set the mMaxCpuCount variable. + Fetch the boot CPU and max CPU numbers from QEMU, and expose them to + UefiCpuPkg modules. Set the mMaxCpuCount variable. **/ VOID MaxCpuCountInitialization ( VOID ) { - UINT16 ProcessorCount; - RETURN_STATUS PcdStatus; + UINT16 BootCpuCount; + RETURN_STATUS Status; =20 + // + // Try to fetch the boot CPU count. + // QemuFwCfgSelectItem (QemuFwCfgItemSmpCpuCount); - ProcessorCount =3D QemuFwCfgRead16 (); - // - // If the fw_cfg key or fw_cfg entirely is unavailable, load mMaxCpuCount - // from the PCD default. No change to PCDs. - // - if (ProcessorCount =3D=3D 0) { + BootCpuCount =3D QemuFwCfgRead16 (); + if (BootCpuCount =3D=3D 0) { + // + // QEMU doesn't report the boot CPU count. Let MpInitLib count APs up = to + // (PcdCpuMaxLogicalProcessorNumber-1), or until + // PcdCpuApInitTimeOutInMicroSeconds elapses (whichever is reached fir= st). + // + DEBUG ((DEBUG_WARN, "%a: boot CPU count unavailable\n", __FUNCTION__)); mMaxCpuCount =3D PcdGet32 (PcdCpuMaxLogicalProcessorNumber); - return; + } else { + // + // We will expose BootCpuCount to MpInitLib. MpInitLib will count APs = up to + // (BootCpuCount-1) precisely, regardless of timeout. + // + // Now try to fetch topology info. + // + FIRMWARE_CONFIG_ITEM FwCfgItem; + UINTN FwCfgSize; + FW_CFG_X86_TOPOLOGY Topology; + + Status =3D QemuFwCfgFindFile ("etc/x86-smp-topology", &FwCfgItem, + &FwCfgSize); + if (RETURN_ERROR (Status) || FwCfgSize !=3D sizeof Topology) { + // + // QEMU doesn't report the topology. Assume that the maximum CPU cou= nt + // equals the boot CPU count (implying no hotplug). + // + DEBUG ((DEBUG_WARN, "%a: topology unavailable\n", __FUNCTION__)); + mMaxCpuCount =3D BootCpuCount; + } else { + // + // Grab the maximum CPU count from the topology info. + // + QemuFwCfgSelectItem (FwCfgItem); + QemuFwCfgReadBytes (FwCfgSize, &Topology); + DEBUG ((DEBUG_VERBOSE, + "%a: DiesPerSocket=3D%u CoresPerDie=3D%u ThreadsPerCore=3D%u\n", + __FUNCTION__, Topology.DiesPerSocket, Topology.CoresPerDie, + Topology.ThreadsPerCore)); + mMaxCpuCount =3D Topology.MaxLogicalProcessors; + } } - // - // Otherwise, set mMaxCpuCount to the value reported by QEMU. - // - mMaxCpuCount =3D ProcessorCount; - // - // Additionally, tell UefiCpuPkg modules (a) the exact number of VCPUs, = (b) - // to wait, in the initial AP bringup, exactly as long as it takes for a= ll of - // the APs to report in. For this, we set the longest representable time= out - // (approx. 71 minutes). - // - PcdStatus =3D PcdSet32S (PcdCpuMaxLogicalProcessorNumber, ProcessorCount= ); - ASSERT_RETURN_ERROR (PcdStatus); - PcdStatus =3D PcdSet32S (PcdCpuApInitTimeOutInMicroSeconds, MAX_UINT32); - ASSERT_RETURN_ERROR (PcdStatus); - DEBUG ((DEBUG_INFO, "%a: QEMU reports %d processor(s)\n", __FUNCTION__, - ProcessorCount)); + + DEBUG ((DEBUG_INFO, "%a: BootCpuCount=3D%d mMaxCpuCount=3D%u\n", __FUNCT= ION__, + BootCpuCount, mMaxCpuCount)); + ASSERT (BootCpuCount <=3D mMaxCpuCount); + + Status =3D PcdSet32S (PcdCpuBootLogicalProcessorNumber, BootCpuCount); + ASSERT_RETURN_ERROR (Status); + Status =3D PcdSet32S (PcdCpuMaxLogicalProcessorNumber, mMaxCpuCount); + ASSERT_RETURN_ERROR (Status); } =20 =20 --=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 (#48566): https://edk2.groups.io/g/devel/message/48566 Mute This Topic: https://groups.io/mt/34441232/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-