public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: edk2-devel-01 <edk2-devel@ml01.01.org>
Cc: Igor Mammedov <imammedo@redhat.com>,
	Jeff Fan <jeff.fan@intel.com>,
	Jordan Justen <jordan.l.justen@intel.com>
Subject: [PATCH 4/4] OvmfPkg/PlatformPei: set PcdCpuKnownLogicalProcessorNumber for MpInitLib
Date: Tue, 22 Nov 2016 21:26:19 +0100	[thread overview]
Message-ID: <20161122202619.12594-5-lersek@redhat.com> (raw)
In-Reply-To: <20161122202619.12594-1-lersek@redhat.com>

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(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index ed43c4514491..4973a5c12719 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -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.
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index ccd156d9231a..1a7de33450b2 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -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.
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 012ce85462c5..08f1542df158 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -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.
diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf
index 776a4ab11f79..872b3c075421 100644
--- a/OvmfPkg/PlatformPei/PlatformPei.inf
+++ b/OvmfPkg/PlatformPei/PlatformPei.inf
@@ -95,6 +95,7 @@ [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable
   gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress
   gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuKnownLogicalProcessorNumber
   gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize
 
 [FixedPcd]
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index c6e1106c9ed0..ce8f38561fbe 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -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));
+  }
 }
 
 
-- 
2.9.2



  parent reply	other threads:[~2016-11-22 20:26 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-22 20:26 [PATCH 0/4] UefiCpuPkg, OvmfPkg: multiprocessing fixes and improvements Laszlo Ersek
2016-11-22 20:26 ` [PATCH 1/4] UefiCpuPkg/LocalApicLib: fix feature test for Extended Topology CPUID leaf Laszlo Ersek
2016-11-23  5:10   ` Fan, Jeff
2016-11-22 20:26 ` [PATCH 2/4] UefiCpuPkg/MpInitLib: " Laszlo Ersek
2016-11-23  5:10   ` Fan, Jeff
2016-11-22 20:26 ` [PATCH 3/4] UefiCpuPkg/MpInitLib: allow platforms to provide a known CPU count upfront Laszlo Ersek
2016-11-23  5:36   ` Fan, Jeff
2016-11-23 16:04     ` Laszlo Ersek
2016-11-24  1:18       ` Fan, Jeff
2016-11-24  9:36         ` Laszlo Ersek
2016-11-24 13:49           ` Fan, Jeff
2016-11-24 18:32           ` Igor Mammedov
2016-11-24 21:20             ` Laszlo Ersek
2016-11-22 20:26 ` Laszlo Ersek [this message]
2016-11-23 20:43 ` [PATCH 0/4] UefiCpuPkg, OvmfPkg: multiprocessing fixes and improvements Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161122202619.12594-5-lersek@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox