mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-26 15:14:02 +02:00
UefiCpuPkg/CpuPageTableLib: Modify RandomTest to check IsModified
Modify RandomTest to check if parameter IsModified of PageTableMap() correctlly indicates whether input page table is modified or not. Signed-off-by: Dun Tan <dun.tan@intel.com> Cc: Eric Dong <eric.dong@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Cc: Rahul Kumar <rahul1.kumar@intel.com> Tested-by: Gerd Hoffmann <kraxel@redhat.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Cc: Zhiguang Liu <zhiguang.liu@intel.com>
This commit is contained in:
parent
c8c6cf149d
commit
8727cc9a8e
@ -636,6 +636,8 @@ SingleMapEntryTest (
|
|||||||
VOID *Buffer;
|
VOID *Buffer;
|
||||||
IA32_MAP_ENTRY *Map;
|
IA32_MAP_ENTRY *Map;
|
||||||
UINTN MapCount;
|
UINTN MapCount;
|
||||||
|
IA32_MAP_ENTRY *Map2;
|
||||||
|
UINTN MapCount2;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
UINTN KeyPointCount;
|
UINTN KeyPointCount;
|
||||||
UINTN NewKeyPointCount;
|
UINTN NewKeyPointCount;
|
||||||
@ -648,11 +650,13 @@ SingleMapEntryTest (
|
|||||||
IA32_MAP_ATTRIBUTE *Attribute;
|
IA32_MAP_ATTRIBUTE *Attribute;
|
||||||
UINT64 LastNotPresentRegionStart;
|
UINT64 LastNotPresentRegionStart;
|
||||||
BOOLEAN IsNotPresent;
|
BOOLEAN IsNotPresent;
|
||||||
|
BOOLEAN IsModified;
|
||||||
|
|
||||||
MapsIndex = MapEntrys->Count;
|
MapsIndex = MapEntrys->Count;
|
||||||
MapCount = 0;
|
MapCount = 0;
|
||||||
LastNotPresentRegionStart = 0;
|
LastNotPresentRegionStart = 0;
|
||||||
IsNotPresent = FALSE;
|
IsNotPresent = FALSE;
|
||||||
|
IsModified = FALSE;
|
||||||
|
|
||||||
GenerateSingleRandomMapEntry (MaxAddress, MapEntrys);
|
GenerateSingleRandomMapEntry (MaxAddress, MapEntrys);
|
||||||
LastMapEntry = &MapEntrys->Maps[MapsIndex];
|
LastMapEntry = &MapEntrys->Maps[MapsIndex];
|
||||||
@ -700,7 +704,7 @@ SingleMapEntryTest (
|
|||||||
LastMapEntry->Length,
|
LastMapEntry->Length,
|
||||||
&LastMapEntry->Attribute,
|
&LastMapEntry->Attribute,
|
||||||
&LastMapEntry->Mask,
|
&LastMapEntry->Mask,
|
||||||
NULL
|
&IsModified
|
||||||
);
|
);
|
||||||
|
|
||||||
Attribute = &LastMapEntry->Attribute;
|
Attribute = &LastMapEntry->Attribute;
|
||||||
@ -761,7 +765,7 @@ SingleMapEntryTest (
|
|||||||
LastMapEntry->Length,
|
LastMapEntry->Length,
|
||||||
&LastMapEntry->Attribute,
|
&LastMapEntry->Attribute,
|
||||||
&LastMapEntry->Mask,
|
&LastMapEntry->Mask,
|
||||||
NULL
|
&IsModified
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -775,18 +779,31 @@ SingleMapEntryTest (
|
|||||||
return TestStatus;
|
return TestStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapCount = 0;
|
MapCount2 = 0;
|
||||||
Status = PageTableParse (*PageTable, PagingMode, NULL, &MapCount);
|
Status = PageTableParse (*PageTable, PagingMode, NULL, &MapCount2);
|
||||||
if (MapCount != 0) {
|
if (MapCount2 != 0) {
|
||||||
UT_ASSERT_EQUAL (Status, RETURN_BUFFER_TOO_SMALL);
|
UT_ASSERT_EQUAL (Status, RETURN_BUFFER_TOO_SMALL);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Allocate memory for Maps
|
// Allocate memory for Map2
|
||||||
// Note the memory is only used in this one Single MapEntry Test
|
// Note the memory is only used in this one Single MapEntry Test
|
||||||
//
|
//
|
||||||
Map = AllocatePages (EFI_SIZE_TO_PAGES (MapCount * sizeof (IA32_MAP_ENTRY)));
|
Map2 = AllocatePages (EFI_SIZE_TO_PAGES (MapCount2 * sizeof (IA32_MAP_ENTRY)));
|
||||||
ASSERT (Map != NULL);
|
ASSERT (Map2 != NULL);
|
||||||
Status = PageTableParse (*PageTable, PagingMode, Map, &MapCount);
|
Status = PageTableParse (*PageTable, PagingMode, Map2, &MapCount2);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check if PageTable has been modified.
|
||||||
|
//
|
||||||
|
if (MapCount2 != MapCount) {
|
||||||
|
UT_ASSERT_EQUAL (IsModified, TRUE);
|
||||||
|
} else {
|
||||||
|
if (CompareMem (Map, Map2, MapCount2 * sizeof (IA32_MAP_ENTRY)) != 0) {
|
||||||
|
UT_ASSERT_EQUAL (IsModified, TRUE);
|
||||||
|
} else {
|
||||||
|
UT_ASSERT_EQUAL (IsModified, FALSE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UT_ASSERT_EQUAL (Status, RETURN_SUCCESS);
|
UT_ASSERT_EQUAL (Status, RETURN_SUCCESS);
|
||||||
@ -796,17 +813,17 @@ SingleMapEntryTest (
|
|||||||
// Note the memory is only used in this one Single MapEntry Test
|
// Note the memory is only used in this one Single MapEntry Test
|
||||||
//
|
//
|
||||||
KeyPointCount = 0;
|
KeyPointCount = 0;
|
||||||
GetKeyPointList (MapEntrys, Map, MapCount, NULL, &KeyPointCount);
|
GetKeyPointList (MapEntrys, Map2, MapCount2, NULL, &KeyPointCount);
|
||||||
KeyPointBuffer = AllocatePages (EFI_SIZE_TO_PAGES (KeyPointCount * sizeof (UINT64)));
|
KeyPointBuffer = AllocatePages (EFI_SIZE_TO_PAGES (KeyPointCount * sizeof (UINT64)));
|
||||||
ASSERT (KeyPointBuffer != NULL);
|
ASSERT (KeyPointBuffer != NULL);
|
||||||
NewKeyPointCount = 0;
|
NewKeyPointCount = 0;
|
||||||
GetKeyPointList (MapEntrys, Map, MapCount, KeyPointBuffer, &NewKeyPointCount);
|
GetKeyPointList (MapEntrys, Map2, MapCount2, KeyPointBuffer, &NewKeyPointCount);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Compare all key point's attribute
|
// Compare all key point's attribute
|
||||||
//
|
//
|
||||||
for (Index = 0; Index < NewKeyPointCount; Index++) {
|
for (Index = 0; Index < NewKeyPointCount; Index++) {
|
||||||
if (!CompareEntrysforOnePoint (KeyPointBuffer[Index], MapEntrys, Map, MapCount, InitMap, InitMapCount)) {
|
if (!CompareEntrysforOnePoint (KeyPointBuffer[Index], MapEntrys, Map2, MapCount2, InitMap, InitMapCount)) {
|
||||||
DEBUG ((DEBUG_INFO, "Error happens at below key point\n"));
|
DEBUG ((DEBUG_INFO, "Error happens at below key point\n"));
|
||||||
DEBUG ((DEBUG_INFO, "Index = %d KeyPointBuffer[Index] = 0x%lx\n", Index, KeyPointBuffer[Index]));
|
DEBUG ((DEBUG_INFO, "Index = %d KeyPointBuffer[Index] = 0x%lx\n", Index, KeyPointBuffer[Index]));
|
||||||
Value = GetEntryFromPageTable (*PageTable, PagingMode, KeyPointBuffer[Index], &Level);
|
Value = GetEntryFromPageTable (*PageTable, PagingMode, KeyPointBuffer[Index], &Level);
|
||||||
@ -820,6 +837,10 @@ SingleMapEntryTest (
|
|||||||
FreePages (Map, EFI_SIZE_TO_PAGES (MapCount * sizeof (IA32_MAP_ENTRY)));
|
FreePages (Map, EFI_SIZE_TO_PAGES (MapCount * sizeof (IA32_MAP_ENTRY)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (MapCount2 != 0) {
|
||||||
|
FreePages (Map2, EFI_SIZE_TO_PAGES (MapCount2 * sizeof (IA32_MAP_ENTRY)));
|
||||||
|
}
|
||||||
|
|
||||||
return UNIT_TEST_PASSED;
|
return UNIT_TEST_PASSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user