Revision: 18905
          http://sourceforge.net/p/edk2/code/18905
Author:   vanjeff
Date:     2015-11-20 01:22:00 +0000 (Fri, 20 Nov 2015)
Log Message:
-----------
UefiCpuPkg: Not touch SmmFeatureControl if Code_Access_Chk not Set

Bit SMM_Code_Access_Chk (SMM-RO) in MSR_SMM_MCA_CAP is defined in SDM.
If set to 1 indicates that the SMM code access restriction is supported and the
MSR_SMM_FEATURE_CONTROL is supported.

If this bit is not set, we needn't to access register SmmFetureControl.
Otherwise, #GP exception may happen.

Cc: Michael Kinney <[email protected]>
Cc: Jiewen Yao <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <[email protected]>
Reviewed-by: Michael Kinney <[email protected]> 
Reviewed-by: Jiewen Yao <[email protected]>

Modified Paths:
--------------
    trunk/edk2/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c

Modified: trunk/edk2/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
===================================================================
--- trunk/edk2/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c       2015-11-19 
14:39:48 UTC (rev 18904)
+++ trunk/edk2/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c       2015-11-20 
01:22:00 UTC (rev 18905)
@@ -1309,10 +1309,10 @@
   NewSmmFeatureControlMsr = SmmFeatureControlMsr;
   if (mSmmCodeAccessCheckEnable) {
     NewSmmFeatureControlMsr |= SMM_CODE_CHK_EN_BIT;
+    if (FeaturePcdGet (PcdCpuSmmFeatureControlMsrLock)) {
+      NewSmmFeatureControlMsr |= SMM_FEATURE_CONTROL_LOCK_BIT;
+    }
   }
-  if (FeaturePcdGet (PcdCpuSmmFeatureControlMsrLock)) {
-    NewSmmFeatureControlMsr |= SMM_FEATURE_CONTROL_LOCK_BIT;
-  }
 
   //
   // Only set the SMM Feature Control MSR value if the new value is different 
than the current value
@@ -1354,13 +1354,6 @@
   //
   if ((AsmReadMsr64 (EFI_MSR_SMM_MCA_CAP) & SMM_CODE_ACCESS_CHK_BIT) == 0) {
     mSmmCodeAccessCheckEnable = FALSE;
-  }
-
-  //
-  // If the SMM Code Access Check feature is disabled and the Feature Control 
MSR
-  // is not being locked, then no additional work is required
-  //
-  if (!mSmmCodeAccessCheckEnable && !FeaturePcdGet 
(PcdCpuSmmFeatureControlMsrLock)) {
     return;
   }
 


------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to