public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 1/1] UefiCpuPkg/MpInitLib: fix apic mode for cpu hotplug
@ 2023-03-07 12:20 Gerd Hoffmann
  2023-03-20  9:56 ` Gerd Hoffmann
  2023-03-21  7:28 ` [edk2-devel] " Ni, Ray
  0 siblings, 2 replies; 8+ messages in thread
From: Gerd Hoffmann @ 2023-03-07 12:20 UTC (permalink / raw)
  To: devel
  Cc: Ray Ni, Pawel Polawski, Rahul Kumar, Gerd Hoffmann,
	Oliver Steffen, Eric Dong

In case the number of CPUs can in increase beyond 255
due to CPU hotplug choose x2apic mode.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 UefiCpuPkg/Library/MpInitLib/MpLib.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index e5dc852ed95f..d73b95001263 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -526,7 +526,9 @@ CollectProcessorCount (
   //
   // Enable x2APIC mode if
   //  1. Number of CPU is greater than 255; or
-  //  2. There are any logical processors reporting an Initial APIC ID of 255 or greater.
+  //  2. The platform exposed the exact *boot* CPU count to us in advance, and
+  //     more than 255 logical processors are possible later, with hotplug; or
+  //  3. There are any logical processors reporting an Initial APIC ID of 255 or greater.
   //
   X2Apic = FALSE;
   if (CpuMpData->CpuCount > 255) {
@@ -534,6 +536,10 @@ CollectProcessorCount (
     // If there are more than 255 processor found, force to enable X2APIC
     //
     X2Apic = TRUE;
+  } else if ((PcdGet32 (PcdCpuBootLogicalProcessorNumber) > 0) &&
+             (PcdGet32 (PcdCpuMaxLogicalProcessorNumber) > 255))
+  {
+    X2Apic = TRUE;
   } else {
     CpuInfoInHob = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob;
     for (Index = 0; Index < CpuMpData->CpuCount; Index++) {
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-07-04  9:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-07 12:20 [PATCH 1/1] UefiCpuPkg/MpInitLib: fix apic mode for cpu hotplug Gerd Hoffmann
2023-03-20  9:56 ` Gerd Hoffmann
2023-03-21  7:28 ` [edk2-devel] " Ni, Ray
2023-03-21 11:53   ` Gerd Hoffmann
2023-03-23  2:45     ` Ni, Ray
2023-05-03  7:24   ` Gerd Hoffmann
2023-05-24 12:32     ` Ni, Ray
2023-07-04  9:43       ` Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox