Skip to content

Commit b79da6d

Browse files
authored
MdeModulePkg: ArmFfaLib: Add FFA_YIELD handling (#1503)
## Description This change adds the FFA_YIELD handling from ArmFfaLib to support long operations from secure partitions. - [x] Impacts functionality? - [ ] Impacts security? - [ ] Breaking change? - [ ] Includes tests? - [ ] Includes documentation? - [x] Backport to release branch? ## How This Was Tested This was tested on proprietary hardware platforms and booted to Windows. ## Integration Instructions N/A
1 parent 2ccb969 commit b79da6d

File tree

6 files changed

+23
-0
lines changed

6 files changed

+23
-0
lines changed

MdeModulePkg/Library/ArmFfaLib/ArmFfaCommon.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <Library/DebugLib.h>
2424
#include <Library/HobLib.h>
2525
#include <Library/PcdLib.h>
26+
#include <Library/TimerLib.h> // MU_CHANGE: Handle FFA_YIELD with timeout
2627

2728
#include <IndustryStandard/ArmFfaSvc.h>
2829
#include <IndustryStandard/ArmFfaPartInfo.h>
@@ -126,6 +127,7 @@ FfaArgsToEfiStatus (
126127
)
127128
{
128129
UINT32 FfaStatus;
130+
UINT64 Timeout; // MU_CHANGE: Handle FFA_YIELD with timeout
129131

130132
if (FfaArgs == NULL) {
131133
FfaStatus = ARM_FFA_RET_INVALID_PARAMETERS;
@@ -145,6 +147,22 @@ FfaArgsToEfiStatus (
145147
FfaStatus = ARM_FFA_RET_NOT_SUPPORTED;
146148
} else if (FfaArgs->Arg0 == ARM_FID_FFA_INTERRUPT) {
147149
FfaStatus = ARM_FFA_RET_INTERRUPTED;
150+
// MU_CHANGE starts: Handle FFA_YIELD with timeout
151+
} else if (FfaArgs->Arg0 == ARM_FID_FFA_YIELD) {
152+
/*
153+
* If the FF-A ABI indicates that the call was yielded, we need to pull the
154+
* timeout period from Arg2 and Arg3.
155+
*/
156+
Timeout = LShiftU64 (FfaArgs->Arg3, 32) | FfaArgs->Arg2;
157+
if (Timeout != 0) {
158+
/*
159+
* If the timeout is non-zero, we handle the delay here.
160+
*/
161+
NanoSecondDelay (Timeout);
162+
}
163+
164+
FfaStatus = ARM_FFA_RET_INTERRUPTED;
165+
// MU_CHANGE ends: Handle FFA_YIELD with timeout
148166
} else {
149167
FfaStatus = ARM_FFA_RET_SUCCESS;
150168
}

MdeModulePkg/Library/ArmFfaLib/ArmFfaDxeLib.inf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
BaseMemoryLib
3434
DebugLib
3535
HobLib
36+
TimerLib # MU_CHANGE
3637

3738
[Pcd]
3839
gEfiMdeModulePkgTokenSpaceGuid.PcdFfaLibConduitSmc

MdeModulePkg/Library/ArmFfaLib/ArmFfaPeiLib.inf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
BaseMemoryLib
3434
DebugLib
3535
HobLib
36+
TimerLib # MU_CHANGE
3637

3738
[Pcd]
3839
gEfiMdeModulePkgTokenSpaceGuid.PcdFfaLibConduitSmc

MdeModulePkg/Library/ArmFfaLib/ArmFfaSecLib.inf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
BaseMemoryLib
3434
DebugLib
3535
HobLib
36+
TimerLib # MU_CHANGE
3637

3738
[Pcd]
3839
gEfiMdeModulePkgTokenSpaceGuid.PcdFfaLibConduitSmc

MdeModulePkg/Library/ArmFfaLib/ArmFfaStandaloneMmCoreLib.inf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
BaseMemoryLib
3535
DebugLib
3636
MmServicesTableLib
37+
TimerLib # MU_CHANGE
3738

3839
[Pcd]
3940
gEfiMdeModulePkgTokenSpaceGuid.PcdFfaLibConduitSmc

MdeModulePkg/Library/ArmFfaLib/ArmFfaStandaloneMmLib.inf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
BaseMemoryLib
3535
DebugLib
3636
MmServicesTableLib
37+
TimerLib # MU_CHANGE
3738

3839
[Pcd]
3940
gEfiMdeModulePkgTokenSpaceGuid.PcdFfaLibConduitSmc

0 commit comments

Comments
 (0)