From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web11.71353.1679576346224806340 for ; Thu, 23 Mar 2023 05:59:06 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=bCU8jmdT; spf=pass (domain: intel.com, ip: 134.134.136.100, 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=1679576346; x=1711112346; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=ggH71Sky8IzpDTN4VIuFuaVa2pjJYRhql6lKqV/y5hQ=; b=bCU8jmdTI3afXOh/Ymb19EV52W5uzxapzG/qj8Ob4OM6yy783ZcAWBU/ d28GGGZtB9fAxYug/lRG6cx7ASBZZ0pmcP4DSbSn6V8UYSL4/rGAkG0Ni LiE0ZGwzZJ4NADHvs8zMMhksmh1HCF8L5AVYhg9nipKk2lrJa1+soWoTh ZMtS3exmhGucpmhqDbxGt1QrSoGGNl38DZ0izPuznBCmmpkYXXPNGIwpi jgjwkoNVCTOtFh0mKOj/Wu/TTODo8mnmqsn7mRR+yiYZ3shODBAirM8dB weeXDA43EaGaGb2fP4MTKXY7CoT8SFqhsZIzgK1IffQzYXTJo93Btv3en g==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="404363498" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="404363498" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 05:59:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="632386190" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="632386190" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga003.jf.intel.com with ESMTP; 23 Mar 2023 05:59:05 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX601.amr.corp.intel.com (10.22.229.14) 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 05:59:05 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX611.amr.corp.intel.com (10.22.229.24) 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 05:59:04 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx610.amr.corp.intel.com (10.22.229.23) 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 05:59:04 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.107) by edgegateway.intel.com (134.134.137.103) 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 05:59:03 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kXKtkai90uMDAX2APve01Ad9z/v5qLX4bZvOnNw0t5nHFHb7tGoV+doKKYx/CgkaC3lN6FrslynabLfqpxagEHhOVijY2verGxcODDfi4HP32lTf2z4+CkUvHuPLGa5+g6HcUnuUDSxSqvDth4QZfkVsGqCCQwzu+fD7Vnvq1ZqE4CQ7bUpgws6ClOZJWvp0CmGDSgDoOGAbeKUXBbMzRi02edmkCAJBmqEYspgnAEZhm+eKZaOZc53eDfj5QdpcIXTriV41aCzcmIsSxB/K13rYpd7RGxo08eFPTFWdJ30y9tBryGglO3SzYiBM0W0Yc1nL+mFkcUwOcsJ5ywO7dw== 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=KTDiPUDHGl5mHRyqcWZu3ew85zDyfhfRlqxxuDuxaCY=; b=aNuJu6YseOrT75yC3TSZB8MpJJP1+2D0X+OzGoCr/2YWU3hK97gvPwm4kSZ+Lz+sib6r9SWLNzmVynp1CLh/v8rCUgg+/eMCta6yhgbh+8qy/gAsqusF3KhLKOX1qjNmIJig0E5Ray0yPCh53Z3x+EqNb78ne1gblWGOAb1025kLyH+9vsyKIX0BV0NxAl8bzJcrSW7MDb8zWf9wZtqMHDukOwNylAppXIYIAn8pRnzG+YCIElGuYgRJKE1Sp/1LjUGTdzyQm2lbqYqKIt3itAQPYv3Iz9y8pC8pWNqWuuCDQLafOEdryaz6XlttOfmbOeNXAAsBu6u6o0bsKDjrOg== 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 BL1PR11MB5352.namprd11.prod.outlook.com (2603:10b6:208:311::6) 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 12:59:02 +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 12:59:02 +0000 From: "Ni, Ray" To: "Tan, Dun" , "devel@edk2.groups.io" CC: "Dong, Eric" , "Kumar, Rahul R" , Gerd Hoffmann Subject: Re: [Patch V4 10/21] UefiCpuPkg/CpuPageTableLib:Modify RandomBoolean() in RandomTest Thread-Topic: [Patch V4 10/21] UefiCpuPkg/CpuPageTableLib:Modify RandomBoolean() in RandomTest Thread-Index: AQHZXVrrAKHov3mb4ECj545Iyvi4CK8IU7mw Date: Thu, 23 Mar 2023 12:59:02 +0000 Message-ID: References: <20230323074057.549-1-dun.tan@intel.com> <20230323074057.549-11-dun.tan@intel.com> In-Reply-To: <20230323074057.549-11-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_|BL1PR11MB5352:EE_ x-ms-office365-filtering-correlation-id: ccc6cfda-17d7-4f89-c8a0-08db2b9e6052 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Rz9DAhQV3M0i9cG0PcLTVpQe6PodbH4aN9cuaZEB4/Jx/Y48qta/t/hEX7WY/q51L0WJQ7lp0CdVSgDDjwIciiaH40Ni3UYMrX4+Uw+kKrsH6k/oD91Hy1nWFtdIj46njz6PKW4UzxgLpTanuV/dlesmjTJ6DUy/FaUxOAwiv2RxdFQ3ZVomgWLWy9ru3I2ZjCvfSe0yHfvJBjrR+IN+vCPqLEvpNFQq63OKWdc+sBQAeh1CkV+OBq2OF1iYB5T+FqItWM85J+eKSsanD10IB7ZYVsrzhg1+vK8r9tdnBiuUIiWiUmyzeQwf7CDUMerfHVaDe7x6oNHY2LhnDEkXaoj2pZj4zFGzuFBeZfrALIcDZvINrLn8NbXOAL4S2+QhIRZ7rISYqBhhfrRtX5JASouqhF3vAOMZ7qOsStc6s2BqrZSlp/gDBMFURWv9EmuhW8GyFKSGd4OWuCKeTYqu3DzZOpAzL6ZvqR1qzpZQDlGyydGpRFCvHVO0tquYo0TNTrLAv8Vt31Sl+st9v8LK+5RrLCg/fm/xLe9QO1RVX+L7Hi7wJPMTdU/Y2VcMA4ZFzThSXLbfZN6vd6gsNDSdjZZBy1KOagV2vADDRTdNMVkhYd8NAY44tQpoC1UfGzaKarNlUM+dzL6yDBTckZOve7DwT+ZryE770yrm4vTG1Uu0JfWD8AFZd6ryS15Fh+niQ1SMa/tQscJQFEjV6lYpsQ== 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)(376002)(366004)(346002)(396003)(39860400002)(136003)(451199018)(55016003)(38070700005)(38100700002)(2906002)(71200400001)(83380400001)(478600001)(9686003)(186003)(33656002)(86362001)(7696005)(316002)(110136005)(54906003)(66476007)(64756008)(8676002)(66556008)(66946007)(66446008)(4326008)(76116006)(52536014)(8936002)(53546011)(26005)(6506007)(122000001)(5660300002)(41300700001)(82960400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?9grA01EBk99Fkb8WRAsM643GoTgoqEAYFITUdd9mhF1dQ5IRr0w2rPQYKlKM?= =?us-ascii?Q?5DI/mFh/eY0zQcVjzMYeIZQXFo/gL9L8m9RPLj5DjGCACzRde/tSqg2CPdBM?= =?us-ascii?Q?wBYw2G12Mvl9ByxoGGC1WW7NFmzK0gyQSqE/7HHjSvPfjNRLBhqeTdY90DGp?= =?us-ascii?Q?rUGK6Yq0tTJVYd1nDn2ZwVf+g2AZjitXd3aBr9CEeCvD6EYrAISd6+0NhC5k?= =?us-ascii?Q?YCqGzcfIGmjDr8lAVfERYBDev0zpb8P8zCr717ZyPU/PpRvKCVm8rupQxfA7?= =?us-ascii?Q?YuYWRquk5E5nbqHV0uR3pe7iuKeVCu7o7jnDdFUdsAgBr3ijry2JxUaCgI4I?= =?us-ascii?Q?usDUP0Wdb6QeUUn1J3s5DAysqjy+wqp+fFCxkMA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wz?= =?us-ascii?Q?U6/QcmKrWwkHsCUbAfzfBIiqxAhbuZ+Ryb1V+3eA0kagqmMKjoXKHSq8TvX6?= =?us-ascii?Q?iUTyAiW6C/A+r4ZbQH4cTzLALLLj45YR4s6BUy5n/uHcyn1qawVQFE+xgcML?= =?us-ascii?Q?vwekYGIYs0K5WjK4YcGwUTCh+/Q00w2J0e+tv3bjyi1tRELHJuGqPsee+dpc?= =?us-ascii?Q?fGP2CANQ+3vvb44O5XsnxVPcoLFotmYKnNb9wxoCR59KngtjP33zW3EBKFlg?= =?us-ascii?Q?uWEnfCOEp1XLUVPG7NkKQMYQZ9Y3EF/IJzZBcSM+Z80Hy90SIuZW4o+JeMAD?= =?us-ascii?Q?baoXmHRWhXjGgckFTo+99ycOsgaITYgPQW4rY18O?= 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: ccc6cfda-17d7-4f89-c8a0-08db2b9e6052 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Mar 2023 12:59:02.3766 (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: FTemITyYCW/qqPXXgCUKhgUhQKhM1Gej2AdLuiY0KcEyN4Uw7JhYo3q6PVBfHsurHTT+fiMV56qcfHAzQSYQJg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB5352 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 > Subject: [Patch V4 10/21] UefiCpuPkg/CpuPageTableLib:Modify > RandomBoolean() in RandomTest >=20 > Add an input parameter to control the probability of returning > true. Change RandomBoolean() in RandomTest from 50% chance > returning true to returning true with the percentage of input > Probability. >=20 > Signed-off-by: Dun Tan > Cc: Eric Dong > Cc: Ray Ni > Cc: Rahul Kumar > Cc: Gerd Hoffmann > --- > UefiCpuPkg/Library/CpuPageTableLib/UnitTest/RandomTest.c | 43 > +++++++++++++++++++++---------------------- > 1 file changed, 21 insertions(+), 22 deletions(-) >=20 > diff --git a/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/RandomTest.c > b/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/RandomTest.c > index 97a388ca1c..52eb9daa10 100644 > --- a/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/RandomTest.c > +++ b/UefiCpuPkg/Library/CpuPageTableLib/UnitTest/RandomTest.c > @@ -1,7 +1,7 @@ > /** @file > Random test case for Unit tests of the CpuPageTableLib instance of the > CpuPageTableLib class >=20 > - Copyright (c) 2022, Intel Corporation. All rights reserved.
> + Copyright (c) 2022 - 2023, Intel Corporation. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > **/ > @@ -81,22 +81,6 @@ LocalRandomBytes ( > } > } >=20 > -/** > - Return a random boolean. > - > - @return boolean > -**/ > -BOOLEAN > -RandomBoolean ( > - VOID > - ) > -{ > - BOOLEAN Value; > - > - LocalRandomBytes ((UINT8 *)&Value, sizeof (BOOLEAN)); > - return Value%2; > -} > - > /** > Return a 32bit random number. >=20 > @@ -139,6 +123,21 @@ Random64 ( > return (UINT64)(Value % (Limit - Start + 1)) + Start; > } >=20 > +/** > + Returns true with the percentage of input Probability. > + > + @param[in] Probability The percentage to return true. > + > + @return boolean > +**/ > +BOOLEAN > +RandomBoolean ( > + UINT8 Probability > + ) > +{ > + return ((Probability > ((UINT8)Random64 (0, 100))) ? TRUE : FALSE); > +} > + > /** > Check if the Page table entry is valid >=20 > @@ -178,7 +177,7 @@ > ValidateAndRandomeModifyPageTablePageTableEntry ( > UT_ASSERT_EQUAL ((PagingEntry->Uint64 & > mValidMaskLeaf[Level].Uint64), PagingEntry->Uint64); > } >=20 > - if ((RandomNumber < 100) && RandomBoolean ()) { > + if ((RandomNumber < 100) && RandomBoolean (50)) { > RandomNumber++; > if (Level =3D=3D 1) { > TempPhysicalBase =3D PagingEntry->Pte4K.Bits.PageTableBaseAddres= s; > @@ -211,7 +210,7 @@ > ValidateAndRandomeModifyPageTablePageTableEntry ( > UT_ASSERT_EQUAL ((PagingEntry->Uint64 & > mValidMaskNoLeaf[Level].Uint64), PagingEntry->Uint64); > } >=20 > - if ((RandomNumber < 100) && RandomBoolean ()) { > + if ((RandomNumber < 100) && RandomBoolean (50)) { > RandomNumber++; > TempPhysicalBase =3D PagingEntry->Pnle.Bits.PageTableBaseAddress; >=20 > @@ -299,7 +298,7 @@ GenerateSingleRandomMapEntry ( > // > // use AlignedTable to avoid that a random number can be very hard to = be > 1G or 2M aligned > // > - if ((MapsIndex !=3D 0) && (RandomBoolean ())) { > + if ((MapsIndex !=3D 0) && (RandomBoolean (50))) { > FormerLinearAddress =3D MapEntrys->Maps[Random32 (0, > (UINT32)MapsIndex-1)].LinearAddress; > if (FormerLinearAddress < 2 * (UINT64)SIZE_1GB) { > FormerLinearAddressBottom =3D 0; > @@ -323,7 +322,7 @@ GenerateSingleRandomMapEntry ( > // > MapEntrys->Maps[MapsIndex].Length =3D Random64 (0, MIN (MaxAddress - > MapEntrys->Maps[MapsIndex].LinearAddress, 10 * (UINT64)SIZE_1GB)) & > AlignedTable[Random32 (0, ARRAY_SIZE (AlignedTable) -1)]; >=20 > - if ((MapsIndex !=3D 0) && (RandomBoolean ())) { > + if ((MapsIndex !=3D 0) && (RandomBoolean (50))) { > MapEntrys->Maps[MapsIndex].Attribute.Uint64 =3D MapEntrys- > >Maps[Random32 (0, (UINT32)MapsIndex-1)].Attribute.Uint64; > MapEntrys->Maps[MapsIndex].Mask.Uint64 =3D MapEntrys- > >Maps[Random32 (0, (UINT32)MapsIndex-1)].Mask.Uint64; > } else { > @@ -344,7 +343,7 @@ GenerateSingleRandomMapEntry ( > // Need to avoid such case when remove the Random option > ONLY_ONE_ONE_MAPPING > // > MapEntrys->Maps[MapsIndex].Attribute.Bits.PageTableBaseAddress =3D > (Random64 (0, (((UINT64)1)<<52) - 1) & AlignedTable[Random32 (0, > ARRAY_SIZE (AlignedTable) -1)])>> 12; > - if (RandomBoolean ()) { > + if (RandomBoolean (50)) { > MapEntrys->Maps[MapsIndex].Mask.Bits.PageTableBaseAddress =3D 0; > } > } > -- > 2.31.1.windows.1