From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web11.15067.1682673355877185030 for ; Fri, 28 Apr 2023 02:15:55 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=XK8Ipbz+; spf=pass (domain: intel.com, ip: 134.134.136.20, 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=1682673355; x=1714209355; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=IZRZXf0k0XhJUBDISnz8u29wLKSJpsokbQxtPWrWvBQ=; b=XK8Ipbz+RzIo9uuqaHqu1fYTxXk2nZPw0KNs+LQsKEKF37PSq1ZkRBhP /mZa7ZxEZDN55fgiPhL3qkXwEvBCtP9jmMRvhyKAuw8vIdFztRGuMLC6c WJx++smz228V6/nN0xKS8PCy6qh4GNnp5/FexgMvNljXIv8xtqEQW3+Ws c+ZCtSK+1ptPOIzeD3k/aUcV6lBtHGoMDuOSbh9ZzJde6lHrAnCcb0hLH YV+avCBDKfUj64cr7Vp+nRjG0TpcIgoQEIasQbToEFcnwwaTu1fQiRAOu FCx3JYy2o28Oipn+sN8MNwgCYNf1oJ8Gwsiv7z63ZJy0jZvijI4kYBXWJ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10693"; a="336749076" X-IronPort-AV: E=Sophos;i="5.99,234,1677571200"; d="scan'208";a="336749076" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Apr 2023 02:15:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10693"; a="818938941" X-IronPort-AV: E=Sophos;i="5.99,234,1677571200"; d="scan'208";a="818938941" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga004.jf.intel.com with ESMTP; 28 Apr 2023 02:15:54 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) 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.23; Fri, 28 Apr 2023 02:15:54 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 28 Apr 2023 02:15:54 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) 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.23 via Frontend Transport; Fri, 28 Apr 2023 02:15:54 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.174) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Fri, 28 Apr 2023 02:15:52 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EeQxCfuEiC9a66XKO0z0wuEnLI0QeTwWm2NlSvfmngrff5vF3z5Fmyp1LZgQhcwKinCF3pjyV5DbhGQBh/79LB1BDWTHjDBZYBNQiiK3PKqw+fWcpNIcN3Hged8MqY6l9f/IjQgc/Pynt1OWoncvzjdUmTs3rCOYp5bkUnbFZQEIVDEvDW35bZoO7hyV1psg5Zxu5ev5pvS4pf/moxTrnueTdXbtjm0AiAVVL2l/h3mCPN0U7frjgc1zl7JEN3AxHVgA/uB3VoRDRD5MWbdnnO9ggtDvwLqWCJiXLQqsPX0asnc+F1ExV06SJrYmk7myF7IxAtb3BlzRvh78rA/TBw== 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=lgft5Rl/kk76/mmwSel1EcuHiEzvIj2rc5yJCzuvz5E=; b=ESLP1rkHqhX1pludPLP3Gh7C7caIH7MoA7O5f/KgWwq1cztyhVO8c6Gho0NU0hM4reyXpjPfKSNDptNVu1XqHOvwi8XWlp/FKgqDB06oRaS6jkgbnkUzZZZTGHG/8K7+++FbWLY8RS2QqO/Ee6ZU1yZtWt0j3CuKZd8NsPwydN1qi8QgJwkosqPhDXttX+3X1c4mZvs+DgtcESWIJAeLhE5UuR6IH+Jlhs9gJ/LlQM1vh5Lxb8VmpeBIS19mSel8Ym3XMWWf9gvdGD3ujksZk7yJFTkrG6PWMqkEXUJa1VwuwjZ2oiw/h3RFhVCrWahIIvEXy3IkMvbPhrwYdziqIg== 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 SJ0PR11MB4845.namprd11.prod.outlook.com (2603:10b6:a03:2d1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.24; Fri, 28 Apr 2023 09:15:46 +0000 Received: from MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::892b:b8e6:bab7:635d]) by MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::892b:b8e6:bab7:635d%5]) with mapi id 15.20.6340.023; Fri, 28 Apr 2023 09:15:46 +0000 From: "Ni, Ray" To: "Liu, Zhiguang" , "devel@edk2.groups.io" CC: "Dong, Eric" , "Kumar, Rahul R" , Gerd Hoffmann , "De, Debkumar" , "West, Catharine" Subject: Re: [PATCH v3 5/5] UefiCpuPkg/ResetVector: Support 5 level page table in ResetVector Thread-Topic: [PATCH v3 5/5] UefiCpuPkg/ResetVector: Support 5 level page table in ResetVector Thread-Index: AQHZeZy31qi4ANzVE0OBdzIk0W2tWK9AcNeg Date: Fri, 28 Apr 2023 09:15:46 +0000 Message-ID: References: <20230428064223.2048-1-zhiguang.liu@intel.com> <20230428064223.2048-5-zhiguang.liu@intel.com> In-Reply-To: <20230428064223.2048-5-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_|SJ0PR11MB4845:EE_ x-ms-office365-filtering-correlation-id: 3daf0f6e-a349-4b25-629c-08db47c92662 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 5rQ7lXv8W9KYekPwcVllcJR+YloaX4InxLYlAAKiTl5HYz1cgatxhPoiuqYM6GsDqqJqC/MwKuI8k1rhum/wrqA3VdqlauAT8ozTq4JqEL8Uh8qL1tiykWnYiNojLi8pSf0LutUpsXpjJ5UwzIagIpuQkdBjI3QqJz8FwnoOTn8RF7mFgs/pABU/C1lWqe6jxUqAxuoM1Rl307TaWVXPPmupxrQRUdOThK3cWl8XJVcozuUgMOzeFIEK4nPV8MoZXPC0f/3ZudLKVdQmQbo68ofEMflrO5/Ij6BhCCH8WYw9kO2KZqLjpVTT/OGVWd+LgUxHig/pq7T5A5Akk5S1lzNe2TW4xUtpb5VJ3hhBtw9ilPwLOjJjo6LvlNc4igvRp+5QB0qBo6vTjhjVvsDat2ffB28EPPkyrvRb4zdWlroqIgHSn23SKVxvmIY5XdLLPXvA3OxYhLi0yftNme87RsFdyu4074qxUxwgAcEaAuIKfttcRxYgs2FjvopS/N2pvfDP4q+Ro8VvEcKDMbkwjQwLXD9QTmE51z0pWb2cMY+K8uTM2VZ6QLRVTEnrqLM8c8nvje00Ex2ridAk5BSgBN3p19loVHmEGHZsflVonZg= 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:(13230028)(346002)(136003)(396003)(39860400002)(376002)(366004)(451199021)(8676002)(8936002)(41300700001)(83380400001)(6506007)(53546011)(9686003)(110136005)(54906003)(2906002)(316002)(5660300002)(52536014)(38070700005)(64756008)(76116006)(66556008)(66946007)(66476007)(66446008)(4326008)(86362001)(55016003)(38100700002)(186003)(19627235002)(107886003)(122000001)(478600001)(82960400001)(33656002)(71200400001)(7696005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?XSGIOQwgle2Rw+GIy3pwPlJskvH4eQc9gXQkwnZ4tvpQnvaUI+ZmK83frAN6?= =?us-ascii?Q?veBweyDgGooXE1iKnLzQdmtTwr6hj/ieGoH2Qskhr/PJXSKlkZyXZUPrbYR6?= =?us-ascii?Q?UaYZ5NH8WxlyjycdiJyJWqD7bkRzb4m6U8AYD6DWmgHu3Z6kwjNRX1bt2xRB?= =?us-ascii?Q?ipxCYGEF5VqU7rDMH4In1Ntm2EuYtFCfyI2c5ryoILugH2DoriPOFE/3tbLA?= =?us-ascii?Q?y3qCpDBoUQotUGE9diwjc03ARl8jYr2ZUzA+DvFtN77YsC1OPpV48Hn4omiX?= =?us-ascii?Q?3ZBn807WRgL37GGEwivci8Ml+4ykOXBm9GeQrAKuO5BHOxMsQUyjsusRx4Ks?= =?us-ascii?Q?enKYrBqRy1hVlu2xZ9n9TUIrSdE7nYJ7/KJMrSSC2v0U26yCkSzLwBAddTCn?= =?us-ascii?Q?cwFRiCwuPsPmfvYiHym9oAY7iaOrrLARAfj1CF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q?Ps8kod+ZRRuJC9AlW1s0EIxwHJ4MyGxAMOnEqpcqKvV+xLbCUcgqL3i0paiS?= =?us-ascii?Q?1ukn2dwFk/67ynhsnAD/4T8A6qT+COzo6BoFZHL/Pc9bgwaapoIgRbkVAl7y?= =?us-ascii?Q?lXxic5xFL152cmYj9N/epc1vukMtnve70qUa5gUiV/Z0Kw/pZ33iqowAH0aH?= =?us-ascii?Q?3I40u4t1cYFsQ3vIvvyJtCMDa3FfkNbcXqK7wXj80MmM6TTchQjFGcqLng?= =?us-ascii?Q?=3D=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: 3daf0f6e-a349-4b25-629c-08db47c92662 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Apr 2023 09:15:46.0592 (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: ZAJHjzpu5iaWs2JiO/7Dg1vL+nEr//HgtISWD5lTMvuMnDXHbNfJvBLxbdpHyhV/09XdeRZhsmnLF+wUxtwJiA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB4845 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 The changes look good to me. Please change the macro per comments to patch #1, then update this patch ac= cordingly. > -----Original Message----- > From: Liu, Zhiguang > Sent: Friday, April 28, 2023 2:42 PM > To: devel@edk2.groups.io > Cc: Liu, Zhiguang ; Dong, Eric > ; Ni, Ray ; Kumar, Rahul R > ; Gerd Hoffmann ; De, > Debkumar ; West, Catharine > > Subject: [PATCH v3 5/5] UefiCpuPkg/ResetVector: Support 5 level page tabl= e > in ResetVector >=20 > Add a macro USE_5_LEVEL_PAGE_TABLE to determine whether to create > 5 level page table. > If macro USE_5_LEVEL_PAGE_TABLE is defined, PML5Table is created > at (4G-12K), while PML4Table is at (4G-16K). In runtime check, if > 5level paging is supported, use PML5Table, otherwise, use PML4Table. > If macro USE_5_LEVEL_PAGE_TABLE is not defined, to save space, 5level > paging is not created, and 4level paging is at (4G-12K) and be used. >=20 > Cc: Eric Dong > Cc: Ray Ni > Cc: Rahul Kumar > Cc: Gerd Hoffmann > Cc: Debkumar De > Cc: Catharine West > Signed-off-by: Zhiguang Liu > --- > .../ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm | 25 +++++++++++++++++-- > .../ResetVector/Vtf0/Ia32/PageTables64.asm | 24 ------------------ > UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb | 1 - > .../ResetVector/Vtf0/X64/PageTables.asm | 9 +++++++ > 4 files changed, 32 insertions(+), 27 deletions(-) > delete mode 100644 UefiCpuPkg/ResetVector/Vtf0/Ia32/PageTables64.asm >=20 > diff --git a/UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm > b/UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm > index 6891397c2a..f119f941a5 100644 > --- a/UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm > +++ b/UefiCpuPkg/ResetVector/Vtf0/Ia32/Flat32ToFlat64.asm > @@ -2,7 +2,7 @@ > ; @file > ; Transition from 32 bit flat protected mode into 64 bit flat protected = mode > ; > -; Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
> +; Copyright (c) 2008 - 2023, Intel Corporation. All rights reserved.
> ; SPDX-License-Identifier: BSD-2-Clause-Patent > ; > ;-----------------------------------------------------------------------= ------- > @@ -14,7 +14,28 @@ BITS 32 > ; > Transition32FlatTo64Flat: >=20 > - OneTimeCall SetCr3ForPageTables64 > +%ifdef USE_5_LEVEL_PAGE_TABLE > + mov eax, 0 > + cpuid > + cmp eax, 07h ; check if basic CPUID leaf cont= ains leaf 07 > + jb NotSupport5LevelPaging ; 5level paging not support, dow= ngrade > to 4level paging > + mov eax, 07h ; check cpuid leaf 7, subleaf 0 > + mov ecx, 0 > + cpuid > + bt ecx, 16 ; [Bits 16] Supports 5-level pag= ing if 1. > + jnc NotSupport5LevelPaging ; 5level paging not support, dow= ngrade > to 4level paging > + mov eax, ADDR_OF(Pml5) > + mov cr3, eax > + mov eax, cr4 > + bts eax, 12 ; Set LA57=3D1. > + mov cr4, eax > + jmp SetCr3Done > +NotSupport5LevelPaging: > +%endif > + > + mov eax, ADDR_OF(Pml4) > + mov cr3, eax > +SetCr3Done: >=20 > mov eax, cr4 > bts eax, 5 ; enable PAE > diff --git a/UefiCpuPkg/ResetVector/Vtf0/Ia32/PageTables64.asm > b/UefiCpuPkg/ResetVector/Vtf0/Ia32/PageTables64.asm > deleted file mode 100644 > index f188da20ba..0000000000 > --- a/UefiCpuPkg/ResetVector/Vtf0/Ia32/PageTables64.asm > +++ /dev/null > @@ -1,24 +0,0 @@ > -;-----------------------------------------------------------------------= ------- > -; @file > -; Sets the CR3 register for 64-bit paging > -; > -; Copyright (c) 2008 - 2023, Intel Corporation. All rights reserved.
> -; SPDX-License-Identifier: BSD-2-Clause-Patent > -; > -;-----------------------------------------------------------------------= ------- > - > -BITS 32 > - > -; > -; Modified: EAX > -; > -SetCr3ForPageTables64: > - > - ; > - ; These pages are built into the ROM image in X64/PageTables.asm > - ; > - mov eax, ADDR_OF(Pml4) > - mov cr3, eax > - > - OneTimeCallRet SetCr3ForPageTables64 > - > diff --git a/UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb > b/UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb > index 136361e62c..5a6563bd34 100644 > --- a/UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb > +++ b/UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb > @@ -54,7 +54,6 @@ >=20 > %ifdef ARCH_X64 > %include "Ia32/Flat32ToFlat64.asm" > -%include "Ia32/PageTables64.asm" > %endif >=20 > %include "Ia16/Real16ToFlat32.asm" > diff --git a/UefiCpuPkg/ResetVector/Vtf0/X64/PageTables.asm > b/UefiCpuPkg/ResetVector/Vtf0/X64/PageTables.asm > index 4ff68cddef..5aa229eb14 100644 > --- a/UefiCpuPkg/ResetVector/Vtf0/X64/PageTables.asm > +++ b/UefiCpuPkg/ResetVector/Vtf0/X64/PageTables.asm > @@ -80,4 +80,13 @@ Pml4: > ; > DQ PG_NLE(Pdp) > TIMES 0x1000 - ($ - Pml4) DB 0 > + > +%ifdef USE_5_LEVEL_PAGE_TABLE > +Pml5: > + ; > + ; Pml5 table (only first entry is present, pointing to Pml4) > + ; > + DQ PG_NLE(Pml4) > + TIMES 0x1000 - ($ - Pml5) DB 0 > +%endif > EndOfPageTables: > -- > 2.31.1.windows.1