UefiCpuPkg/PiSmmCpuDxeSmm: Add GetSupportedMaxLogicalProcessorNumber

MM CPU can not use the dynamic PCD (PcdCpuMaxLogicalProcessorNumber),
so move the PCD usage to DxeSmm.

Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Dun Tan <dun.tan@intel.com>
Cc: Hongbin1 Zhang <hongbin1.zhang@intel.com>
Cc: Wei6 Xu <wei6.xu@intel.com>
Cc: Yuanhao Xie <yuanhao.xie@intel.com>
This commit is contained in:
Jiaxin Wu 2024-07-01 16:14:51 +08:00 committed by mergify[bot]
parent 167e902624
commit 7b9b4ed57f
4 changed files with 54 additions and 11 deletions

View File

@ -652,15 +652,17 @@ GetMpInformation (
GuidHob = GetNextGuidHob (&gMpInformation2HobGuid, GET_NEXT_HOB (GuidHob));
}
ASSERT (*NumberOfCpus <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber));
*MaxNumberOfCpus = *NumberOfCpus;
//
// If support CPU hot plug, we need to allocate resources for possibly hot-added processors
//
if (FeaturePcdGet (PcdCpuHotPlugSupport)) {
*MaxNumberOfCpus = PcdGet32 (PcdCpuMaxLogicalProcessorNumber);
} else {
*MaxNumberOfCpus = *NumberOfCpus;
if (!mIsStandaloneMm) {
ASSERT (*NumberOfCpus <= GetSupportedMaxLogicalProcessorNumber ());
//
// If support CPU hot plug, we need to allocate resources for possibly hot-added processors
//
if (FeaturePcdGet (PcdCpuHotPlugSupport)) {
*MaxNumberOfCpus = GetSupportedMaxLogicalProcessorNumber ();
}
}
MpInfo2Hobs = AllocatePool (sizeof (MP_INFORMATION2_HOB_DATA *) * HobCount);

View File

@ -1558,6 +1558,17 @@ SmmWriteProtectReadOnlyPage (
} \
} while (FALSE)
/**
Get the maximum number of logical processors supported by the system.
@retval The maximum number of logical processors supported by the system
is indicated by the return value.
**/
UINTN
GetSupportedMaxLogicalProcessorNumber (
VOID
);
/**
Extract NumberOfCpus, MaxNumberOfCpus and EFI_PROCESSOR_INFORMATION for all CPU from gEfiMpServiceProtocolGuid.

View File

@ -121,6 +121,20 @@ GetAcpiS3EnableFlag (
mAcpiS3Enable = PcdGetBool (PcdAcpiS3Enable);
}
/**
Get the maximum number of logical processors supported by the system.
@retval The maximum number of logical processors supported by the system
is indicated by the return value.
**/
UINTN
GetSupportedMaxLogicalProcessorNumber (
VOID
)
{
return PcdGet32 (PcdCpuMaxLogicalProcessorNumber);
}
/**
Extract NumberOfCpus, MaxNumberOfCpus and EFI_PROCESSOR_INFORMATION for all CPU from gEfiMpServiceProtocolGuid.
@ -165,7 +179,7 @@ GetMpInformationFromMpServices (
return NULL;
}
ASSERT (NumberOfProcessors <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber));
ASSERT (NumberOfProcessors <= GetSupportedMaxLogicalProcessorNumber ());
/// Allocate buffer for processor information
ProcessorInfo = AllocateZeroPool (sizeof (EFI_PROCESSOR_INFORMATION) * NumberOfProcessors);
@ -187,12 +201,12 @@ GetMpInformationFromMpServices (
*NumberOfCpus = NumberOfEnabledProcessors;
ASSERT (*NumberOfCpus <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber));
ASSERT (*NumberOfCpus <= GetSupportedMaxLogicalProcessorNumber ());
//
// If support CPU hot plug, we need to allocate resources for possibly hot-added processors
//
if (FeaturePcdGet (PcdCpuHotPlugSupport)) {
*MaxNumberOfCpus = PcdGet32 (PcdCpuMaxLogicalProcessorNumber);
*MaxNumberOfCpus = GetSupportedMaxLogicalProcessorNumber ();
} else {
*MaxNumberOfCpus = *NumberOfCpus;
}

View File

@ -101,6 +101,22 @@ GetAcpiS3EnableFlag (
}
}
/**
Get the maximum number of logical processors supported by the system.
@retval The maximum number of logical processors supported by the system
is indicated by the return value.
**/
UINTN
GetSupportedMaxLogicalProcessorNumber (
VOID
)
{
ASSERT (FALSE);
return 0;
}
/**
Extract NumberOfCpus, MaxNumberOfCpus and EFI_PROCESSOR_INFORMATION.