]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/PiSmmCpuDxeSmm: Shouldn't use gSmst->CurrentlyExecutingCpu
authorJeff Fan <jeff.fan@intel.com>
Mon, 2 Nov 2015 03:04:19 +0000 (03:04 +0000)
committervanjeff <vanjeff@Edk2>
Mon, 2 Nov 2015 03:04:19 +0000 (03:04 +0000)
In ConfigSmmCodeAccessCheck(), we used gSmst->CurrentlyExecutingCpu to get the
current SMM BSP. But ConfigSmmCodeAccessCheck() maybe invoked before executing
SmmCoreEntry() and gSmst->CurrentlyExecutingCpu hasn't been updated to the
latest value. The code flow is as below:

  BSPHandler()
    gSmmCpuPrivate->SmmCoreEntryContext.CurrentlyExecutingCpu = CpuIndex;
    //
    // when mRestoreSmmConfigurationInS3 is set:
    //
    ConfigSmmCodeAccessCheck()
      //
      // reads gSmst->CurrentlyExecutingCpu to early
      //
    gSmmCpuPrivate->SmmCoreEntry (&gSmmCpuPrivate->SmmCoreEntryContext)
      //
      // sets gSmst->CurrentlyExecutingCpu with CopyMem() too late
      //
      CopyMem (&gSmmCoreSmst.SmmStartupThisAp,
        SmmEntryContext, sizeof (EFI_SMM_ENTRY_CONTEXT));

Instead, we should use
gSmmCpuPrivate->SmmCoreEntryContext.CurrentlyExecutingCpu directly.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18715 6f19259b-4bc3-4df7-8a09-765794883524

UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c

index e210c8d44659357e02e6989021148e57842e287c..c351875262b495728b795e96883a671fa9b83518 100644 (file)
@@ -1386,7 +1386,7 @@ ConfigSmmCodeAccessCheck (
   //\r
   // Check to see if the Feature Control MSR is supported on this CPU\r
   //\r
-  Index = gSmst->CurrentlyExecutingCpu;\r
+  Index = gSmmCpuPrivate->SmmCoreEntryContext.CurrentlyExecutingCpu;\r
   if (!SmmCpuFeaturesIsSmmRegisterSupported (Index, SmmRegFeatureControl)) {\r
     mSmmCodeAccessCheckEnable = FALSE;\r
     return;\r
@@ -1428,7 +1428,7 @@ ConfigSmmCodeAccessCheck (
   // Enable SMM Code Access Check feature for the APs.\r
   //\r
   for (Index = 0; Index < gSmst->NumberOfCpus; Index++) {\r
-    if (Index != gSmst->CurrentlyExecutingCpu) {\r
+    if (Index != gSmmCpuPrivate->SmmCoreEntryContext.CurrentlyExecutingCpu) {\r
 \r
       //\r
       // Acquire Config SMM Code Access Check spin lock.  The AP will release the\r