@@ -488,6 +488,8 @@ [PcdsDynamicDefault]
gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|FALSE
+ gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownLogicalProcessorNumber|0
+
################################################################################
#
# Components Section - list of all EDK II Modules needed by this Platform.
@@ -496,6 +496,8 @@ [PcdsDynamicDefault]
gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|FALSE
+ gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownLogicalProcessorNumber|0
+
################################################################################
#
# Components Section - list of all EDK II Modules needed by this Platform.
@@ -495,6 +495,8 @@ [PcdsDynamicDefault]
gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|FALSE
gEfiMdeModulePkgTokenSpaceGuid.PcdPropertiesTableEnable|FALSE
+ gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownLogicalProcessorNumber|0
+
################################################################################
#
# Components Section - list of all EDK II Modules needed by this Platform.
@@ -95,6 +95,7 @@ [Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable
gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress
gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber
+ gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownLogicalProcessorNumber
gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize
[FixedPcd]
@@ -394,6 +394,7 @@ MiscInitialization (
UINTN AcpiCtlReg;
UINT8 AcpiEnBit;
RETURN_STATUS PcdStatus;
+ UINT16 KnownProcessorCount;
//
// Disable A20 Mask
@@ -473,6 +474,27 @@ MiscInitialization (
//
PciExBarInitialization ();
}
+
+ //
+ // Fetch the number of boot CPUs from QEMU and expose it to MpInitLib in
+ // UefiCpuPkg.
+ //
+ QemuFwCfgSelectItem (QemuFwCfgItemSmpCpuCount);
+ KnownProcessorCount = QemuFwCfgRead16 ();
+ if (KnownProcessorCount > PcdGet32 (PcdCpuMaxLogicalProcessorNumber)) {
+ DEBUG ((DEBUG_ERROR,
+ "%a: KnownProcessorCount (%d) > PcdCpuMaxLogicalProcessorNumber (%u)\n",
+ __FUNCTION__, KnownProcessorCount,
+ PcdGet32 (PcdCpuMaxLogicalProcessorNumber)));
+ ASSERT (FALSE);
+ CpuDeadLoop ();
+ } else if (KnownProcessorCount > 0) {
+ PcdStatus = PcdSet32S (PcdCpuKnownLogicalProcessorNumber,
+ KnownProcessorCount);
+ ASSERT_RETURN_ERROR (PcdStatus);
+ DEBUG ((DEBUG_INFO, "%a: QEMU reports %d processors\n", __FUNCTION__,
+ KnownProcessorCount));
+ }
}
This setting will allow CpuMpPei and CpuDxe to wait for the initial AP check-ins exactly as long as necessary. It is safe to set PcdCpuKnownLogicalProcessorNumber in OvmfPkg/PlatformPei. OvmfPkg/PlatformPei installs the permanent PEI RAM, producing gEfiPeiMemoryDiscoveredPpiGuid, and UefiCpuPkg/CpuMpPei has a depex on gEfiPeiMemoryDiscoveredPpiGuid. It is safe to read the fw_cfg item QemuFwCfgItemSmpCpuCount (0x0005). It was added to QEMU in 2008 as key FW_CFG_NB_CPUS, in commit 905fdcb5264c ("Add common keys to firmware configuration"). Even if the key is unavailable (or if fw_cfg is entirely unavailable, for example on Xen), QemuFwCfgRead16() will return 0, and then we stick with the current behavior (PcdCpuKnownLogicalProcessorNumber == 0, which is the default in "UefiCpuPkg/UefiCpuPkg.dec".) Cc: Igor Mammedov <imammedo@redhat.com> Cc: Jeff Fan <jeff.fan@intel.com> Cc: Jordan Justen <jordan.l.justen@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> --- OvmfPkg/OvmfPkgIa32.dsc | 2 ++ OvmfPkg/OvmfPkgIa32X64.dsc | 2 ++ OvmfPkg/OvmfPkgX64.dsc | 2 ++ OvmfPkg/PlatformPei/PlatformPei.inf | 1 + OvmfPkg/PlatformPei/Platform.c | 22 ++++++++++++++++++++ 5 files changed, 29 insertions(+) -- 2.9.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel