VOID *Buffer;\r
IA32_MAP_ENTRY *Map;\r
UINTN MapCount;\r
+ IA32_MAP_ENTRY *Map2;\r
+ UINTN MapCount2;\r
UINTN Index;\r
UINTN KeyPointCount;\r
UINTN NewKeyPointCount;\r
IA32_MAP_ATTRIBUTE *Attribute;\r
UINT64 LastNotPresentRegionStart;\r
BOOLEAN IsNotPresent;\r
+ BOOLEAN IsModified;\r
\r
MapsIndex = MapEntrys->Count;\r
MapCount = 0;\r
LastNotPresentRegionStart = 0;\r
IsNotPresent = FALSE;\r
+ IsModified = FALSE;\r
\r
GenerateSingleRandomMapEntry (MaxAddress, MapEntrys);\r
LastMapEntry = &MapEntrys->Maps[MapsIndex];\r
LastMapEntry->Length,\r
&LastMapEntry->Attribute,\r
&LastMapEntry->Mask,\r
- NULL\r
+ &IsModified\r
);\r
\r
Attribute = &LastMapEntry->Attribute;\r
LastMapEntry->Length,\r
&LastMapEntry->Attribute,\r
&LastMapEntry->Mask,\r
- NULL\r
+ &IsModified\r
);\r
}\r
\r
return TestStatus;\r
}\r
\r
- MapCount = 0;\r
- Status = PageTableParse (*PageTable, PagingMode, NULL, &MapCount);\r
- if (MapCount != 0) {\r
+ MapCount2 = 0;\r
+ Status = PageTableParse (*PageTable, PagingMode, NULL, &MapCount2);\r
+ if (MapCount2 != 0) {\r
UT_ASSERT_EQUAL (Status, RETURN_BUFFER_TOO_SMALL);\r
\r
//\r
- // Allocate memory for Maps\r
+ // Allocate memory for Map2\r
// Note the memory is only used in this one Single MapEntry Test\r
//\r
- Map = AllocatePages (EFI_SIZE_TO_PAGES (MapCount * sizeof (IA32_MAP_ENTRY)));\r
- ASSERT (Map != NULL);\r
- Status = PageTableParse (*PageTable, PagingMode, Map, &MapCount);\r
+ Map2 = AllocatePages (EFI_SIZE_TO_PAGES (MapCount2 * sizeof (IA32_MAP_ENTRY)));\r
+ ASSERT (Map2 != NULL);\r
+ Status = PageTableParse (*PageTable, PagingMode, Map2, &MapCount2);\r
+ }\r
+\r
+ //\r
+ // Check if PageTable has been modified.\r
+ //\r
+ if (MapCount2 != MapCount) {\r
+ UT_ASSERT_EQUAL (IsModified, TRUE);\r
+ } else {\r
+ if (CompareMem (Map, Map2, MapCount2 * sizeof (IA32_MAP_ENTRY)) != 0) {\r
+ UT_ASSERT_EQUAL (IsModified, TRUE);\r
+ } else {\r
+ UT_ASSERT_EQUAL (IsModified, FALSE);\r
+ }\r
}\r
\r
UT_ASSERT_EQUAL (Status, RETURN_SUCCESS);\r
// Note the memory is only used in this one Single MapEntry Test\r
//\r
KeyPointCount = 0;\r
- GetKeyPointList (MapEntrys, Map, MapCount, NULL, &KeyPointCount);\r
+ GetKeyPointList (MapEntrys, Map2, MapCount2, NULL, &KeyPointCount);\r
KeyPointBuffer = AllocatePages (EFI_SIZE_TO_PAGES (KeyPointCount * sizeof (UINT64)));\r
ASSERT (KeyPointBuffer != NULL);\r
NewKeyPointCount = 0;\r
- GetKeyPointList (MapEntrys, Map, MapCount, KeyPointBuffer, &NewKeyPointCount);\r
+ GetKeyPointList (MapEntrys, Map2, MapCount2, KeyPointBuffer, &NewKeyPointCount);\r
\r
//\r
// Compare all key point's attribute\r
//\r
for (Index = 0; Index < NewKeyPointCount; Index++) {\r
- if (!CompareEntrysforOnePoint (KeyPointBuffer[Index], MapEntrys, Map, MapCount, InitMap, InitMapCount)) {\r
+ if (!CompareEntrysforOnePoint (KeyPointBuffer[Index], MapEntrys, Map2, MapCount2, InitMap, InitMapCount)) {\r
DEBUG ((DEBUG_INFO, "Error happens at below key point\n"));\r
DEBUG ((DEBUG_INFO, "Index = %d KeyPointBuffer[Index] = 0x%lx\n", Index, KeyPointBuffer[Index]));\r
Value = GetEntryFromPageTable (*PageTable, PagingMode, KeyPointBuffer[Index], &Level);\r
FreePages (Map, EFI_SIZE_TO_PAGES (MapCount * sizeof (IA32_MAP_ENTRY)));\r
}\r
\r
+ if (MapCount2 != 0) {\r
+ FreePages (Map2, EFI_SIZE_TO_PAGES (MapCount2 * sizeof (IA32_MAP_ENTRY)));\r
+ }\r
+\r
return UNIT_TEST_PASSED;\r
}\r
\r