From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.71110.1679574366409571336 for ; Thu, 23 Mar 2023 05:26:06 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=BTXVIZVI; spf=pass (domain: intel.com, ip: 134.134.136.24, 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=1679574366; x=1711110366; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=u9wbsyGwy/tVHDOFvhBS44WBONRugS/kgzpCD4Y2rJ0=; b=BTXVIZVIhRmERA5jN9lp/jcvAxJon4z3Ca02dHhj9XJLjndrJbcKyVbG v5xvflWGU4TSWLCdmNlE124gJJQXZbnpjwgrsy+Zr8lpzYhM2ZXJRM1X/ MymSpS9bQYLYSetFGYtBg76PtQ1sywekpF4TkSMaPyLMnc/MuBDMF4TRQ v+1iJzIUCPoF59g0SPYfzMGtnLtqbZoj1mM3fFmEFO7ziGCoehEWd3s3g t37x6nZA1tM9X0leujIJeyDPiu+4aYrPStoJLkvbAWNGe87TLTwbd8P2D +jtsmOYMD32gqQwLVwrrukaUJoyiBVmciQknC0rVCaJHsThG/NGGfvWL1 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="341009711" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="341009711" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2023 05:26:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10657"; a="856464024" X-IronPort-AV: E=Sophos;i="5.98,283,1673942400"; d="scan'208";a="856464024" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orsmga005.jf.intel.com with ESMTP; 23 Mar 2023 05:26:05 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX602.amr.corp.intel.com (10.22.229.15) 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:26:05 -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:26:05 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.174) 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:26:04 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FGaY/QZEv6UiwwZiRxbacOJW8W0g2AqDAZWlrgE0d1Ip9vNbAe485qzkJocKwhMbPHpt2w0W288nFLYH4JA4u1Ei+ObZzDkPIZ0y8GpKxQfatXOobNGM7nh27qDcYYC1xog4yEIr84sbkGoQVgi6SQjowAY+JROSpRVMWjxwMfPc4J8iox9QPEMA3s19vqBzMmqgDIqfFfdUO84KD+/DmiUXzmiKlgG2SZJIjx1dvCUOpDSmFP1WPcxKsUQ2keFM8zaczoRh/nZCgwABQOe4Wpmyvr7R2D+nq14QmU0Z3uEV5+88oh17v7jo77T13TsCWSvyU43Jb3DiPU5rMK4mlQ== 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=KrMbZGduNkbOfBnqteJMTsRjpPoa/2PcheJAna9z8VU=; b=GvSU7XzCVo2HOsfuJLaxUpwdeEj2AD++n26q2o4G+BzyGflMGkA+fJTLqpASY9FoAM27K7V9R9bgGmlctbhPvNOJot4t2ev2bthoW99gVyPxd0Qk/vE+AKjNVROnpL8cAoZxigXizirYVq2b99CDkM8doJA9U/e4LtCYJohbElT0o4fDVh6+gHsgQq2kkMz4i4U3CZgAuMfNdljxnpz/pQlgHMa9/oIZV++qGNjcgsUi8ARTdJc2Yw6O0lwmeJ/k9HiASU7LyGU/dc2qxAmDF7iqCP6kS0CancBRqb3ZgBO6dmeeJOSsqHKMPWgpq30gNjXQvYerLNg4UwB3tXnTzQ== 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 PH0PR11MB4853.namprd11.prod.outlook.com (2603:10b6:510:40::20) 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:26:03 +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:26:02 +0000 From: "Ni, Ray" To: "Tan, Dun" , "devel@edk2.groups.io" CC: "Dong, Eric" , "Kumar, Rahul R" , Gerd Hoffmann Subject: Re: [Patch V4 03/21] UefiCpuPkg/CpuPageTableLib:Initialize some LocalVariable at beginning Thread-Topic: [Patch V4 03/21] UefiCpuPkg/CpuPageTableLib:Initialize some LocalVariable at beginning Thread-Index: AQHZXVrdD3EDj1Z/A0Ch4wantN2jFa8ISn6A Date: Thu, 23 Mar 2023 12:26:02 +0000 Message-ID: References: <20230323074057.549-1-dun.tan@intel.com> <20230323074057.549-4-dun.tan@intel.com> In-Reply-To: <20230323074057.549-4-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_|PH0PR11MB4853:EE_ x-ms-office365-filtering-correlation-id: 92b6f9b5-54c8-410e-367a-08db2b99c468 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: XxaRDAQJjgM2zzz9fdc4YSsegHaFuID/gPAkmTuaUAex9kMSAJmHbzl7dfudWL+tjKUjiXT//sONKNZIkwQpSukVK8KySrJGkzZzLfifd1edzTP+wCR/aITWJj3baupud32OaDaC5zjDRZEMcx3S7kY73p8qSx60je/eqQAM18BMd771gsrxV8qDA3fTnsUrqkSUDb91bsWo3p4yZK+F6y5vAzr8ZGk1ccH7UgF18S2xCILQfCFyj+xAFmQlIZwknTCY5vFE/l9CciqY+uFKwk03bfNYGdhWiKFyx6orY9nyLlKFo9jZO0GKlft/aJBV7+IWzaZGKt37HBJupItMxiKwZlhAj59Eu+cJTnOtD2GDltwe6bLnkUJ+J8hZcOLnu0Ng5nGqwxiFKi4ctq/wI2iMgdpjnQuDmSPclP9gogZyxK10g3k7ZEKKPXpuFSngG3uefCqqyIAhd9C4byq6+JUhCPbfRDRqsSAkjjO7fUoHYw6IBhXyZ+yVWoFpMcrLjeUYavuAg31kXYsSfs3SMlEhmfDBixB6/fSXKI3E9a2kuIzoPgQOwganjcKOKd1BuM8iUKtlKHhx+gCGezzTF1107hKYwZZY67JPnndzOygpXB0u1NaYLo0jBF5xQ1dLOl1g6R+jyADPk/IMLc88kXxMLi2e6RpdF4VL6/M1ER7L3VIg/bzJbU1fkOKeuQWSNJadSF9iQXXUUgBJrnUkSQ== 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)(39860400002)(366004)(376002)(136003)(346002)(396003)(451199018)(4326008)(76116006)(66556008)(66476007)(66446008)(64756008)(8676002)(66946007)(110136005)(316002)(19627235002)(54906003)(5660300002)(122000001)(82960400001)(41300700001)(8936002)(52536014)(53546011)(26005)(6506007)(186003)(9686003)(83380400001)(71200400001)(478600001)(7696005)(33656002)(86362001)(55016003)(38070700005)(38100700002)(2906002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?gbvMWW6loq6rB8FJZ83zAbpJKkV2e+qpfrYVlGnTdv0wQnjkDT7skPVuch77?= =?us-ascii?Q?0LIio9U8Lhp7yp9xDZMb3qxNz4OB403DOVVgIXA1tCkZQmRn8tozSQHvoGEQ?= =?us-ascii?Q?FaXJoRXHa7OqMI5wfi3tQn7gA2E8gqsXoFI2C9fK0+DkDg5moUVtMROyAhgw?= =?us-ascii?Q?3lLA/Qnw5bS/DzWBBGyRvmjxRa4xEzV2RFhbNX/YCu8wqB5QaYHUdtGcR6Yv?= =?us-ascii?Q?/wcOtB895uIYpjbAsOU27lwfEH9Hca+xTMogfsMN3o+dX52qWaAi5y3srJOW?= =?us-ascii?Q?r5VZ/SGg/ixEk1p7b0mOauP+1ZlH4wERrDmhqwvCaJ4ypfobSV3sQwtx6Nlb?= =?us-ascii?Q?GpeLIji8UoHhwrpl9fOg0Yh/8j9wDiiWemDgdock7K1x7Wm1Sv8zYwdMczn2?= =?us-ascii?Q?/7f6eIFjIyb+r3ioXkqwg8r4rlDwlN0ARCJezy9Iy0kfN6lMpC6Bh9G0ozel?= =?us-ascii?Q?xJ/ymYjWkmCoLjIG20oaFs5DI/90N5pQIRdrV5ribzPwmC56xn87GQ54COY/?= =?us-ascii?Q?1sQIRhPD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2?= =?us-ascii?Q?ZTiZ5b+GoNfUgBFz3EVj39vsPzZrr3BZvRiAw8a9BnVKm/okbhBPGi08JaiO?= =?us-ascii?Q?2kUzQ/4EClPTeOCSpxa2cKrKv/+fReSwaDyQFEBgEaVfOjy7PXwHKzVUkSwr?= =?us-ascii?Q?Mf4a5VUfnwAHbr9iP1Y=3D?= 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: 92b6f9b5-54c8-410e-367a-08db2b99c468 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Mar 2023 12:26:02.7586 (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: EYoVCYv9HzBwT+061BIwEpaFiTdAPcAD54ljF/dgJFx6MfAfBVFxVV/OxucqoOC3P5bIDnxVo0Kuzi+P1Y9Z1Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB4853 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 03/21] UefiCpuPkg/CpuPageTableLib:Initialize some > LocalVariable at beginning >=20 > Move some local variable initialization to the beginning of the > function. Also delete duplicated calculation for RegionLength. >=20 > Signed-off-by: Dun Tan > Cc: Eric Dong > Cc: Ray Ni > Cc: Rahul Kumar > Cc: Gerd Hoffmann > --- > UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c | 21 > ++++++++++++--------- > 1 file changed, 12 insertions(+), 9 deletions(-) >=20 > diff --git a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c > b/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c > index 218068a3e1..127b65183f 100644 > --- a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c > +++ b/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c > @@ -258,6 +258,7 @@ PageTableLibMapInLevel ( > UINTN BitStart; > UINTN Index; > IA32_PAGING_ENTRY *PagingEntry; > + UINTN PagingEntryIndex; > IA32_PAGING_ENTRY *CurrentPagingEntry; > UINT64 RegionLength; > UINT64 SubLength; > @@ -288,6 +289,14 @@ PageTableLibMapInLevel ( > LocalParentAttribute.Uint64 =3D ParentAttribute->Uint64; > ParentAttribute =3D &LocalParentAttribute; >=20 > + // > + // RegionLength: 256T (1 << 48) 512G (1 << 39), 1G (1 << 30), 2M (1 <<= 21) > or 4K (1 << 12). > + // > + BitStart =3D 12 + (Level - 1) * 9; > + PagingEntryIndex =3D (UINTN)BitFieldRead64 (LinearAddress + Offset, > BitStart, BitStart + 9 - 1); > + RegionLength =3D REGION_LENGTH (Level); > + RegionMask =3D RegionLength - 1; > + > // > // ParentPagingEntry ONLY is deferenced for checking Present and > MustBeOne bits > // when Modify is FALSE. > @@ -353,8 +362,7 @@ PageTableLibMapInLevel ( > // > PageTableLibSetPnle (&ParentPagingEntry->Pnle, &NopAttribute, > &AllOneMask); >=20 > - RegionLength =3D REGION_LENGTH (Level); > - PagingEntry =3D (IA32_PAGING_ENTRY > *)(UINTN)IA32_PNLE_PAGE_TABLE_BASE_ADDRESS (&ParentPagingEntry- > >Pnle); > + PagingEntry =3D (IA32_PAGING_ENTRY > *)(UINTN)IA32_PNLE_PAGE_TABLE_BASE_ADDRESS (&ParentPagingEntry- > >Pnle); > for (SubOffset =3D 0, Index =3D 0; Index < 512; Index++) { > PagingEntry[Index].Uint64 =3D OneOfPagingEntry.Uint64 + SubOffse= t; > SubOffset +=3D RegionLength; > @@ -425,15 +433,10 @@ PageTableLibMapInLevel ( > } >=20 > // > - // RegionLength: 256T (1 << 48) 512G (1 << 39), 1G (1 << 30), 2M (1 <<= 21) or > 4K (1 << 12). > // RegionStart: points to the linear address that's aligned on Region= Length > and lower than (LinearAddress + Offset). > // > - BitStart =3D 12 + (Level - 1) * 9; > - Index =3D (UINTN)BitFieldRead64 (LinearAddress + Offset, BitSta= rt, > BitStart + 9 - 1); > - RegionLength =3D LShiftU64 (1, BitStart); > - RegionMask =3D RegionLength - 1; > - RegionStart =3D (LinearAddress + Offset) & ~RegionMask; > - > + Index =3D PagingEntryIndex; > + RegionStart =3D (LinearAddress + Offset) & ~RegionMask; > ParentAttribute->Uint64 =3D PageTableLibGetPnleMapAttribute > (&ParentPagingEntry->Pnle, ParentAttribute); >=20 > // > -- > 2.31.1.windows.1