Because TimeoutInMicrosecsond is a unsigned value, converting it to
signed value will cause the data region changed. so this patch fix
that.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <[email protected]>
---
 EmulatorPkg/CpuRuntimeDxe/MpService.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/EmulatorPkg/CpuRuntimeDxe/MpService.c 
b/EmulatorPkg/CpuRuntimeDxe/MpService.c
index d6dd984..8263915 100644
--- a/EmulatorPkg/CpuRuntimeDxe/MpService.c
+++ b/EmulatorPkg/CpuRuntimeDxe/MpService.c
@@ -378,7 +378,7 @@ CpuMpServicesStartupAllAps (
   UINTN                 NextNumber;
   PROCESSOR_STATE       APInitialState;
   PROCESSOR_STATE       ProcessorState;
-  INTN                  Timeout;
+  UINTN                 Timeout;
 
 
   if (!IsBSP ()) {
@@ -540,13 +540,13 @@ CpuMpServicesStartupAllAps (
       goto Done;
     }
 
-    if ((TimeoutInMicroseconds != 0) && (Timeout < 0)) {
+    if ((TimeoutInMicroseconds != 0) && (Timeout == 0)) {
       Status = EFI_TIMEOUT;
       goto Done;
     }
 
-    gBS->Stall (gPollInterval);
-    Timeout -= gPollInterval;
+    Timeout -= MIN (Timeout, gPollInterval);
+    gBS->Stall (Timeout);
   }
 
 Done:
@@ -659,7 +659,7 @@ CpuMpServicesStartupThisAP (
   OUT BOOLEAN                   *Finished               OPTIONAL
   )
 {
-  INTN            Timeout;
+  UINTN            Timeout;
 
   if (!IsBSP ()) {
     return EFI_DEVICE_ERROR;
@@ -717,12 +717,12 @@ CpuMpServicesStartupThisAP (
 
     gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
 
-    if ((TimeoutInMicroseconds != 0) && (Timeout < 0)) {
+    if ((TimeoutInMicroseconds != 0) && (Timeout == 0)) {
       return EFI_TIMEOUT;
     }
 
-    gBS->Stall (gPollInterval);
-    Timeout -= gPollInterval;
+    Timeout -= MIN (Timeout, gPollInterval);
+    gBS->Stall (Timeout);
   }
 
   return EFI_SUCCESS;
@@ -987,7 +987,7 @@ CpuCheckAllAPsStatus (
   BOOLEAN               Found;
 
   if (gMPSystem.TimeoutActive) {
-    gMPSystem.Timeout -= gPollInterval;
+    gMPSystem.Timeout -= MIN (gMPSystem.Timeout, gPollInterval);
   }
 
   for (ProcessorNumber = 0; ProcessorNumber < gMPSystem.NumberOfProcessors; 
ProcessorNumber++) {
@@ -1040,7 +1040,7 @@ CpuCheckAllAPsStatus (
     }
   }
 
-  if (gMPSystem.TimeoutActive && gMPSystem.Timeout < 0) {
+  if (gMPSystem.TimeoutActive && gMPSystem.Timeout == 0) {
     //
     // Timeout
     //
-- 
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to