]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg: Update AESNI support checking logic
authorSong, BinX <binx.song@intel.com>
Mon, 25 Dec 2017 03:11:21 +0000 (11:11 +0800)
committerEric Dong <eric.dong@intel.com>
Wed, 27 Dec 2017 07:31:34 +0000 (15:31 +0800)
With correct model CPU, current checking logic will
always execute AsmReadMsr64 operation and then check
ECX.AESNI[bit 25] = 1. Update checking logic to check
ECX.AESNI[bit 25] = 1 first and then do AsmReadMsr64
operation.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bell Song <binx.song@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c

index 880f0922ab6116cad0701d898b138c685c8a46e1..56b1b551d9778f54e3ff86b0ba3f77f61299bb47 100644 (file)
@@ -62,15 +62,17 @@ AesniSupport (
 {\r
   MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER   *MsrFeatureConfig;\r
 \r
 {\r
   MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER   *MsrFeatureConfig;\r
 \r
-  if (IS_SANDY_BRIDGE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||\r
-      IS_SILVERMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||\r
-      IS_XEON_5600_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||\r
-      IS_XEON_E7_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||\r
-      IS_XEON_PHI_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) {\r
-    MsrFeatureConfig = (MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *) ConfigData;\r
-    ASSERT (MsrFeatureConfig != NULL);\r
-    MsrFeatureConfig[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_FEATURE_CONFIG);\r
-    return (CpuInfo->CpuIdVersionInfoEcx.Bits.AESNI == 1);\r
+  if (CpuInfo->CpuIdVersionInfoEcx.Bits.AESNI == 1) {\r
+    if (IS_SANDY_BRIDGE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||\r
+        IS_SILVERMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||\r
+        IS_XEON_5600_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||\r
+        IS_XEON_E7_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||\r
+        IS_XEON_PHI_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) {\r
+      MsrFeatureConfig = (MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *) ConfigData;\r
+      ASSERT (MsrFeatureConfig != NULL);\r
+      MsrFeatureConfig[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_FEATURE_CONFIG);\r
+    }\r
+    return TRUE;\r
   }\r
   return FALSE;\r
 }\r
   }\r
   return FALSE;\r
 }\r