Add boundary check against variable MTRR count.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10787 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
xli24 2010-08-10 08:57:36 +00:00
parent 13314ba32a
commit a48caeebba
1 changed files with 6 additions and 1 deletions

View File

@ -93,11 +93,16 @@ GetVariableMtrrCount (
VOID
)
{
UINT32 VariableMtrrCount;
if (!IsMtrrSupported ()) {
return 0;
}
return (UINT32)(AsmReadMsr64 (MTRR_LIB_IA32_MTRR_CAP) & MTRR_LIB_IA32_MTRR_CAP_VCNT_MASK);
VariableMtrrCount = (UINT32)(AsmReadMsr64 (MTRR_LIB_IA32_MTRR_CAP) & MTRR_LIB_IA32_MTRR_CAP_VCNT_MASK);
ASSERT (VariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);
return VariableMtrrCount;
}
/**