]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Library/MtrrLib/MtrrLib.c
UefiCpuPkg/MtrrLib: Revert "Skip MSR access when the pair is invalid"
[mirror_edk2.git] / UefiCpuPkg / Library / MtrrLib / MtrrLib.c
index dfce9a996b3b80ae2a1494fabc2aa6e0389ea215..086f7ad8f051bb6cd02750bd8576b138a90db18b 100644 (file)
@@ -449,13 +449,10 @@ MtrrGetVariableMtrrWorker (
 \r
   for (Index = 0; Index < VariableMtrrCount; Index++) {\r
     if (MtrrSetting == NULL) {\r
-      VariableSettings->Mtrr[Index].Mask = AsmReadMsr64 (MSR_IA32_MTRR_PHYSMASK0 + (Index << 1));\r
-      //\r
-      // Skip to read the Base MSR when the Mask.V is not set.\r
-      //\r
-      if (((MSR_IA32_MTRR_PHYSMASK_REGISTER *)&VariableSettings->Mtrr[Index].Mask)->Bits.V != 0) {\r
-        VariableSettings->Mtrr[Index].Base = AsmReadMsr64 (MSR_IA32_MTRR_PHYSBASE0 + (Index << 1));\r
-      }\r
+      VariableSettings->Mtrr[Index].Base =\r
+        AsmReadMsr64 (MSR_IA32_MTRR_PHYSBASE0 + (Index << 1));\r
+      VariableSettings->Mtrr[Index].Mask =\r
+        AsmReadMsr64 (MSR_IA32_MTRR_PHYSMASK0 + (Index << 1));\r
     } else {\r
       VariableSettings->Mtrr[Index].Base = MtrrSetting->Variables.Mtrr[Index].Base;\r
       VariableSettings->Mtrr[Index].Mask = MtrrSetting->Variables.Mtrr[Index].Mask;\r
@@ -2604,14 +2601,14 @@ MtrrSetVariableMtrrWorker (
   ASSERT (VariableMtrrCount <= ARRAY_SIZE (VariableSettings->Mtrr));\r
 \r
   for (Index = 0; Index < VariableMtrrCount; Index++) {\r
-    //\r
-    // Mask MSR is always updated since caller might need to invalidate the MSR pair.\r
-    // Base MSR is skipped when Mask.V is not set.\r
-    //\r
-    AsmWriteMsr64 (MSR_IA32_MTRR_PHYSMASK0 + (Index << 1), VariableSettings->Mtrr[Index].Mask);\r
-    if (((MSR_IA32_MTRR_PHYSMASK_REGISTER *)&VariableSettings->Mtrr[Index].Mask)->Bits.V != 0) {\r
-      AsmWriteMsr64 (MSR_IA32_MTRR_PHYSBASE0 + (Index << 1), VariableSettings->Mtrr[Index].Base);\r
-    }\r
+    AsmWriteMsr64 (\r
+      MSR_IA32_MTRR_PHYSBASE0 + (Index << 1),\r
+      VariableSettings->Mtrr[Index].Base\r
+      );\r
+    AsmWriteMsr64 (\r
+      MSR_IA32_MTRR_PHYSMASK0 + (Index << 1),\r
+      VariableSettings->Mtrr[Index].Mask\r
+      );\r
   }\r
 }\r
 \r
@@ -2868,7 +2865,7 @@ MtrrDebugPrintAllMtrrsWorker (
     }\r
     ContainVariableMtrr = FALSE;\r
     for (Index = 0; Index < VariableMtrrCount; Index++) {\r
-      if (((MSR_IA32_MTRR_PHYSMASK_REGISTER *)&Mtrrs->Variables.Mtrr[Index].Mask)->Bits.V == 0) {\r
+      if ((Mtrrs->Variables.Mtrr[Index].Mask & BIT11) == 0) {\r
         //\r
         // If mask is not valid, then do not display range\r
         //\r