]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/PiSmmCpuDxeSmm: SMM_CPU_DATA_BLOCK is not cleared
authorJeff Fan <jeff.fan@intel.com>
Fri, 15 Jul 2016 06:24:28 +0000 (14:24 +0800)
committerMichael Kinney <michael.d.kinney@intel.com>
Thu, 21 Jul 2016 01:50:53 +0000 (18:50 -0700)
The commit 8b9311 changed the zeroing of mSmmMpSyncData of type
SMM_DISPATCHER_MP_SYNC_DATA by the following patch.
 -    ZeroMem (mSmmMpSyncData, mSmmMpSyncDataSize);
 +    mSmmMpSyncData->SwitchBsp = FALSE;

mSmmMpSyncDataSize not only includes SMM_DISPATCHER_MP_SYNC_DATA, but
also includes the SMM_CPU_DATA_BLOCK array and one BOOLEAN variable
array as shown here:

  mSmmMpSyncDataSize = sizeof (SMM_DISPATCHER_MP_SYNC_DATA) +
       (sizeof (SMM_CPU_DATA_BLOCK) + sizeof (BOOLEAN)) *
       gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus;

This patch restores the original ZeroMem() to clear all CPU Sync data.
The commit 8b9311 may cause unexpected behavior.

v2:
  Mentioned CandidateBsp array in comments to make it more accurate.

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c

index 5ba0514a3536fda03d6be79b31b4969d46cb720e..12466ef5de1f633b20c24bcec75e1ffff0c1e586 100644 (file)
@@ -1276,7 +1276,11 @@ InitializeMpSyncData (
   UINTN                      CpuIndex;\r
 \r
   if (mSmmMpSyncData != NULL) {\r
-    mSmmMpSyncData->SwitchBsp = FALSE;\r
+    //\r
+    // mSmmMpSyncDataSize includes one structure of SMM_DISPATCHER_MP_SYNC_DATA, one\r
+    // CpuData array of SMM_CPU_DATA_BLOCK and one CandidateBsp array of BOOLEAN.\r
+    //\r
+    ZeroMem (mSmmMpSyncData, mSmmMpSyncDataSize);\r
     mSmmMpSyncData->CpuData = (SMM_CPU_DATA_BLOCK *)((UINT8 *)mSmmMpSyncData + sizeof (SMM_DISPATCHER_MP_SYNC_DATA));\r
     mSmmMpSyncData->CandidateBsp = (BOOLEAN *)(mSmmMpSyncData->CpuData + gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus);\r
     if (FeaturePcdGet (PcdCpuSmmEnableBspElection)) {\r