From: "Ni, Ray" <ray.ni@intel.com>
To: "Liu, Zhiguang" <zhiguang.liu@intel.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Kumar, Rahul R" <rahul.r.kumar@intel.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Laszlo Ersek <lersek@redhat.com>
Subject: Re: [edk2-devel] [PATCH v2 2/3] UefiCpuPkg/CpuPageTableLib/TestCase: Refine test case for PAE paging.
Date: Fri, 1 Dec 2023 08:41:03 +0000 [thread overview]
Message-ID: <MN6PR11MB8244057C70EC2B829AE023638C81A@MN6PR11MB8244.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20231130062909.2003-2-zhiguang.liu@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Thanks,
Ray
> -----Original Message-----
> From: Liu, Zhiguang <zhiguang.liu@intel.com>
> Sent: Thursday, November 30, 2023 2:29 PM
> To: devel@edk2.groups.io
> Cc: Liu, Zhiguang <zhiguang.liu@intel.com>; Ni, Ray <ray.ni@intel.com>;
> Kumar, Rahul R <rahul.r.kumar@intel.com>; Gerd Hoffmann
> <kraxel@redhat.com>; Laszlo Ersek <lersek@redhat.com>
> Subject: [PATCH v2 2/3] UefiCpuPkg/CpuPageTableLib/TestCase: Refine test
> case for PAE paging.
>
> Refine test case:
> 1. Check PAE paging reserved bits is zero.
> 2. Set stack as random value.
>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Rahul Kumar <rahul1.kumar@intel.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
> ---
> .../CpuPageTableLib/UnitTest/RandomTest.c | 24 ++++++++++++++++++-
> .../CpuPageTableLib/UnitTest/TestHelper.c | 14 ++++++++---
> 2 files changed, 34 insertions(+), 4 deletions(-)
>
> diff --git a/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/RandomTest.c
> b/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/RandomTest.c
> index f7a77d00e7..9ac3188be0 100644
> --- a/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/RandomTest.c
> +++ b/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/RandomTest.c
> @@ -138,6 +138,23 @@ RandomBoolean (
> return ((Probability > ((UINT8)Random64 (0, 100))) ? TRUE : FALSE);
> }
>
> +/**
> + Set 8K stack as random value.
> +**/
> +VOID
> +SetRandomStack (
> + VOID
> + )
> +{
> + UINT64 Buffer[SIZE_1KB];
> + UINTN Index;
> +
> + for (Index = 0; Index < SIZE_1KB; Index++) {
> + Buffer[Index] = Random64 (0, MAX_UINT64);
> + Buffer[Index] = Buffer[Index];
> + }
> +}
> +
> /**
> Check if the Page table entry is valid
>
> @@ -670,6 +687,7 @@ SingleMapEntryTest (
> IsNotPresent = FALSE;
> IsModified = FALSE;
>
> + SetRandomStack ();
> GenerateSingleRandomMapEntry (MaxAddress, MapEntrys);
> LastMapEntry = &MapEntrys->Maps[MapsIndex];
> Status = PageTableParse (*PageTable, PagingMode, NULL, &MapCount);
> @@ -1039,7 +1057,11 @@ TestCaseforRandomTest (
> mSupportedBit.Bits.Pat = 1;
> mSupportedBit.Bits.Global = 1;
> mSupportedBit.Bits.ProtectionKey = 0xF;
> - mSupportedBit.Bits.Nx = 1;
> + if (((CPU_PAGE_TABLE_LIB_RANDOM_TEST_CONTEXT *)Context)-
> >PagingMode == PagingPae) {
> + mSupportedBit.Bits.ProtectionKey = 0;
> + }
> +
> + mSupportedBit.Bits.Nx = 1;
>
> mRandomOption = ((CPU_PAGE_TABLE_LIB_RANDOM_TEST_CONTEXT
> *)Context)->RandomOption;
> mNumberIndex = 0;
> diff --git a/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/TestHelper.c
> b/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/TestHelper.c
> index 67776255c2..d2c50a6c8a 100644
> --- a/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/TestHelper.c
> +++ b/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/TestHelper.c
> @@ -9,6 +9,7 @@
> #include "CpuPageTableLibUnitTest.h"
> #include "../CpuPageTable.h"
>
> +#define IA32_PAE_RESERVED_MASK 0x7FF0000000000000ull
> //
> // Global Data to validate if the page table is legal
> // mValidMaskNoLeaf[0] is not used
> @@ -95,6 +96,7 @@ InitGlobalData (
> @param[in] Level the level of PagingEntry.
> @param[in] MaxLeafLevel Max leaf entry level.
> @param[in] LinearAddress The linear address verified.
> + @param[in] PagingMode The paging mode.
>
> @retval Leaf entry.
> **/
> @@ -103,13 +105,18 @@ IsPageTableEntryValid (
> IN IA32_PAGING_ENTRY *PagingEntry,
> IN UINTN Level,
> IN UINTN MaxLeafLevel,
> - IN UINT64 Address
> + IN UINT64 Address,
> + IN PAGING_MODE PagingMode
> )
> {
> UINT64 Index;
> IA32_PAGING_ENTRY *ChildPageEntry;
> UNIT_TEST_STATUS Status;
>
> + if (PagingMode == PagingPae) {
> + UT_ASSERT_EQUAL (PagingEntry->Uint64 & IA32_PAE_RESERVED_MASK,
> 0);
> + }
> +
> if (PagingEntry->Pce.Present == 0) {
> return UNIT_TEST_PASSED;
> }
> @@ -142,7 +149,7 @@ IsPageTableEntryValid (
>
> ChildPageEntry = (IA32_PAGING_ENTRY
> *)(UINTN)(IA32_PNLE_PAGE_TABLE_BASE_ADDRESS (&PagingEntry->Pnle));
> for (Index = 0; Index < 512; Index++) {
> - Status = IsPageTableEntryValid (&ChildPageEntry[Index], Level-1,
> MaxLeafLevel, Address + (Index<<(9*(Level-1) + 3)));
> + Status = IsPageTableEntryValid (&ChildPageEntry[Index], Level-1,
> MaxLeafLevel, Address + (Index<<(9*(Level-1) + 3)), PagingMode);
> if (Status != UNIT_TEST_PASSED) {
> return Status;
> }
> @@ -190,9 +197,10 @@ IsPageTableValid (
> if (PagingMode == PagingPae) {
> UT_ASSERT_EQUAL (PagingEntry[Index].PdptePae.Bits.MustBeZero, 0);
> UT_ASSERT_EQUAL (PagingEntry[Index].PdptePae.Bits.MustBeZero2, 0);
> + UT_ASSERT_EQUAL (PagingEntry[Index].PdptePae.Bits.MustBeZero3, 0);
> }
>
> - Status = IsPageTableEntryValid (&PagingEntry[Index], MaxLevel,
> MaxLeafLevel, Index << (9 * MaxLevel + 3));
> + Status = IsPageTableEntryValid (&PagingEntry[Index], MaxLevel,
> MaxLeafLevel, Index << (9 * MaxLevel + 3), PagingMode);
> if (Status != UNIT_TEST_PASSED) {
> return Status;
> }
> --
> 2.31.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111978): https://edk2.groups.io/g/devel/message/111978
Mute This Topic: https://groups.io/mt/102889279/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2023-12-01 8:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-30 6:29 [edk2-devel] [PATCH v2 1/3] UefiCpuPkg/CpuPageTableLib: Init local variable before using it Zhiguang Liu
2023-11-30 6:29 ` [edk2-devel] [PATCH v2 2/3] UefiCpuPkg/CpuPageTableLib/TestCase: Refine test case for PAE paging Zhiguang Liu
2023-12-01 8:41 ` Ni, Ray [this message]
2023-11-30 6:29 ` [edk2-devel] [PATCH v2 3/3] UefiCpuPkg/CpuMpPei: Use CpuPageTableLib to set memory attribute Zhiguang Liu
2023-12-01 8:42 ` Ni, Ray
2023-12-12 0:35 ` Laszlo Ersek
2023-12-01 8:40 ` [edk2-devel] [PATCH v2 1/3] UefiCpuPkg/CpuPageTableLib: Init local variable before using it Ni, Ray
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=MN6PR11MB8244057C70EC2B829AE023638C81A@MN6PR11MB8244.namprd11.prod.outlook.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox