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.1870.1669769257049132898 for ; Tue, 29 Nov 2022 16:47:37 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=HxQlJ0rh; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: jiaxin.wu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669769257; x=1701305257; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=Tg8PpPAfrJaCmdKfpDUgI9SCyyvSBXg6mjOioJWfGKk=; b=HxQlJ0rhYd67p+NEcGieSBROqs/IDM6zbZrdJxp11mvrdMyVXOCYdX5a MlowxzqQ5NITpRrzNfQQwBU+U9nrwfoMHK96I4LCkmXb6zeDOeiyEK8hB lx/bQki6MdO3uhn1AZuNKEhrqlxSsrmHGzH6eeJadhRlF8VT49ppaHvps 4FFZIk2d9rxfR7dqEiLMtJ1mlYy13hNekMpQ3lD8xfCBPHTUxGFhocmaI TULJ0Kl5ZnsFi89eN282os5GNYDPAamcCKws9Vu7IFs0JitlHYAkQ4pMa HW92NMb2A0CN67dL6TBhXjyspspmWLN92R8huPKdGGKz+74rHWWR1yk7M Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="315299902" X-IronPort-AV: E=Sophos;i="5.96,204,1665471600"; d="scan'208";a="315299902" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2022 16:47:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="707443677" X-IronPort-AV: E=Sophos;i="5.96,204,1665471600"; d="scan'208";a="707443677" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga008.fm.intel.com with ESMTP; 29 Nov 2022 16:47:18 -0800 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 29 Nov 2022 16:47:17 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Tue, 29 Nov 2022 16:47:17 -0800 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) 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.16 via Frontend Transport; Tue, 29 Nov 2022 16:47:17 -0800 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.168) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.16; Tue, 29 Nov 2022 16:47:16 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Oz9Ri9MiCHSWMlNiEymFagfCQ3ccnVvsL/xDEM8cWFyYl8vTqInj7B9+oTy/HLVGqYsnnRecr3ZX4becumhVRyz5qI3htYtrqcnZssIo61KRYpT+lVwwh11OdDiFYBYOfXnwSl7XBQKOXNBzCcpOqnfZDjyvdTfp6yh58MAedCS+3p7fgR4u62dFG72IpJ6ZcFuEzTfVvXE1k0TrmAjk2Kehq2WQu7rzh+uWaVQ5nhpRtr8COEFOpLjLYYj4sbGLRnTkj0XI2DMcXir0dGU0F0THAhuiMEVXTpNyVRfYszurFCdQsyjE1unIajDDXoJ2yroMl2fjpDhbVJhYD86duQ== 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=J7PUslxIsb3YszuLcfwDsoCDXjwxhBAXLfLfE6rjX6k=; b=AgbZlUQbFlOadmSBatHW/22V4Ez5MsnZYoC+nw8yoEzKOAVt+zhsiB4DAg+EM6gpjwyn34YhgiZYMuUsVUqY+59Vg8qEuVQeg47DyFoFLqaHr5X0P1Bxll8PKsyv9dLXy5sYGqMBZU4FFrXpZInXMlDXbi3Jb1DHKOdZJm06Rmp+ajbZ3KI738dgNLsHPbMNnLGFANL//U2y+Lpv+OsGh3xYzC91+CDUgGgxi/6v0nymic4UNyuxFvitZiMCOoZU+PScGcSwDKu8JFPkD0hlcM90RdoUhJUXpEtcEBmca3QcBHoH3IOeY58mXtT24gM4OkH8tx3uRDEpEFA/LobUKA== 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 MN0PR11MB6158.namprd11.prod.outlook.com (2603:10b6:208:3ca::18) by DM6PR11MB4659.namprd11.prod.outlook.com (2603:10b6:5:2a5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Wed, 30 Nov 2022 00:47:09 +0000 Received: from MN0PR11MB6158.namprd11.prod.outlook.com ([fe80::8997:923d:c193:8e31]) by MN0PR11MB6158.namprd11.prod.outlook.com ([fe80::8997:923d:c193:8e31%3]) with mapi id 15.20.5857.023; Wed, 30 Nov 2022 00:47:09 +0000 From: "Wu, Jiaxin" To: "devel@edk2.groups.io" , "Ni, Ray" , "Guenzel, Robert" Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg: Bug fix in 5LPage handling Thread-Topic: [edk2-devel] [PATCH] UefiCpuPkg: Bug fix in 5LPage handling Thread-Index: Adj1CvpW46tAdlIWQQ+9dW0j49U6vQES0p3wAr+ld9A= Date: Wed, 30 Nov 2022 00:47:09 +0000 Message-ID: References: In-Reply-To: Accept-Language: zh-CN, 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: MN0PR11MB6158:EE_|DM6PR11MB4659:EE_ x-ms-office365-filtering-correlation-id: f6a868ef-4d00-4679-3e9d-08dad26c6956 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ln7Vv8DA3I5BEUc8ruw+puFa6YvAA8MACJEQHnVZcZUPTJrhMvZO+oY5FDiOpIGrIId08nSRAXpJJoRdYgqHOZ+8VP0DwR669ycU7W1Uwe2vs+JjNL4XgbacEC4MWzHbOKCDVVvDb/XvkgK0V1cz0pJMJ42TIYj0nCsZMMLSyWPHFrmiG9370Qjl5K3Aog6Po5PwPGht4HZVxB+JtPA7cSBpmWb1RClSrB5oQzR47e/sZP+ZT8f/pcWq1vVen1gxwbVcS9zdILojI1pNo+5veWgNyJPtrfpkcO43Hehfld6o/itwU7o6y/NzCWCjwWhxASSLqlJ2EN4dtU885LuUDhJzTiNM9h4hKV7Xp+dLcO0CD3U73CA83IOCUnWjzHpMJPMPNGB+Fg5HrlSA+DWQJ3ubypVFVxRpaqOAOXtfJLoWh2ySyG/c+BtIs8wCtbL12FY6MWMI+6nxStfPFYtwuS56SCv0dJx9Xvq0UcF0NsAW2vhyhI7l1cVJgoilPTDLWbQtkzgPzNhlA0LR5OE4B6JyiN3HnRbS9sCxVI776blarNEILIBidHjS39A0K/VJiIV34faH78jdismh+dCoUd6eyyJbhkEsev4uPVMKuP8jSU/qlTP1+qPS/zLSQYIAwMejzeasYi8tjrora1nxyAE04H7+soAkbNE0MTSqk8+ofDMsM4HFGOKGIL463/duM78XPPLzD0pOInca8ZuPKJhH9C8DS3AkpwOlrap9E2XJn6njL6Pe7fv4DXH7L/t65kbbUIdZeoAWTIP6GfOOzw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN0PR11MB6158.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(136003)(396003)(366004)(376002)(346002)(39860400002)(451199015)(55016003)(38070700005)(15974865002)(86362001)(9686003)(6506007)(110136005)(966005)(71200400001)(26005)(33656002)(7696005)(5660300002)(6636002)(53546011)(478600001)(52536014)(8936002)(66556008)(66446008)(41300700001)(2906002)(19627235002)(66946007)(64756008)(8676002)(66476007)(76116006)(316002)(82960400001)(122000001)(186003)(38100700002)(83380400001)(66899015);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?bv+PApikSe9QjtpLIQk7JYdjg0JwTHBcQvc9I/aj0KShRf2/y/MidCBvSFV9?= =?us-ascii?Q?GHFM3a7Eyk3TlEJsrTnpXhCH1p8G05aiRC0XMMpyWACV73U57+PsHEjZs5ON?= =?us-ascii?Q?Z3WKZMvxhRt1HiWC7eVZuFbGTG0tSh8iOk0ov74TJ/JRPr8orYFhAclnSt8J?= =?us-ascii?Q?vNtewYZVWdvxXBpj+nJjGtBhDIwDKBErKQbEsunjBWwaRBxMWqRMsjqzZhND?= =?us-ascii?Q?5VjF5aGfRPmMIuxG1+sTu8qrn4saGbuzKYMALcRR9hOjnZIL4B/dXDmpWdKq?= =?us-ascii?Q?42/QErtkevSdaImkxahtjbgJefz+zkeyiVjy8BiYPW0QP+o7dtZsLV+A6QXU?= =?us-ascii?Q?Pc9DT5YJ4QMYgZJbEAHuCKbkKjFni4YyYsuPaOyH9GtL/cMrO7V11eBSwRFQ?= =?us-ascii?Q?slyAEIBFNpLb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ALoYTO0hwnJXEKmxVlnH?= =?us-ascii?Q?reJlyHgP3DZK/EeX4JQ7oDsfO2/h2ANJI00HPLkDAeL4wzZxhkAg2wzxoZa0?= =?us-ascii?Q?/bqt10tuP7PfUMmRvdxlnrgqrQr89iM5cx2108kSCEg2O91OkV5KfvrYHIFG?= =?us-ascii?Q?bAoss7+Kerdw/4u71RbX8ka5tgpS2VISuHUiqeVkgPOdNqI465ebhDnSfUu4?= =?us-ascii?Q?BeKt0d7kC9iHLHR7QPu0QtWLB4Y5/zBn3mdbwnkPjy7Zr+hB71CrlHQ8rNL0?= =?us-ascii?Q?mBM44cPNWUKO5aFOAIdwmrfXw80w0sKsVooKE/EQ?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN0PR11MB6158.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f6a868ef-4d00-4679-3e9d-08dad26c6956 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Nov 2022 00:47:09.1426 (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: tE9YNXLEJFsVTD4QohnqkUHSfzAxb/YyPqgK00aiQIO90uckIfyTHQnhfXhHXVdzZyPX82oOWTJkCrRsHhOg3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4659 Return-Path: jiaxin.wu@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Glad to see this fix, could you add/include the existing Bugzilla in the co= mment? REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4168 Thanks, Jiaxin > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Ni, Ray > Sent: Wednesday, November 16, 2022 8:57 AM > To: devel@edk2.groups.io; Guenzel, Robert > Subject: Re: [edk2-devel] [PATCH] UefiCpuPkg: Bug fix in 5LPage handling >=20 > Reviewed-by: Ray Ni >=20 > > -----Original Message----- > > From: devel@edk2.groups.io On Behalf Of > Guenzel, Robert > > Sent: Thursday, November 10, 2022 9:51 PM > > To: devel@edk2.groups.io > > Subject: [edk2-devel] [PATCH] UefiCpuPkg: Bug fix in 5LPage handling > > > > 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/PiSmmCpuDx > eSmm/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).E= CX) > > 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/PiSmmCpuDxeSmm/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 Sil= va > > Chairperson of the Supervisory Board: Nicole Lau > > Registered Office: Munich > > Commercial Register: Amtsgericht Muenchen HRB 186928 > > > > > > > > > > >=20 >=20 >=20 >=20 >=20