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 26A979414DB for ; Wed, 10 Jan 2024 09:08:42 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=XI9kibcy1VgfKbsfVkzCd2UXtaL76F3aiJUx1QD0Aak=; 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=1704877721; v=1; b=BHD/e34hm7vb5OQdGu7uG71+Q3SQkVZI1nfGNC0BSFPUVOHY5R+KEPRbU2JNz+hw60eDQuqA 2zSnvLhQofH8JrjFxV9t2GQdI8Qc2CUI0wOn9inzymo1+BnNh4GV4i7TjhgPpiWJjltIs12Qc5v LJLPCm4/SwobNDkIJLtz6PFY= X-Received: by 127.0.0.2 with SMTP id 809bYY7687511xmFeMijBwn7; Wed, 10 Jan 2024 01:08:41 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by mx.groups.io with SMTP id smtpd.web11.8005.1704877720842266791 for ; Wed, 10 Jan 2024 01:08:41 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10947"; a="11802554" X-IronPort-AV: E=Sophos;i="6.04,184,1695711600"; d="scan'208";a="11802554" X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jan 2024 01:08:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10947"; a="905468480" X-IronPort-AV: E=Sophos;i="6.04,184,1695711600"; d="scan'208";a="905468480" X-Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga004.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 10 Jan 2024 01:08:40 -0800 X-Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) 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.35; Wed, 10 Jan 2024 01:08:39 -0800 X-Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) 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.35; Wed, 10 Jan 2024 01:08:38 -0800 X-Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) 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 01:08:38 -0800 X-Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.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.35; Wed, 10 Jan 2024 01:08:38 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oTK/SNJsGFy/TGxgXImavyrKObm1tu+YBVeJz7cbzoPvRSNefJ+ofPDi7oISzpt4qmFMJYGNXw6ybsK2PXzEqIm2ymHkL/bfjCQeo1rxYqBencDijozKKN99WOoNC4tPZvhB/8IndDQsmPJNuHn1T0bGMQPJXQDpoSE4hXxkDhP6J9nDvN+UAsxMVLXMGtWn65qfKu8l795AtpZYb8E+TJDqqfQL6tgzVpW5HohKJcoZCE8sQhXuzsMXfkgtnxR7HI/GACSVXvScY2TwlUMUbdoZOBksn0xrvYaEf6jKdhsfZNIX35tAaqJEyzZyCdG0UZ8LfoaHwz1bxQwDynFy9w== 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=JqagPHtdDtbdNnMZd2JszabLpy1Ec2Q+oxeZYWc20g8=; b=jsb12cD4uAjDMau/26Qjb2K78DHy6Lrjay9sxM/mPTjD4affpqKhj4/GD0nmUrq9hIrlkCRRcPSKW+IgVAtUuzO9R10rC75x8XvhvMhlrbfa+/flMOmgQbUGGQLI1LZ9hqXia4ZBw1S/N5KxEtteeoe4NaesEWMnTg6aDvPf49eYh/9OZbiTfVpTKRpys8yjjdV6m5jEmH+zqvBRGO4hExzqVM9ri72K6g87b4YI/G7P9eDCzoL++JpxMQSqthDa9tAceY8VTj8cdOwm5QpUD4AVWmHnxOBL0J3E4/02TXKOERebmSlSLz+qwl20d424NcyIwgX8TDpdMEALCRDsew== 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 SJ0PR11MB5038.namprd11.prod.outlook.com (2603:10b6:a03:2d8::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.23; Wed, 10 Jan 2024 09:08:36 +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; Wed, 10 Jan 2024 09:08:35 +0000 From: "Ni, Ray" To: "Tan, Dun" , "devel@edk2.groups.io" CC: Laszlo Ersek , "Kumar, Rahul R" , Gerd Hoffmann Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg:Limit PhysicalAddressBits in speicial case Thread-Topic: [PATCH] UefiCpuPkg:Limit PhysicalAddressBits in speicial case Thread-Index: AQHaQ5vhFYd6s7/n006aYYcMoDsTfbDSweIA Date: Wed, 10 Jan 2024 09:08:35 +0000 Message-ID: References: <20240110080544.1350-1-dun.tan@intel.com> In-Reply-To: <20240110080544.1350-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_|SJ0PR11MB5038:EE_ x-ms-office365-filtering-correlation-id: c2622179-0156-4fd9-0735-08dc11bbb9c1 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: GbpHUkiU56/nmxVPIYRykyaVbzjoVSus1wsFQo8hZ8OdzDPB9vufHfHTv9aGgQoXLpIOht8hrb0ivXf5Ar6Ja59uTAUdDcZ6/0VUVzCUTuEfquW76kZddI7stdKQegRQJiF8Obz2rJvq100ngXrFEAvr76NgZF8kEAfB+1jAkv35le2lcdtzrT0ktDcaagYO7aWGJ4hKVZLBBSAg0+57ASrEweEyF9hcQE7DcPA9Viwo+bE8KlXfi4XB/kmYJSNn9LF17HpSQb5dnVewQYOhiq4Q+MO5E+laQC4sgWW4M4ymXxpojLcAX+XJuE8966R2AT52t3E4LdVqS8KU8/7l26MkvOOrPgpqUtJQRb3gkAc+amOjsfqhLfgsV3SJtfQU1NTfYw/1e0PutQt0mEhqCo3whai/VAQXqLrY6FN58UDkNz2tEGIun5W/AWIi/BdJDmF7lKGVyxukioIIJKePcc8avxNriaNCxRyHNR1rsvkBH/Le1D6yokFJhidCXeIIBv8e1cT4NnZDF1xUVlWMxtEzVkO10zEpjpsejO2XWMaHztXtFASPM76GKbM6pGrRqVoszmdpWX/3baDfM+Z31/QWQ2XuD9oBxaiO/AJbwJbUW9YjIfQGIKUox+lLHx09 x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?cehoOakL+csbi57OLddptWzlkMZZ8lpZT8AVR7iDafqWDcyAUhVGW8H0IqvG?= =?us-ascii?Q?W0flr0hbejR2K9J0VzcMrbaQ1/2F15zKCIT1jWApny9VeowZdz8mLSKcDxf3?= =?us-ascii?Q?18MXC/WjJN7vFFJOGLLwlSD4fcdvLnL5sbfZZWW3loYq/M+ba7zTkmnJVjf0?= =?us-ascii?Q?/kaZVF1mfCYCH0Z8JWZYS258m7IhzeSgk5n3Fng6Zb6A852oDET6daGxaEtd?= =?us-ascii?Q?znjfS0oc5G4c7qqr9IehrePg9xM3fgRMOfg06foTt4Euqi49NDMJLXAUtTW5?= =?us-ascii?Q?YRn4SVDrAoHTNI0ZbnJAsllHBV+nZNYCR5945NqYL7VVEdH/V39uvELfsP6M?= =?us-ascii?Q?YE8EPlrqGEzQHKkyff+LF296MBYuiUPQ8nI31/weK+mHMhIoHYAVv7GwByOE?= =?us-ascii?Q?ZIPMAWV++OjRmVXZwj72XgkhZK2nqnYyjHTb3EV9DUW3BMSsEY3kj9edvFct?= =?us-ascii?Q?VdHXprVyvfQJB05zMUkqlUV1aFLP1O4F/E1JvHfgO+sXo11kBQ9cmhj56kXf?= =?us-ascii?Q?Q4t5YE7pB9G07ICWQy8hgwU64V3qUQ0EnwIAuVE/AGUTjcB7rXSjZMNmMlOe?= =?us-ascii?Q?0Sy0Zo3BSK5DJ1Rv8ESTgkLSMSe7N0omJoaLPwarr0XYXUKkWaBdNWjmiTJx?= =?us-ascii?Q?TkeelZh1g5BzFI8kTiW3+7C27yfhnEMaLlEitBSUtzf7d21A6xuDtD7i8Jtz?= =?us-ascii?Q?VL4SUyP6q4f22cTXgqpK4xrmnvkguYAo1AprqEZV+PACj/TE2KKhPnPtHHmH?= =?us-ascii?Q?8MAEyX/y0qfB1BZu5dkepq5ytyBdHAvpYnwPd3eB9Ws2FRNokzuXXidgB1xi?= =?us-ascii?Q?v/4LZtGC8Q7y7QHIwNNXD5r4rdpPzGBYdTD6OrKHg7IrGT7a8MCTs6o+HELM?= =?us-ascii?Q?23s5T+A54AJB91HFp1og30hOiHa80KMg3z9jT/DNkZvyBH85sFABw1iUgeey?= =?us-ascii?Q?etneA78s9iGb//OKx0nQb44+xEXCupOgh6TPQ67Kt5li8OVgRn5vHraZ++UX?= =?us-ascii?Q?5H/N7TCnSjBmA2svnQqO6obKi8XpzMW5lz9eWtzUSvTqHnsHGs7Zh2lnEgEV?= =?us-ascii?Q?UOT9BL4Ede+NpvxjXBbySrEiZjdtptjSpZRNmlyX7vizITKNCeyG+GpzAi+E?= =?us-ascii?Q?VOWSxrM4cD4hYf8vuHxcUf2hgsGfFP6QS+8aKiW2bzqvluh9jPpD4RNgMyPU?= =?us-ascii?Q?j0R4mkjuZdxFRJrCBI7rYVv/ds/GA+T7+oXLW9Tu7Eb/ubBYXEGq1/s5wXpr?= =?us-ascii?Q?yQDzYSQjJwn/o840yB+goxSIiaPG23t7tzcS1fzXhjxNalVo93pBHiiWUMG7?= =?us-ascii?Q?DtEdwReh9Wsc7Poc8+TOXw61CLDsHUBHUD0p7eIr60H0jaxiSgQ/93eVfMZH?= =?us-ascii?Q?K78FqgaE3RF387Bdw3231qcUViaFTLr5RHBmPkpMblRoKgO7PpOiYHXTPYzL?= =?us-ascii?Q?lhZc7hdFyYsywDEHeAw06ZDQ67FyoB7IceyQQiMeCMB3VaDs50ZDMyT4lmFI?= =?us-ascii?Q?lmBXSJ/7R90ziFPYfwHViLr6mR/RVgKYg3TPllo5C3223Lx+GXyuQmIn/yh2?= =?us-ascii?Q?b4eewVh+Xx8qeR0q4oE=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: c2622179-0156-4fd9-0735-08dc11bbb9c1 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Jan 2024 09:08:35.2607 (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: NqtuKWTNd94OYOSMG/R4d/y5w/cta7tw7YoUCAShxuFcSRdnDGo3JGeEzRe53nq9oJkmHnegMsS779RdczUpVg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB5038 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: 6mtJ46Zq3SPeaJt6hJk9kdNMx7686176AA= 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="BHD/e34h"; 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: Wednesday, January 10, 2024 4:06 PM > To: devel@edk2.groups.io > Cc: Ni, Ray ; Laszlo Ersek ; Kumar, > Rahul R ; Gerd Hoffmann > Subject: [PATCH] UefiCpuPkg:Limit PhysicalAddressBits in speicial case >=20 > When creating smm page table, limit maximum > supported physical address bits returned by > CalculateMaximumSupportAddress() to 48 if > 5-Level Paging is disabled. > When 5-Level Paging is disabled and the > PhysicalAddressBits retrived from CPU HOB or > CpuId is bigger than 48, only [0, 2^48 -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..e6f174ca10 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 neede= d. > + > @return the maximum support address. > **/ > UINT8 > CalculateMaximumSupportAddress ( > - VOID > + BOOLEAN Is5LevelPagingNeeded > ) > { > UINT32 RegEax; > @@ -164,6 +166,15 @@ CalculateMaximumSupportAddress ( > } > } >=20 > + // > + // Only [0, 2^48 -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 > 48)) { > + PhysicalAddressBits =3D 48; > + } > + > 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 (#113519): https://edk2.groups.io/g/devel/message/113519 Mute This Topic: https://groups.io/mt/103637402/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-