From nobody Fri Oct 18 08:37:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101642+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101642+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1679557309; cv=none; d=zohomail.com; s=zohoarc; b=Oqv40c6Y+bFHPMoQUQEsVGQXXgWjhd1P8Z0oNUKQ6qWlZh0vRrA4s04oLPTBNAWKmgucpHniRb8JxR6M0U6+Tfllj04uY3RN9eCdCq6Rb/4yr+iJ1+cxtypwne/Kq6ggEj9ZEaa5hAroxhPA5Zy22CJZaoa1wRhO2sYOln+LHRg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679557309; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=WmS4vGsHoqRhZeca76byfs44CG03QR96WsKu5SJMPQc=; b=Bxwm9NfSlwqD6fdQMqKamKXr9ygzPr6ODOoH2mBzXvFBAiNkXHKh1DvhUakthi7wTUOraQxNaI/ux3MwLZR71rtHaU2IIgVW+ZKZ6B9CT8Ldg36uot3e5lXNAFHwGgaPL15Cs9Fyf/jLqU8eWurClJhDpQ7f+yehXyrPU82PJsw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101642+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1679557309738489.0024738483214; Thu, 23 Mar 2023 00:41:49 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id QkvbYY1788612xNftpMi8ZyJ; Thu, 23 Mar 2023 00:41:48 -0700 X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web11.66779.1679557305298569223 for ; Thu, 23 Mar 2023 00:41:47 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="425699764" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="425699764" X-Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 00:41:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="684616868" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="684616868" X-Received: from shwdeopenlab702.ccr.corp.intel.com ([10.239.55.92]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 00:41:45 -0700 From: "duntan" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann , Zhiguang Liu Subject: [edk2-devel] [Patch V4 14/21] UefiCpuPkg/CpuPageTableLib: Modify RandomTest to check IsModified Date: Thu, 23 Mar 2023 15:40:50 +0800 Message-Id: <20230323074057.549-15-dun.tan@intel.com> In-Reply-To: <20230323074057.549-1-dun.tan@intel.com> References: <20230323074057.549-1-dun.tan@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,dun.tan@intel.com X-Gm-Message-State: mjDHYcTWSWqBGmp8VzBxZj1qx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679557308; bh=DsZv+zcEys4AsUj5sxILw19BAQ4q8cGlVIXFDddKFKE=; h=Cc:Date:From:Reply-To:Subject:To; b=FMbi5B5JYKXG/RWybMBww741KOK0fEnEVcusTZ3UU0+uVnVRfUlRHT6tsMCYfgItb6I 0yjmErDA+sVvpvWkEtO/JtzGGyL9aEthArS4HMMLhe5SEoEFxQ6E1UrUiPCRVFlBYcaCc 85U0ESRQwfHQI6mHIIhuTg9vImwc2NtoAiY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679557315871100004 Content-Type: text/plain; charset="utf-8" Modify RandomTest to check if parameter IsModified of PageTableMap() correctlly indicates whether input page table is modified or not. Signed-off-by: Dun Tan Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann Cc: Zhiguang Liu Reviewed-by: Ray Ni --- UefiCpuPkg/Library/CpuPageTableLib/UnitTest/RandomTest.c | 45 ++++++++++++= +++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/RandomTest.c b/Uef= iCpuPkg/Library/CpuPageTableLib/UnitTest/RandomTest.c index 816fd7b446..6f1485976a 100644 --- a/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/RandomTest.c +++ b/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/RandomTest.c @@ -636,6 +636,8 @@ SingleMapEntryTest ( VOID *Buffer; IA32_MAP_ENTRY *Map; UINTN MapCount; + IA32_MAP_ENTRY *Map2; + UINTN MapCount2; UINTN Index; UINTN KeyPointCount; UINTN NewKeyPointCount; @@ -648,11 +650,13 @@ SingleMapEntryTest ( UINT64 PreviousAddress; UINT64 RangeLimit; BOOLEAN IsNotPresent; + BOOLEAN IsModified; =20 MapsIndex =3D MapEntrys->Count; MapCount =3D 0; PreviousAddress =3D 0; IsNotPresent =3D FALSE; + IsModified =3D FALSE; =20 GenerateSingleRandomMapEntry (MaxAddress, MapEntrys); RangeLimit =3D MapEntrys->Maps[MapsIndex].LinearAddress + MapEntrys->Map= s[MapsIndex].Length; @@ -697,7 +701,7 @@ SingleMapEntryTest ( MapEntrys->Maps[MapsIndex].Length, &MapEntrys->Maps[MapsIndex].Attribute, &MapEntrys->Maps[MapsIndex].Mask, - NULL + &IsModified ); =20 Attribute =3D &MapEntrys->Maps[MapsIndex].Attribute; @@ -758,7 +762,7 @@ SingleMapEntryTest ( MapEntrys->Maps[MapsIndex].Length, &MapEntrys->Maps[MapsIndex].Attribute, &MapEntrys->Maps[MapsIndex].Mask, - NULL + &IsModified ); } =20 @@ -772,18 +776,31 @@ SingleMapEntryTest ( return TestStatus; } =20 - MapCount =3D 0; - Status =3D PageTableParse (*PageTable, PagingMode, NULL, &MapCount); - if (MapCount !=3D 0) { + MapCount2 =3D 0; + Status =3D PageTableParse (*PageTable, PagingMode, NULL, &MapCount2); + if (MapCount2 !=3D 0) { UT_ASSERT_EQUAL (Status, RETURN_BUFFER_TOO_SMALL); =20 // - // Allocate memory for Maps + // Allocate memory for Map2 // Note the memory is only used in this one Single MapEntry Test // - Map =3D AllocatePages (EFI_SIZE_TO_PAGES (MapCount * sizeof (IA32_MAP_= ENTRY))); - ASSERT (Map !=3D NULL); - Status =3D PageTableParse (*PageTable, PagingMode, Map, &MapCount); + Map2 =3D AllocatePages (EFI_SIZE_TO_PAGES (MapCount2 * sizeof (IA32_MA= P_ENTRY))); + ASSERT (Map2 !=3D NULL); + Status =3D PageTableParse (*PageTable, PagingMode, Map2, &MapCount2); + } + + // + // Check if PageTable has been modified. + // + if (MapCount2 !=3D MapCount) { + UT_ASSERT_EQUAL (IsModified, TRUE); + } else { + if (CompareMem (Map, Map2, MapCount2 * sizeof (IA32_MAP_ENTRY)) !=3D 0= ) { + UT_ASSERT_EQUAL (IsModified, TRUE); + } else { + UT_ASSERT_EQUAL (IsModified, FALSE); + } } =20 UT_ASSERT_EQUAL (Status, RETURN_SUCCESS); @@ -793,17 +810,17 @@ SingleMapEntryTest ( // Note the memory is only used in this one Single MapEntry Test // KeyPointCount =3D 0; - GetKeyPointList (MapEntrys, Map, MapCount, NULL, &KeyPointCount); + GetKeyPointList (MapEntrys, Map2, MapCount2, NULL, &KeyPointCount); KeyPointBuffer =3D AllocatePages (EFI_SIZE_TO_PAGES (KeyPointCount * siz= eof (UINT64))); ASSERT (KeyPointBuffer !=3D NULL); NewKeyPointCount =3D 0; - GetKeyPointList (MapEntrys, Map, MapCount, KeyPointBuffer, &NewKeyPointC= ount); + GetKeyPointList (MapEntrys, Map2, MapCount2, KeyPointBuffer, &NewKeyPoin= tCount); =20 // // Compare all key point's attribute // for (Index =3D 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, "Index =3D %d KeyPointBuffer[Index] =3D 0x%lx\n"= , Index, KeyPointBuffer[Index])); Value =3D GetEntryFromPageTable (*PageTable, PagingMode, KeyPointBuf= fer[Index], &Level); @@ -817,6 +834,10 @@ SingleMapEntryTest ( FreePages (Map, EFI_SIZE_TO_PAGES (MapCount * sizeof (IA32_MAP_ENTRY))= ); } =20 + if (MapCount2 !=3D 0) { + FreePages (Map2, EFI_SIZE_TO_PAGES (MapCount2 * sizeof (IA32_MAP_ENTRY= ))); + } + return UNIT_TEST_PASSED; } =20 --=20 2.31.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#101642): https://edk2.groups.io/g/devel/message/101642 Mute This Topic: https://groups.io/mt/97796391/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-