From nobody Sat May 18 23:55:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+97911+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97911+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1672810934; cv=none; d=zohomail.com; s=zohoarc; b=bhJrfYMfVInzwWCQJ8QiXaiXXSOk4C3qAGtfobMJL7VaahEv8GKAn7fnI9rovRwPeSPvcsTRDPQQBCQz5wX0b6ZXiPAniLdfWv/sF9ASi3sPCCLJ6GpJXPCd/XuHnukUs2Nlapl+n+NfiG1IXlOzqkTxvYD8rsckzVsicyROa7w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672810934; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=dtZiACzllMADizo10X+5exc14fAFT4G7iziwJiPXcHY=; b=BXtgGjKYmz2rJhPChv6jntL8w0iXeVbsdOVKZurZDrMEukTaKg/Rz9xs20b/MhKYKWL3HudXLY9LbH+RNdMWPOu6moo5KrLtjp1S/Y5/maIwhYQkDNYDqTmbiyU6CxssaOuJXaitauGSLTFcil+XhwNHnY5c8zHyJWP8fU3eua0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+97911+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16728109349732.5137834224091193; Tue, 3 Jan 2023 21:42:14 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 5jVlYY1788612xD2FZbIpkLu; Tue, 03 Jan 2023 21:42:14 -0800 X-Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web11.5512.1672810932996305792 for ; Tue, 03 Jan 2023 21:42:13 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="302214816" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="302214816" X-Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2023 21:42:12 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10579"; a="723523717" X-IronPort-AV: E=Sophos;i="5.96,297,1665471600"; d="scan'208";a="723523717" X-Received: from shwdesfp01.ccr.corp.intel.com ([10.239.158.151]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2023 21:42:10 -0800 From: "Zhiguang Liu" To: devel@edk2.groups.io Cc: Zhiguang Liu , Ray Ni , Rahul Kumar , Eric Dong Subject: [edk2-devel] [PATCH] UefiCpuPkg: Fix SMM code hangs when InitPaging Date: Wed, 4 Jan 2023 13:41:18 +0800 Message-Id: <20230104054118.280-1-zhiguang.liu@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,zhiguang.liu@intel.com X-Gm-Message-State: 1fv9OTfCYEOBRDcFXpdVLbiex1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1672810934; bh=7qDC1EFceU/xa6AZ658PKMdhNhoSV1jeEOkjga1kZIg=; h=Cc:Date:From:Reply-To:Subject:To; b=Y+Cwoz7HHPYF988ry6AIKE83AkW7JNOOV1j+iwLcbslPELj8WjUcoqBpfYA0TOxrrrT hvdfw9iVC9jOytyPKRMQpRkze6xF7c65J+7M8bQnt8HTQwDGr8b6GvuTJ4WQjuZYEexn2 f4Ny+x0iKFlW7bIa6RWZ10aAoYjoP9a6tOE= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1672810936881100002 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4246 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. Cc: Ray Ni Cc: Rahul Kumar Signed-off-by: Eric Dong Signed-off-by: Zhiguang Liu Reviewed-by: Ray Ni Reviewed-by: Star Zeng Reviewed-by: Wu, Jiaxin --- UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c b/UefiCpuPkg/PiSmmCpuDx= eSmm/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 - 48); - SizeOfMemorySpace =3D 48; } =20 + SizeOfMemorySpace =3D SizeOfMemorySpace > 48 ? 48 : SizeOfMemorySpac= e; NumberOfPml4Entries =3D 1; if (SizeOfMemorySpace > 39) { NumberOfPml4Entries =3D (UINTN)LShiftU64 (1, SizeOfMemorySpace - 39); --=20 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 (#97911): https://edk2.groups.io/g/devel/message/97911 Mute This Topic: https://groups.io/mt/96045489/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-