From 1ec374cb5052dd7999b8289927c5257216fa1026 Mon Sep 17 00:00:00 2001 From: YuanhaoXie Date: Mon, 11 Sep 2023 19:02:14 +0800 Subject: [PATCH] UefiCpuPkg/MtrrUnitTest: Update UnitTestMtrrGetDefaultMemoryType. Update UnitTestMtrrGetDefaultMemoryType for the case the when Fixed MTRRs are not supported. The original implementation returns FALSE when either fixed MTRR isn't supported or the number of variable MTRRs is 0. The correct behavior should return FALSE only when both fixed MTRR isn't supported and the number of variable MTRRs is 0. Signed-off-by: Ray Ni Cc: Eric Dong Cc: Rahul Kumar Cc: Gerd Hoffmann Reviewed-by: Eric Dong Reviewed-by: Ray Ni --- UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c b/UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c index 75ae4d65b9..1d3573e7b0 100644 --- a/UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c +++ b/UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c @@ -904,18 +904,24 @@ UnitTestMtrrGetDefaultMemoryType ( Result = MtrrGetDefaultMemoryType (); UT_ASSERT_EQUAL (Result, CacheUncacheable); + // + // If MTRRs are supported, but Fixed MTRRs are not supported. + // SystemParameter.MtrrSupported = TRUE; SystemParameter.FixedMtrrSupported = FALSE; InitializeMtrrRegs (&SystemParameter); Result = MtrrGetDefaultMemoryType (); - UT_ASSERT_EQUAL (Result, CacheUncacheable); + UT_ASSERT_EQUAL (Result, SystemParameter.DefaultCacheType); + // + // If MTRRs are supported, but Variable MTRRs are not supported. + // SystemParameter.MtrrSupported = TRUE; SystemParameter.FixedMtrrSupported = TRUE; SystemParameter.VariableMtrrCount = 0; InitializeMtrrRegs (&SystemParameter); Result = MtrrGetDefaultMemoryType (); - UT_ASSERT_EQUAL (Result, CacheUncacheable); + UT_ASSERT_EQUAL (Result, SystemParameter.DefaultCacheType); return UNIT_TEST_PASSED; }