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.191963.1673946092851545948 for ; Tue, 17 Jan 2023 01:01:33 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=gdNozfK4; 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=1673946092; x=1705482092; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=Tdd8yuWc28++DkhyD7KqJkmBZvvt/4f6jXWKPeITHsI=; b=gdNozfK43fyQ/uPYAd+vwXWZ1MeevVYFme9hd5QB4ryEpwwRseencDfs IW678AH4BpPi26S1HN8Emo2PRXxWfNYBmTw+faHRpCIJog+K0VdEe06HC I/TLfwbBbTFtRRrmUZ+8NPvyWvtCHxCx2IX4cWwg6vB2y+uNLsFTVSiWC 6Gj+Fz0XEXfN+LpMSfmCdaA5Ox+5lO6GiI1la9h7UXeVQVSf+KN1CyxO8 fCdT9aNx/KnC070zCfSD+dq85VmyZByNaRGtg81Qkv9Cmf2KIRxRaCvgM 4uwGQ5ksr+tIgoCsm9eh2yt9YX35HiOj/FAsKd1HZkxMA/LPMMj2ia1FU A==; X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="324700411" X-IronPort-AV: E=Sophos;i="5.97,222,1669104000"; d="scan'208";a="324700411" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2023 01:01:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="783172394" X-IronPort-AV: E=Sophos;i="5.97,222,1669104000"; d="scan'208";a="783172394" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga004.jf.intel.com with ESMTP; 17 Jan 2023 01:01:32 -0800 Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) 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.16; Tue, 17 Jan 2023 01:01:31 -0800 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.16 via Frontend Transport; Tue, 17 Jan 2023 01:01:31 -0800 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.57.42) 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.16; Tue, 17 Jan 2023 01:01:31 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NQkoxYefJJhkU+mTv53Z8vKDeRkpQp9l8MUNoMD1xC95aEi9m1wgGGqnaDVrR2XHYW5GFXekCvMuaRgCWmxlwd3ogBQf1SKGOZ/iTdguGzyOZdLyC54LzY9ht718Cp9b8x3M/jfUBzI0t+Mo5qQBoXxD7mHdqb3dDoeDBrC/8/belk9W8mMl68uh7K0MU6tdswpt4y+U7uUTZ8/kSB8HhDFiJH0BlnloAP2ZE6QSmpcPJoi4h7jP4DyX/nz1IOASSQ1UT9zq4+V6O3/6sg6L3OxNHf/7PKGLxwp2x5BcuF7NaxC2PnJ/Ry5cFiKT5bfxVmCaW9KvIVsQ6MHwDTDrRw== 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=b57raaF3V/jxbAJ1sRGb+fj3Y1tUvFJ+4aG/zOher9Q=; b=JZ6GFsO/UDWPakT0Mkf8OhhDr0NlRRJuLmhaWM0mTXM47aEF4T0eqOipo2PsNJRRR0yjaSrc9OjpTYIA98KfvYjiQkVcx4Hj3PyipGkIXf8O9hsaKWUe4NHLUzF22Ffx35mbUQlkclqMOx4//6FGOuh6bNKeelV/mCAdlufo8Iqfq7fC1AdTb5yDxirQYp1LqJzpcwzFYRRST2QCnOSO5MhH3Iz4mlrbGKnvdU0vYu6bzLcB0iIzI8FMCQpQ6Xck13cY5/XhUo1Rc18rKq9jFEbN6IRdL/YmMYExBIXxGB1ee427vH2207r6WLCkB+/xE18btXiQMMhQ4LnGi+mRTA== 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 DM4PR11MB6239.namprd11.prod.outlook.com (2603:10b6:8:a7::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.19; Tue, 17 Jan 2023 09:01:29 +0000 Received: from MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::f890:e4ec:e2d8:5831]) by MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::f890:e4ec:e2d8:5831%3]) with mapi id 15.20.5986.023; Tue, 17 Jan 2023 09:01:29 +0000 From: "Ni, Ray" To: "Liu, Zhiguang" , "devel@edk2.groups.io" CC: "Kumar, Rahul R" , "Dong, Eric" Subject: Re: [PATCH] UefiCpuPkg: Fix SMM code hangs when InitPaging Thread-Topic: [PATCH] UefiCpuPkg: Fix SMM code hangs when InitPaging Thread-Index: AQHZH/9P2T/UYdbjFEWXX0eG9sRu/q6iZIbw Date: Tue, 17 Jan 2023 09:01:29 +0000 Message-ID: References: <20230104054118.280-1-zhiguang.liu@intel.com> In-Reply-To: <20230104054118.280-1-zhiguang.liu@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_|DM4PR11MB6239:EE_ x-ms-office365-filtering-correlation-id: 8ea77b9c-47c0-4888-1401-08daf8696bfa x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: kTvuaQKjJPRWKU+qFmyFKknKND/vLr3FIxSMFk7YUZSNCN7+UbXCEyOF6myxB2G/oF5NDbyX+U3pP9IdKN5+fovnXXaq6xcimtfDMCjSpnLp/KRLFyB/PkKH+W8TojTtWQ3SedyA/oCZjREy0wDPId8J1SaJ8sbWR8NgSX65mJdhgc7B1BYEYzDTEhH7zQt19Mb1D2vVa0jyLW9Ynr+Z0yeLgS81uH7Ky0NwDDkjqtFZLDW19YrtVSo7EotyOf2woqvpVn2Zh7UQJItMbzars2DnMe2KMfIKUJ35siYyGPEssBQ169jW1rH93Mp7drGKsTtT7/tbhUXQfWpmwZNShgy1jBA3i7bYniMuJ730Zfzri82zsDVTSipTAihBmiyUcAC8bhjOJU+/XY+SQJwnLZtwRP6iBTahI5796vEmDv/m00AL2ktLXmQiWHCxZAyHDV2BT1ONDKRCjFbi2iTBxkb8R5ADaRlhlFX9mS5ck6FKUrbpqT/jjFDJYvjJv/cqSeank0dBfEb+QpJhCmfu9/+IwKIS4Ofl5NOPgp63GXTmyagp1rTaoKkl8hLzmcJxdTeF7GJ5uV1m4nsvYU9hDyJbBLEvXTtmYrBqnwlEr9U5jQFNfpTGtqHX31X1GIfvDBukYrxMQq/+GG/Ir5chomESB5o66t7jsIuJyOZdVUhNQnao4wGjrqNHI19tblfMa60HPuKdNF8sXcz3jrWyu3FC4NCXYLvdkFDtoOcKSyY= 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:(13230022)(376002)(39860400002)(366004)(396003)(136003)(346002)(451199015)(38070700005)(5660300002)(33656002)(86362001)(8936002)(41300700001)(38100700002)(82960400001)(122000001)(7696005)(966005)(53546011)(71200400001)(478600001)(110136005)(54906003)(83380400001)(52536014)(186003)(9686003)(107886003)(19627235002)(6506007)(316002)(8676002)(66446008)(66476007)(66556008)(66946007)(26005)(76116006)(4326008)(64756008)(2906002)(55016003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?h/t1av7fWX71Ubq+IQOvCPIstv6SX0lLT7DvbcTeQyVvObVOHmjDyDpO9by0?= =?us-ascii?Q?EWlgltamNJ7Mj9yc0HlAGgfR81e9VsWx0RHQ43o23aRotTP3pPknMkvEuC4b?= =?us-ascii?Q?JgYWSepdzdZb+ftiuexcjb1DlPBADKRObx/wPJE7QMB3M6+r9xlbUiiaHttb?= =?us-ascii?Q?ycLlmhoC3kVZLWAg3B/OezTx8tE1AxZ9epFS0xtdKAzS6+/6AwO0Dj52wd/P?= =?us-ascii?Q?FuSOk8fHYTe9Ay8dEhYtQe+pzc4EAdOC6K/WIs8M9AoPlsfUG9Hn39cLn2+L?= =?us-ascii?Q?r/kisZLO5ZydIUTGBBGNb+SRTcbqQJyiJZNjZM6wlc5QX0oIlEdJc1F49zHw?= =?us-ascii?Q?1jchBu+bjBmIC37U1/HPeR5YVy41q/olQg52r8S8r8VD/jkQEqNSpds0s9Jg?= =?us-ascii?Q?VyFVY2U6EoA/6xbJC84Nx8vFB4mxFsJ29PpNLGZR6Y8yG7GySxMgMEo6eyRE?= =?us-ascii?Q?8cOogzk7z95bvCpesBhnlyRTTd5Nkt3HL1qju066NhnNvstPSqETLGGDlUBQ?= =?us-ascii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sIibnc5r4Lxy+No?= =?us-ascii?Q?vVlXwby7J7jgv2C7lOYV9zLR+ZAjsj7PxCc201L0pdvkqEmsmDQ9BLMIvlwy?= =?us-ascii?Q?biYosffanvkxaWENKjWzlLqvLDRAXen6/whogM7nWdBRNVB2SaaZRAVQVkG1?= =?us-ascii?Q?vwHXtNV4WHZaPCeAlec=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: 8ea77b9c-47c0-4888-1401-08daf8696bfa X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Jan 2023 09:01:29.2683 (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: /ZIcZf9QrLmQWRiRVmZxM28t2OJ+Wl6Fybw9eoBRCQa+WZqV/1/V7FUPySIrdp2rbHOTtPM8F7WVyKm0dTy19g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB6239 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: Liu, Zhiguang > Sent: Wednesday, January 4, 2023 1:41 PM > To: devel@edk2.groups.io > Cc: Liu, Zhiguang ; Ni, Ray ; K= umar, Rahul R ; Dong, > Eric > Subject: [PATCH] UefiCpuPkg: Fix SMM code hangs when InitPaging >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4246 >=20 > In function InitPaging, NumberOfPml5Entries is calculated by below code > NumberOfPml5Entries =3D (UINTN)LShiftU64 (1, SizeOfMemorySpace - 48); > If the SizeOfMemorySpace is larger than 48, NumberOfPml5Entries will be > larger than 1. However, this doesn't make sense if the hardware doesn't > support 5 level page table. >=20 > Cc: Ray Ni > Cc: Rahul Kumar > Signed-off-by: Eric Dong > Signed-off-by: Zhiguang Liu > --- > UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) >=20 > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c b/UefiCpuPkg/PiSmmCpu= DxeSmm/SmmProfile.c > index c1efda7126..c597b39b8c 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c > @@ -1,7 +1,7 @@ > /** @file > Enable SMM profile. >=20 > -Copyright (c) 2012 - 2019, Intel Corporation. All rights reserved.
> +Copyright (c) 2012 - 2023, Intel Corporation. All rights reserved.
> Copyright (c) 2017 - 2020, AMD Incorporated. All rights reserved.
>=20 > SPDX-License-Identifier: BSD-2-Clause-Patent > @@ -587,15 +587,17 @@ InitPaging ( > } >=20 > SizeOfMemorySpace =3D HighBitSet64 (gPhyMask) + 1; > + ASSERT (SizeOfMemorySpace <=3D 52); > + > // > - // Calculate the table entries of PML4E and PDPTE. > + // Calculate the table entries of PML5E, PML4E and PDPTE. > // > NumberOfPml5Entries =3D 1; > - if (SizeOfMemorySpace > 48) { > + if (Enable5LevelPaging && (SizeOfMemorySpace > 48)) { > NumberOfPml5Entries =3D (UINTN)LShiftU64 (1, SizeOfMemorySpace - 4= 8); > - SizeOfMemorySpace =3D 48; > } >=20 > + SizeOfMemorySpace =3D SizeOfMemorySpace > 48 ? 48 : SizeOfMemorySp= ace; > NumberOfPml4Entries =3D 1; > if (SizeOfMemorySpace > 39) { > NumberOfPml4Entries =3D (UINTN)LShiftU64 (1, SizeOfMemorySpace - 3= 9); > -- > 2.31.1.windows.1