From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web11.94534.1679637641374533517 for ; Thu, 23 Mar 2023 23:01:20 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=BHIWZUQP; spf=pass (domain: intel.com, ip: 192.55.52.151, mailfrom: dun.tan@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679637680; x=1711173680; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dQ5rwDVborc76cpUPSGV5sWSK4z4WLY0lB464ML7ZTk=; b=BHIWZUQP5j7Fr2vLnO7BdjM3pThMMtRwTDjzm/wGsVIj1WBdE3pPQmdF MR7eLcyiqcyM66X6tmPBwsdRS78TLBK3tuwKKWoqV2NJh5pp7Sp2UOLJc 2MrGRjQDOeVCqWBT5er1T+yeNXiI2x3jMN66oKKuIHUB3NpZsTBx3FqJZ FTekOhrJw19gqN4FkYGDB+n+sLpqIw3L2FM0wqYdgoHtMQiVAf8xC/Qwd iFw/ugD+YdKONzPPx8fXbgA3qdaOi91nVoXiCExd7aNBuM2BNQql7s7qX F1i/FxU/ocdjNdCBeDfE7gW+Z2KhROeoy/PzVn28iqq8Ue+mjNMwLL8s8 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="320094102" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="320094102" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 23:01:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="1012122343" X-IronPort-AV: E=Sophos;i="5.98,286,1673942400"; d="scan'208";a="1012122343" Received: from shwdeopenlab702.ccr.corp.intel.com ([10.239.55.92]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 23:01:18 -0700 From: "duntan" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann Subject: [Patch V5 21/22] UefiCpuPkg/CpuPageTableLib: Add RandomTest for PAE paging Date: Fri, 24 Mar 2023 14:00:19 +0800 Message-Id: <20230324060020.940-22-dun.tan@intel.com> X-Mailer: git-send-email 2.31.1.windows.1 In-Reply-To: <20230324060020.940-1-dun.tan@intel.com> References: <20230324060020.940-1-dun.tan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add RandomTest for PAE paging. Signed-off-by: Dun Tan Cc: Eric Dong Reviewed-by: Ray Ni Cc: Rahul Kumar Tested-by: Gerd Hoffmann Acked-by: Gerd Hoffmann --- UefiCpuPkg/Library/CpuPageTableLib/UnitTest/CpuPageTableLibUnitTestHost.c | 2 ++ UefiCpuPkg/Library/CpuPageTableLib/UnitTest/RandomTest.c | 3 +-- UefiCpuPkg/Library/CpuPageTableLib/UnitTest/TestHelper.c | 12 ++++++++---- 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..d3fb9e2fcb 100644 --- a/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/CpuPageTableLibUnitTestHost.c +++ b/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/CpuPageTableLibUnitTestHost.c @@ -9,6 +9,7 @@ #include "CpuPageTableLibUnitTest.h" // ----------------------------------------------------------------------- PageMode--TestCount-TestRangeCount---RandomOptions +static CPU_PAGE_TABLE_LIB_RANDOM_TEST_CONTEXT mTestContextPagingPae = { PagingPae, 100, 20, USE_RANDOM_ARRAY }; static CPU_PAGE_TABLE_LIB_RANDOM_TEST_CONTEXT mTestContextPaging4Level = { Paging4Level, 100, 20, USE_RANDOM_ARRAY }; 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 }; @@ -880,6 +881,7 @@ UefiTestMain ( goto EXIT; } + AddTestCase (RandomTestCase, "Random Test for PagingPae", "Random Test Case1", TestCaseforRandomTest, NULL, NULL, &mTestContextPagingPae); AddTestCase (RandomTestCase, "Random Test for Paging4Level", "Random Test Case1", TestCaseforRandomTest, NULL, NULL, &mTestContextPaging4Level); 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); 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. -- 2.31.1.windows.1