[edk2-devel] [PATCH v1 07/12] StandaloneMmPkg: Add option to use FF-A calls for communication with SPM
Sami Mujawar
sami.mujawar at arm.com
Mon Nov 23 12:38:40 UTC 2020
Hi Sughosh,
Please find my response inline marked [SAMI].
Regards,
Sami Mujawar
-----Original Message-----
From: Sughosh Ganu <mailto:sughosh.ganu at linaro.org>
Sent: 21 October 2020 12:32 PM
To: mailto:devel at edk2.groups.io
Cc: Ard Biesheuvel <mailto:Ard.Biesheuvel at arm.com>; Sami Mujawar <mailto:Sami.Mujawar at arm.com>; Jiewen Yao <mailto:jiewen.yao at intel.com>; Achin Gupta <mailto:Achin.Gupta at arm.com>
Subject: [PATCH v1 07/12] StandaloneMmPkg: Add option to use FF-A calls for communication with SPM
From: Achin Gupta <mailto:achin.gupta at arm.com>
Add support for reporting completion of a MM request using either the
Firmware Framework(FF-A) ABI transport or through the earlier used SVC
calls.
Signed-off-by: Achin Gupta <mailto:achin.gupta at arm.com>
Co-developed-by: Sughosh Ganu <mailto:sughosh.ganu at linaro.org>
---
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c | 68 ++++++++++++++++----
1 file changed, 54 insertions(+), 14 deletions(-)
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c
index 7d1e3c4d7c..06a8f487f9 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c
@@ -112,6 +112,7 @@ DelegatedEventLoop (
IN ARM_SVC_ARGS *EventCompleteSvcArgs
)
{
+ BOOLEAN FfaEnabled;
EFI_STATUS Status;
UINTN SvcStatus;
@@ -123,16 +124,32 @@ DelegatedEventLoop (
DEBUG ((DEBUG_INFO, "X1 : 0x%x\n", (UINT32) EventCompleteSvcArgs->Arg1));
DEBUG ((DEBUG_INFO, "X2 : 0x%x\n", (UINT32) EventCompleteSvcArgs->Arg2));
DEBUG ((DEBUG_INFO, "X3 : 0x%x\n", (UINT32) EventCompleteSvcArgs->Arg3));
-
- Status = CpuDriverEntryPoint (
- EventCompleteSvcArgs->Arg0,
- EventCompleteSvcArgs->Arg3,
- EventCompleteSvcArgs->Arg1
- );
-
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Failed delegated event 0x%x, Status 0x%x\n",
- EventCompleteSvcArgs->Arg0, Status));
+ DEBUG ((DEBUG_INFO, "X4 : 0x%x\n", (UINT32) EventCompleteSvcArgs->Arg4));
+ DEBUG ((DEBUG_INFO, "X5 : 0x%x\n", (UINT32) EventCompleteSvcArgs->Arg5));
+ DEBUG ((DEBUG_INFO, "X6 : 0x%x\n", (UINT32) EventCompleteSvcArgs->Arg6));
+ DEBUG ((DEBUG_INFO, "X7 : 0x%x\n", (UINT32) EventCompleteSvcArgs->Arg7));
+
+ FfaEnabled = FeaturePcdGet (PcdFfaEnable);
+ if (FfaEnabled) {
+ Status = CpuDriverEntryPoint (
+ EventCompleteSvcArgs->Arg0,
+ EventCompleteSvcArgs->Arg6,
+ EventCompleteSvcArgs->Arg3
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Failed delegated event 0x%x, Status 0x%x\n",
+ EventCompleteSvcArgs->Arg3, Status));
[SAMI] Please align as suggested in the coding guide,
see https://edk2-docs.gitbook.io/edk-ii-c-coding-standards-specification/5_source_files/52_spacing#5-2-2-4-subsequent-lines-of-multi-line-function-calls-should-line-up-two-spaces-from-the-beginning-of-the-function-name
[/SAMI]
+ }
+ } else {
+ Status = CpuDriverEntryPoint (
+ EventCompleteSvcArgs->Arg0,
+ EventCompleteSvcArgs->Arg3,
+ EventCompleteSvcArgs->Arg1
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "Failed delegated event 0x%x, Status 0x%x\n",
+ EventCompleteSvcArgs->Arg0, Status));
[SAMI] Please align as suggested in the coding guide. [/SAMI]
+ }
}
switch (Status) {
@@ -156,8 +173,16 @@ DelegatedEventLoop (
break;
}
- EventCompleteSvcArgs->Arg0 = ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64;
- EventCompleteSvcArgs->Arg1 = SvcStatus;
+ if (FfaEnabled) {
+ EventCompleteSvcArgs->Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH64;
+ EventCompleteSvcArgs->Arg1 = 0;
+ EventCompleteSvcArgs->Arg2 = 0;
+ EventCompleteSvcArgs->Arg3 = ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64;
+ EventCompleteSvcArgs->Arg4 = SvcStatus;
+ } else {
+ EventCompleteSvcArgs->Arg0 = ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64;
+ EventCompleteSvcArgs->Arg1 = SvcStatus;
+ }
}
}
@@ -216,6 +241,22 @@ GetSpmVersion (VOID)
return Status;
}
+STATIC
+VOID
+InitArmSvcArgs (ARM_SVC_ARGS *InitMmFoundationSvcArgs, EFI_STATUS *Status)
[SAMI] Please follow coding guidelines for function definition and documentation.
Ref: https://edk2-docs.gitbook.io/edk-ii-c-coding-standards-specification/5_source_files/57_c_programming#5-7-1-function-definition-layout
[/SAMI]
+{
+ if (FeaturePcdGet (PcdFfaEnable)) {
+ InitMmFoundationSvcArgs->Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH64;
+ InitMmFoundationSvcArgs->Arg1 = 0;
+ InitMmFoundationSvcArgs->Arg2 = 0;
+ InitMmFoundationSvcArgs->Arg3 = ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64;
+ InitMmFoundationSvcArgs->Arg4 = *Status;
+ } else {
+ InitMmFoundationSvcArgs->Arg0 = ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64;
+ InitMmFoundationSvcArgs->Arg1 = *Status;
[SAMI] The 'Event Status code' is a 32-bit value, see https://trustedfirmware-a.readthedocs.io/en/latest/components/secure-partition-manager-mm.html#mm-sp-event-complete-aarch64
When this code is compiled for AARCH64, EFI_STATUS is 64-Bit value. In case of an error the status code will have the bit 63 set, see definition for macro ENCODE_ERROR().
This would mean a 32-bit positive value would be returned in an error condition, right?
[/SAMI]
+ }
+}
+
/**
The entry point of Standalone MM Foundation.
@@ -329,7 +370,6 @@ _ModuleEntryPoint (
finish:
ZeroMem (&InitMmFoundationSvcArgs, sizeof(InitMmFoundationSvcArgs));
- InitMmFoundationSvcArgs.Arg0 = ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64;
- InitMmFoundationSvcArgs.Arg1 = Status;
+ InitArmSvcArgs(&InitMmFoundationSvcArgs, &Status);
[SAMI] Space needed between function name and starting parentheses.
Ref: https://edk2-docs.gitbook.io/edk-ii-c-coding-standards-specification/5_source_files/52_spacing#5-2-2-6-always-put-space-before-an-open-parenthesis
[/SAMI]
DelegatedEventLoop (&InitMmFoundationSvcArgs);
}
--
2.17.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#67800): https://edk2.groups.io/g/devel/message/67800
Mute This Topic: https://groups.io/mt/77703655/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list