Skip to content

Commit ad2505e

Browse files
LeviYeoReumkuqin12
authored andcommitted
[CHERRY-PICK] Global: fix ArmFfaLibRun() caller couldn't get ret-args
When ArmFfaLibDirectMsgReq(2) is preempted, caller of these functions should resume it works via ArmFfaLibRun() and the secure partition will be return with FFA_DIRECT_MSG_RESP(2) with return arguments. However, since ArmFfaLibRun() gets its return in its stack variable, So caller of ArmFfaLibRun() doesn't get the return arguments from secure partition. To resolve this, add output parameter to ArmFfaLibRun() to receive return arguments. Continuous-integration-options: PatchCheck.ignore-multi-package Fixes: 5d1b38d ("ArmPkg: Add ArmFfaLib used in Dxe driver") Reported-by: Mariam Elshakfy <[email protected]> Signed-off-by: Yeoreum Yun <[email protected]> (cherry picked from commit d8e875e62505e15a48f82ccb49db42be9fda519f)
1 parent 5f7c5ba commit ad2505e

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

MdeModulePkg/Library/ArmFfaLib/ArmFfaCommon.c

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ ArmFfaLibPartitionInfoGet (
553553
554554
@param [in] PartId Partition id
555555
@param [in] CpuNumber Cpu number in partition
556+
@param [out] DirectMsgArg return arguments for direct msg resp/resp2
556557
557558
@retval EFI_SUCCESS
558559
@retval Other Error
@@ -561,10 +562,12 @@ ArmFfaLibPartitionInfoGet (
561562
EFI_STATUS
562563
EFIAPI
563564
ArmFfaLibRun (
564-
IN UINT16 PartId,
565-
IN UINT16 CpuNumber
565+
IN UINT16 PartId,
566+
IN UINT16 CpuNumber,
567+
OUT DIRECT_MSG_ARGS *DirectMsgArg OPTIONAL
566568
)
567569
{
570+
EFI_STATUS Status;
568571
ARM_FFA_ARGS FfaArgs;
569572

570573
ZeroMem (&FfaArgs, sizeof (ARM_FFA_ARGS));
@@ -574,7 +577,39 @@ ArmFfaLibRun (
574577

575578
ArmCallFfa (&FfaArgs);
576579

577-
return FfaArgsToEfiStatus (&FfaArgs);
580+
Status = FfaArgsToEfiStatus (&FfaArgs);
581+
if (EFI_ERROR (Status)) {
582+
return Status;
583+
}
584+
585+
if (DirectMsgArg != NULL) {
586+
ZeroMem (DirectMsgArg, sizeof (DIRECT_MSG_ARGS));
587+
588+
if (FfaArgs.Arg0 == ARM_FID_FFA_MSG_SEND_DIRECT_RESP) {
589+
DirectMsgArg->Arg0 = FfaArgs.Arg3;
590+
DirectMsgArg->Arg1 = FfaArgs.Arg4;
591+
DirectMsgArg->Arg2 = FfaArgs.Arg5;
592+
DirectMsgArg->Arg3 = FfaArgs.Arg6;
593+
DirectMsgArg->Arg4 = FfaArgs.Arg7;
594+
} else if (FfaArgs.Arg0 == ARM_FID_FFA_MSG_SEND_DIRECT_RESP2) {
595+
DirectMsgArg->Arg0 = FfaArgs.Arg4;
596+
DirectMsgArg->Arg1 = FfaArgs.Arg5;
597+
DirectMsgArg->Arg2 = FfaArgs.Arg6;
598+
DirectMsgArg->Arg3 = FfaArgs.Arg7;
599+
DirectMsgArg->Arg4 = FfaArgs.Arg8;
600+
DirectMsgArg->Arg5 = FfaArgs.Arg9;
601+
DirectMsgArg->Arg6 = FfaArgs.Arg10;
602+
DirectMsgArg->Arg7 = FfaArgs.Arg11;
603+
DirectMsgArg->Arg8 = FfaArgs.Arg12;
604+
DirectMsgArg->Arg9 = FfaArgs.Arg13;
605+
DirectMsgArg->Arg10 = FfaArgs.Arg14;
606+
DirectMsgArg->Arg11 = FfaArgs.Arg15;
607+
DirectMsgArg->Arg12 = FfaArgs.Arg16;
608+
DirectMsgArg->Arg13 = FfaArgs.Arg17;
609+
}
610+
}
611+
612+
return Status;
578613
}
579614

580615
/**

MdePkg/Include/Library/ArmFfaLib.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ ArmFfaLibSpmIdGet (
301301
302302
@param [in] PartId Partition id
303303
@param [in] CpuNumber Cpu number in partition
304+
@param [out] DirectMsgArg return arguments for direct msg resp/resp2
304305
305306
@retval EFI_SUCCESS
306307
@retval Other Error
@@ -309,8 +310,9 @@ ArmFfaLibSpmIdGet (
309310
EFI_STATUS
310311
EFIAPI
311312
ArmFfaLibRun (
312-
IN UINT16 PartId,
313-
IN UINT16 CpuNumber
313+
IN UINT16 PartId,
314+
IN UINT16 CpuNumber,
315+
OUT DIRECT_MSG_ARGS *DirectMsgArg OPTIONAL
314316
);
315317

316318
/**

0 commit comments

Comments
 (0)