X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=UefiCpuPkg%2FLibrary%2FMtrrLib%2FMtrrLib.c;h=333341f7be4d5aceb72c4ec26c3230ae807d509f;hp=1f85ac7e65232bd1294cf2f9a9e1f1b4dd4bc909;hb=cee85c48e92be0cb1555f8ab6746cfd15891de2c;hpb=ffb4c72d7b637d4ac377fc7da7575069f15c288e 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; }