Skip to content

Commit

Permalink
SysCall: Refactored MakeUserPageTableTemplate().
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Krichanov committed Dec 9, 2024
1 parent 5588895 commit 84ab39c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions MdeModulePkg/Core/Dxe/SysCall/IA32/InitializeIA32.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
VOID
EFIAPI
MakeUserPageTableTemplate (
OUT VOID **UserPageTableTemplate,
OUT UINTN *UserPageTableTemplate,
OUT UINTN *UserPageTableTemplateSize
)
{
Expand Down Expand Up @@ -83,7 +83,7 @@ MakeUserPageTableTemplate (
);
}

*UserPageTableTemplate = (VOID *)PageMap;
*UserPageTableTemplate = (UINTN)PageMap;
*UserPageTableTemplateSize = EFI_PAGES_TO_SIZE (TotalPagesNum);
}

Expand Down
14 changes: 6 additions & 8 deletions MdeModulePkg/Core/Dxe/SysCall/Initialization.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ VOID *gRing3Interfaces;
UINTN gUartBaseAddress;

UEFI_IMAGE_RECORD *mDxeRing3;
VOID *mUserPageTableTemplate;
UINTN mUserPageTableTemplateSize;
EXCEPTION_ADDRESSES *mExceptionAddresses;

extern UINTN SysCallBase;
Expand All @@ -29,7 +27,7 @@ extern UINTN SysCallEnd;
VOID
EFIAPI
MakeUserPageTableTemplate (
OUT VOID **UserPageTableTemplate,
OUT UINTN *UserPageTableTemplate,
OUT UINTN *UserPageTableTemplateSize
);

Expand Down Expand Up @@ -195,8 +193,6 @@ InitializeRing3 (
gRing3Data->SystemTable.NumberOfTableEntries
);

MakeUserPageTableTemplate (&mUserPageTableTemplate, &mUserPageTableTemplateSize);

mExceptionAddresses = GetExceptionAddresses ();

return Status;
Expand All @@ -209,15 +205,17 @@ InitializeUserPageTable (
)
{
UINTN UserPageTable;
UINTN UserPageTableSize;
UEFI_IMAGE_RECORD_SEGMENT *ImageRecordSegment;
UINTN SectionAddress;
UINT32 Index;
UEFI_IMAGE_RECORD *UserImageRecord;
IA32_DESCRIPTOR IdtDescriptor;

UserPageTable = (UINTN)AllocatePages (EFI_SIZE_TO_PAGES (mUserPageTableTemplateSize));

CopyMem ((VOID *)UserPageTable, mUserPageTableTemplate, mUserPageTableTemplateSize);
//
// TODO: Remove ASSERTs, add proper checks and return status.
//
MakeUserPageTableTemplate (&UserPageTable, &UserPageTableSize);

//
// Map gRing3Data, gRing3Interfaces, gRing3CallStackBase, DxeRing3
Expand Down
4 changes: 2 additions & 2 deletions MdeModulePkg/Core/Dxe/SysCall/X64/InitializeX64.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
VOID
EFIAPI
MakeUserPageTableTemplate (
OUT VOID **UserPageTableTemplate,
OUT UINTN *UserPageTableTemplate,
OUT UINTN *UserPageTableTemplateSize
)
{
Expand Down Expand Up @@ -280,7 +280,7 @@ MakeUserPageTableTemplate (
ZeroMem (PageMapLevel5Entry, (512 - IndexOfPml5Entries) * sizeof (PAGE_MAP_AND_DIRECTORY_POINTER));
}

*UserPageTableTemplate = (VOID *)PageMap;
*UserPageTableTemplate = (UINTN)PageMap;
*UserPageTableTemplateSize = EFI_PAGES_TO_SIZE (TotalPagesNum);
}

Expand Down

0 comments on commit 84ab39c

Please sign in to comment.