mirror of https://github.com/acidanthera/audk.git
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.
|
||||
//
|
||||
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 (
|
||||
(EFI_PHYSICAL_ADDRESS)(UINTN)gRing3Data,
|
||||
EFI_SIZE_TO_PAGES (sizeof (RING3_DATA))
|
||||
|
|
|
@ -1400,9 +1400,30 @@ SysCallBootService (
|
|||
IN VOID *UserRsp
|
||||
)
|
||||
{
|
||||
return CallBootService (
|
||||
Type,
|
||||
(CORE_STACK *)CoreRbp,
|
||||
(RING3_STACK *)UserRsp
|
||||
);
|
||||
EFI_STATUS Status;
|
||||
EFI_PHYSICAL_ADDRESS Physical;
|
||||
|
||||
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;
|
||||
UINTN SizeOfStack;
|
||||
EFI_PHYSICAL_ADDRESS Physical;
|
||||
UINTN Index;
|
||||
EFI_CONFIGURATION_TABLE *Conf;
|
||||
|
||||
//
|
||||
// Set Ring3 EntryPoint and BootServices.
|
||||
|
@ -50,6 +52,28 @@ InitializeRing3 (
|
|||
gRing3Data = (RING3_DATA *)(UINTN)Physical;
|
||||
|
||||
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.
|
||||
//
|
||||
|
|
|
@ -58,6 +58,7 @@ GoToRing3 (
|
|||
VA_END (Marker);
|
||||
EnableSMAP ();
|
||||
|
||||
#if defined (MDE_CPU_X64) || defined (MDE_CPU_IA32)
|
||||
if (Number == 2) {
|
||||
//
|
||||
// Necessary fix for ProcessLibraryConstructorList() -> DxeCcProbeLibConstructor()
|
||||
|
@ -68,9 +69,11 @@ GoToRing3 (
|
|||
EFI_MEMORY_XP | EFI_MEMORY_USER
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
Status = CallRing3 (Input);
|
||||
|
||||
#if defined (MDE_CPU_X64) || defined (MDE_CPU_IA32)
|
||||
if (Number == 2) {
|
||||
SetUefiImageMemoryAttributes (
|
||||
FixedPcdGet32 (PcdOvmfWorkAreaBase),
|
||||
|
@ -78,6 +81,7 @@ GoToRing3 (
|
|||
EFI_MEMORY_XP
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
CoreFreePages (Ring3Pages, PagesNumber);
|
||||
|
||||
|
|
Loading…
Reference in New Issue