From: "Gerd Hoffmann" <kraxel@redhat.com>
To: devel@edk2.groups.io
Cc: Oliver Steffen <osteffen@redhat.com>, Ray Ni <ray.ni@intel.com>,
Laszlo Ersek <lersek@redhat.com>,
Rahul Kumar <rahul1.kumar@intel.com>,
Gerd Hoffmann <kraxel@redhat.com>
Subject: [edk2-devel] [PATCH 5/5] UefiCpuPkg/MpInitLib: Add support for multiple HOBs to SaveCpuMpData()
Date: Thu, 15 Feb 2024 10:31:49 +0100 [thread overview]
Message-ID: <20240215093149.251319-6-kraxel@redhat.com> (raw)
In-Reply-To: <20240215093149.251319-1-kraxel@redhat.com>
Add support for splitting Hand-Off data into multiple HOBs. This is
required for VMs with thousands of CPUs. The actual CPU count per HOB
is much smaller (128) for better test coverage.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
UefiCpuPkg/Library/MpInitLib/PeiMpLib.c | 48 ++++++++++++++-----------
1 file changed, 27 insertions(+), 21 deletions(-)
diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
index f80e00edcff3..a5710789c8c3 100644
--- a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
@@ -126,35 +126,41 @@ SaveCpuMpData (
IN CPU_MP_DATA *CpuMpData
)
{
- UINT64 Data64;
- UINTN Index;
- CPU_INFO_IN_HOB *CpuInfoInHob;
- MP_HAND_OFF *MpHandOff;
- UINTN MpHandOffSize;
+ STATIC CONST UINT32 CpusPerHob = 128;
+ UINT64 Data64;
+ UINT32 Index, HobBase;
+ CPU_INFO_IN_HOB *CpuInfoInHob;
+ MP_HAND_OFF *MpHandOff;
+ UINTN MpHandOffSize;
//
// When APs are in a state that can be waken up by a store operation to a memory address,
// report the MP_HAND_OFF data for DXE to use.
//
- CpuInfoInHob = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob;
- MpHandOffSize = sizeof (MP_HAND_OFF) + sizeof (PROCESSOR_HAND_OFF) * CpuMpData->CpuCount;
- MpHandOff = (MP_HAND_OFF *)BuildGuidHob (&mMpHandOffGuid, MpHandOffSize);
- ASSERT (MpHandOff != NULL);
- ZeroMem (MpHandOff, MpHandOffSize);
- MpHandOff->ProcessorIndex = 0;
+ CpuInfoInHob = (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob;
- MpHandOff->CpuCount = CpuMpData->CpuCount;
- if (CpuMpData->ApLoopMode != ApInHltLoop) {
- MpHandOff->StartupSignalValue = MP_HAND_OFF_SIGNAL;
- MpHandOff->WaitLoopExecutionMode = sizeof (VOID *);
- }
+ for (Index = 0; Index < CpuMpData->CpuCount; Index++) {
+ if (Index % CpusPerHob == 0) {
+ MpHandOffSize = sizeof (MP_HAND_OFF) + sizeof (PROCESSOR_HAND_OFF) * CpusPerHob;
+ MpHandOff = (MP_HAND_OFF *)BuildGuidHob (&mMpHandOffGuid, MpHandOffSize);
+ ASSERT (MpHandOff != NULL);
+ ZeroMem (MpHandOff, MpHandOffSize);
- for (Index = 0; Index < MpHandOff->CpuCount; Index++) {
- MpHandOff->Info[Index].ApicId = CpuInfoInHob[Index].ApicId;
- MpHandOff->Info[Index].Health = CpuInfoInHob[Index].Health;
+ HobBase = Index;
+ MpHandOff->ProcessorIndex = HobBase;
+ MpHandOff->CpuCount = MIN (CpuMpData->CpuCount - HobBase, CpusPerHob);
+
+ if (CpuMpData->ApLoopMode != ApInHltLoop) {
+ MpHandOff->StartupSignalValue = MP_HAND_OFF_SIGNAL;
+ MpHandOff->WaitLoopExecutionMode = sizeof (VOID *);
+ }
+ }
+
+ MpHandOff->Info[Index-HobBase].ApicId = CpuInfoInHob[Index].ApicId;
+ MpHandOff->Info[Index-HobBase].Health = CpuInfoInHob[Index].Health;
if (CpuMpData->ApLoopMode != ApInHltLoop) {
- MpHandOff->Info[Index].StartupSignalAddress = (UINT64)(UINTN)CpuMpData->CpuData[Index].StartupApSignal;
- MpHandOff->Info[Index].StartupProcedureAddress = (UINT64)(UINTN)&CpuMpData->CpuData[Index].ApFunction;
+ MpHandOff->Info[Index-HobBase].StartupSignalAddress = (UINT64)(UINTN)CpuMpData->CpuData[Index].StartupApSignal;
+ MpHandOff->Info[Index-HobBase].StartupProcedureAddress = (UINT64)(UINTN)&CpuMpData->CpuData[Index].ApFunction;
}
}
--
2.43.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115501): https://edk2.groups.io/g/devel/message/115501
Mute This Topic: https://groups.io/mt/104369848/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-02-15 9:32 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-15 9:31 [edk2-devel] [PATCH 0/5] UefiCpuPkg/MpInitLib: Add support for multiple MP_HAND_OFF HOBs Gerd Hoffmann
2024-02-15 9:31 ` [edk2-devel] [PATCH 1/5] UefiCpuPkg/MpInitLib: Add ProcessorIndex argument to GetMpHandOffHob() Gerd Hoffmann
2024-02-19 2:34 ` Ni, Ray
2024-02-19 9:51 ` Gerd Hoffmann
2024-02-20 3:42 ` Ni, Ray
2024-02-19 11:18 ` Laszlo Ersek
2024-02-15 9:31 ` [edk2-devel] [PATCH 2/5] UefiCpuPkg/MpInitLib: Add support for multiple HOBs to GetBspNumber() Gerd Hoffmann
2024-02-19 2:41 ` Ni, Ray
2024-02-19 11:18 ` Laszlo Ersek
2024-02-19 11:37 ` Gerd Hoffmann
2024-02-19 20:02 ` Laszlo Ersek
2024-02-15 9:31 ` [edk2-devel] [PATCH 3/5] UefiCpuPkg/MpInitLib: Add support for multiple HOBs to SwitchApContext() Gerd Hoffmann
2024-02-19 2:43 ` Ni, Ray
2024-02-19 11:25 ` Laszlo Ersek
2024-02-15 9:31 ` [edk2-devel] [PATCH 4/5] UefiCpuPkg/MpInitLib: Add support for multiple HOBs to MpInitLibInitialize Gerd Hoffmann
2024-02-19 2:57 ` Ni, Ray
2024-02-19 11:56 ` Laszlo Ersek
2024-02-15 9:31 ` Gerd Hoffmann [this message]
2024-02-19 3:02 ` [edk2-devel] [PATCH 5/5] UefiCpuPkg/MpInitLib: Add support for multiple HOBs to SaveCpuMpData() Ni, Ray
2024-02-19 12:50 ` Laszlo Ersek
2024-02-20 7:35 ` Ni, Ray
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=20240215093149.251319-6-kraxel@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