summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg/Library
diff options
context:
space:
mode:
Diffstat (limited to 'UefiCpuPkg/Library')
-rw-r--r--UefiCpuPkg/Library/MtrrLib/MtrrLib.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
index 1f85ac7e65..333341f7be 100644
--- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
+++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
@@ -2270,8 +2270,13 @@ MtrrSetMemoryAttributesInMtrrSettings (
goto Exit;
}
if (((Ranges[Index].BaseAddress & ~MtrrValidAddressMask) != 0) ||
- ((Ranges[Index].Length & ~MtrrValidAddressMask) != 0)
+ ((((Ranges[Index].BaseAddress + Ranges[Index].Length) & ~MtrrValidAddressMask) != 0) &&
+ (Ranges[Index].BaseAddress + Ranges[Index].Length) != MtrrValidBitsMask + 1)
) {
+ //
+ // Either the BaseAddress or the Limit doesn't follow the alignment requirement.
+ // Note: It's still valid if Limit doesn't follow the alignment requirement but equals to MAX Address.
+ //
Status = RETURN_UNSUPPORTED;
goto Exit;
}