For avoid the compiler optimizing the code, we let Parameter
and Procedure in CpuData volatile.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.f...@cn.fujitsu.com>
Signed-off-by: Jeff Fan <jeff....@intel.com>
---
 UefiCpuPkg/CpuDxe/CpuMp.c | 4 ++--
 UefiCpuPkg/CpuDxe/CpuMp.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c
index 0d6c4ec..523f9f2 100644
--- a/UefiCpuPkg/CpuDxe/CpuMp.c
+++ b/UefiCpuPkg/CpuDxe/CpuMp.c
@@ -1194,7 +1194,7 @@ ProcessorToIdleState (
   UINTN                 ProcessorNumber;
   CPU_DATA_BLOCK        *CpuData;
   EFI_AP_PROCEDURE      Procedure;
-  VOID                  *ProcedureArgument;
+  volatile VOID         *ProcedureArgument;
 
   AsmApDoneWithCommonStack ();
 
@@ -1232,7 +1232,7 @@ ProcessorToIdleState (
     if (Procedure != NULL) {
       SetApState (CpuData, CpuStateBusy);
 
-      Procedure (ProcedureArgument);
+      Procedure ((VOID*) ProcedureArgument);
 
       GetMpSpinLock (CpuData);
       CpuData->Procedure = NULL;
diff --git a/UefiCpuPkg/CpuDxe/CpuMp.h b/UefiCpuPkg/CpuDxe/CpuMp.h
index cb3460f..021b808 100644
--- a/UefiCpuPkg/CpuDxe/CpuMp.h
+++ b/UefiCpuPkg/CpuDxe/CpuMp.h
@@ -94,8 +94,8 @@ typedef struct {
   INTN                           LockSelf;
   volatile CPU_STATE             State;
 
-  EFI_AP_PROCEDURE               Procedure;
-  VOID                           *Parameter;
+  volatile EFI_AP_PROCEDURE      Procedure;
+  volatile VOID*                 Parameter;
   BOOLEAN                        *Finished;
   INTN                           Timeout;
   EFI_EVENT                      WaitEvent;
-- 
1.9.3


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to