diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.c index 48b6fe62c4..ecb16454ca 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.c @@ -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); diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h index 828080946e..475da8f1d7 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuCommon.h @@ -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. diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c index 97b2bc6efb..c5e7f4363b 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -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; } diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuStandaloneMm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuStandaloneMm.c index 235e53cde5..ed5466a74d 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuStandaloneMm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuStandaloneMm.c @@ -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.