mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-23 13:44:33 +02:00
Ring3: Fixed some page faults caused by wrong memory attribution.
This commit is contained in:
parent
d03b93be3d
commit
c542f9f3b0
@ -768,6 +768,15 @@ CoreExitBootServices (
|
|||||||
// Free resources allocated for Ring3.
|
// Free resources allocated for Ring3.
|
||||||
//
|
//
|
||||||
if (gRing3Data != NULL) {
|
if (gRing3Data != NULL) {
|
||||||
|
DisableSMAP ();
|
||||||
|
if (gRing3Data->SystemTable.ConfigurationTable != NULL) {
|
||||||
|
CoreFreePages (
|
||||||
|
(EFI_PHYSICAL_ADDRESS)(UINTN)gRing3Data->SystemTable.ConfigurationTable,
|
||||||
|
EFI_SIZE_TO_PAGES (gRing3Data->SystemTable.NumberOfTableEntries * sizeof (EFI_CONFIGURATION_TABLE))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
EnableSMAP ();
|
||||||
|
|
||||||
CoreFreePages (
|
CoreFreePages (
|
||||||
(EFI_PHYSICAL_ADDRESS)(UINTN)gRing3Data,
|
(EFI_PHYSICAL_ADDRESS)(UINTN)gRing3Data,
|
||||||
EFI_SIZE_TO_PAGES (sizeof (RING3_DATA))
|
EFI_SIZE_TO_PAGES (sizeof (RING3_DATA))
|
||||||
|
@ -1400,9 +1400,30 @@ SysCallBootService (
|
|||||||
IN VOID *UserRsp
|
IN VOID *UserRsp
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return CallBootService (
|
EFI_STATUS Status;
|
||||||
Type,
|
EFI_PHYSICAL_ADDRESS Physical;
|
||||||
(CORE_STACK *)CoreRbp,
|
|
||||||
(RING3_STACK *)UserRsp
|
Status = CoreAllocatePages (
|
||||||
);
|
AllocateAnyPages,
|
||||||
|
EfiRing3MemoryType,
|
||||||
|
EFI_SIZE_TO_PAGES (8 * sizeof (UINTN)),
|
||||||
|
&Physical
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
DisableSMAP ();
|
||||||
|
CopyMem ((VOID *)(UINTN)Physical, (VOID *)UserRsp, 8 * sizeof (UINTN));
|
||||||
|
EnableSMAP ();
|
||||||
|
|
||||||
|
Status = CallBootService (
|
||||||
|
Type,
|
||||||
|
(CORE_STACK *)CoreRbp,
|
||||||
|
(RING3_STACK *)(UINTN)Physical
|
||||||
|
);
|
||||||
|
|
||||||
|
CoreFreePages (Physical, EFI_SIZE_TO_PAGES (8 * sizeof (UINTN)));
|
||||||
|
|
||||||
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,8 @@ InitializeRing3 (
|
|||||||
VOID *TopOfStack;
|
VOID *TopOfStack;
|
||||||
UINTN SizeOfStack;
|
UINTN SizeOfStack;
|
||||||
EFI_PHYSICAL_ADDRESS Physical;
|
EFI_PHYSICAL_ADDRESS Physical;
|
||||||
|
UINTN Index;
|
||||||
|
EFI_CONFIGURATION_TABLE *Conf;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set Ring3 EntryPoint and BootServices.
|
// Set Ring3 EntryPoint and BootServices.
|
||||||
@ -50,6 +52,28 @@ InitializeRing3 (
|
|||||||
gRing3Data = (RING3_DATA *)(UINTN)Physical;
|
gRing3Data = (RING3_DATA *)(UINTN)Physical;
|
||||||
|
|
||||||
CopyMem ((VOID *)gRing3Data, (VOID *)Image->Info.SystemTable, sizeof (EFI_SYSTEM_TABLE));
|
CopyMem ((VOID *)gRing3Data, (VOID *)Image->Info.SystemTable, sizeof (EFI_SYSTEM_TABLE));
|
||||||
|
|
||||||
|
Status = CoreAllocatePages (
|
||||||
|
AllocateAnyPages,
|
||||||
|
EfiRing3MemoryType,
|
||||||
|
EFI_SIZE_TO_PAGES (gRing3Data->SystemTable.NumberOfTableEntries * sizeof (EFI_CONFIGURATION_TABLE)),
|
||||||
|
&Physical
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
DEBUG ((DEBUG_ERROR, "Core: Failed to allocate memory for Ring3 ConfigurationTable.\n"));
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
Conf = (EFI_CONFIGURATION_TABLE *)(UINTN)Physical;
|
||||||
|
|
||||||
|
for (Index = 0; Index < gRing3Data->SystemTable.NumberOfTableEntries; ++Index) {
|
||||||
|
Conf->VendorGuid = gRing3Data->SystemTable.ConfigurationTable[Index].VendorGuid;
|
||||||
|
Conf->VendorTable = gRing3Data->SystemTable.ConfigurationTable[Index].VendorTable;
|
||||||
|
++Conf;
|
||||||
|
}
|
||||||
|
|
||||||
|
gRing3Data->SystemTable.ConfigurationTable = (EFI_CONFIGURATION_TABLE *)(UINTN)Physical;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Initialize DxeRing3 with Supervisor privileges.
|
// Initialize DxeRing3 with Supervisor privileges.
|
||||||
//
|
//
|
||||||
|
@ -58,6 +58,7 @@ GoToRing3 (
|
|||||||
VA_END (Marker);
|
VA_END (Marker);
|
||||||
EnableSMAP ();
|
EnableSMAP ();
|
||||||
|
|
||||||
|
#if defined (MDE_CPU_X64) || defined (MDE_CPU_IA32)
|
||||||
if (Number == 2) {
|
if (Number == 2) {
|
||||||
//
|
//
|
||||||
// Necessary fix for ProcessLibraryConstructorList() -> DxeCcProbeLibConstructor()
|
// Necessary fix for ProcessLibraryConstructorList() -> DxeCcProbeLibConstructor()
|
||||||
@ -68,9 +69,11 @@ GoToRing3 (
|
|||||||
EFI_MEMORY_XP | EFI_MEMORY_USER
|
EFI_MEMORY_XP | EFI_MEMORY_USER
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
Status = CallRing3 (Input);
|
Status = CallRing3 (Input);
|
||||||
|
|
||||||
|
#if defined (MDE_CPU_X64) || defined (MDE_CPU_IA32)
|
||||||
if (Number == 2) {
|
if (Number == 2) {
|
||||||
SetUefiImageMemoryAttributes (
|
SetUefiImageMemoryAttributes (
|
||||||
FixedPcdGet32 (PcdOvmfWorkAreaBase),
|
FixedPcdGet32 (PcdOvmfWorkAreaBase),
|
||||||
@ -78,6 +81,7 @@ GoToRing3 (
|
|||||||
EFI_MEMORY_XP
|
EFI_MEMORY_XP
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
CoreFreePages (Ring3Pages, PagesNumber);
|
CoreFreePages (Ring3Pages, PagesNumber);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user