From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (NAM02-BL2-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web12.10840.1591363676588816927 for ; Fri, 05 Jun 2020 06:27:57 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=F/2SCPSP; spf=none, err=SPF record not found (domain: amd.com, ip: , mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XR0UATc6JMBz/tQ7Oq5I875RFGeRXfUJFWYXL3lvyiEGE3C55fIsYyjq494Xd1o0CQcu3akNuvKFQQqMAER8C60SBkxCHveJW5wSyNTRNxWQQgxUtl06thHsAsmuMC81T4fs21KRLvotux/rGtOhZROQ/VbZwjc3hQnu45a9BHZ7+Q7M8BTuuj4bbr4O+T3HpY4Z4/xMb7zesBg8dCL8NyfnM9L36G1YDXTo8Gzo2V3poTahQCG7PDLIQps631t1yKNVZQJPbdK1Z1A8xZjyOnGYLT8m48nBRc2P0GC2rS3U17axtNKuPhMfXWILmomCwRyPX8E9VRqYeh0M8HNebA== 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=bLqNtTKMf+ILzCHrK7dxdyWbpiCuYvZJqTw3GfCUNfI=; b=ZMLmqh/lKgsee07aALAVP5kz5EAxr1huYRvVTMX8Qj6ZxBWW6IKQNjhL8+Vcf3YbDXYHu2q6E7GTNuTDro93MIba3sbaYCa4Pb7hRBwNYIbhVasg7IeLSogwZfvCXO2RubRxKsh45iSgZEJTFcJzyoCo4Bk84ezHDx2OGZ10VCgQVoKd6UPrU1MyM+LaZ3q0KOHqsygW5wZWg1HqmB9pjNz4jjRJB7UFU/HYF5AjgBJq8/gkGLxWQGjB+LZts6AH0vObK8hdQbmCCZJoeLzIdxSLRQoFDHyUj9qfuKvFKM/lJ65DieOcq/aGLQGtXFNF7P7GesXv9SPr3+/m0vuNQg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bLqNtTKMf+ILzCHrK7dxdyWbpiCuYvZJqTw3GfCUNfI=; b=F/2SCPSPk1y4OHd2JYIByfjYDyv8AhhPzaVSMrQefEIzwgw4dsZeT+GqykrOnBFirgQd4lU5qJWPH6UfFmqi1ceXRlas2TWImH/6ko62E7e9GkKaAwgRU8MHFjdVhXgTamWU+BsBL6xiXrGAs4jTBpLjqoJ+RYjiY5NFbXWm554= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=amd.com; Received: from DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) by DM5PR12MB1594.namprd12.prod.outlook.com (2603:10b6:4:e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18; Fri, 5 Jun 2020 13:27:54 +0000 Received: from DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::4ce1:9947:9681:c8b1]) by DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::4ce1:9947:9681:c8b1%10]) with mapi id 15.20.3066.019; Fri, 5 Jun 2020 13:27:54 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io Cc: Brijesh Singh , Ard Biesheuvel , Eric Dong , Jordan Justen , Laszlo Ersek , Liming Gao , Michael D Kinney , Ray Ni , Jian J Wang , Hao A Wu , Dandan Bi Subject: [PATCH v9 05/46] MdeModulePkg/DxeIplPeim: Support GHCB pages when creating page tables Date: Fri, 5 Jun 2020 08:26:56 -0500 Message-Id: <894a7513d246e7f5dae75dc7d06b961516a750f5.1591363657.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: DM5PR19CA0060.namprd19.prod.outlook.com (2603:10b6:3:116::22) To DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) Return-Path: thomas.lendacky@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from tlendack-t1.amd.com (165.204.77.1) by DM5PR19CA0060.namprd19.prod.outlook.com (2603:10b6:3:116::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Fri, 5 Jun 2020 13:27:53 +0000 X-Mailer: git-send-email 2.27.0 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 4c1b3282-6772-4db5-1ed1-08d8095440d5 X-MS-TrafficTypeDiagnostic: DM5PR12MB1594: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-Forefront-PRVS: 0425A67DEF X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o7IBM5NVmnmjH25Ab8nrX5aqNE4jZ+JqrQ6xD48TwfFdO7tKJiilI6PI0rjv8K4fj5gw66iyHuD9Ct+vsT3wxe7w7KIINGL8b6KjOvJyNTzVV2FaP1qBfFk6ie5y23/NQHt7VAYvyj3vCd+O5LZcGYkEDKT+m/wBZ6Imud9R2LMPd03KgORbjpN3dYttiwW4aQnVs3IkH0AiLivczDi1hMHUPZhyNtbswYI5rCRA6ZBwWb2tQHu8p9sycDDyM8GKSjvtUYUAL4unX5axGimCZzGEJHbVET0LXFHXunX/SPm24UogxM9uNMzbFmjITXeG93RGJfCkSXM5v7yejxeBshA5C2SG+vIJJnShkoe13dzk9woQEu1I7F04aunadsZ8/5Q5x48iMBAmqXWtaWl5GWxXqwm4l65sANgMkojvlEhieY50oydKXuYiSLqSbyoP9qLlVNP0ui7XdPw3zsoHhQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR12MB1355.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(39860400002)(366004)(346002)(376002)(396003)(136003)(83380400001)(6486002)(4326008)(16526019)(26005)(2906002)(2616005)(956004)(186003)(8936002)(7696005)(52116002)(8676002)(6916009)(30864003)(19627235002)(36756003)(66476007)(66946007)(5660300002)(66556008)(7416002)(966005)(316002)(478600001)(86362001)(54906003)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: N2ZR4CKFsKiJjrKP/xqml1VxzYHqVrk2gsa15O6gfLQ0agnPgJpa1Wbzw9swTvojYqqcnXB5BBWx8e03dhXMUt2uCfVJRYbOSR1m4z6mjHQhP4zG3FCcO26LWepQfx4VfUlmV2E/ie50TwnopJTe+FGxZmvafwJpjY/I0KRUi3jYC7CntzD7IoY/jnLl/nHV73otFgsJxc612/5+Tb+j6SftPhXGhxHCW6eoFaVPtbjmmNItEjk8sFA4nKaKs9uevG1XUdTQkhDGdMCIj5IstFpG0sKFLQWPfsIX3J/6J6ttiQgv3uAacx/AhoipOcQZ67VR2biwqgh0P1e0d7tuYwhQ+T18CuwoEHUedW6LL6suYHzn+UUijqHIOJsv+thXtKnUG2VRSziudWvFZwd0RG29SO9+lzT7wGoq57Aw9O+MTmkUoZN/79yfCLzW+6gnaFVY3GA1qR1TY+EY9Hpt9/+bDhzlly17U+W9DBciHVc= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c1b3282-6772-4db5-1ed1-08d8095440d5 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2020 13:27:54.5055 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HnvnWUZ9gOAqpOLGIu8ibE7Eoj4E06Wm8VbFPzlGdzWfBFZd+oKmMl5XX4t33EBggwiilZlaUwQy7AAgmNrSCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1594 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2198 GHCB pages must be mapped as shared pages, so modify the process of creating identity mapped pagetable entries so that GHCB entries are created 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 page. Only the GHCB page is mapped as shared. 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 + MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.h | 12 ++++- MdeModulePkg/Core/DxeIplPeim/Ia32/DxeLoadFunc.c | 4 +- MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c | 11 +++- MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c | 57 ++++++++++++++++---- 5 files changed, 70 insertions(+), 16 deletions(-) diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf b/MdeModulePkg/Core/Dx= eIplPeim/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=0D gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard ##= CONSUMES=0D gEfiMdeModulePkgTokenSpaceGuid.PcdUse5LevelPageTable ##= SOMETIMES_CONSUMES=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbBase ##= CONSUMES=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdGhcbSize ##= CONSUMES=0D =0D [Pcd.IA32,Pcd.X64,Pcd.ARM,Pcd.AARCH64]=0D gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack ## SOMETIM= ES_CONSUMES=0D diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.h b/MdeModulePk= g/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.=0D @param[in] StackBase Stack base address.=0D @param[in] StackSize Stack size.=0D + @param[in] GhcbBase GHCB page area base address.=0D + @param[in] GhcbSize GHCB page area size.=0D =0D **/=0D VOID=0D @@ -208,7 +210,9 @@ Split2MPageTo4K ( IN EFI_PHYSICAL_ADDRESS PhysicalAddress,=0D IN OUT UINT64 *PageEntry2M,=0D IN EFI_PHYSICAL_ADDRESS StackBase,=0D - IN UINTN StackSize=0D + IN UINTN StackSize,=0D + IN EFI_PHYSICAL_ADDRESS GhcbBase,=0D + IN UINTN GhcbSize=0D );=0D =0D /**=0D @@ -217,6 +221,8 @@ Split2MPageTo4K ( =0D @param[in] StackBase Stack base address.=0D @param[in] StackSize Stack size.=0D + @param[in] GhcbBase GHCB page area base address.=0D + @param[in] GhcbSize GHCB page area size.=0D =0D @return The address of 4 level page map.=0D =0D @@ -224,7 +230,9 @@ Split2MPageTo4K ( UINTN=0D CreateIdentityMappingPageTables (=0D IN EFI_PHYSICAL_ADDRESS StackBase,=0D - IN UINTN StackSize=0D + IN UINTN StackSize,=0D + IN EFI_PHYSICAL_ADDRESS GhcbBase,=0D + IN UINTN GhcbkSize=0D );=0D =0D =0D 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 ( //=0D // Need to split this 2M page that covers stack range.=0D //=0D - Split2MPageTo4K (PhysicalAddress, (UINT64 *) PageDirectoryEntry, S= tackBase, StackSize);=0D + Split2MPageTo4K (PhysicalAddress, (UINT64 *) PageDirectoryEntry, S= tackBase, StackSize, 0, 0);=0D } else {=0D //=0D // Fill in the Page Directory entries=0D @@ -282,7 +282,7 @@ HandOffToDxeCore ( //=0D // Create page table and save PageMapLevel4 to CR3=0D //=0D - PageTables =3D CreateIdentityMappingPageTables (BaseOfStack, STACK_SIZ= E);=0D + PageTables =3D CreateIdentityMappingPageTables (BaseOfStack, STACK_SIZ= E, 0, 0);=0D =0D //=0D // End of PEI phase signal=0D 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;=0D EFI_VECTOR_HANDOFF_INFO *VectorInfo;=0D EFI_PEI_VECTOR_HANDOFF_INFO_PPI *VectorHandoffInfoPpi;=0D + VOID *GhcbBase;=0D + UINTN GhcbSize;=0D =0D //=0D // Clear page 0 and mark it as allocated if NULL pointer detection is en= abled.=0D @@ -81,12 +83,19 @@ HandOffToDxeCore ( TopOfStack =3D (VOID *) ((UINTN) BaseOfStack + EFI_SIZE_TO_PAGES (STACK_= SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);=0D TopOfStack =3D ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);=0D =0D + //=0D + // Get the address and size of the GHCB pages=0D + //=0D + GhcbBase =3D (VOID *) PcdGet64 (PcdGhcbBase);=0D + GhcbSize =3D PcdGet64 (PcdGhcbSize);=0D +=0D PageTables =3D 0;=0D if (FeaturePcdGet (PcdDxeIplBuildPageTables)) {=0D //=0D // Create page table and save PageMapLevel4 to CR3=0D //=0D - PageTables =3D CreateIdentityMappingPageTables ((EFI_PHYSICAL_ADDRESS)= (UINTN) BaseOfStack, STACK_SIZE);=0D + PageTables =3D CreateIdentityMappingPageTables ((EFI_PHYSICAL_ADDRESS)= (UINTN) BaseOfStack, STACK_SIZE,=0D + (EFI_PHYSICAL_ADDRESS) (= UINTN) GhcbBase, GhcbSize);=0D } else {=0D //=0D // Set NX for stack feature also require PcdDxeIplBuildPageTables be T= RUE=0D diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c b/MdeModulePk= g/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.=0D @param StackBase Base address of stack.=0D @param StackSize Size of stack.=0D + @param GhcbBase Base address of GHCB pages.=0D + @param GhcbSize Size of GHCB area.=0D =0D @retval TRUE Page table should be split.=0D @retval FALSE Page table should not be split.=0D @@ -190,7 +192,9 @@ ToSplitPageTable ( IN EFI_PHYSICAL_ADDRESS Address,=0D IN UINTN Size,=0D IN EFI_PHYSICAL_ADDRESS StackBase,=0D - IN UINTN StackSize=0D + IN UINTN StackSize,=0D + IN EFI_PHYSICAL_ADDRESS GhcbBase,=0D + IN UINTN GhcbSize=0D )=0D {=0D if (IsNullDetectionEnabled () && Address =3D=3D 0) {=0D @@ -209,6 +213,12 @@ ToSplitPageTable ( }=0D }=0D =0D + if (GhcbBase !=3D 0) {=0D + if ((Address < GhcbBase + GhcbSize) && ((Address + Size) > GhcbBase)) = {=0D + return TRUE;=0D + }=0D + }=0D +=0D return FALSE;=0D }=0D /**=0D @@ -322,6 +332,8 @@ AllocatePageTableMemory ( @param[in, out] PageEntry2M Pointer to 2M page entry.=0D @param[in] StackBase Stack base address.=0D @param[in] StackSize Stack size.=0D + @param[in] GhcbBase GHCB page area base address.=0D + @param[in] GhcbSize GHCB page area size.=0D =0D **/=0D VOID=0D @@ -329,7 +341,9 @@ Split2MPageTo4K ( IN EFI_PHYSICAL_ADDRESS PhysicalAddress,=0D IN OUT UINT64 *PageEntry2M,=0D IN EFI_PHYSICAL_ADDRESS StackBase,=0D - IN UINTN StackSize=0D + IN UINTN StackSize,=0D + IN EFI_PHYSICAL_ADDRESS GhcbBase,=0D + IN UINTN GhcbSize=0D )=0D {=0D EFI_PHYSICAL_ADDRESS PhysicalAddress4K;=0D @@ -355,7 +369,20 @@ Split2MPageTo4K ( //=0D // Fill in the Page Table entries=0D //=0D - PageTableEntry->Uint64 =3D (UINT64) PhysicalAddress4K | AddressEncMask= ;=0D + PageTableEntry->Uint64 =3D (UINT64) PhysicalAddress4K;=0D +=0D + //=0D + // The GHCB range consists of two pages per CPU, the GHCB and a=0D + // per-CPU variable page. The GHCB page needs to be mapped as an=0D + // unencrypted page while the per-CPU variable page needs to be=0D + // mapped encrypted. These pages alternate in assignment.=0D + //=0D + if ((GhcbBase =3D=3D 0)=0D + || (PhysicalAddress4K < GhcbBase)=0D + || (PhysicalAddress4K >=3D GhcbBase + GhcbSize)=0D + || (((PhysicalAddress4K - GhcbBase) & SIZE_4KB) !=3D 0)) {=0D + PageTableEntry->Uint64 |=3D AddressEncMask;=0D + }=0D PageTableEntry->Bits.ReadWrite =3D 1;=0D =0D if ((IsNullDetectionEnabled () && PhysicalAddress4K =3D=3D 0) ||=0D @@ -383,6 +410,8 @@ Split2MPageTo4K ( @param[in, out] PageEntry1G Pointer to 1G page entry.=0D @param[in] StackBase Stack base address.=0D @param[in] StackSize Stack size.=0D + @param[in] GhcbBase GHCB page area base address.=0D + @param[in] GhcbSize GHCB page area size.=0D =0D **/=0D VOID=0D @@ -390,7 +419,9 @@ Split1GPageTo2M ( IN EFI_PHYSICAL_ADDRESS PhysicalAddress,=0D IN OUT UINT64 *PageEntry1G,=0D IN EFI_PHYSICAL_ADDRESS StackBase,=0D - IN UINTN StackSize=0D + IN UINTN StackSize,=0D + IN EFI_PHYSICAL_ADDRESS GhcbBase,=0D + IN UINTN GhcbSize=0D )=0D {=0D EFI_PHYSICAL_ADDRESS PhysicalAddress2M;=0D @@ -413,11 +444,11 @@ Split1GPageTo2M ( =0D PhysicalAddress2M =3D PhysicalAddress;=0D for (IndexOfPageDirectoryEntries =3D 0; IndexOfPageDirectoryEntries < 51= 2; IndexOfPageDirectoryEntries++, PageDirectoryEntry++, PhysicalAddress2M += =3D SIZE_2MB) {=0D - if (ToSplitPageTable (PhysicalAddress2M, SIZE_2MB, StackBase, StackSiz= e)) {=0D + if (ToSplitPageTable (PhysicalAddress2M, SIZE_2MB, StackBase, StackSiz= e, GhcbBase, GhcbSize)) {=0D //=0D // Need to split this 2M page that covers NULL or stack range.=0D //=0D - Split2MPageTo4K (PhysicalAddress2M, (UINT64 *) PageDirectoryEntry, S= tackBase, StackSize);=0D + Split2MPageTo4K (PhysicalAddress2M, (UINT64 *) PageDirectoryEntry, S= tackBase, StackSize, GhcbBase, GhcbSize);=0D } else {=0D //=0D // Fill in the Page Directory entries=0D @@ -616,6 +647,8 @@ EnablePageTableProtection ( =0D @param[in] StackBase Stack base address.=0D @param[in] StackSize Stack size.=0D + @param[in] GhcbBase GHCB base address.=0D + @param[in] GhcbSize GHCB size.=0D =0D @return The address of 4 level page map.=0D =0D @@ -623,7 +656,9 @@ EnablePageTableProtection ( UINTN=0D CreateIdentityMappingPageTables (=0D IN EFI_PHYSICAL_ADDRESS StackBase,=0D - IN UINTN StackSize=0D + IN UINTN StackSize,=0D + IN EFI_PHYSICAL_ADDRESS GhcbBase,=0D + IN UINTN GhcbSize=0D )=0D {=0D UINT32 RegEax;=0D @@ -809,8 +844,8 @@ CreateIdentityMappingPageTables ( PageDirectory1GEntry =3D (VOID *) PageDirectoryPointerEntry;=0D =0D for (IndexOfPageDirectoryEntries =3D 0; IndexOfPageDirectoryEntrie= s < 512; IndexOfPageDirectoryEntries++, PageDirectory1GEntry++, PageAddress= +=3D SIZE_1GB) {=0D - if (ToSplitPageTable (PageAddress, SIZE_1GB, StackBase, StackSiz= e)) {=0D - Split1GPageTo2M (PageAddress, (UINT64 *) PageDirectory1GEntry,= StackBase, StackSize);=0D + if (ToSplitPageTable (PageAddress, SIZE_1GB, StackBase, StackSiz= e, GhcbBase, GhcbSize)) {=0D + Split1GPageTo2M (PageAddress, (UINT64 *) PageDirectory1GEntry,= StackBase, StackSize, GhcbBase, GhcbSize);=0D } else {=0D //=0D // Fill in the Page Directory entries=0D @@ -840,11 +875,11 @@ CreateIdentityMappingPageTables ( PageDirectoryPointerEntry->Bits.Present =3D 1;=0D =0D for (IndexOfPageDirectoryEntries =3D 0; IndexOfPageDirectoryEntr= ies < 512; IndexOfPageDirectoryEntries++, PageDirectoryEntry++, PageAddress= +=3D SIZE_2MB) {=0D - if (ToSplitPageTable (PageAddress, SIZE_2MB, StackBase, StackS= ize)) {=0D + if (ToSplitPageTable (PageAddress, SIZE_2MB, StackBase, StackS= ize, GhcbBase, GhcbSize)) {=0D //=0D // Need to split this 2M page that covers NULL or stack rang= e.=0D //=0D - Split2MPageTo4K (PageAddress, (UINT64 *) PageDirectoryEntry,= StackBase, StackSize);=0D + Split2MPageTo4K (PageAddress, (UINT64 *) PageDirectoryEntry,= StackBase, StackSize, GhcbBase, GhcbSize);=0D } else {=0D //=0D // Fill in the Page Directory entries=0D --=20 2.27.0