From fc08f7d2731799fac65a3a06f7520f2f6fcef90b Mon Sep 17 00:00:00 2001 From: Mikhail Krichanov Date: Tue, 9 Jul 2024 16:17:27 +0300 Subject: [PATCH] Ring3: Fixed several bugs for ARM. --- .../Arm/DefaultExceptionHandler.c | 2 +- .../Core/Dxe/SysCall/ARM/InitializeMsr.c | 4 ++-- .../Core/Dxe/SysCall/SupportedProtocols.c | 21 ++----------------- 3 files changed, 5 insertions(+), 22 deletions(-) diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c index 6293843f32..8519642a8c 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c @@ -227,7 +227,7 @@ DefaultExceptionHandler ( return mSysCallHandler ( SystemContext.SystemContextArm->R0, &(SystemContext.SystemContextArm->R1), - &(SystemContext.SystemContextArm->SP) + (VOID *)SystemContext.SystemContextArm->SP ); } diff --git a/MdeModulePkg/Core/Dxe/SysCall/ARM/InitializeMsr.c b/MdeModulePkg/Core/Dxe/SysCall/ARM/InitializeMsr.c index 8fc8db82ad..eb6d555734 100644 --- a/MdeModulePkg/Core/Dxe/SysCall/ARM/InitializeMsr.c +++ b/MdeModulePkg/Core/Dxe/SysCall/ARM/InitializeMsr.c @@ -71,11 +71,11 @@ SysCallBootService ( // // First 3 arguments are passed through R1-R3 and copied to SysCall Stack. // - CopyMem ((VOID *)((UINTN)Physical + sizeof (UINTN)), (VOID *)CoreRbp, 3 * sizeof (UINTN)); + CopyMem ((VOID *)((UINTN)Physical + 2 * sizeof (UINTN)), (VOID *)CoreRbp, 3 * sizeof (UINTN)); // // All remaining arguments are on User Stack. // - CopyMem ((VOID *)((UINTN)Physical + 4 * sizeof (UINTN)), (VOID *)UserRsp, 5 * sizeof (UINTN)); + CopyMem ((VOID *)((UINTN)Physical + 5 * sizeof (UINTN)), (VOID *)UserRsp, 4 * sizeof (UINTN)); EnableSMAP (); Status = CallBootService ( diff --git a/MdeModulePkg/Core/Dxe/SysCall/SupportedProtocols.c b/MdeModulePkg/Core/Dxe/SysCall/SupportedProtocols.c index 852ec7c663..43e7e93920 100644 --- a/MdeModulePkg/Core/Dxe/SysCall/SupportedProtocols.c +++ b/MdeModulePkg/Core/Dxe/SysCall/SupportedProtocols.c @@ -360,7 +360,7 @@ CoreFileSetPosition ( File->Ring3File, Position ); -#elif defined (MDE_CPU_IA32) +#elif defined (MDE_CPU_IA32) || defined (MDE_CPU_ARM) // // UINT64 Position is passed as 2 double words on stack. // @@ -370,13 +370,6 @@ CoreFileSetPosition ( File->Ring3File, Position ); -#else - return GoToRing3 ( - 2, - (VOID *)mRing3FileProtocol.SetPosition, - File->Ring3File, - Position - ); #endif } @@ -643,7 +636,7 @@ CoreFileOpen ( OpenMode, Attributes ); -#elif defined (MDE_CPU_IA32) +#elif defined (MDE_CPU_IA32) || defined (MDE_CPU_ARM) // // UINT64 OpenMode and Attributes are each passed as 2 double words on stack. // @@ -656,16 +649,6 @@ CoreFileOpen ( OpenMode, Attributes ); -#else - Status = GoToRing3 ( - 5, - (VOID *)mRing3FileProtocol.Open, - File->Ring3File, - Ring3NewHandle, - Ring3FileName, - OpenMode, - Attributes - ); #endif if (EFI_ERROR (Status)) { *NewHandle = NULL;