diff options
author | Chen Fan <chen.fan.fnst@cn.fujitsu.com> | 2014-11-21 22:46:36 +0000 |
---|---|---|
committer | jljusten <jljusten@Edk2> | 2014-11-21 22:46:36 +0000 |
commit | c156d27b397489814a85f700abb584fc835644a7 (patch) | |
tree | d168123d6de2204662b77a7db074405f97aa3460 /EmulatorPkg/CpuRuntimeDxe | |
parent | ca186b1d4f186779a11319b1fa45a29de20534dc (diff) | |
download | edk2-platforms-c156d27b397489814a85f700abb584fc835644a7.tar.xz |
EmulatorPkg/MpService: StartupAllAPs should verify processor state before setting state
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.fnst@cn.fujitsu.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16416 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EmulatorPkg/CpuRuntimeDxe')
-rw-r--r-- | EmulatorPkg/CpuRuntimeDxe/MpService.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/EmulatorPkg/CpuRuntimeDxe/MpService.c b/EmulatorPkg/CpuRuntimeDxe/MpService.c index 2312fc527e..f941519c29 100644 --- a/EmulatorPkg/CpuRuntimeDxe/MpService.c +++ b/EmulatorPkg/CpuRuntimeDxe/MpService.c @@ -420,6 +420,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));
@@ -461,17 +479,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;
}
}
|