From 1bde91a85d76c5593fd7543abfac18b936ef959b Mon Sep 17 00:00:00 2001 From: Mikhail Krichanov Date: Fri, 29 Nov 2024 19:42:10 +0300 Subject: [PATCH] Ring3: Set 1G User pages as not present by default, fixed padding. --- MdeModulePkg/Core/Dxe/SysCall/X64/InitializeMsr.c | 2 +- .../CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/SysCall/X64/InitializeMsr.c b/MdeModulePkg/Core/Dxe/SysCall/X64/InitializeMsr.c index af451fe547..c3bcc33919 100644 --- a/MdeModulePkg/Core/Dxe/SysCall/X64/InitializeMsr.c +++ b/MdeModulePkg/Core/Dxe/SysCall/X64/InitializeMsr.c @@ -111,7 +111,7 @@ MakeUserPageTableTemplate ( // PageDirectory1GEntry->Uint64 = (UINT64)PageAddress | PageTableInfo->AddressEncMask; PageDirectory1GEntry->Bits.ReadWrite = 1; - PageDirectory1GEntry->Bits.Present = 1; + PageDirectory1GEntry->Bits.Present = 0; PageDirectory1GEntry->Bits.MustBe1 = 1; } } else { diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm index 49f6267982..31e1a70780 100644 --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm @@ -63,11 +63,14 @@ global ASM_PFX(UserPageTable) ASM_PFX(UserPageTable): resq 1 -ALIGN 4096 global ASM_PFX(mSwitchCr3Flag) ASM_PFX(mSwitchCr3Flag): db 0x0 +ALIGN 4096 +Padding: + db 0x0 + DEFAULT REL SECTION .text