if any enabled APs are not in idle state, StartupAllAPs() should return immediately, and must not change the other idled processor state. so we checked the state before changed them.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chen Fan <chen.fan.f...@cn.fujitsu.com> Reviewed-by: Jordan Justen <jordan.l.jus...@intel.com> --- EmulatorPkg/CpuRuntimeDxe/MpService.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/EmulatorPkg/CpuRuntimeDxe/MpService.c b/EmulatorPkg/CpuRuntimeDxe/MpService.c index 03873fb..372b9a4 100644 --- a/EmulatorPkg/CpuRuntimeDxe/MpService.c +++ b/EmulatorPkg/CpuRuntimeDxe/MpService.c @@ -397,6 +397,24 @@ CpuMpServicesStartupAllAps ( return EFI_UNSUPPORTED; } + for (Number = 0; Number < gMPSystem.NumberOfProcessors; Number++) { + ProcessorData = &gMPSystem.ProcessorData[Number]; + if ((ProcessorData->Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) { + // Skip BSP + continue; + } + + if ((ProcessorData->Info.StatusFlag & PROCESSOR_ENABLED_BIT) == 0) { + // Skip Disabled processors + continue; + } + gThread->MutexLock(ProcessorData->StateLock); + if (ProcessorData->State != CPU_STATE_IDLE) { + gThread->MutexUnlock (ProcessorData->StateLock); + return EFI_NOT_READY; + } + gThread->MutexUnlock(ProcessorData->StateLock); + } if (FailedCpuList != NULL) { gMPSystem.FailedList = AllocatePool ((gMPSystem.NumberOfProcessors + 1) * sizeof (UINTN)); @@ -438,17 +456,13 @@ CpuMpServicesStartupAllAps ( // if not "SingleThread", all APs are put to ready state from the beginning // gThread->MutexLock(ProcessorData->StateLock); - if (ProcessorData->State == CPU_STATE_IDLE) { - ProcessorData->State = APInitialState; - gThread->MutexUnlock (ProcessorData->StateLock); + ASSERT (ProcessorData->State == CPU_STATE_IDLE); + ProcessorData->State = APInitialState; + gThread->MutexUnlock (ProcessorData->StateLock); - gMPSystem.StartCount++; - if (SingleThread) { - APInitialState = CPU_STATE_BLOCKED; - } - } else { - gThread->MutexUnlock (ProcessorData->StateLock); - return EFI_NOT_READY; + gMPSystem.StartCount++; + if (SingleThread) { + APInitialState = CPU_STATE_BLOCKED; } } -- 1.9.3 ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel