From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id C8A6FAC0A2A for ; Thu, 11 Jan 2024 03:36:34 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=t7PHsmsN0grbiliocVly3yC6NWlQdm1F4i4/EVOcNQg=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1704944193; v=1; b=lSmf1HaEec4FfiZ81Cz4D5DyN+GHBe9RtSzM1oXWYPE7r1ZXhorhmvmXA5LgLfCAUIlofYkS 814zmnknXjJu8ogguc3xRAb74YyAnEzkoxxF9j70V5wnsxA3fBKO/gODC5PUQTwJDiFf7xTOuSD l5vei+NoRvS44nmX/+U+1WU8= X-Received: by 127.0.0.2 with SMTP id 2rYjYY7687511xr3vBWT25s8; Wed, 10 Jan 2024 19:36:33 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mx.groups.io with SMTP id smtpd.web11.4277.1704944192616410751 for ; Wed, 10 Jan 2024 19:36:32 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10949"; a="17325945" X-IronPort-AV: E=Sophos;i="6.04,185,1695711600"; d="scan'208";a="17325945" X-Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jan 2024 19:36:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10949"; a="1113683413" X-IronPort-AV: E=Sophos;i="6.04,185,1695711600"; d="scan'208";a="1113683413" X-Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmsmga005.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 10 Jan 2024 19:36:31 -0800 X-Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 10 Jan 2024 19:36:31 -0800 X-Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) 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.35; Wed, 10 Jan 2024 19:36:30 -0800 X-Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Wed, 10 Jan 2024 19:36:30 -0800 X-Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.101) 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.35; Wed, 10 Jan 2024 19:36:30 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E37yRIjYkEz0JCI9cLNyoDL5CGLKzOIXAQDQkJ9QaA3fO2eDe932ntxI2JMuN3B5eFhpAvjfGlRlNkx9h4IsHBTtWRiaw9vMnBuzl0zb9u1xEX45uty4G4XjNEB2C+kXHDGSKRW1U03lt+gGCeOpno2SjLKV8g+LcQM2sVwRESmMpnop1Wu1pbDzuzdiaL5D28Mt+k5o7lc3UX5S9+PFASrX4vtIi2mhvykEW9vgrxWcyD+MKAaBXWcB9Hr4rAch7u7e7uzOpRxI49X3ZOpn5yCY1zHsIDEoPNk+PMIr2Ckfq4MSKuG5Q2mj/4/n/j2OqqSxDDYxZaxYy1A8reRysA== 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=vPbsE6E2kcbF3QAW6fejjFjjeatzJ0Mz7nma68rGXIE=; b=kw17wxdrPWuXfasZNEu43rs3LZ4M8ka1LkyygYY91Lw+08J/G0iZx8YS7GryfvpjlM3oTdQ6IwehLhXJ5H9/sBWjmSYY5hn3LpTPeA8aMm5iaPC0Bhu3RyGwNp9pWtEoSRPQ0NQFhcfnBdY6j3LBM7GKI4bMtel6+5L1MKXxdegY6D9wPiNHF8kpaTwodNE1HtCLNQTC8HlyubhnFcg0wa3+r/xQgTviFZUuWGm1aNNlio8mlPx/jwqAOPeqyvIvnY/tdBE9QBpiUeTGl+lHLpQm3Yg8StO/q0IMchxB9orxj5FfUdhcaZLHcV2kcEUGgLsEBUkYUgwElsOfJZNEmQ== 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 X-Received: from MN6PR11MB8244.namprd11.prod.outlook.com (2603:10b6:208:470::14) by CY5PR11MB6236.namprd11.prod.outlook.com (2603:10b6:930:23::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.13; Thu, 11 Jan 2024 03:36:27 +0000 X-Received: from MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::3fea:ca2b:2ef7:e3d4]) by MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::3fea:ca2b:2ef7:e3d4%4]) with mapi id 15.20.7159.020; Thu, 11 Jan 2024 03:36:27 +0000 From: "Ni, Ray" To: "Tan, Dun" , "devel@edk2.groups.io" CC: Laszlo Ersek , "Kumar, Rahul R" , Gerd Hoffmann Subject: Re: [edk2-devel] [Patch V2] UefiCpuPkg:Limit PhysicalAddressBits in speicial case Thread-Topic: [Patch V2] UefiCpuPkg:Limit PhysicalAddressBits in speicial case Thread-Index: AQHaRDOFMOht6LuDMkeuyCxySYeSH7DT9g0Q Date: Thu, 11 Jan 2024 03:36:27 +0000 Message-ID: References: <20240111021118.1453-1-dun.tan@intel.com> In-Reply-To: <20240111021118.1453-1-dun.tan@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN6PR11MB8244:EE_|CY5PR11MB6236:EE_ x-ms-office365-filtering-correlation-id: 9bcebea5-e086-455f-04f2-08dc12567e50 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: iUhs7wxWBAyq5dEbw1uL+QXJbmGQeLxwJ1qahsheSPD11DtDRr+GBluzDwnMktuLkfALwylJwkcNAaTrTUu28qvQilhClhvKr+9yAhElR5gCJyBPWS2KJye3LdgK7Wd6kXHcgEx1WXv1wYf8vBQ0H++nxs9PRNnrJOSt//alYm+ZpNnjeW3IxlFSU/0OWrNF4WLPlh4IdUTwRqQT+6e++i4/j2x/wQXLPeaCkwLs+NxPtBm7a5jn/5l2X1OfaplrL3A5FEqF5rE70OuS0H7fRO5PFCUFSDhmz4DnbnyxI2v1HVgbqKaGUqy22t4EQ06uu/hBIop/tO4lwGlHlc43mKn0N4/OauBsTPwGaYwg7Y0XycKq7V3ZDCCI0s7NJYRpePLzYG79RHGI9HqwXwpglUEE+vg/urAgoUWKtOk07JLmavExZz+cGUYTL1rArOKSPW4gmOyOJOAq6zvR28zG2q+5LDUocMI7wy2/QPkVWDurbg84ZJqMLypQagXICizRhMoPXnxEyQ8VA8+EvETh6eQbMvTijQLLAgK4BATtAcqtC7riqttL5IlHvE0dotquX87ROHg8BxEMxLpvAnNW63FqZ5/yy/L7NUgTmemTBEeZEEYRk6z0uFNbl/RENW5v x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?y6p4haI8FdDlUT6dvmZ11mK/HPiWt0QKK+t+0CsVukReEdC4KnRoUv6uhHf1?= =?us-ascii?Q?Pg2iD1irjXwsfty0noUoorUqbiU2vbllAY1puqDA35Sxr1407uOhhMTWJdxW?= =?us-ascii?Q?+WuCEhmeiasy3IiEoKKqk/EmED6bMuRQVMBp7oWwZbIqdUPGmsVSQv7UtC/A?= =?us-ascii?Q?c5VrBMdqVvVKwLGA1n06lvavxaA6ktMp1+1ekCddkbye4L1/HCZwniU2P+Ke?= =?us-ascii?Q?ga6HBuS45w6tj4poWP5Nn64nraNTg5b7nqUmqjTr8SUpE7DABjXUvC0yoPVC?= =?us-ascii?Q?paCQHCaWH9Vjkmdp3jXYULUyXgLV3U+eS7zI9nUasCrwWsWX/1QqQbookWjD?= =?us-ascii?Q?7YAhONAv4LKrM+sHkhVwB1/pDPv3dN95uq88mauY3r+l3eJs0hXz7Si8ic5P?= =?us-ascii?Q?71Xi/IQE7BZTmLX6X8AJt2On5HTDnPvFtEA2B0vqm4fbZChpsP80NBu+mVMT?= =?us-ascii?Q?wdK6Y9R3y/L62YcNmSwR+kIqJ9Fvxv2Mgm6IoaFCV68dR/D1zE4Sk8dT3J6O?= =?us-ascii?Q?xMCBXFlmF5dwF15j/MqD38pyRHwKwM1QPreGYLve816c5htYjCXUd+VORbyV?= =?us-ascii?Q?ozB2uoGe02CfG8BfYccPr0eP3fLPTo6s97Yp2P1/uLZJ/l/2WWQhl/Z2e0lg?= =?us-ascii?Q?KW6DYUsvFgtxaJfeOHslb42iVmJ4SsXv/lRDvqV3U7XZieUDMYVzCWN1/+Ka?= =?us-ascii?Q?VPPKme6eTfrvP5t31NVUTyZ64LP7238aGRjIKzGjGIos6CITNovQRn9S7Z94?= =?us-ascii?Q?jStt3ELKkHnLHGJyIW7f3RLzbGNmSOpAdu1d+/Q9QJIeAVzVTErUD3aL3kv7?= =?us-ascii?Q?BtyuWvT6yovb44q8Cb+CduVZMWaKOgoO0uN0EA6CppGJUQHunj9tGfNeE5Up?= =?us-ascii?Q?A+GO6eFL7Gb+2+56Jn77IMwbpaf3LMAld4MZMtVZes4XxqpfeyMtwBj4FaTm?= =?us-ascii?Q?x47MZ5jKk2O3Hh0I1WaAx4Zd9TloRmgWccb9WD2WlMQCZkVlFVyrQ3ZJUgYb?= =?us-ascii?Q?yLAJDtW3NyOVLgYkMnemtiWRTrzHb8RTsevP1v88xHSxdQ6kmfnvF3FcO3D7?= =?us-ascii?Q?wrHSuapiJ5+qV2ketZTKUei4zK3afI+4d02a3MFIvmakD1wFZ64kujvGxDz+?= =?us-ascii?Q?ZLZWNJrOp+U/S4lor4vqdc4Re7pDuhT8qjdYGLc25TXGGkUKLgtUQ/LCpdtw?= =?us-ascii?Q?GGMEFTMSVWeSqV0nxiWLTw5Dcop3nBiCVMzqBnxaizxBpcn8AODTCdAth4sS?= =?us-ascii?Q?gOM9LWHw/zKsQWM15LnbCFP+z6NJvo6r7dh20R67Wzj3OLXqNW/2ZkLW4w6K?= =?us-ascii?Q?qifGa+ewT85vsP1xBNP8OUIPsohTD0qdjHW+M9ImzzwaWfEl6OuGZUNb9Djr?= =?us-ascii?Q?xuMzBicJ0l8h18eZmNddaqoU2PTHqU9Scmeg9xIRKD0V6a8YvYWnaVYpNru1?= =?us-ascii?Q?Ud2E93iXdau7LjAOyC9OvrOvgTzSKec+yPy56hbWHhCNFP61nPm8SRYBiBDL?= =?us-ascii?Q?Vqw2/lcZYDnpjbDh1OUfKz3JGCYBMGYrwKM/R+UVkpvyG5C7XSf2pFwcZU+c?= =?us-ascii?Q?hkeS8YziT6Okrx63lBE=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: 9bcebea5-e086-455f-04f2-08dc12567e50 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Jan 2024 03:36:27.5221 (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: XWVF/Nv+3tTmsIJDcdLPgLmxge47CaSq1j3pJuq7VEfIGQ2Rtl9b+Z6xvDMndKPnuEULbqswogqDrCQL5eHcxQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR11MB6236 X-OriginatorOrg: intel.com Precedence: Bulk 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,ray.ni@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: VL4VVLIL3FR4wIqSnUOL5vuLx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=lSmf1HaE; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Reviewed-by: Ray Ni Thanks, Ray > -----Original Message----- > From: Tan, Dun > Sent: Thursday, January 11, 2024 10:11 AM > To: devel@edk2.groups.io > Cc: Ni, Ray ; Laszlo Ersek ; Kumar, > Rahul R ; Gerd Hoffmann > Subject: [Patch V2] UefiCpuPkg:Limit PhysicalAddressBits in speicial case >=20 > When creating smm page table, limit maximum > supported physical address bits returned by > CalculateMaximumSupportAddress() to 47 if > 5-Level Paging is disabled. > When 5-Level Paging is disabled and the > PhysicalAddressBits retrived from CPU HOB or > CpuId is bigger than 47, and since virtual > addresses are sign-extended, only [0, 2^47-1] > range in 52-bit physical address is mapped > in page table. >=20 > Signed-off-by: Dun Tan > Cc: Ray Ni > Cc: Laszlo Ersek > Cc: Rahul Kumar > Cc: Gerd Hoffmann > --- > UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) >=20 > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c > b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c > index ddd9be66b5..35c282a771 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c > @@ -137,11 +137,13 @@ GetSubEntriesNum ( > /** > Calculate the maximum support address. >=20 > + @param[in] Is5LevelPagingNeeded If 5-level paging enabling is > needed. > + > @return the maximum support address. > **/ > UINT8 > CalculateMaximumSupportAddress ( > - VOID > + BOOLEAN Is5LevelPagingNeeded > ) > { > UINT32 RegEax; > @@ -164,6 +166,15 @@ CalculateMaximumSupportAddress ( > } > } >=20 > + // > + // Only [0, 2^47 -1] in 52-bit physical addresses is mapped in page ta= ble > + // when 5-Level Paging is disabled. > + // > + ASSERT (PhysicalAddressBits <=3D 52); > + if (!Is5LevelPagingNeeded && (PhysicalAddressBits > 47)) { > + PhysicalAddressBits =3D 47; > + } > + > return PhysicalAddressBits; > } >=20 > @@ -197,7 +208,7 @@ SmmInitPageTable ( > mCpuSmmRestrictedMemoryAccess =3D PcdGetBool > (PcdCpuSmmRestrictedMemoryAccess); > m1GPageTableSupport =3D Is1GPageSupport (); > m5LevelPagingNeeded =3D Is5LevelPagingNeeded (); > - mPhysicalAddressBits =3D CalculateMaximumSupportAddress (); > + mPhysicalAddressBits =3D CalculateMaximumSupportAddress > (m5LevelPagingNeeded); > PatchInstructionX86 (gPatch5LevelPagingNeeded, m5LevelPagingNeeded, > 1); > if (m5LevelPagingNeeded) { > mPagingMode =3D m1GPageTableSupport ? Paging5Level1GB : > Paging5Level; > -- > 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 (#113575): https://edk2.groups.io/g/devel/message/113575 Mute This Topic: https://groups.io/mt/103655312/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-