Calculate byte offset in MSR directly and removing the loop. Cc: Feng Tian <feng.t...@intel.com> Cc: Michael Kinney <michael.d.kin...@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff....@intel.com> --- UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c index fd3a617..9fb3a31 100644 --- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c +++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c @@ -485,18 +485,10 @@ ProgramFixedMtrr ( // // We found the fixed MTRR to be programmed // - for (ByteShift = 0; ByteShift < 8; ByteShift++) { - if (*Base == - ( - mMtrrLibFixedMtrrTable[MsrNum].BaseAddress + - (ByteShift * mMtrrLibFixedMtrrTable[MsrNum].Length) - ) - ) { - break; - } - } + ByteShift = ((UINT32)*Base - mMtrrLibFixedMtrrTable[MsrNum].BaseAddress) + / mMtrrLibFixedMtrrTable[MsrNum].Length; - if (ByteShift == 8) { + if (ByteShift >= 8) { return RETURN_UNSUPPORTED; } -- 2.7.4.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel