diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h index c4c287cb2a..1d2cbe3f23 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.h +++ b/MdeModulePkg/Core/Dxe/DxeMain.h @@ -2821,7 +2821,6 @@ UINTN EFIAPI CoreBootServices ( IN UINT8 Type, - IN UINTN FunctionAddress, ... ); diff --git a/MdeModulePkg/Core/Dxe/SysCall/BootServices.c b/MdeModulePkg/Core/Dxe/SysCall/BootServices.c index 98b3ab6662..689754fb9e 100644 --- a/MdeModulePkg/Core/Dxe/SysCall/BootServices.c +++ b/MdeModulePkg/Core/Dxe/SysCall/BootServices.c @@ -36,7 +36,6 @@ UINTN EFIAPI CallBootService ( IN UINT8 Type, - IN VOID **FunctionAddress, IN UINTN CoreRbp, IN UINTN UserRsp ) @@ -52,11 +51,12 @@ CallBootService ( // Stack: // rcx - Rip for SYSCALL - // r8 - Argument 1 + // rdx - Argument 1 // rbp - User Rbp - // r9 - Argument 2 + // r8 - Argument 2 // r11 - User data segment selector <- CoreRbp // rsp - User Rsp + // r9 - Argument 3 switch (Type) { case SysCallLocateProtocol: DisableSMAP (); @@ -87,7 +87,7 @@ CallBootService ( } DisableSMAP (); - *(UINTN *)(*((UINTN *)UserRsp + 5)) = (UINTN)Pointer; + *(UINTN *)(*((UINTN *)CoreRbp - 2)) = (UINTN)Pointer; EnableSMAP (); FreePool (CoreProtocol); @@ -97,9 +97,9 @@ CallBootService ( case SysCallOpenProtocol: DisableSMAP (); CoreProtocol = AllocateCopyPool (sizeof (EFI_GUID), (VOID *)*((UINTN *)CoreRbp + 1)); - Arg4 = (VOID *)*((UINTN *)UserRsp + 6); - Arg5 = (VOID *)*((UINTN *)UserRsp + 7); - Arg6 = (UINT32)*((UINTN *)UserRsp + 8); + Arg4 = (VOID *)*((UINTN *)UserRsp + 5); + Arg5 = (VOID *)*((UINTN *)UserRsp + 6); + Arg6 = (UINT32)*((UINTN *)UserRsp + 7); EnableSMAP (); if (CoreProtocol == NULL) { DEBUG ((DEBUG_ERROR, "Ring0: Failed to allocate core copy of the Protocol variable.\n")); @@ -129,7 +129,7 @@ CallBootService ( } DisableSMAP (); - *(UINTN *)(*((UINTN *)UserRsp + 5)) = (UINTN)Pointer; + *(UINTN *)(*((UINTN *)CoreRbp - 2)) = (UINTN)Pointer; EnableSMAP (); FreePool (CoreProtocol); diff --git a/MdeModulePkg/Core/Dxe/SysCall/X64/CoreBootServices.nasm b/MdeModulePkg/Core/Dxe/SysCall/X64/CoreBootServices.nasm index 421dbcc8da..3eb32b75bd 100644 --- a/MdeModulePkg/Core/Dxe/SysCall/X64/CoreBootServices.nasm +++ b/MdeModulePkg/Core/Dxe/SysCall/X64/CoreBootServices.nasm @@ -15,6 +15,7 @@ extern ASM_PFX(gCoreSysCallStackTop) ; Prepare SYSRET arguments. mov rcx, [rbp + 8*4] pop rdx + pop rdx ; Switch from Core to User data segment selectors. pop r11 @@ -61,17 +62,16 @@ ASM_PFX(EnableSMAP): ; EFIAPI ; CoreBootServices ( ; IN UINT8 Type, -; IN UINTN FunctionAddress, ; ... ; ); ; ; (rcx) RIP of the next instruction saved by SYSCALL in SysCall(). -; (rdx) FunctionAddress. -; (r8) Argument 1 of the called function. -; (r9) Argument 2 of the called function. +; (rdx) Argument 1 of the called function. +; (r8) Argument 2 of the called function. +; (r9) Argument 3 of the called function. ; (r10) Type. ; (r11) RFLAGS saved by SYSCALL in SysCall(). -;On stack Argument 3, 4, ... +;On stack Argument 4, 5, ... ;------------------------------------------------------------------------------ global ASM_PFX(CoreBootServices) ASM_PFX(CoreBootServices): @@ -92,21 +92,22 @@ ASM_PFX(CoreBootServices): mov [rax], rcx mov rcx, r10 sub rax, 8 - mov [rax], r8 + mov [rax], rdx sub rax, 8 mov [rax], rbp sub rax, 8 - mov [rax], r9 + mov [rax], r8 ; Save User data segment selector on Core SysCall Stack. sub rax, 8 mov [rax], r11 - mov r9, rsp + mov r8, rsp mov rsp, rax mov rbp, rsp - mov r8, rbp + mov rdx, rbp + push r8 push r9 call ASM_PFX(CallBootService) diff --git a/MdePkg/Library/Ring3UefiBootServicesTableLib/Ring3.h b/MdePkg/Library/Ring3UefiBootServicesTableLib/Ring3.h index e13c3e4daa..66e566f751 100644 --- a/MdePkg/Library/Ring3UefiBootServicesTableLib/Ring3.h +++ b/MdePkg/Library/Ring3UefiBootServicesTableLib/Ring3.h @@ -9,7 +9,6 @@ UINTN EFIAPI SysCall ( IN UINT8 Type, - IN UINTN FunctionAddress, ... ); diff --git a/MdePkg/Library/Ring3UefiBootServicesTableLib/Ring3UefiBootServicesTableLib.c b/MdePkg/Library/Ring3UefiBootServicesTableLib/Ring3UefiBootServicesTableLib.c index cfd204559b..4c336e1a29 100644 --- a/MdePkg/Library/Ring3UefiBootServicesTableLib/Ring3UefiBootServicesTableLib.c +++ b/MdePkg/Library/Ring3UefiBootServicesTableLib/Ring3UefiBootServicesTableLib.c @@ -443,7 +443,6 @@ Ring3OpenProtocol ( Status = (EFI_STATUS)SysCall ( SysCallOpenProtocol, - 0, CoreUserHandle, Protocol, Interface, @@ -531,7 +530,6 @@ Ring3LocateProtocol ( Status = (EFI_STATUS)SysCall ( SysCallLocateProtocol, - 0, Protocol, CoreRegistration, Interface diff --git a/MdePkg/Library/Ring3UefiBootServicesTableLib/Ring3UefiBootServicesTableLib.inf b/MdePkg/Library/Ring3UefiBootServicesTableLib/Ring3UefiBootServicesTableLib.inf index f1128c94d3..c17cb16fe5 100644 --- a/MdePkg/Library/Ring3UefiBootServicesTableLib/Ring3UefiBootServicesTableLib.inf +++ b/MdePkg/Library/Ring3UefiBootServicesTableLib/Ring3UefiBootServicesTableLib.inf @@ -35,3 +35,7 @@ [LibraryClasses] BaseMemoryLib DebugLib + +[Protocols] + gEfiDevicePathUtilitiesProtocolGuid ## SOMETIMES_CONSUMES + gEfiLoadedImageProtocolGuid ## SOMETIMES_CONSUMES diff --git a/MdePkg/Library/Ring3UefiBootServicesTableLib/X64/SysCall.nasm b/MdePkg/Library/Ring3UefiBootServicesTableLib/X64/SysCall.nasm index b888ab5d8c..f6ea57d787 100644 --- a/MdePkg/Library/Ring3UefiBootServicesTableLib/X64/SysCall.nasm +++ b/MdePkg/Library/Ring3UefiBootServicesTableLib/X64/SysCall.nasm @@ -11,7 +11,6 @@ ; EFIAPI ; SysCall ( ; IN UINT8 Type, -; IN UINTN FunctionAddress, ; ... ; ); ;------------------------------------------------------------------------------