Revision: 16416
          http://sourceforge.net/p/edk2/code/16416
Author:   jljusten
Date:     2014-11-21 22:46:36 +0000 (Fri, 21 Nov 2014)
Log Message:
-----------
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 <[email protected]>
Reviewed-by: Jordan Justen <[email protected]>

Modified Paths:
--------------
    trunk/edk2/EmulatorPkg/CpuRuntimeDxe/MpService.c

Modified: trunk/edk2/EmulatorPkg/CpuRuntimeDxe/MpService.c
===================================================================
--- trunk/edk2/EmulatorPkg/CpuRuntimeDxe/MpService.c    2014-11-21 22:46:26 UTC 
(rev 16415)
+++ trunk/edk2/EmulatorPkg/CpuRuntimeDxe/MpService.c    2014-11-21 22:46:36 UTC 
(rev 16416)
@@ -420,7 +420,25 @@
     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));
     if (gMPSystem.FailedList == NULL) {
@@ -461,17 +479,13 @@
     // 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;
     }
   }
 


------------------------------------------------------------------------------
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-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to