]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/DxeIplPeim/X64/DxeLoadFunc.c
Create X64 mode page tables in memory even when PEI is already X64
[mirror_edk2.git] / MdeModulePkg / Core / DxeIplPeim / X64 / DxeLoadFunc.c
index 51055e157aa87f08ed947714b31f8de7eaf0ca95..05c5203d820f5706a2b4ba6c27b577f21e21b3cd 100644 (file)
@@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/\r
 \r
 #include "DxeIpl.h"\r
+#include "X64/VirtualMemory.h"\r
 \r
 \r
 \r
@@ -36,6 +37,7 @@ HandOffToDxeCore (
   VOID                *BaseOfStack;\r
   VOID                *TopOfStack;\r
   EFI_STATUS          Status;\r
+  UINTN               PageTables;\r
 \r
   //\r
   // Allocate 128KB for the Stack\r
@@ -50,12 +52,19 @@ HandOffToDxeCore (
   TopOfStack = (VOID *) ((UINTN) BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);\r
   TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);\r
 \r
+  //\r
+  // Create page table and save PageMapLevel4 to CR3\r
+  //\r
+  PageTables = CreateIdentityMappingPageTables ();\r
+\r
   //\r
   // End of PEI phase singal\r
   //\r
   Status = PeiServicesInstallPpi (&gEndOfPeiSignalPpi);\r
   ASSERT_EFI_ERROR (Status);\r
 \r
+  AsmWriteCr3 (PageTables);\r
+\r
   //\r
   // Update the contents of BSP stack HOB to reflect the real stack info passed to DxeCore.\r
   //    \r