Reviewed-by: Michael Kinney <[email protected]> 

Mike
-----Original Message-----
From: Fan, Jeff 
Sent: Tuesday, November 17, 2015 10:45 PM
To: [email protected]
Cc: Kinney, Michael D <[email protected]>; Yao, Jiewen 
<[email protected]>
Subject: [Patch 1/2] 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.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <[email protected]>
CC: Michael Kinney <[email protected]>
CC: Jiewen Yao <[email protected]>
---
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
index de681c0..532ac09 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
@@ -1309,9 +1309,9 @@ ConfigSmmCodeAccessCheckOnCurrentProcessor (
   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;
+    }
   }
 
   //
@@ -1354,13 +1354,6 @@ ConfigSmmCodeAccessCheck (
   //
   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;
   }
 
--
1.9.5.msysgit.0

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

Reply via email to