diff options
author | Ruiyu Ni <ruiyu.ni@intel.com> | 2018-01-09 10:33:57 +0800 |
---|---|---|
committer | Ruiyu Ni <ruiyu.ni@intel.com> | 2018-01-10 10:28:28 +0800 |
commit | cee85c48e92be0cb1555f8ab6746cfd15891de2c (patch) | |
tree | 66b0707e53243d4d4f2c8292725867ceecaee11b /UefiCpuPkg/Library | |
parent | ffb4c72d7b637d4ac377fc7da7575069f15c288e (diff) | |
download | edk2-cee85c48e92be0cb1555f8ab6746cfd15891de2c.tar.gz |
UefiCpuPkg/MtrrLib: Handle one setting request covering all memory
*SetMemoryAttribute*() API cannot handle the setting request that
looks like <0, MAX_ADDRESS, Type>. The buggy parameter checking
logic returns Unsupported for this case.
The patch fixes the checking logic to handle such case.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
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 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;
}
|