Skip to content

Commit

Permalink
SysCall: Simplified MakeUserPageTableTemplate().
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Krichanov committed Dec 5, 2024
1 parent 85070fb commit 79e0eca
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
6 changes: 2 additions & 4 deletions MdeModulePkg/Core/Dxe/SysCall/IA32/InitializeIA32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions MdeModulePkg/Core/Dxe/SysCall/X64/InitializeX64.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions OvmfPkg/Include/IndustryStandard/PageTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 79e0eca

Please sign in to comment.