From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web11.7716.1668088256038576268 for ; Thu, 10 Nov 2022 05:50:56 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=lPAxsUge; spf=pass (domain: intel.com, ip: 192.55.52.151, mailfrom: robert.guenzel@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668088256; x=1699624256; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=p7QtnlH56Cd8iF6DJhR9fD/ioDHNRjNsask/X2/idG0=; b=lPAxsUgeFzz9m35tai9ptalgYmW48K5ESedfiozhJcHFS71j8EByjSmT hZ2kRu6eA4WnZALS38mRS/e/IBVqAhlgfkQXj3OZH/YSmXemZedqeDq9z aORDwHvC1/cZyrSGrHFzDFFBquf0Tp/VFtW2QyfR3LW1Lr1G8Y+57pAAV b8cVsgjP+d4h+UCAZa4+8mECBAap+KT/W9mapmOUgffhdt8ehUzijNuTg MhbfNNl0/U6F5B+vu+pHGvKFN55P+CZCkYBcdjH2CeutRen6MMHAfE9cE XjqnSOlavkYBLjPvXBEyZMFRio7NyU9g94wOarGqMjmEDjj5ppufR9R0p Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="291706779" X-IronPort-AV: E=Sophos;i="5.96,153,1665471600"; d="scan'208";a="291706779" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Nov 2022 05:50:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="882360353" X-IronPort-AV: E=Sophos;i="5.96,153,1665471600"; d="scan'208";a="882360353" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmsmga006.fm.intel.com with ESMTP; 10 Nov 2022 05:50:55 -0800 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 10 Nov 2022 05:50:55 -0800 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) 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.2375.31; Thu, 10 Nov 2022 05:50:54 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) 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.2375.31 via Frontend Transport; Thu, 10 Nov 2022 05:50:54 -0800 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.105) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Thu, 10 Nov 2022 05:50:54 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VD941uZq/Rd9T7+2dLbsAPofcMUdjj2q6SSIs/BAWOqwa93sQfJfy6XEIg3SjgDs5ujwi0uZWo9HsWGiEPT5R8eOsQ75GzI209O4zbsQaCOHeAOwbfVsbn/dqV/VasbfJlVcpkIM9PGuMSsMKs0Vygg4QbCjj14FhBNcuOto80tLn3IE70NJK37nvB5EklJfEg+ng6SaYSHhM52H/Z4HvhnYJBkssw8hUNzmdcGzap4iJF0v/jNrpGsND7isZiTxJoxrcU63Vx/T6X4ra5XXV1C0QztCVDRNLl1pGXFMwExCLfgRg9h6QfQDRfBGRyIeAX3eDiLS3y/dj18uqlDEKw== 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=9fkPQDAKyrbpRTmZt6V9qWIhsAA4p/hdn3pwPBysRGk=; b=jR1iT0D8RVLCo+qtYuFfegkRt4SCGs/XPquQOkVHHOKU51neYqUOFsmMNxiRGU/ZVDVxpCLjRUG/Fs9sIsBqdptdnNOoo7hPXCuKQUDEgm9RaLfuTNOy2JvJRo1tAqgpZ4qgMOJPLNhFmS3GZYqETzGJGhDL2Q1zmM5Rl5/JgiyfqoQ9UK18nPPE+4G+TwjZWl/RNSximY+wx7BW30J2YWQ5h7R+tpvPzszI4J+shhzXUWsvW6cSS6f966eI0QWXEhzXbJfd0iZN87ZKnc1JXoizryqBOaT9xyjzSPOaxNzhtbkYlTGRp+0CAJg5A0cvMNbqPY1JJxMDJM8m0dw9ag== 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 SN6PR11MB2832.namprd11.prod.outlook.com (2603:10b6:805:5b::23) by BN9PR11MB5420.namprd11.prod.outlook.com (2603:10b6:408:101::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13; Thu, 10 Nov 2022 13:50:53 +0000 Received: from SN6PR11MB2832.namprd11.prod.outlook.com ([fe80::b7e2:a42a:e707:29d5]) by SN6PR11MB2832.namprd11.prod.outlook.com ([fe80::b7e2:a42a:e707:29d5%4]) with mapi id 15.20.5791.027; Thu, 10 Nov 2022 13:50:52 +0000 From: "Guenzel, Robert" To: "devel@edk2.groups.io" Subject: [PATCH] UefiCpuPkg: Bug fix in 5LPage handling Thread-Topic: [PATCH] UefiCpuPkg: Bug fix in 5LPage handling Thread-Index: Adj1CvpW46tAdlIWQQ+9dW0j49U6vQ== Date: Thu, 10 Nov 2022 13:50:52 +0000 Message-ID: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.6.500.17 dlp-reaction: no-action 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: SN6PR11MB2832:EE_|BN9PR11MB5420:EE_ x-ms-office365-filtering-correlation-id: b20fe9e3-99e8-4d95-cff9-08dac3229563 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 4SGYIiVw0kzBPKiN+BIYFPohZq+2LZrRML1vToDbUGr+Tyxxo6pqLOYRBBeoFhGWZHhV+h+4kcSHbWz3JT9oa8oq6yOzP7WxZBCjxlTul0eJ2r++Nv56yLSS0mOSuLeFcOxXDo8cC0eAHlsbgN5wRu109rCR8fiFrlGgOZ7FBb1PcB2fBnAr6gae6P+9Ml+QRh75k7fIpIRgLwqMHfsVpeYGjArFAsyjTPcch9XT3bMgEcL2FJB1l44GXaBEk98RuTDp3tb+MZXN39ID4Y2q5L1n3GSjw4d6IHCT8OoQuSqnNcRD5EIr1s1K8CkErrYlMiwQGGCOUxTfPAa2Sv+JIxisJih5eMWQXMFY9iVmqoBUauv2w7k7mvkyg0QFAocB86I1wgLnI3dwiaEVDQ6XbJ+AuliMt2Og8QIxHWpb9elVYxvVBgYj6HVpEcRBSey2jAPZJmEgYbYh95jx9L+0RlEftvZf2e8erFLUJmaKk5+GO+NbprogxXugocwyhQ5t1lCmfboiGsu6pX1sNLhYxUVsO+Il9f+qnvQQ7YQYUuRoxg8XIhe3ckSqRgr2pJs3pmOBfGoipWCVuGFc8WV958YsOOsw9eRbxvWzkFRa8meObIAubm2f0xlItMTSBFrVRkKCB6Rjd2pZ9qeO8aTxOQPDVHPawj7w5F098LFBf1w0Wbk+LmA/MPrZYXIemCJLse7hpGUM4WPsI142nek/JafNJpvPMrkrf+RwgVPiM9ggxI2dtqd70he8DRsQuEiYqBMBGl0Sfow2D6yoFlXQgNDct+eK0PVhS08FrXRCAA0= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR11MB2832.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(136003)(346002)(376002)(39860400002)(396003)(366004)(451199015)(82960400001)(33656002)(6506007)(7696005)(38070700005)(2906002)(122000001)(38100700002)(86362001)(8936002)(5660300002)(83380400001)(41300700001)(186003)(52536014)(19627235002)(66446008)(66476007)(66556008)(316002)(66946007)(6916009)(26005)(9686003)(76116006)(55016003)(71200400001)(8676002)(478600001)(966005)(64756008);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?lr/a5Gpg3FtndHAllOf9Gy8m3AgDUmCRdrAABZcVLrt0nEBtlAo3rr7HVw5T?= =?us-ascii?Q?7+zGn3LHbDdMtx8SmvsBzECw4CQyNKVWaQuCflLV45FWjKJy+og5wxiiabtQ?= =?us-ascii?Q?hmivMnXmQjVM2b9ISUBsSWU1WCobmxND76yqFb6eT7KeEwPl/ykKIFWclAt7?= =?us-ascii?Q?BphASDj/bhsAs0gqYjjDwG/y2Vv2IzfDlCQHy0C6Qq5qwLP4L0g97h0kKYL/?= =?us-ascii?Q?W02+hSjNDJCugGpzcwobzcl+WrE6J1jvhNSeNOUxjw1CeM7siA/t/g2dvuzl?= =?us-ascii?Q?EbyilORS1lFfnee0c421whm4iRalwj926r+URQQoyoDLZm2kF2NxBGt8Ww+y?= =?us-ascii?Q?ysrx7pU/mTRPubFrekw+T8xXq6MQabx/p7xpk1z9a0pDhcCEM4P0UFlJj13n?= =?us-ascii?Q?6vvc9K94z1AbDWJSd3qoGzZYdLBQRkp7/ZnCbFKpwjDQHfBUHE53yFMJ9goE?= =?us-ascii?Q?owak2c94wWCKwP3vlEy07IjI/GWGP1LxpqFOGJCmv0O/D+bzKNjzXqc6nibs?= =?us-ascii?Q?tbnhMR+rCh25eubWyGypnM4ioFJDa3umjFYGK8UgpP9XLusnGLOH7WHVbD37?= =?us-ascii?Q?BUn+SiBbK2ksiRaREQTjzJetodMA774xQ7wLG1YxFgIfXFFSN4Ifi6pxUZou?= =?us-ascii?Q?/2muvTKKCS+SaZbXoLyUiKexFowbyVJQZMY1a/Vv2oBWB7uSqjHmt/2/4Tiu?= =?us-ascii?Q?jDAs5eWZGeR0CL7XcEqwejljJ9HzSTU0dYGqeh/oLv6/afkbLjJWYdkcm542?= =?us-ascii?Q?UcJHij1N992yXfpQnIE4hrVbuoqretcWPDpVDkRJu5HJalnCpxxki7QVTXh/?= =?us-ascii?Q?zpAh+bXd6OOApYgMjoBFlc653oClAPPliRKHVuJifzPqKi1YweQfQ14sFGJC?= =?us-ascii?Q?6ioMfSf3jTEnjf4zVUO8I26jHLr5gKh+yOSiBZiRcWwdCsNQiC9JhHgdKRP1?= =?us-ascii?Q?q2WiHV6Kxx1EuYCi8vpl0y5P6DTur92pc34iG5Qay8xU7EpqSuEf20W9pG2n?= =?us-ascii?Q?3o0yQWcOThjLlSyE52ybDLm9/6zpldJX4Fm19WxCbV/fioYJbRd9+yiqV3Gj?= =?us-ascii?Q?G9rNjzZJN6nuvxQrtceqa5I3ljZ8/KGVm2vhq9Kl5d+yS4R5Jb1SZ2SFztga?= =?us-ascii?Q?ZWmwrsLw6/GF8GVgOG2gEnt3AXQvNln9CJltmFxz04mGRUuVSGLMB248e2sN?= =?us-ascii?Q?aOCGWPPz3yIJWNMhm9RVUkJW4qI/DcN9gKcMET7d/AwiE5mUxapuKKQunphG?= =?us-ascii?Q?4JGFVu8dzlYBDE/0J6idciwaicywJX5LLHMO0wV1MkI06NXYljcPg0oIL1y2?= =?us-ascii?Q?l/ALREPrcd67qTYaQfoitWZdWjPjfs4XeumD+iZZFX4uzWwyN2Swts4a7qeE?= =?us-ascii?Q?M+tzWMnNB9DvGrOi3YZUjQe58Lx1FCWHShevzN3g5amEtKMY+AFLld7mDb1X?= =?us-ascii?Q?1HKs5gCFsHb6toYq2b1IomBobQXCdPt15n5qOIG9fDXHLH7ybUMnMmvVN75r?= =?us-ascii?Q?mkj7XQxhaxsZSn8Gmu6msoL61n3/NuKtOeaS+VOUpYfyUZ7WAVr3o18o0xK3?= =?us-ascii?Q?Q2FelKrG0r7mr1mMZs6ta9e6wXDgJNkp6rwdqoIe?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR11MB2832.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b20fe9e3-99e8-4d95-cff9-08dac3229563 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Nov 2022 13:50:52.8684 (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: 51AiVPYfq7r7lZ0O0vNbFjX52O86/Z0iI9A8+yTlUct5qmaDpnl6IHiPjO2aDFFo0V3N3NlGsd+Zm6r4azu0Ewhb+szQ0q/o5eiyZ8yEWuU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR11MB5420 Return-Path: robert.guenzel@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable When build in DEBUG, the code asserts that 5LPage support is there when the physical address width is larger than 48. In a RELEASE build it will just force LA57 to 1 in CR4 even if CPUID(7).ECX[16] says it is not supported. The hang (in the ASSERT) in DEBUG is not warranted as there are legal configurations with CPUID(7).ECX[16](=3D=3DLA57)=3D0 and with a physical address width of larger than 48 (like 52). This is also supported by this code: https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/PiSmmCpuDxeSmm/X64= /PageTbl.c#L221 There (as long as physical address width is smaller or equal to 52) any address width above 48 will be reduced to 48 and the system can and will work without 5LPaging. The forced setting of LA57 in CR4 (in the absence of LA57 in CPUID(7).ECX) is a spec violation and should not happen. Hence the proposed fix a) removes the assert. b) only returns TRUE from Is5LevelPagingNeeded if 5LPaging is actually supported by HW. Signed-off-by: Robert Guenzel mailto:robert.guenzel@intel.com --- UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c b/UefiCpuPkg/PiSmmCpuD= xeSmm/X64/PageTbl.c index 6587212f4e..f8b1ac31f1 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c @@ -104,8 +104,8 @@ Is5LevelPagingNeeded ( ExtFeatureEcx.Bits.FiveLevelPage )); - if (VirPhyAddressSize.Bits.PhysicalAddressBits > 4 * 9 + 12) { - ASSERT (ExtFeatureEcx.Bits.FiveLevelPage =3D=3D 1); + if ((VirPhyAddressSize.Bits.PhysicalAddressBits > 4 * 9 + 12) && + (ExtFeatureEcx.Bits.FiveLevelPage =3D=3D 1)) { return TRUE; } else { return FALSE; -- = 2.34.1 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva = Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928