summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg
diff options
context:
space:
mode:
authorDun Tan <dun.tan@intel.com>2023-03-22 12:14:30 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-03-27 08:21:58 +0000
commitaea5930c40326f2c7981fd42239faeec32ef3e71 (patch)
treefe7ca3bc4ec04932aea2bde7777f8f2c63d124c2 /UefiCpuPkg
parentaad9a301442a81c44333b44e01e39a10174930c1 (diff)
downloadedk2-aea5930c40326f2c7981fd42239faeec32ef3e71.tar.gz
edk2-aea5930c40326f2c7981fd42239faeec32ef3e71.tar.bz2
edk2-aea5930c40326f2c7981fd42239faeec32ef3e71.zip
UefiCpuPkg/CpuPageTableLib: Add RandomTest for PAE paging
Add RandomTest for PAE paging. 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>
Diffstat (limited to 'UefiCpuPkg')
-rw-r--r--UefiCpuPkg/Library/CpuPageTableLib/UnitTest/CpuPageTableLibUnitTestHost.c2
-rw-r--r--UefiCpuPkg/Library/CpuPageTableLib/UnitTest/RandomTest.c3
-rw-r--r--UefiCpuPkg/Library/CpuPageTableLib/UnitTest/TestHelper.c12
3 files changed, 11 insertions, 6 deletions
diff --git a/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/CpuPageTableLibUnitTestHost.c b/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/CpuPageTableLibUnitTestHost.c
index 4303095579..b0be2c5a73 100644
--- a/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/CpuPageTableLibUnitTestHost.c
+++ b/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/CpuPageTableLibUnitTestHost.c
@@ -13,6 +13,7 @@ static CPU_PAGE_TABLE_LIB_RANDOM_TEST_CONTEXT mTestContextPaging4Level = { P
static CPU_PAGE_TABLE_LIB_RANDOM_TEST_CONTEXT mTestContextPaging4Level1GB = { Paging4Level1GB, 100, 20, USE_RANDOM_ARRAY };
static CPU_PAGE_TABLE_LIB_RANDOM_TEST_CONTEXT mTestContextPaging5Level = { Paging5Level, 100, 20, USE_RANDOM_ARRAY };
static CPU_PAGE_TABLE_LIB_RANDOM_TEST_CONTEXT mTestContextPaging5Level1GB = { Paging5Level1GB, 100, 20, USE_RANDOM_ARRAY };
+static CPU_PAGE_TABLE_LIB_RANDOM_TEST_CONTEXT mTestContextPagingPae = { PagingPae, 100, 20, USE_RANDOM_ARRAY };
/**
Check if the input parameters are not supported.
@@ -884,6 +885,7 @@ UefiTestMain (
AddTestCase (RandomTestCase, "Random Test for Paging4Level1G", "Random Test Case2", TestCaseforRandomTest, NULL, NULL, &mTestContextPaging4Level1GB);
AddTestCase (RandomTestCase, "Random Test for Paging5Level", "Random Test Case3", TestCaseforRandomTest, NULL, NULL, &mTestContextPaging5Level);
AddTestCase (RandomTestCase, "Random Test for Paging5Level1G", "Random Test Case4", TestCaseforRandomTest, NULL, NULL, &mTestContextPaging5Level1GB);
+ AddTestCase (RandomTestCase, "Random Test for PagingPae", "Random Test Case5", TestCaseforRandomTest, NULL, NULL, &mTestContextPagingPae);
//
// Execute the tests.
diff --git a/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/RandomTest.c b/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/RandomTest.c
index 2db49f7de7..f7a77d00e7 100644
--- a/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/RandomTest.c
+++ b/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/RandomTest.c
@@ -258,10 +258,9 @@ ValidateAndRandomeModifyPageTable (
UNIT_TEST_STATUS Status;
IA32_PAGING_ENTRY *PagingEntry;
- if ((PagingMode == Paging32bit) || (PagingMode == PagingPae) || (PagingMode >= PagingModeMax)) {
+ if ((PagingMode == Paging32bit) || (PagingMode >= PagingModeMax)) {
//
// 32bit paging is never supported.
- // PAE paging will be supported later.
//
return UNIT_TEST_ERROR_TEST_FAILED;
}
diff --git a/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/TestHelper.c b/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/TestHelper.c
index 22f179c21f..67776255c2 100644
--- a/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/TestHelper.c
+++ b/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/TestHelper.c
@@ -175,10 +175,9 @@ IsPageTableValid (
return UNIT_TEST_PASSED;
}
- if ((PagingMode == Paging32bit) || (PagingMode == PagingPae) || (PagingMode >= PagingModeMax)) {
+ if ((PagingMode == Paging32bit) || (PagingMode >= PagingModeMax)) {
//
// 32bit paging is never supported.
- // PAE paging will be supported later.
//
return UNIT_TEST_ERROR_TEST_FAILED;
}
@@ -187,7 +186,12 @@ IsPageTableValid (
MaxLevel = (UINT8)(PagingMode >> 8);
PagingEntry = (IA32_PAGING_ENTRY *)(UINTN)PageTable;
- for (Index = 0; Index < 512; Index++) {
+ for (Index = 0; Index < ((PagingMode == PagingPae) ? 4 : 512); Index++) {
+ if (PagingMode == PagingPae) {
+ UT_ASSERT_EQUAL (PagingEntry[Index].PdptePae.Bits.MustBeZero, 0);
+ UT_ASSERT_EQUAL (PagingEntry[Index].PdptePae.Bits.MustBeZero2, 0);
+ }
+
Status = IsPageTableEntryValid (&PagingEntry[Index], MaxLevel, MaxLeafLevel, Index << (9 * MaxLevel + 3));
if (Status != UNIT_TEST_PASSED) {
return Status;
@@ -264,7 +268,7 @@ GetEntryFromPageTable (
UINT64 Index;
IA32_PAGING_ENTRY *PagingEntry;
- if ((PagingMode == Paging32bit) || (PagingMode == PagingPae) || (PagingMode >= PagingModeMax)) {
+ if ((PagingMode == Paging32bit) || (PagingMode >= PagingModeMax)) {
//
// 32bit paging is never supported.
// PAE paging will be supported later.