summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--UefiCpuPkg/CpuDxe/CpuDxe.c1
-rw-r--r--UefiCpuPkg/Library/MtrrLib/MtrrLib.c6
2 files changed, 7 insertions, 0 deletions
diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c
index e117b9ab56..457823d5cd 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.c
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.c
@@ -857,6 +857,7 @@ RefreshGcdMemoryAttributes (
UINT32 FirmwareVariableMtrrCount;
FirmwareVariableMtrrCount = GetFirmwareVariableMtrrCount ();
+ ASSERT (FirmwareVariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);
// mIsFlushingGCD = TRUE;
mIsFlushingGCD = FALSE;
diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
index 3c3115c8a0..4e6878f282 100644
--- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
+++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
@@ -1156,6 +1156,8 @@ MtrrGetMemoryAttribute (
// Go through the variable MTRR
//
VariableMtrrCount = GetVariableMtrrCount ();
+ ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);
+
for (Index = 0; Index < VariableMtrrCount; Index++) {
if (VariableMtrr[Index].Valid) {
if (Address >= VariableMtrr[Index].BaseAddress &&
@@ -1189,6 +1191,8 @@ MtrrGetVariableMtrr (
UINT32 VariableMtrrCount;
VariableMtrrCount = GetVariableMtrrCount ();
+ ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);
+
for (Index = 0; Index < VariableMtrrCount; Index++) {
VariableSettings->Mtrr[Index].Base =
AsmReadMsr64 (MTRR_LIB_IA32_VARIABLE_MTRR_BASE + (Index << 1));
@@ -1215,6 +1219,8 @@ MtrrSetVariableMtrrWorker (
UINT32 VariableMtrrCount;
VariableMtrrCount = GetVariableMtrrCount ();
+ ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);
+
for (Index = 0; Index < VariableMtrrCount; Index++) {
AsmWriteMsr64 (
MTRR_LIB_IA32_VARIABLE_MTRR_BASE + (Index << 1),