diff --git a/MdeModulePkg/Core/Dxe/SysCall/Initialization.c b/MdeModulePkg/Core/Dxe/SysCall/Initialization.c index dd4b3a16d8..d2c18cb3e0 100644 --- a/MdeModulePkg/Core/Dxe/SysCall/Initialization.c +++ b/MdeModulePkg/Core/Dxe/SysCall/Initialization.c @@ -213,6 +213,7 @@ InitializeUserPageTable ( UINTN SectionAddress; UINT32 Index; UEFI_IMAGE_RECORD *UserImageRecord; + IA32_DESCRIPTOR IdtDescriptor; UserPageTable = (UINTN)AllocatePages (EFI_SIZE_TO_PAGES (mUserPageTableTemplateSize)); @@ -261,7 +262,7 @@ InitializeUserPageTable ( } // - // Map CoreBootServices, gCoreSysCallStackBase, ExceptionHandlers, ExceptionStacks + // Map CoreBootServices, gCoreSysCallStackBase // gCpu->SetUserMemoryAttributes ( gCpu, @@ -286,7 +287,10 @@ InitializeUserPageTable ( EFI_SIZE_TO_PAGES (USER_STACK_SIZE) * EFI_PAGE_SIZE, EFI_MEMORY_XP ); - + + // + // Map ExceptionHandlers, ExceptionStacks, Idt + // gCpu->SetUserMemoryAttributes ( gCpu, UserPageTable, @@ -311,6 +315,15 @@ InitializeUserPageTable ( EFI_MEMORY_XP ); + AsmReadIdtr (&IdtDescriptor); + gCpu->SetUserMemoryAttributes ( + gCpu, + UserPageTable, + IdtDescriptor.Base, + SIZE_4KB, + EFI_MEMORY_RO | EFI_MEMORY_XP + ); + // // Necessary fix for ProcessLibraryConstructorList() -> DxeCcProbeLibConstructor() // diff --git a/UefiCpuPkg/Library/CpuArchLib/CpuDxe.c b/UefiCpuPkg/Library/CpuArchLib/CpuDxe.c index b7ee3cd877..fac32d4381 100644 --- a/UefiCpuPkg/Library/CpuArchLib/CpuDxe.c +++ b/UefiCpuPkg/Library/CpuArchLib/CpuDxe.c @@ -728,8 +728,9 @@ InitInterruptDescriptorTable ( // // Increase Interrupt Descriptor Table and Copy the old IDT table in // - IdtTable = AllocateZeroPool (sizeof (IA32_IDT_GATE_DESCRIPTOR) * CPU_INTERRUPT_NUM); + IdtTable = AllocatePages (1); ASSERT (IdtTable != NULL); + SetMem (IdtTable, EFI_PAGE_SIZE, 0); CopyMem (IdtTable, (VOID *)IdtDescriptor.Base, sizeof (IA32_IDT_GATE_DESCRIPTOR) * IdtEntryCount); //