edk2/edk2-UefiCpuPkg-MpInitLib-A...

101 lines
3.6 KiB
Diff

From 9b609dba20e4ff82b83e73b9a61a36710a8014b8 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Thu, 22 Feb 2024 17:01:03 +0100
Subject: [PATCH 07/10] UefiCpuPkg/MpInitLib: Add support for multiple HOBs to
SwitchApContext()
RH-Author: Gerd Hoffmann <None>
RH-MergeRequest: 59: backport 4096 vcpu patches for c9s
RH-Jira: RHEL-22202
RH-Acked-by: Oliver Steffen <osteffen@redhat.com>
RH-Commit: [7/10] faa8253e80a08b71e0adc0fed6a5d17fada30402 (kraxel.rh/centos-src-edk2)
Rename the MpHandOff parameter to FirstMpHandOff. Add loops so the
function inspects all HOBs present in the system.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20240222160106.686484-4-kraxel@redhat.com>
(cherry picked from commit e2c9d8eba49754b644ed4599331395d777afc379)
---
UefiCpuPkg/Library/MpInitLib/MpLib.c | 35 ++++++++++++++++++----------
UefiCpuPkg/Library/MpInitLib/MpLib.h | 2 +-
2 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 770874b09d..1494355f49 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -1944,31 +1944,42 @@ GetBspNumber (
This procedure allows the AP to switch to another section of
memory and continue its loop there.
- @param[in] MpHandOff Pointer to MP hand-off data structure.
+ @param[in] FirstMpHandOff Pointer to first MP hand-off HOB body.
**/
VOID
SwitchApContext (
- IN MP_HAND_OFF *MpHandOff
+ IN CONST MP_HAND_OFF *FirstMpHandOff
)
{
- UINTN Index;
- UINT32 BspNumber;
+ UINTN Index;
+ UINT32 BspNumber;
+ CONST MP_HAND_OFF *MpHandOff;
- BspNumber = GetBspNumber (MpHandOff);
+ BspNumber = GetBspNumber (FirstMpHandOff);
- for (Index = 0; Index < MpHandOff->CpuCount; Index++) {
- if (Index != BspNumber) {
- *(UINTN *)(UINTN)MpHandOff->Info[Index].StartupProcedureAddress = (UINTN)SwitchContextPerAp;
- *(UINT32 *)(UINTN)MpHandOff->Info[Index].StartupSignalAddress = MpHandOff->StartupSignalValue;
+ for (MpHandOff = FirstMpHandOff;
+ MpHandOff != NULL;
+ MpHandOff = GetNextMpHandOffHob (MpHandOff))
+ {
+ for (Index = 0; Index < MpHandOff->CpuCount; Index++) {
+ if (MpHandOff->ProcessorIndex + Index != BspNumber) {
+ *(UINTN *)(UINTN)MpHandOff->Info[Index].StartupProcedureAddress = (UINTN)SwitchContextPerAp;
+ *(UINT32 *)(UINTN)MpHandOff->Info[Index].StartupSignalAddress = MpHandOff->StartupSignalValue;
+ }
}
}
//
// Wait all APs waken up if this is not the 1st broadcast of SIPI
//
- for (Index = 0; Index < MpHandOff->CpuCount; Index++) {
- if (Index != BspNumber) {
- WaitApWakeup ((UINT32 *)(UINTN)(MpHandOff->Info[Index].StartupSignalAddress));
+ for (MpHandOff = FirstMpHandOff;
+ MpHandOff != NULL;
+ MpHandOff = GetNextMpHandOffHob (MpHandOff))
+ {
+ for (Index = 0; Index < MpHandOff->CpuCount; Index++) {
+ if (MpHandOff->ProcessorIndex + Index != BspNumber) {
+ WaitApWakeup ((UINT32 *)(UINTN)(MpHandOff->Info[Index].StartupSignalAddress));
+ }
}
}
}
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h b/UefiCpuPkg/Library/MpInitLib/MpLib.h
index fab2b2d493..3a7b9896cf 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.h
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h
@@ -482,7 +482,7 @@ GetWakeupBuffer (
**/
VOID
SwitchApContext (
- IN MP_HAND_OFF *MpHandOff
+ IN CONST MP_HAND_OFF *FirstMpHandOff
);
/**
--
2.39.3