From 79e0eca1552d360e56b645cb75030159b205715c Mon Sep 17 00:00:00 2001 From: Mikhail Krichanov Date: Thu, 5 Dec 2024 16:12:31 +0300 Subject: [PATCH] SysCall: Simplified MakeUserPageTableTemplate(). --- MdeModulePkg/Core/Dxe/SysCall/IA32/InitializeIA32.c | 6 ++---- MdeModulePkg/Core/Dxe/SysCall/X64/InitializeX64.c | 6 ++---- OvmfPkg/Include/IndustryStandard/PageTable.h | 2 -- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/SysCall/IA32/InitializeIA32.c b/MdeModulePkg/Core/Dxe/SysCall/IA32/InitializeIA32.c index edc6bed78f..f9fe87feb6 100644 --- a/MdeModulePkg/Core/Dxe/SysCall/IA32/InitializeIA32.c +++ b/MdeModulePkg/Core/Dxe/SysCall/IA32/InitializeIA32.c @@ -42,7 +42,7 @@ MakeUserPageTableTemplate ( NumberOfPdpEntriesNeeded = (UINT32)LShiftU64 (1, (PhysicalAddressBits - 30)); TotalPagesNum = NumberOfPdpEntriesNeeded + 1; - PageAddress = (UINTN)AllocateAlignedPages (TotalPagesNum, PAGE_TABLE_POOL_ALIGNMENT); + PageAddress = (UINTN)AllocatePages (TotalPagesNum); ASSERT (PageAddress != 0); PageMap = (VOID *)PageAddress; @@ -84,9 +84,7 @@ MakeUserPageTableTemplate ( } *UserPageTableTemplate = (VOID *)PageMap; - *UserPageTableTemplateSize = ALIGN_VALUE (EFI_PAGES_TO_SIZE (TotalPagesNum), PAGE_TABLE_POOL_ALIGNMENT); - - SetUefiImageMemoryAttributes ((UINT64)(UINTN)PageMap, *UserPageTableTemplateSize, EFI_MEMORY_XP); + *UserPageTableTemplateSize = EFI_PAGES_TO_SIZE (TotalPagesNum); } VOID diff --git a/MdeModulePkg/Core/Dxe/SysCall/X64/InitializeX64.c b/MdeModulePkg/Core/Dxe/SysCall/X64/InitializeX64.c index 51f89dcde9..3754ab65f4 100644 --- a/MdeModulePkg/Core/Dxe/SysCall/X64/InitializeX64.c +++ b/MdeModulePkg/Core/Dxe/SysCall/X64/InitializeX64.c @@ -155,7 +155,7 @@ MakeUserPageTableTemplate ( TotalPagesNum--; } - BigPageAddress = (UINTN)AllocateAlignedPages (TotalPagesNum, PAGE_TABLE_POOL_ALIGNMENT); + BigPageAddress = (UINTN)AllocatePages (TotalPagesNum); if (BigPageAddress == 0) { DEBUG ((DEBUG_ERROR, "Core: Could not allocate buffer for User page table.\n")); CpuDeadLoop (); @@ -281,9 +281,7 @@ MakeUserPageTableTemplate ( } *UserPageTableTemplate = (VOID *)PageMap; - *UserPageTableTemplateSize = ALIGN_VALUE (EFI_PAGES_TO_SIZE (TotalPagesNum), PAGE_TABLE_POOL_ALIGNMENT); - - SetUefiImageMemoryAttributes ((UINT64)PageMap, *UserPageTableTemplateSize, EFI_MEMORY_XP); + *UserPageTableTemplateSize = EFI_PAGES_TO_SIZE (TotalPagesNum); } VOID diff --git a/OvmfPkg/Include/IndustryStandard/PageTable.h b/OvmfPkg/Include/IndustryStandard/PageTable.h index d9a1195c04..a75b3fcfe7 100644 --- a/OvmfPkg/Include/IndustryStandard/PageTable.h +++ b/OvmfPkg/Include/IndustryStandard/PageTable.h @@ -158,6 +158,4 @@ typedef union { #define PTE_OFFSET(x) ( (x >> 12) & PAGETABLE_ENTRY_MASK) #define PAGING_1G_ADDRESS_MASK_64 0x000FFFFFC0000000ull -#define PAGE_TABLE_POOL_ALIGNMENT BASE_2MB - #endif