From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web10.72440.1679577799432239610 for ; Thu, 23 Mar 2023 06:23:19 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=BW+0iQNS; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: ray.ni@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679577799; x=1711113799; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=4OrD4qdYTmAyJIMrjKEMpdyPy6kM7qr1eJ/K8sgTvrw=; b=BW+0iQNSye/W93owj3i2nVjzs+dPal3ukK2Hn7hwIvhN0iX05+AZPJBe B9X5OaKUXqfdREfow6eRgLbdykRFZ0C7Rx1WKP8RMax9zMJhn+yLuMTwh hvMxf3YP2MxcLg9aEpc+9x0Oa22B3tRQaPcTAyvl8fdOCT8z6imAaAZL3 XywxtN9Tj2twu9LSXqO502KR6Q3qdtM/bbYb07rTLjJUqiTCwXRVpTJub 4/qlk+APLysJrbgrayuRf7PWPRpPtMv13pXnMONZeTY8+CD0PCQp5MS4s D2wcmiDoTN1bLeBeY/R8xHLvhWSlTq9dJjR3Id5gJrVyVVHCtJKqE8CIm g==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="339518133" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="339518133" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 06:23:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="928232505" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="928232505" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga006.fm.intel.com with ESMTP; 23 Mar 2023 06:23:18 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 23 Mar 2023 06:23:18 -0700 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 23 Mar 2023 06:23:18 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21 via Frontend Transport; Thu, 23 Mar 2023 06:23:17 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.168) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.21; Thu, 23 Mar 2023 06:23:17 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n0e8lHs/oCtjWwS/HtBkEcXW21W9+B+wAfM6ECn7g9iY2zHrIipAwzSxwJbs/xU21gb2Ljn8JT5ufBu+mQuyVavzCoN6A8QBDZWCmYbDAuMayM+EWFU6wkJYP7G5e+BP3SZt/7fejGNSsQbkQMw/8xLOD26poaN1np0Xxf66LYruVUvIOqJafujIOKW8hjziICOO4mSJLTOqMGs0IDBQJVYb5NAj3R4ycREMcZMA0y2kuLqxVklHfrpNEXO0Wb3LiPaEvKpDJ+Sr+6U1Xyqgy0BxLFFgEd2lKEOauxKMCFasxQVJWUC80TlmjsGeGqtre5uwN9T4CPMZ1EzL+SItmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fWxUOGUqNkTNQIqKgdTxf7Yr9WVXUudYuEfgtrXwbm4=; b=N9kWRe1BG7Fe1pP/fJvRNyNC/wcm5y+/kKl1XJwhLCg7Kpa5/zX0wRcknLQ7qHrc03MpLicT8Op/yiykVhNBkcxNNu+wmISjCn1maJD4zA0NlnW/lllGf09nkukDQYvGi9voHmjGLn0GRqsZ2MfZASY3zCgGd6BiecKQK8ujD7V+5LmtbU1+pKG0iPKZKlhz8rP3katmL0avHatT4/3ByypXsXd8NQ6fxtcsKEgSIKdiy0HZEcwj63IvPlHJxiBKhecUYae9xWbDT210+xvMq+GycpUF9A9VNwhGtAbH7Pnjm0opZ8JVC3y7ZjKQ9SK68/RozWecnxYl5PeobcJCOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from MN6PR11MB8244.namprd11.prod.outlook.com (2603:10b6:208:470::14) by DM4PR11MB5971.namprd11.prod.outlook.com (2603:10b6:8:5e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.38; Thu, 23 Mar 2023 13:23:04 +0000 Received: from MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::ae07:e96a:4a24:8a69]) by MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::ae07:e96a:4a24:8a69%7]) with mapi id 15.20.6178.037; Thu, 23 Mar 2023 13:23:04 +0000 From: "Ni, Ray" To: "Tan, Dun" , "devel@edk2.groups.io" CC: "Dong, Eric" , "Kumar, Rahul R" , Gerd Hoffmann , "Liu, Zhiguang" Subject: Re: [Patch V4 14/21] UefiCpuPkg/CpuPageTableLib: Modify RandomTest to check IsModified Thread-Topic: [Patch V4 14/21] UefiCpuPkg/CpuPageTableLib: Modify RandomTest to check IsModified Thread-Index: AQHZXVr2SIX74oRaLUuFad/ITmyUWq8IWmug Date: Thu, 23 Mar 2023 13:23:04 +0000 Message-ID: References: <20230323074057.549-1-dun.tan@intel.com> <20230323074057.549-15-dun.tan@intel.com> In-Reply-To: <20230323074057.549-15-dun.tan@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN6PR11MB8244:EE_|DM4PR11MB5971:EE_ x-ms-office365-filtering-correlation-id: ead69e34-ff38-4ff1-a178-08db2ba1bbc8 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Ny8D9wypFfuSmBUhcAnY51MAkP/j63JYK/neT8XIXV/CxSLBNN2LoPvrfjMeNaO9bljBk00I5HZA7jpU9s6iw1FuJXLjCWSzIgRNEtY839OygG8UMS+LKuchcnGPokvfFTZYYxZKE9kD4KwgLrIxnio70+tUHA7QNSHK20DwtGhACcF+gUgP0hVWgN6xNp1/P3PFmzQP45BvnseuNr5nJnDmlUB4zQv4n0iqb/Yla3SshLUXAO1F1t6/v+1qHUL/oNA6dEn8woCHKUmAHtJTFiKIxrshQcT4E/LZ7bQn1XkQJq2fJH/y9lMqyIZ+v5Ow9IkQpmYdMVNKWLG2kE7ugEe/yusIcGSdHY8TeNAVDsIod1F3l278iOfwypsU1Br1GBZyQdqoMFCE0AMU3038hEfohNegmFh6OXgYyJG94zfl5yHje/1g6Q09CLU4VaECmYp0I7P0SWO/jc1QT9l/3Y8gWzJmtwrektKdpC4YZ08vwtxBRrRRAtrmrYuOIMfg3M9G0SeheEs8TEUAKiYiJ00PT4hm6pZt1/D4J6ZBaXlKp5Iy7udnvohdj1Utrkm5Z/VITBOW6iJVdCEjCfU8dx91Uio5RJBnkjVmnmk9jFEQ3qQvzSdhR1iEed/wf/MPzJY1QhATBGQYCCvvFn6dIEM7zvqr+j3P1TtPu3xA+S+j0GWyl+EsMeOKjC3MkFACy6cknRz6VCRwHDMUPjcCoA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN6PR11MB8244.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(6029001)(366004)(376002)(396003)(346002)(136003)(39860400002)(451199018)(33656002)(107886003)(6506007)(26005)(53546011)(186003)(9686003)(110136005)(54906003)(66446008)(41300700001)(66946007)(66556008)(66476007)(316002)(64756008)(4326008)(8676002)(71200400001)(76116006)(478600001)(5660300002)(7696005)(8936002)(52536014)(38100700002)(55016003)(82960400001)(122000001)(86362001)(38070700005)(83380400001)(2906002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?kNFl3zVKbn/gVMSF7ZgWfPfwQbsO4DDd8beRq32m31bbu23ZyOZY0E6PvNXg?= =?us-ascii?Q?g6LYjqasu3f2QJTNgAzBJHbX0gtFdTDauR9ca1lxT0dYxqOukCFvLzgpw2fS?= =?us-ascii?Q?Zh/8Ho60CNWHUHpGc52Io0bSad0RPuUHTzDbf002SpM3gRYLEAaEd8RS/Qh8?= =?us-ascii?Q?dimE6BNCvM0tVP7r+TGMLhf2tu8YgDICHjSXww6FiLsCC3XIFyrbRYeZSJb7?= =?us-ascii?Q?H/9VDRx4ClbNFDmEBUWYJEwCP/O20FNjOB5zkcpzxdWDsly0hgitSUDIXSwB?= =?us-ascii?Q?P+j2y6vGDvAoSwkDwHR1tBrRqYwMRrluztVkRgcS+l2Yx8ZCPR17fWCNRIbl?= =?us-ascii?Q?FhXCC5QoskfZBx1z9wiWRBcAI4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aMJ5ZqNZgmtOxWYa1E83s2eQ7JtMjjKyD7bMSvFRtKgg8MISvI?= =?us-ascii?Q?umOaVG1UOJykslNqqwXUyRg2yI9LuhngjfrJiyFtWs3YlYPE8/j6wmXqQ96D?= =?us-ascii?Q?Lmmeuko7HKuTmP8MF9cB9EKEjBkAsZKmDEt8D9VaaFbe5D1x7/HK8h9cC56s?= =?us-ascii?Q?ktelb/JYUyxJ3npSr70O6N05K41dgWQuMdxF6c/iKx6HNhkrjPvO8M8WJ6eT?= =?us-ascii?Q?d0pSS509gk8AhJljLGdSX+Re/YQbr8nTDqsiKBZByjZA28wtFJgPHaZSgj9N?= =?us-ascii?Q?1I+E5l+gbvrL40NrwASW4/sEI/JKq7XbNslj6L57?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN6PR11MB8244.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ead69e34-ff38-4ff1-a178-08db2ba1bbc8 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Mar 2023 13:23:04.2961 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: aFUtuH6zFsfN0tlNXf8NvZtMJd4QNexOO2hrQww60U7jwfDRRKnUGAwq32IUPr4N+y4Sh6nzJ9E8R31mPqtDSQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB5971 Return-Path: ray.ni@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ray Ni > -----Original Message----- > From: Tan, Dun > Sent: Thursday, March 23, 2023 3:41 PM > To: devel@edk2.groups.io > Cc: Dong, Eric ; Ni, Ray ; Kumar, > Rahul R ; Gerd Hoffmann ; > Liu, Zhiguang > Subject: [Patch V4 14/21] UefiCpuPkg/CpuPageTableLib: Modify RandomTest > to check IsModified >=20 > Modify RandomTest to check if parameter IsModified of > PageTableMap() correctlly indicates whether input page table > is modified or not. >=20 > Signed-off-by: Dun Tan > Cc: Eric Dong > Cc: Ray Ni > Cc: Rahul Kumar > Cc: Gerd Hoffmann > Cc: Zhiguang Liu > --- > UefiCpuPkg/Library/CpuPageTableLib/UnitTest/RandomTest.c | 45 > +++++++++++++++++++++++++++++++++------------ > 1 file changed, 33 insertions(+), 12 deletions(-) >=20 > diff --git a/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/RandomTest.c > b/UefiCpuPkg/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- > >Maps[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_MAP_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 * > sizeof (UINT64))); > ASSERT (KeyPointBuffer !=3D NULL); > NewKeyPointCount =3D 0; > - GetKeyPointList (MapEntrys, Map, MapCount, KeyPointBuffer, > &NewKeyPointCount); > + GetKeyPointList (MapEntrys, Map2, MapCount2, KeyPointBuffer, > &NewKeyPointCount); >=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, > KeyPointBuffer[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 > -- > 2.31.1.windows.1