Skip to content

Commit

Permalink
Ring3: Added debug printings and some fixes for FAT wrappers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Krichanov committed Mar 8, 2024
1 parent 96d43d9 commit 3f2f955
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 10 deletions.
62 changes: 61 additions & 1 deletion MdeModulePkg/Core/Dxe/DxeRing3/Ring3UefiBootServices.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ Ring3GetMemoryMap (
OUT UINT32 *DescriptorVersion
)
{
DEBUG ((DEBUG_ERROR, "Ring3: GetMemoryMap is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -171,6 +173,8 @@ Ring3CreateEvent (
OUT EFI_EVENT *Event
)
{
DEBUG ((DEBUG_ERROR, "Ring3: CreateEvent is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -182,6 +186,8 @@ Ring3SetTimer (
IN UINT64 TriggerTime
)
{
DEBUG ((DEBUG_ERROR, "Ring3: SetTimer is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -193,6 +199,8 @@ Ring3WaitForEvent (
OUT UINTN *UserIndex
)
{
DEBUG ((DEBUG_ERROR, "Ring3: WaitForEvent is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -202,6 +210,8 @@ Ring3SignalEvent (
IN EFI_EVENT UserEvent
)
{
DEBUG ((DEBUG_ERROR, "Ring3: SignalEvent is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -211,6 +221,8 @@ Ring3CloseEvent (
IN EFI_EVENT UserEvent
)
{
DEBUG ((DEBUG_ERROR, "Ring3: CloseEvent is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -220,6 +232,8 @@ Ring3CheckEvent (
IN EFI_EVENT UserEvent
)
{
DEBUG ((DEBUG_ERROR, "Ring3: CheckEvent is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -232,6 +246,8 @@ Ring3InstallProtocolInterface (
IN VOID *Interface
)
{
DEBUG ((DEBUG_ERROR, "Ring3: InstallProtocolInterface is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -244,6 +260,8 @@ Ring3ReinstallProtocolInterface (
IN VOID *NewInterface
)
{
DEBUG ((DEBUG_ERROR, "Ring3: ReinstallProtocolInterface is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -255,6 +273,8 @@ Ring3UninstallProtocolInterface (
IN VOID *Interface
)
{
DEBUG ((DEBUG_ERROR, "Ring3: UninstallProtocolInterface is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand Down Expand Up @@ -290,6 +310,8 @@ Ring3RegisterProtocolNotify (
OUT VOID **Registration
)
{
DEBUG ((DEBUG_ERROR, "Ring3: RegisterProtocolNotify is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -303,6 +325,8 @@ Ring3LocateHandle (
OUT EFI_HANDLE *Buffer
)
{
DEBUG ((DEBUG_ERROR, "Ring3: LocateHandle is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -314,6 +338,8 @@ Ring3LocateDevicePath (
OUT EFI_HANDLE *Device
)
{
DEBUG ((DEBUG_ERROR, "Ring3: LocateDevicePath is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -324,6 +350,8 @@ Ring3InstallConfigurationTable (
IN VOID *Table
)
{
DEBUG ((DEBUG_ERROR, "Ring3: InstallConfigurationTable is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -338,6 +366,8 @@ Ring3LoadImage (
OUT EFI_HANDLE *ImageHandle
)
{
DEBUG ((DEBUG_ERROR, "Ring3: LoadImage is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -349,6 +379,8 @@ Ring3StartImage (
OUT CHAR16 **ExitData OPTIONAL
)
{
DEBUG ((DEBUG_ERROR, "Ring3: StartImage is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -361,6 +393,8 @@ Ring3Exit (
IN CHAR16 *ExitData OPTIONAL
)
{
DEBUG ((DEBUG_ERROR, "Ring3: Exit is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -370,6 +404,8 @@ Ring3UnloadImage (
IN EFI_HANDLE ImageHandle
)
{
DEBUG ((DEBUG_ERROR, "Ring3: UnloadImage is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -380,6 +416,8 @@ Ring3ExitBootServices (
IN UINTN MapKey
)
{
DEBUG ((DEBUG_ERROR, "Ring3: ExitBootServices is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -389,6 +427,8 @@ Ring3GetNextMonotonicCount (
OUT UINT64 *Count
)
{
DEBUG ((DEBUG_ERROR, "Ring3: GetNextMonotonicCount is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -398,6 +438,8 @@ Ring3Stall (
IN UINTN Microseconds
)
{
DEBUG ((DEBUG_ERROR, "Ring3: Stall is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -410,6 +452,8 @@ Ring3SetWatchdogTimer (
IN CHAR16 *WatchdogData OPTIONAL
)
{
DEBUG ((DEBUG_ERROR, "Ring3: SetWatchdogTimer is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -422,6 +466,8 @@ Ring3ConnectController (
IN BOOLEAN Recursive
)
{
DEBUG ((DEBUG_ERROR, "Ring3: ConnectController is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -433,6 +479,8 @@ Ring3DisconnectController (
IN EFI_HANDLE ChildHandle OPTIONAL
)
{
DEBUG ((DEBUG_ERROR, "Ring3: DisconnectController is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand Down Expand Up @@ -462,7 +510,7 @@ Ring3OpenProtocol (
return Status;
}

return FixInterface (Protocol, Interface);
return (Interface != NULL) ? FixInterface (Protocol, Interface) : Status;
}

EFI_STATUS
Expand Down Expand Up @@ -492,6 +540,8 @@ Ring3OpenProtocolInformation (
OUT UINTN *EntryCount
)
{
DEBUG ((DEBUG_ERROR, "Ring3: OpenProtocolInformation is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -503,6 +553,8 @@ Ring3ProtocolsPerHandle (
OUT UINTN *ProtocolBufferCount
)
{
DEBUG ((DEBUG_ERROR, "Ring3: ProtocolsPerHandle is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -516,6 +568,8 @@ Ring3LocateHandleBuffer (
OUT EFI_HANDLE **Buffer
)
{
DEBUG ((DEBUG_ERROR, "Ring3: LocateHandleBuffer is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand Down Expand Up @@ -585,6 +639,8 @@ Ring3UninstallMultipleProtocolInterfaces (
...
)
{
DEBUG ((DEBUG_ERROR, "Ring3: UninstallMultipleProtocolInterfaces is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -596,6 +652,8 @@ Ring3CalculateCrc32 (
OUT UINT32 *Crc32
)
{
DEBUG ((DEBUG_ERROR, "Ring3: CalculateCrc32 is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand All @@ -610,6 +668,8 @@ Ring3CreateEventEx (
OUT EFI_EVENT *Event
)
{
DEBUG ((DEBUG_ERROR, "Ring3: CreateEventEx is not supported\n"));

return EFI_UNSUPPORTED;
}

Expand Down
2 changes: 1 addition & 1 deletion MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ ProtectUefiImage (
//
// CPU ARCH present. Update memory attribute directly.
//
if (AsciiStrStr (PdbPointer, "Ntfs") != NULL) {
if (AsciiStrStr (PdbPointer, "Fat") != NULL) {
SetUefiImageProtectionAttributes (ImageRecord, TRUE);
*IsUserImage = TRUE;
} else if (AsciiStrStr (PdbPointer, "Ring3") != NULL) {
Expand Down
25 changes: 17 additions & 8 deletions MdeModulePkg/Core/Dxe/SysCall/BootServices.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ FindGuid (
*Core = &gEfiComponentNameProtocolGuid;
*CoreSize = sizeof (EFI_COMPONENT_NAME_PROTOCOL);

} else if (CompareGuid (Ring3, &gEfiComponentName2ProtocolGuid)) {

*Core = &gEfiComponentName2ProtocolGuid;
*CoreSize = sizeof (EFI_COMPONENT_NAME2_PROTOCOL);

} else if (CompareGuid (Ring3, &gEfiDevicePathProtocolGuid)) {

*Core = &gEfiDevicePathProtocolGuid;
Expand All @@ -74,7 +79,7 @@ FindGuid (
*CoreSize = sizeof (EFI_SIMPLE_FILE_SYSTEM_PROTOCOL);

} else {
DEBUG ((DEBUG_ERROR, "Ring0: Unknown protocol.\n"));
DEBUG ((DEBUG_ERROR, "Ring0: Unknown protocol - %g.\n", Ring3));
return EFI_NOT_FOUND;
}

Expand Down Expand Up @@ -222,7 +227,7 @@ CallBootService (
//
// Argument 1: EFI_HANDLE CoreUserHandle
// Argument 2: EFI_GUID *Protocol
// Argument 3: VOID **Interface
// Argument 3: VOID **Interface OPTIONAL
// Argument 4: EFI_HANDLE CoreImageHandle
// Argument 5: EFI_HANDLE CoreControllerHandle
// Argument 6: UINT32 Attributes
Expand All @@ -231,10 +236,12 @@ CallBootService (
ASSERT ((Attributes & EFI_MEMORY_USER) != 0);
gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)(CoreRbp->Argument2 + sizeof (EFI_GUID) - 1), &Attributes);
ASSERT ((Attributes & EFI_MEMORY_USER) != 0);
gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)CoreRbp->Argument3, &Attributes);
ASSERT ((Attributes & EFI_MEMORY_USER) != 0);
gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)(CoreRbp->Argument3 + sizeof (VOID *) - 1), &Attributes);
ASSERT ((Attributes & EFI_MEMORY_USER) != 0);
if ((VOID **)CoreRbp->Argument3 != NULL) {
gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)CoreRbp->Argument3, &Attributes);
ASSERT ((Attributes & EFI_MEMORY_USER) != 0);
gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)(CoreRbp->Argument3 + sizeof (VOID *) - 1), &Attributes);
ASSERT ((Attributes & EFI_MEMORY_USER) != 0);
}
gCpu->GetMemoryAttributes (gCpu, (EFI_PHYSICAL_ADDRESS)((UINTN)UserRsp + 8 * sizeof (UINTN) - 1), &Attributes);
ASSERT ((Attributes & EFI_MEMORY_USER) != 0);

Expand All @@ -253,7 +260,7 @@ CallBootService (
Status = gBS->OpenProtocol (
(EFI_HANDLE)CoreRbp->Argument1,
CoreProtocol,
&Interface,
((VOID **)CoreRbp->Argument3 != NULL) ? &Interface : NULL,
(EFI_HANDLE)Argument4,
(EFI_HANDLE)Argument5,
(UINT32)Argument6
Expand All @@ -264,7 +271,9 @@ CallBootService (
Interface = PrepareRing3Interface (CoreProtocol, Interface, MemoryCoreSize);
}

*(VOID **)CoreRbp->Argument3 = Interface;
if ((VOID **)CoreRbp->Argument3 != NULL) {
*(VOID **)CoreRbp->Argument3 = Interface;
}
EnableSMAP ();

return Status;
Expand Down

0 comments on commit 3f2f955

Please sign in to comment.