diff --git a/MdeModulePkg/Core/Dxe/DxeRing3/Ring3UefiBootServices.c b/MdeModulePkg/Core/Dxe/DxeRing3/Ring3UefiBootServices.c index 47010db29b..9d02c2c6b8 100644 --- a/MdeModulePkg/Core/Dxe/DxeRing3/Ring3UefiBootServices.c +++ b/MdeModulePkg/Core/Dxe/DxeRing3/Ring3UefiBootServices.c @@ -98,7 +98,17 @@ Ring3FreePool ( IN VOID *Buffer ) { - return EFI_UNSUPPORTED; + EFI_STATUS Status; + + Status = SysCall ( + SysCallFreePool, + Buffer + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Ring3: Failed to free buffer.\n")); + } + + return Status; } EFI_STATUS diff --git a/MdeModulePkg/Core/Dxe/SysCall/BootServices.c b/MdeModulePkg/Core/Dxe/SysCall/BootServices.c index 92f931f0a1..55d38e4864 100644 --- a/MdeModulePkg/Core/Dxe/SysCall/BootServices.c +++ b/MdeModulePkg/Core/Dxe/SysCall/BootServices.c @@ -95,7 +95,6 @@ CallBootService ( DisableSMAP (); Interface = AllocateRing3Copy (Interface, MemoryCoreSize, MemoryCoreSize); if (Interface == NULL) { - DEBUG ((DEBUG_ERROR, "Ring0: Failed to allocate pages for Ring3 PROTOCOL structure.\n")); EnableSMAP (); return EFI_OUT_OF_RESOURCES; } @@ -141,7 +140,6 @@ CallBootService ( DisableSMAP (); Interface = AllocateRing3Copy (Interface, MemoryCoreSize, MemoryCoreSize); if (Interface == NULL) { - DEBUG ((DEBUG_ERROR, "Ring0: Failed to allocate pages for Ring3 PROTOCOL structure.\n")); EnableSMAP (); return EFI_OUT_OF_RESOURCES; } @@ -219,6 +217,18 @@ CallBootService ( ); EnableSMAP (); + return Status; + + case SysCallFreePool: + // + // Argument 1: IN VOID *Buffer + // + DisableSMAP (); + Status = gBS->FreePool ( + (VOID *)CoreRbp->Argument1 + ); + EnableSMAP (); + return Status; default: break; diff --git a/MdeModulePkg/Core/Dxe/SysCall/SupportedProtocols.c b/MdeModulePkg/Core/Dxe/SysCall/SupportedProtocols.c index 9140ce7ec1..4557536998 100644 --- a/MdeModulePkg/Core/Dxe/SysCall/SupportedProtocols.c +++ b/MdeModulePkg/Core/Dxe/SysCall/SupportedProtocols.c @@ -55,13 +55,33 @@ CoreDriverBindingSupported ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL ) { - return GoToRing3 ( - 3, - (VOID *)mRing3DriverBindingProtocol.Supported, + EFI_STATUS Status; + + DisableSMAP (); + This = AllocateRing3Copy ( This, - ControllerHandle, - RemainingDevicePath + sizeof (EFI_DRIVER_BINDING_PROTOCOL), + sizeof (EFI_DRIVER_BINDING_PROTOCOL) ); + if (This == NULL) { + EnableSMAP (); + return EFI_OUT_OF_RESOURCES; + } + EnableSMAP (); + + Status = GoToRing3 ( + 3, + (VOID *)mRing3DriverBindingProtocol.Supported, + This, + ControllerHandle, + RemainingDevicePath + ); + + DisableSMAP (); + FreePool (This); + EnableSMAP (); + + return Status; } EFI_STATUS @@ -72,13 +92,33 @@ CoreDriverBindingStart ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL ) { - return GoToRing3 ( - 3, - (VOID *)mRing3DriverBindingProtocol.Start, + EFI_STATUS Status; + + DisableSMAP (); + This = AllocateRing3Copy ( This, - ControllerHandle, - RemainingDevicePath + sizeof (EFI_DRIVER_BINDING_PROTOCOL), + sizeof (EFI_DRIVER_BINDING_PROTOCOL) ); + if (This == NULL) { + EnableSMAP (); + return EFI_OUT_OF_RESOURCES; + } + EnableSMAP (); + + Status = GoToRing3 ( + 3, + (VOID *)mRing3DriverBindingProtocol.Start, + This, + ControllerHandle, + RemainingDevicePath + ); + + DisableSMAP (); + FreePool (This); + EnableSMAP (); + + return Status; } EFI_STATUS @@ -90,12 +130,32 @@ CoreDriverBindingStop ( IN EFI_HANDLE *ChildHandleBuffer OPTIONAL ) { - return GoToRing3 ( - 4, - (VOID *)mRing3DriverBindingProtocol.Stop, + EFI_STATUS Status; + + DisableSMAP (); + This = AllocateRing3Copy ( This, - ControllerHandle, - NumberOfChildren, - ChildHandleBuffer + sizeof (EFI_DRIVER_BINDING_PROTOCOL), + sizeof (EFI_DRIVER_BINDING_PROTOCOL) ); + if (This == NULL) { + EnableSMAP (); + return EFI_OUT_OF_RESOURCES; + } + EnableSMAP (); + + Status = GoToRing3 ( + 4, + (VOID *)mRing3DriverBindingProtocol.Stop, + This, + ControllerHandle, + NumberOfChildren, + ChildHandleBuffer + ); + + DisableSMAP (); + FreePool (This); + EnableSMAP (); + + return Status; } diff --git a/MdePkg/Include/Uefi/UefiSpec.h b/MdePkg/Include/Uefi/UefiSpec.h index 0cc71e4693..f22ced291a 100644 --- a/MdePkg/Include/Uefi/UefiSpec.h +++ b/MdePkg/Include/Uefi/UefiSpec.h @@ -2019,6 +2019,7 @@ typedef enum { SysCallOpenProtocol, SysCallInstallMultipleProtocolInterfaces, SysCallAllocatePool, + SysCallFreePool, SysCallMax } SYS_CALL_TYPE;