diff options
author | xli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-08-10 08:57:36 +0000 |
---|---|---|
committer | xli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-08-10 08:57:36 +0000 |
commit | a48caeebbab99e22bfd4072829ecaf553cc92c9c (patch) | |
tree | 76e58bf581cbd82e1ec5f1172abba90bdd1d8bff /UefiCpuPkg/Library | |
parent | 13314ba32a0b7eadda3c2340090b66bc0b99cd26 (diff) | |
download | edk2-a48caeebbab99e22bfd4072829ecaf553cc92c9c.tar.gz edk2-a48caeebbab99e22bfd4072829ecaf553cc92c9c.tar.bz2 edk2-a48caeebbab99e22bfd4072829ecaf553cc92c9c.zip |
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
Diffstat (limited to 'UefiCpuPkg/Library')
-rw-r--r-- | UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c index 1f2604ab8b..fca9258ed7 100644 --- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c +++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c @@ -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;
}
/**
|