Good to me.

Reviewed-by: Feng Tian <[email protected]>

-----Original Message-----
From: edk2-devel [mailto:[email protected]] On Behalf Of Michael 
Kinney
Sent: Saturday, October 31, 2015 08:18
To: [email protected]
Subject: [edk2] [PATCH] MdeModulePkg: PiSmmCore: Remove confusing CopyMem() of 
SMM_ENTRY_CONTEXT

A subset of fields in the EFI_SMM_SYSTEM_TABLE2 structure are identical to the 
fields in the SMM_ENTRY_CONTEXT structure.  CopyMem() is used to transfer the 
contents of the SMM_ENTRY_CONTEXT structure into the EFI_SMM_SYSTEM_TABLE2.  
This is confusing because SMM_ENTRY_CONTEXT is not used in the declaration of 
EFI_SMM_SYSTEM_TABLE2 and field contents are transferred without any reference 
to individual field names (i.e.
CurrentlyExecutingCpu).  In order to make the code easier to maintain and 
understand, the CopyMem() is replaced with statements that transfer each field 
of SMM_ENTRY_CONTEXT into EFI_SMM_SYSTEM_TABLE2.

Reported-by: Laszlo Ersek <[email protected]>
Link: http://article.gmane.org/gmane.comp.bios.edk2.devel/3567

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney <[email protected]>
---
 MdeModulePkg/Core/PiSmmCore/PiSmmCore.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c 
b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
index 496638a..cc7ccec 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
@@ -430,13 +430,17 @@ SmmEntryPoint (
   BOOLEAN                     IsOverlapped;
 
   PERF_START (NULL, "SMM", NULL, 0) ;
 
   //
-  // Update SMST using the context
+  // Update SMST with contents of the SmmEntryContext structure
   //
-  CopyMem (&gSmmCoreSmst.SmmStartupThisAp, SmmEntryContext, sizeof 
(EFI_SMM_ENTRY_CONTEXT));
+  gSmmCoreSmst.SmmStartupThisAp      = SmmEntryContext->SmmStartupThisAp;
+  gSmmCoreSmst.CurrentlyExecutingCpu = SmmEntryContext->CurrentlyExecutingCpu;
+  gSmmCoreSmst.NumberOfCpus          = SmmEntryContext->NumberOfCpus;
+  gSmmCoreSmst.CpuSaveStateSize      = SmmEntryContext->CpuSaveStateSize;
+  gSmmCoreSmst.CpuSaveState          = SmmEntryContext->CpuSaveState;
 
   //
   // Call platform hook before Smm Dispatch
   //
   PlatformHookBeforeSmmDispatch ();
--
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to