From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web12.5301.1596433276068198944 for ; Sun, 02 Aug 2020 22:41:16 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=J8+Gi4VY; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: hao.a.wu@intel.com) IronPort-SDR: /w4w4/wD3Y0LLjaVDEI01pLmt8MhJzvJlJxrfVhm3xqhQNuVESHqGdWdDXrUS+qnov3YcsPYmV jmrTvlgLV3lg== X-IronPort-AV: E=McAfee;i="6000,8403,9701"; a="152017262" X-IronPort-AV: E=Sophos;i="5.75,429,1589266800"; d="scan'208";a="152017262" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Aug 2020 22:41:15 -0700 IronPort-SDR: UvbPOG5egRDX7/bp20sr2ZtBkO5AIGSHdpjAZUiq5jRY8lNHZxZ7vD2Hok+0Kb6xaPuxlfRqRF tRjqlrspa3Pw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,429,1589266800"; d="scan'208";a="323932146" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmsmga002.fm.intel.com with ESMTP; 02 Aug 2020 22:41:14 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) 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.1713.5; Sun, 2 Aug 2020 22:41:14 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Sun, 2 Aug 2020 22:41:14 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.106) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 2 Aug 2020 22:41:12 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wuva67wfMHbxc/coQcOM3vh/S6cAEYD/eZc50sXRkHBG5dFF5xCH8Mekv+UOpdLyOU/eU2KK7zKY0uxC+zn9P6t6io8IONsBV2CxOs7Q5/7jdtC8kA9JQtqKrdUMls3dMy+fTQMdWIyKreWP2PeGCqESdir07Dy/ZLI/0Mq36KLG//KzV397j+u0z5rAXJ0fui8tLl411b+Yz1S9xVgZB2ojG5Le7kKOumPEY2uuGE739cr+BJairsmwgPDaJpeqREsWLsNc6gZ+j46A1LlvU8bkHwy4Wb9Twx2/SJaWsD+TMo5FqeAqczD9zdSofE6MDwYTORMiYxNmsjn6WRpkRQ== 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-SenderADCheck; bh=Y3xHq2cn853ktbfcilb9LFbinJFZMM1dCW+VojgFH9c=; b=Bdgq83YXsF/t693sgKls0yZLi/I4fjsYrQhfCVgrDYV2460o72lEYb4RIk/TRqe53PaiJVS59mEqubRZBSNL6/siB/CQ8lPk73UySSMdmiPP9kHJ18ZXwMU5ZB949aZam+2+2aWz7psr7eKs0qZAna4kug6Vei00e/hgx7BixkUFTE9L84RGJrOCEYQsGXo1FY6DSkFkdjS4cakh3Z5WwMIghzDk4QbLgF3DU5qQY3kwItipA6fwE2/GIYjqXReJCNyUQa4QG69xYGyf/mbuH4u8FeI2bFeofDl1i9ZvzkBg0oacbDO9QoOKyGM2VSYObide9fr3kdHaJUxBNuuDlA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Y3xHq2cn853ktbfcilb9LFbinJFZMM1dCW+VojgFH9c=; b=J8+Gi4VYBRZX4WDZFm3GYQ8qOfHGPfkTfU00QylAQ+H2Sh8pAGUxhLLNr9SrSv+VCBsWgXk0iM/1wEeEg7FejXxWYi5vtpS3E/Hkbv3AJ0xkF/Hnkj6VWIqhRG4DeERZDQAuvKs9USZ1oOkVmKnceQOLrcnymocdFiQ0E3A4atI= Received: from BN8PR11MB3666.namprd11.prod.outlook.com (2603:10b6:408:8c::19) by BN8PR11MB3617.namprd11.prod.outlook.com (2603:10b6:408:82::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.16; Mon, 3 Aug 2020 05:41:08 +0000 Received: from BN8PR11MB3666.namprd11.prod.outlook.com ([fe80::78b6:7108:8852:7536]) by BN8PR11MB3666.namprd11.prod.outlook.com ([fe80::78b6:7108:8852:7536%7]) with mapi id 15.20.3239.021; Mon, 3 Aug 2020 05:41:08 +0000 From: "Wu, Hao A" To: "devel@edk2.groups.io" , "thomas.lendacky@amd.com" CC: Brijesh Singh , Ard Biesheuvel , "Dong, Eric" , "Justen, Jordan L" , Laszlo Ersek , "Gao, Liming" , "Kinney, Michael D" , "Ni, Ray" , "Wang, Jian J" , "Bi, Dandan" Subject: Re: [edk2-devel] [PATCH v13 05/46] MdeModulePkg/DxeIplPeim: Support GHCB pages when creating page tables Thread-Topic: [edk2-devel] [PATCH v13 05/46] MdeModulePkg/DxeIplPeim: Support GHCB pages when creating page tables Thread-Index: AQHWZqGWs7qtuKSF20yOcfIL/6cOqakl4tdQ Date: Mon, 3 Aug 2020 05:41:08 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.147.218] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ea3610da-83b5-4ac1-55a7-08d8376fd2b4 x-ms-traffictypediagnostic: BN8PR11MB3617: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3513; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: KPiY7lHnbj0v37zAkorZjPRHjU22FZtoyOxwL73wyWnJXcDsMvIcOxs/Pugon6MrHIFKf5rhrRR3tngok7eOozF7hACuJkFfow3uiCXwP/iDsoSmsEA+f8Im5hbKavLfqAUit4GsD8Nf5jwY8T11xPgc5B715SAr20vjePZB69mjS5cD/1UBgHRlLHHrW6oYXqSBwrZn2qZozPxsAgf+xfvkQqHm48pl4mysodXX1NjMHwDejpXGngSnsaAVZcfyDMfi1BzSJBxBUb0HlJSj/8V+DyyrwV7YIvFzgf+rrCyAZzNThI67GThIFc6zRiz2m01Nl6/L2ooYVVv8v138rtdUO4GlQE5BpJqfrh+H7n/h5ggQUO+64Dd+w7/P9+ndgUAZHI3m5yZZegVETeWweg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR11MB3666.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(376002)(136003)(366004)(346002)(39860400002)(396003)(5660300002)(52536014)(55016002)(66446008)(9686003)(66946007)(30864003)(86362001)(76116006)(66476007)(83380400001)(19627235002)(66556008)(64756008)(53546011)(54906003)(2906002)(316002)(110136005)(71200400001)(478600001)(107886003)(8936002)(26005)(7696005)(8676002)(186003)(33656002)(4326008)(6506007)(966005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: 0Utk5MYpdDP+JvBcLjpTXPLWQLWQcuP/Q7FMFefj5VOsOu1ZV8TexzoZvJCFj6U4BsCFsW+vLQBkQE7QLKOqkt60mdO2ynFQDBxv4Dc8yEJRwGs2sCvwwGWAPfp2ooGtP4nck0xF9UmRnk7M83aIwuDdpLLLC3yULoFH0AZKF3xUyRz8o0QHnEOCKPZH8fVmwjc0Lv9JvoGY3Ax7VKjgAFH9kaasnyNlitJKnuZmBAL0HKPtTgnEgT8UBa3xZZbUyQbWQvrCuyP9gNFV6gawVn+Q3/CnVLHAuLREA8RRaa773VtHI/u/roWx75nE9apRWGMWICLUDPHF4XvqpHt05X3dg9LGo5KNinXn/bq3ly5xrWVNMTpbxk3+QMQAofFz06VW7NiSwbpEbAQvTHm3xP7aRjjkgKOKjWzHqdbIQick0F9JUUJUcM+U9NgGvnAicTgN9WXcX3/JYQDWhZiR8FeX6x5LSM0wNNknN91Up4xAY4CkAXJEKonwHGk0smy2XxY/Lj+Taois0ccJZaR+XU6UCTEpQi7hMqby65AfK9AS6lWdst24SByPxhtIFlEdD3yTQsNDc7SXbc8eI2c8104ngx0cmYm9QbElUOwtBbC8IIudX0FUjWqfpJcWDx9msOy9HFo21OjTyR0q3lSAgA== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN8PR11MB3666.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ea3610da-83b5-4ac1-55a7-08d8376fd2b4 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Aug 2020 05:41:08.7617 (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: cw8LCkNA9kqalqZCILMiFiNWvS+JmT7h5E/ICwnziC0Q3OCoYVuOhdllGQyec/FXDQHqGN1l22iPpyO2xuAaRQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR11MB3617 Return-Path: hao.a.wu@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of > Lendacky, Thomas > Sent: Friday, July 31, 2020 2:43 AM > To: devel@edk2.groups.io > Cc: Brijesh Singh ; Ard Biesheuvel > ; Dong, Eric ; Justen, > Jordan L ; Laszlo Ersek ; > Gao, Liming ; Kinney, Michael D > ; Ni, Ray ; Wang, Jian J > ; Wu, Hao A ; Bi, Dandan > > Subject: [edk2-devel] [PATCH v13 05/46] MdeModulePkg/DxeIplPeim: > Support GHCB pages when creating page tables >=20 > From: Tom Lendacky >=20 > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2198 >=20 > GHCB pages must be mapped as shared pages, so modify the process of > creating identity mapped pagetable entries so that GHCB entries are crea= ted > without the encryption bit set. The GHCB range consists of two pages per > CPU, the first being the GHCB and the second being a per-CPU variable pa= ge. > Only the GHCB page is mapped as shared. >=20 > Cc: Jian J Wang > Cc: Hao A Wu > Cc: Dandan Bi > Cc: Liming Gao > Signed-off-by: Tom Lendacky > --- > MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf | 2 + > .../Core/DxeIplPeim/X64/VirtualMemory.h | 12 +++- > .../Core/DxeIplPeim/Ia32/DxeLoadFunc.c | 4 +- > .../Core/DxeIplPeim/X64/DxeLoadFunc.c | 11 +++- > .../Core/DxeIplPeim/X64/VirtualMemory.c | 57 +++++++++++++++---- > 5 files changed, 70 insertions(+), 16 deletions(-) >=20 > diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf > b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf > index 3f1702854660..19b8a4c8aefa 100644 > --- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf > +++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf > @@ -115,6 +115,8 @@ [Pcd.IA32,Pcd.X64] > gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask > ## CONSUMES > gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard = ## > CONSUMES > gEfiMdeModulePkgTokenSpaceGuid.PcdUse5LevelPageTable = ## > SOMETIMES_CONSUMES > + gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbBase = ## > CONSUMES > + gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbSize = ## > CONSUMES >=20 > [Pcd.IA32,Pcd.X64,Pcd.ARM,Pcd.AARCH64] > gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack ## > SOMETIMES_CONSUMES > diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.h > b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.h > index 2d0493f109e8..6b7c38a441d6 100644 > --- a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.h > +++ b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.h > @@ -201,6 +201,8 @@ EnableExecuteDisableBit ( > @param[in, out] PageEntry2M Pointer to 2M page entry. > @param[in] StackBase Stack base address. > @param[in] StackSize Stack size. > + @param[in] GhcbBase GHCB page area base address. > + @param[in] GhcbSize GHCB page area size. >=20 > **/ > VOID > @@ -208,7 +210,9 @@ Split2MPageTo4K ( > IN EFI_PHYSICAL_ADDRESS PhysicalAddress, > IN OUT UINT64 *PageEntry2M, > IN EFI_PHYSICAL_ADDRESS StackBase, > - IN UINTN StackSize > + IN UINTN StackSize, > + IN EFI_PHYSICAL_ADDRESS GhcbBase, > + IN UINTN GhcbSize > ); >=20 > /** > @@ -217,6 +221,8 @@ Split2MPageTo4K ( >=20 > @param[in] StackBase Stack base address. > @param[in] StackSize Stack size. > + @param[in] GhcbBase GHCB page area base address. > + @param[in] GhcbSize GHCB page area size. >=20 > @return The address of 4 level page map. >=20 > @@ -224,7 +230,9 @@ Split2MPageTo4K ( > UINTN > CreateIdentityMappingPageTables ( > IN EFI_PHYSICAL_ADDRESS StackBase, > - IN UINTN StackSize > + IN UINTN StackSize, > + IN EFI_PHYSICAL_ADDRESS GhcbBase, > + IN UINTN GhcbkSize > ); >=20 >=20 > diff --git a/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c > b/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c > index 6e8ca824d469..284b34818ca7 100644 > --- a/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c > +++ b/MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c > @@ -123,7 +123,7 @@ Create4GPageTablesIa32Pae ( > // > // Need to split this 2M page that covers stack range. > // > - Split2MPageTo4K (PhysicalAddress, (UINT64 *) PageDirectoryEntry= , > StackBase, StackSize); > + Split2MPageTo4K (PhysicalAddress, (UINT64 *) > + PageDirectoryEntry, StackBase, StackSize, 0, 0); > } else { > // > // Fill in the Page Directory entries @@ -282,7 +282,7 @@ > HandOffToDxeCore ( > // > // Create page table and save PageMapLevel4 to CR3 > // > - PageTables =3D CreateIdentityMappingPageTables (BaseOfStack, > STACK_SIZE); > + PageTables =3D CreateIdentityMappingPageTables (BaseOfStack, > + STACK_SIZE, 0, 0); >=20 > // > // End of PEI phase signal > diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c > b/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c > index f465eb1d8ac4..156a477d8467 100644 > --- a/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c > +++ b/MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c > @@ -35,6 +35,8 @@ HandOffToDxeCore ( > UINT32 Index; > EFI_VECTOR_HANDOFF_INFO *VectorInfo; > EFI_PEI_VECTOR_HANDOFF_INFO_PPI *VectorHandoffInfoPpi; > + VOID *GhcbBase; > + UINTN GhcbSize; >=20 > // > // Clear page 0 and mark it as allocated if NULL pointer detection is > enabled. > @@ -81,12 +83,19 @@ HandOffToDxeCore ( > TopOfStack =3D (VOID *) ((UINTN) BaseOfStack + EFI_SIZE_TO_PAGES > (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT); > TopOfStack =3D ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT); >=20 > + // > + // Get the address and size of the GHCB pages // GhcbBase =3D (VOID > + *) PcdGet64 (PcdGhcbBase); GhcbSize =3D PcdGet64 (PcdGhcbSize); > + > PageTables =3D 0; > if (FeaturePcdGet (PcdDxeIplBuildPageTables)) { > // > // Create page table and save PageMapLevel4 to CR3 > // > - PageTables =3D CreateIdentityMappingPageTables > ((EFI_PHYSICAL_ADDRESS) (UINTN) BaseOfStack, STACK_SIZE); > + PageTables =3D CreateIdentityMappingPageTables > ((EFI_PHYSICAL_ADDRESS) (UINTN) BaseOfStack, STACK_SIZE, > + > + (EFI_PHYSICAL_ADDRESS) (UINTN) GhcbBase, GhcbSize); > } else { > // > // Set NX for stack feature also require PcdDxeIplBuildPageTables b= e TRUE > diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c > b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c > index 516cf908bc88..6831946c54d3 100644 > --- a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c > +++ b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c > @@ -181,6 +181,8 @@ EnableExecuteDisableBit ( > @param Size Size of the given physical memory. > @param StackBase Base address of stack. > @param StackSize Size of stack. > + @param GhcbBase Base address of GHCB pages. > + @param GhcbSize Size of GHCB area. >=20 > @retval TRUE Page table should be split. > @retval FALSE Page table should not be split. > @@ -190,7 +192,9 @@ ToSplitPageTable ( > IN EFI_PHYSICAL_ADDRESS Address, > IN UINTN Size, > IN EFI_PHYSICAL_ADDRESS StackBase, > - IN UINTN StackSize > + IN UINTN StackSize, > + IN EFI_PHYSICAL_ADDRESS GhcbBase, > + IN UINTN GhcbSize > ) > { > if (IsNullDetectionEnabled () && Address =3D=3D 0) { @@ -209,6 +213,1= 2 @@ > ToSplitPageTable ( > } > } >=20 > + if (GhcbBase !=3D 0) { > + if ((Address < GhcbBase + GhcbSize) && ((Address + Size) > GhcbBase= )) { > + return TRUE; > + } > + } > + > return FALSE; > } > /** > @@ -322,6 +332,8 @@ AllocatePageTableMemory ( > @param[in, out] PageEntry2M Pointer to 2M page entry. > @param[in] StackBase Stack base address. > @param[in] StackSize Stack size. > + @param[in] GhcbBase GHCB page area base address. > + @param[in] GhcbSize GHCB page area size. >=20 > **/ > VOID > @@ -329,7 +341,9 @@ Split2MPageTo4K ( > IN EFI_PHYSICAL_ADDRESS PhysicalAddress, > IN OUT UINT64 *PageEntry2M, > IN EFI_PHYSICAL_ADDRESS StackBase, > - IN UINTN StackSize > + IN UINTN StackSize, > + IN EFI_PHYSICAL_ADDRESS GhcbBase, > + IN UINTN GhcbSize > ) > { > EFI_PHYSICAL_ADDRESS PhysicalAddress4K; > @@ -355,7 +369,20 @@ Split2MPageTo4K ( > // > // Fill in the Page Table entries > // > - PageTableEntry->Uint64 =3D (UINT64) PhysicalAddress4K | AddressEncM= ask; > + PageTableEntry->Uint64 =3D (UINT64) PhysicalAddress4K; > + > + // > + // The GHCB range consists of two pages per CPU, the GHCB and a > + // per-CPU variable page. The GHCB page needs to be mapped as an > + // unencrypted page while the per-CPU variable page needs to be > + // mapped encrypted. These pages alternate in assignment. > + // > + if ((GhcbBase =3D=3D 0) > + || (PhysicalAddress4K < GhcbBase) > + || (PhysicalAddress4K >=3D GhcbBase + GhcbSize) > + || (((PhysicalAddress4K - GhcbBase) & SIZE_4KB) !=3D 0)) { > + PageTableEntry->Uint64 |=3D AddressEncMask; > + } > PageTableEntry->Bits.ReadWrite =3D 1; >=20 > if ((IsNullDetectionEnabled () && PhysicalAddress4K =3D=3D 0) || @@= -383,6 > +410,8 @@ Split2MPageTo4K ( > @param[in, out] PageEntry1G Pointer to 1G page entry. > @param[in] StackBase Stack base address. > @param[in] StackSize Stack size. > + @param[in] GhcbBase GHCB page area base address. > + @param[in] GhcbSize GHCB page area size. >=20 > **/ > VOID > @@ -390,7 +419,9 @@ Split1GPageTo2M ( > IN EFI_PHYSICAL_ADDRESS PhysicalAddress, > IN OUT UINT64 *PageEntry1G, > IN EFI_PHYSICAL_ADDRESS StackBase, > - IN UINTN StackSize > + IN UINTN StackSize, > + IN EFI_PHYSICAL_ADDRESS GhcbBase, > + IN UINTN GhcbSize > ) > { > EFI_PHYSICAL_ADDRESS PhysicalAddress2M; > @@ -413,11 +444,11 @@ Split1GPageTo2M ( >=20 > PhysicalAddress2M =3D PhysicalAddress; > for (IndexOfPageDirectoryEntries =3D 0; IndexOfPageDirectoryEntries <= 512; > IndexOfPageDirectoryEntries++, PageDirectoryEntry++, PhysicalAddress2M > +=3D SIZE_2MB) { > - if (ToSplitPageTable (PhysicalAddress2M, SIZE_2MB, StackBase, Stack= Size)) > { > + if (ToSplitPageTable (PhysicalAddress2M, SIZE_2MB, StackBase, > + StackSize, GhcbBase, GhcbSize)) { > // > // Need to split this 2M page that covers NULL or stack range. > // > - Split2MPageTo4K (PhysicalAddress2M, (UINT64 *) PageDirectoryEntry= , > StackBase, StackSize); > + Split2MPageTo4K (PhysicalAddress2M, (UINT64 *) > + PageDirectoryEntry, StackBase, StackSize, GhcbBase, GhcbSize); > } else { > // > // Fill in the Page Directory entries @@ -616,6 +647,8 @@ > EnablePageTableProtection ( >=20 > @param[in] StackBase Stack base address. > @param[in] StackSize Stack size. > + @param[in] GhcbBase GHCB base address. > + @param[in] GhcbSize GHCB size. >=20 > @return The address of 4 level page map. >=20 > @@ -623,7 +656,9 @@ EnablePageTableProtection ( UINTN > CreateIdentityMappingPageTables ( > IN EFI_PHYSICAL_ADDRESS StackBase, > - IN UINTN StackSize > + IN UINTN StackSize, > + IN EFI_PHYSICAL_ADDRESS GhcbBase, > + IN UINTN GhcbSize > ) > { > UINT32 RegEax; > @@ -809,8 +844,8 @@ CreateIdentityMappingPageTables ( > PageDirectory1GEntry =3D (VOID *) PageDirectoryPointerEntry; >=20 > for (IndexOfPageDirectoryEntries =3D 0; IndexOfPageDirectoryEnt= ries < > 512; IndexOfPageDirectoryEntries++, PageDirectory1GEntry++, PageAddress > +=3D SIZE_1GB) { > - if (ToSplitPageTable (PageAddress, SIZE_1GB, StackBase, Stack= Size)) { > - Split1GPageTo2M (PageAddress, (UINT64 *) PageDirectory1GEnt= ry, > StackBase, StackSize); > + if (ToSplitPageTable (PageAddress, SIZE_1GB, StackBase, Stack= Size, > GhcbBase, GhcbSize)) { > + Split1GPageTo2M (PageAddress, (UINT64 *) > + PageDirectory1GEntry, StackBase, StackSize, GhcbBase, GhcbSize); > } else { > // > // Fill in the Page Directory entries @@ -840,11 +875,11 @@ > CreateIdentityMappingPageTables ( > PageDirectoryPointerEntry->Bits.Present =3D 1; >=20 > for (IndexOfPageDirectoryEntries =3D 0; IndexOfPageDirectoryE= ntries < > 512; IndexOfPageDirectoryEntries++, PageDirectoryEntry++, PageAddress += =3D > SIZE_2MB) { > - if (ToSplitPageTable (PageAddress, SIZE_2MB, StackBase, Sta= ckSize)) { > + if (ToSplitPageTable (PageAddress, SIZE_2MB, StackBase, > + StackSize, GhcbBase, GhcbSize)) { > // > // Need to split this 2M page that covers NULL or stack r= ange. > // > - Split2MPageTo4K (PageAddress, (UINT64 *) PageDirectoryEnt= ry, > StackBase, StackSize); > + Split2MPageTo4K (PageAddress, (UINT64 *) > + PageDirectoryEntry, StackBase, StackSize, GhcbBase, GhcbSize); Looks to me that the logic remains the same when PcdGhcbBase and PcdGhcbSi= ze are of their default values. Therefore: Acked-by: Hao A Wu Best Regards, Hao Wu > } else { > // > // Fill in the Page Directory entries > -- > 2.27.0 >=20 >=20 >=20