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 <chen.fan.f...@cn.fujitsu.com>
---
 EmulatorPkg/CpuRuntimeDxe/MpService.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/EmulatorPkg/CpuRuntimeDxe/MpService.c 
b/EmulatorPkg/CpuRuntimeDxe/MpService.c
index d6dd984..03873fb 100644
--- a/EmulatorPkg/CpuRuntimeDxe/MpService.c
+++ b/EmulatorPkg/CpuRuntimeDxe/MpService.c
@@ -378,8 +378,8 @@ CpuMpServicesStartupAllAps (
   UINTN                 NextNumber;
   PROCESSOR_STATE       APInitialState;
   PROCESSOR_STATE       ProcessorState;
-  INTN                  Timeout;
-
+  UINTN                 Timeout;
+  UINTN                 StallTime;
 
   if (!IsBSP ()) {
     return EFI_DEVICE_ERROR;
@@ -540,13 +540,14 @@ CpuMpServicesStartupAllAps (
       goto Done;
     }
 
-    if ((TimeoutInMicroseconds != 0) && (Timeout < 0)) {
+    if ((TimeoutInMicroseconds != 0) && (Timeout == 0)) {
       Status = EFI_TIMEOUT;
       goto Done;
     }
 
-    gBS->Stall (gPollInterval);
-    Timeout -= gPollInterval;
+    StallTime = MIN (Timeout, gPollInterval);
+    gBS->Stall (StallTime);
+    Timeout -= StallTime;
   }
 
 Done:
@@ -659,7 +660,8 @@ CpuMpServicesStartupThisAP (
   OUT BOOLEAN                   *Finished               OPTIONAL
   )
 {
-  INTN            Timeout;
+  UINTN            Timeout;
+  UINTN            StallTime;
 
   if (!IsBSP ()) {
     return EFI_DEVICE_ERROR;
@@ -717,12 +719,13 @@ 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;
+    StallTime = MIN (Timeout, gPollInterval);
+    gBS->Stall (StallTime);
+    Timeout -= StallTime;
   }
 
   return EFI_SUCCESS;
@@ -987,7 +990,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 +1043,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
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to