Core/Dxe: Fixed memory type in Ring3AllocatePages(), and code alignment.

This commit is contained in:
Mikhail Krichanov 2024-11-29 11:30:49 +03:00
parent c23d434619
commit 7720181673
2 changed files with 73 additions and 73 deletions

View File

@ -128,7 +128,7 @@ Ring3AllocatePages (
Status = SysCall ( Status = SysCall (
SysCallAllocatePages, SysCallAllocatePages,
Type, Type,
MemoryType, EfiRing3MemoryType,
NumberOfPages, NumberOfPages,
Memory Memory
); );

View File

@ -222,40 +222,40 @@ InitializeUserPageTable (
// Map gRing3Data, gRing3Interfaces, gRing3CallStackBase, DxeRing3 // Map gRing3Data, gRing3Interfaces, gRing3CallStackBase, DxeRing3
// //
gCpu->SetUserMemoryAttributes ( gCpu->SetUserMemoryAttributes (
gCpu, gCpu,
UserPageTable, UserPageTable,
(UINTN)gRing3Data, (UINTN)gRing3Data,
ALIGN_VALUE (sizeof (RING3_DATA), EFI_PAGE_SIZE), ALIGN_VALUE (sizeof (RING3_DATA), EFI_PAGE_SIZE),
EFI_MEMORY_XP | EFI_MEMORY_USER EFI_MEMORY_XP | EFI_MEMORY_USER
); );
gCpu->SetUserMemoryAttributes ( gCpu->SetUserMemoryAttributes (
gCpu, gCpu,
UserPageTable, UserPageTable,
(UINTN)gRing3Interfaces, (UINTN)gRing3Interfaces,
EFI_PAGES_TO_SIZE (RING3_INTERFACES_PAGES), EFI_PAGES_TO_SIZE (RING3_INTERFACES_PAGES),
EFI_MEMORY_XP | EFI_MEMORY_USER EFI_MEMORY_XP | EFI_MEMORY_USER
); );
gCpu->SetUserMemoryAttributes ( gCpu->SetUserMemoryAttributes (
gCpu, gCpu,
UserPageTable, UserPageTable,
(UINTN)gRing3CallStackBase, (UINTN)gRing3CallStackBase,
EFI_SIZE_TO_PAGES (USER_STACK_SIZE) * EFI_PAGE_SIZE, EFI_SIZE_TO_PAGES (USER_STACK_SIZE) * EFI_PAGE_SIZE,
EFI_MEMORY_XP | EFI_MEMORY_USER EFI_MEMORY_XP | EFI_MEMORY_USER
); );
SectionAddress = mDxeRing3->StartAddress; SectionAddress = mDxeRing3->StartAddress;
for (Index = 0; Index < mDxeRing3->NumSegments; Index++) { for (Index = 0; Index < mDxeRing3->NumSegments; Index++) {
ImageRecordSegment = &mDxeRing3->Segments[Index]; ImageRecordSegment = &mDxeRing3->Segments[Index];
gCpu->SetUserMemoryAttributes ( gCpu->SetUserMemoryAttributes (
gCpu, gCpu,
UserPageTable, UserPageTable,
SectionAddress, SectionAddress,
ImageRecordSegment->Size, ImageRecordSegment->Size,
ImageRecordSegment->Attributes | EFI_MEMORY_USER ImageRecordSegment->Attributes | EFI_MEMORY_USER
); );
SectionAddress += ImageRecordSegment->Size; SectionAddress += ImageRecordSegment->Size;
} }
@ -264,63 +264,63 @@ InitializeUserPageTable (
// Map CoreBootServices, gCoreSysCallStackBase, ExceptionHandlers, ExceptionStacks // Map CoreBootServices, gCoreSysCallStackBase, ExceptionHandlers, ExceptionStacks
// //
gCpu->SetUserMemoryAttributes ( gCpu->SetUserMemoryAttributes (
gCpu, gCpu,
UserPageTable, UserPageTable,
(UINTN)&SysCallBase, (UINTN)&SysCallBase,
(UINTN)&SysCallEnd - (UINTN)&SysCallBase, (UINTN)&SysCallEnd - (UINTN)&SysCallBase,
EFI_MEMORY_RO EFI_MEMORY_RO
); );
gCpu->SetUserMemoryAttributes ( gCpu->SetUserMemoryAttributes (
gCpu, gCpu,
UserPageTable, UserPageTable,
(UINTN)&gCorePageTable, (UINTN)&gCorePageTable,
SIZE_4KB, SIZE_4KB,
EFI_MEMORY_RO | EFI_MEMORY_XP EFI_MEMORY_RO | EFI_MEMORY_XP
); );
gCpu->SetUserMemoryAttributes ( gCpu->SetUserMemoryAttributes (
gCpu, gCpu,
UserPageTable, UserPageTable,
(UINTN)gCoreSysCallStackBase, (UINTN)gCoreSysCallStackBase,
EFI_SIZE_TO_PAGES (USER_STACK_SIZE) * EFI_PAGE_SIZE, EFI_SIZE_TO_PAGES (USER_STACK_SIZE) * EFI_PAGE_SIZE,
EFI_MEMORY_XP EFI_MEMORY_XP
); );
gCpu->SetUserMemoryAttributes ( gCpu->SetUserMemoryAttributes (
gCpu, gCpu,
UserPageTable, UserPageTable,
mExceptionAddresses->ExceptionStackBase, mExceptionAddresses->ExceptionStackBase,
mExceptionAddresses->ExceptionStackSize, mExceptionAddresses->ExceptionStackSize,
EFI_MEMORY_XP EFI_MEMORY_XP
); );
gCpu->SetUserMemoryAttributes ( gCpu->SetUserMemoryAttributes (
gCpu, gCpu,
UserPageTable, UserPageTable,
mExceptionAddresses->ExceptionHandlerBase, mExceptionAddresses->ExceptionHandlerBase,
mExceptionAddresses->ExceptionHandlerSize, mExceptionAddresses->ExceptionHandlerSize,
EFI_MEMORY_RO EFI_MEMORY_RO
); );
gCpu->SetUserMemoryAttributes ( gCpu->SetUserMemoryAttributes (
gCpu, gCpu,
UserPageTable, UserPageTable,
mExceptionAddresses->ExceptionDataBase, mExceptionAddresses->ExceptionDataBase,
SIZE_4KB, SIZE_4KB,
EFI_MEMORY_XP EFI_MEMORY_XP
); );
// //
// Necessary fix for ProcessLibraryConstructorList() -> DxeCcProbeLibConstructor() // Necessary fix for ProcessLibraryConstructorList() -> DxeCcProbeLibConstructor()
// //
gCpu->SetUserMemoryAttributes ( gCpu->SetUserMemoryAttributes (
gCpu, gCpu,
UserPageTable, UserPageTable,
FixedPcdGet32 (PcdOvmfWorkAreaBase), FixedPcdGet32 (PcdOvmfWorkAreaBase),
FixedPcdGet32 (PcdOvmfWorkAreaSize), FixedPcdGet32 (PcdOvmfWorkAreaSize),
EFI_MEMORY_XP | EFI_MEMORY_USER EFI_MEMORY_XP | EFI_MEMORY_USER
); );
// //
// Map User Image // Map User Image
@ -333,12 +333,12 @@ InitializeUserPageTable (
ImageRecordSegment = &UserImageRecord->Segments[Index]; ImageRecordSegment = &UserImageRecord->Segments[Index];
gCpu->SetUserMemoryAttributes ( gCpu->SetUserMemoryAttributes (
gCpu, gCpu,
UserPageTable, UserPageTable,
SectionAddress, SectionAddress,
ImageRecordSegment->Size, ImageRecordSegment->Size,
ImageRecordSegment->Attributes | EFI_MEMORY_USER ImageRecordSegment->Attributes | EFI_MEMORY_USER
); );
SectionAddress += ImageRecordSegment->Size; SectionAddress += ImageRecordSegment->Size;
} }