Skip to content

Commit

Permalink
Ring3: Fixed bug in Uart initialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Krichanov committed Jan 30, 2025
1 parent bc70cc3 commit 9216e41
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
3 changes: 2 additions & 1 deletion ArmVirtPkg/Library/DebugLibFdtPL011Uart/User.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ DebugLibFdtPL011UartUserConstructor (
for (Index = 0; Index < SystemTable->NumberOfTableEntries; ++Index) {
if (CompareGuid (&gEarlyPL011BaseAddressGuid, &(SystemTable->ConfigurationTable[Index].VendorGuid))) {
mDebugLibFdtPL011UartAddress = (UINTN)SystemTable->ConfigurationTable[Index].VendorTable;
return EFI_SUCCESS;
}
}

return EFI_SUCCESS;
return EFI_NOT_FOUND;
}

/**
Expand Down
28 changes: 13 additions & 15 deletions MdeModulePkg/Core/Dxe/SysCall/Initialization.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ InitializeRing3 (
EFI_MEMORY_XP | EFI_MEMORY_USER
);

Status = InitializePlatform (&gRing3Data->SystemTable);
if (EFI_ERROR (Status)) {
CoreFreePages (
(EFI_PHYSICAL_ADDRESS)(UINTN)gRing3Data,
EFI_SIZE_TO_PAGES (sizeof (RING3_DATA))
);
return Status;
}

//
// Initialize DxeRing3 with Supervisor privileges.
//
Expand All @@ -81,14 +90,16 @@ InitializeRing3 (

SetUefiImageProtectionAttributes (mDxeRing3, FALSE);

AllowSupervisorAccessToUserMemory ();
Status = Image->EntryPoint (ImageHandle, (EFI_SYSTEM_TABLE *)gRing3Data);

SetUefiImageProtectionAttributes (mDxeRing3, TRUE);

gRing3EntryPoint = gRing3Data->EntryPoint;

gRing3Data->SystemTable.BootServices = gRing3Data->BootServices;
gRing3Data->SystemTable.RuntimeServices = gRing3Data->RuntimeServices;
ForbidSupervisorAccessToUserMemory ();

SetUefiImageProtectionAttributes (mDxeRing3, TRUE);

Status = CoreAllocatePages (
AllocateAnyPages,
Expand All @@ -112,19 +123,6 @@ InitializeRing3 (
EFI_MEMORY_XP | EFI_MEMORY_USER
);

Status = InitializePlatform (&gRing3Data->SystemTable);
if (EFI_ERROR (Status)) {
CoreFreePages (
(EFI_PHYSICAL_ADDRESS)(UINTN)gRing3Data,
EFI_SIZE_TO_PAGES (sizeof (RING3_DATA))
);
CoreFreePages (
(EFI_PHYSICAL_ADDRESS)(UINTN)gRing3Interfaces,
RING3_INTERFACES_PAGES
);
return Status;
}

mExceptionAddresses = GetExceptionAddresses ();

PeiHob.Raw = GetHobList ();
Expand Down

0 comments on commit 9216e41

Please sign in to comment.