Reviewed-by: Ray Ni <ray...@intel.com> Thanks, Ray > -----Original Message----- > From: Gerd Hoffmann <kra...@redhat.com> > Sent: Wednesday, February 21, 2024 1:50 AM > To: devel@edk2.groups.io > Cc: Oliver Steffen <ostef...@redhat.com>; Laszlo Ersek > <ler...@redhat.com>; Kumar, Rahul R <rahul.r.ku...@intel.com>; Ni, Ray > <ray...@intel.com>; Gerd Hoffmann <kra...@redhat.com> > Subject: [PATCH v2 3/5] UefiCpuPkg/MpInitLib: Add support for multiple > HOBs to SwitchApContext() > > Rename the MpHandOff parameter to FirstMpHandOff. Add loops so the > function inspects all HOBs present in the system. > > Signed-off-by: Gerd Hoffmann <kra...@redhat.com> > --- > UefiCpuPkg/Library/MpInitLib/MpLib.h | 2 +- > UefiCpuPkg/Library/MpInitLib/MpLib.c | 35 ++++++++++++++++++---------- > 2 files changed, 24 insertions(+), 13 deletions(-) > > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h > b/UefiCpuPkg/Library/MpInitLib/MpLib.h > index bc2a0232291d..b5214b904b41 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 > ); > > /** > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c > b/UefiCpuPkg/Library/MpInitLib/MpLib.c > index 8f198ff6d817..c13de34e5769 100644 > --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c > +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c > @@ -1938,31 +1938,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. > **/ > 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)); > + } > } > } > } > -- > 2.43.2
-=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#115713): https://edk2.groups.io/g/devel/message/115713 Mute This Topic: https://groups.io/mt/104472306/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-