X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=UefiCpuPkg%2FCpuDxe%2FCpuMp.c;h=da3686e2788e8c50f0652bd743a3a010c42e5a2e;hp=4ddcca208a36cf7f82ff89764f8f4b22fe034228;hb=944f45ae2f7ecbff2c66622d15d52ffbc3455bfb;hpb=368002a31c7998d8f00f5e77acee14d49afc2b2d diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c index 4ddcca208a..da3686e278 100644 --- a/UefiCpuPkg/CpuDxe/CpuMp.c +++ b/UefiCpuPkg/CpuDxe/CpuMp.c @@ -1642,35 +1642,40 @@ InitializeMpSupport ( return; } - if (gMaxLogicalProcessorNumber == 1) { - return; - } - gApStackSize = (UINTN) PcdGet32 (PcdCpuApStackSize); - ASSERT ((gApStackSize & (SIZE_4KB - 1)) == 0); - mApStackStart = AllocatePages (EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize)); - ASSERT (mApStackStart != NULL); + InitMpSystemData (); // - // the first buffer of stack size used for common stack, when the amount of AP - // more than 1, we should never free the common stack which maybe used for AP reset. + // Only perform AP detection if PcdCpuMaxLogicalProcessorNumber is greater than 1 // - mCommonStack = mApStackStart; - mTopOfApCommonStack = (UINT8*) mApStackStart + gApStackSize; - mApStackStart = mTopOfApCommonStack; + if (gMaxLogicalProcessorNumber > 1) { - InitMpSystemData (); + gApStackSize = (UINTN) PcdGet32 (PcdCpuApStackSize); + ASSERT ((gApStackSize & (SIZE_4KB - 1)) == 0); + + mApStackStart = AllocatePages (EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize)); + ASSERT (mApStackStart != NULL); + + // + // the first buffer of stack size used for common stack, when the amount of AP + // more than 1, we should never free the common stack which maybe used for AP reset. + // + mCommonStack = mApStackStart; + mTopOfApCommonStack = (UINT8*) mApStackStart + gApStackSize; + mApStackStart = mTopOfApCommonStack; - PrepareAPStartupCode (); + PrepareAPStartupCode (); - StartApsStackless (); + StartApsStackless (); + } DEBUG ((DEBUG_INFO, "Detect CPU count: %d\n", mMpSystemData.NumberOfProcessors)); if (mMpSystemData.NumberOfProcessors == 1) { FreeApStartupCode (); - FreePages (mCommonStack, EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize)); - return; + if (mCommonStack != NULL) { + FreePages (mCommonStack, EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize)); + } } mMpSystemData.CpuDatas = ReallocatePool ( @@ -1692,10 +1697,12 @@ InitializeMpSupport ( ); ASSERT_EFI_ERROR (Status); - if (mMpSystemData.NumberOfProcessors < gMaxLogicalProcessorNumber) { - FreePages (mApStackStart, EFI_SIZE_TO_PAGES ( - (gMaxLogicalProcessorNumber - mMpSystemData.NumberOfProcessors) * - gApStackSize)); + if (mMpSystemData.NumberOfProcessors > 1 && mMpSystemData.NumberOfProcessors < gMaxLogicalProcessorNumber) { + if (mApStackStart != NULL) { + FreePages (mApStackStart, EFI_SIZE_TO_PAGES ( + (gMaxLogicalProcessorNumber - mMpSystemData.NumberOfProcessors) * + gApStackSize)); + } } Status = gBS->CreateEvent (