From: "Sayanta Pattanayak" <sayanta.pattanayak@arm.com>
To: devel@edk2.groups.io
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>,
Sami Mujawar <sami.mujawar@arm.com>
Subject: [edk2][PATCH V1 1/1] ArmPkg: introduce FF-A interface support in MM_COMMUNICATE
Date: Wed, 16 Jun 2021 11:04:03 +0530 [thread overview]
Message-ID: <20210616053403.30312-1-sayanta.pattanayak@arm.com> (raw)
From: Aditya Angadi <aditya.angadi@arm.com>
With the introduction of Firmware Framework for Arm platforms (FF-A),
normal world and secure world endpoints can use FF-A interface for
communication with each other. In this patch, FFA_MSG_SEND_DIRECT_REQ
and FFA_VERSION interfaces are introduced. This change adds an option
to either use the existing SMC interface or the introduced FF-A
interface based on the value of PcdFfaEnable.
Signed-off-by: Aditya Angadi <aditya.angadi@arm.com>
Signed-off-by: Sayanta Pattanayak <sayanta.pattanayak@arm.com>
---
ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf | 3 +
ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 2 +
ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 73 ++++++++++++++++----
3 files changed, 63 insertions(+), 15 deletions(-)
diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
index 05b6de73ff34..da8462755a6f 100644
--- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
@@ -52,5 +52,8 @@
gArmTokenSpaceGuid.PcdMmBufferBase
gArmTokenSpaceGuid.PcdMmBufferSize
+[FeaturePcd.AARCH64]
+ gArmTokenSpaceGuid.PcdFfaEnable
+
[Depex]
gEfiCpuArchProtocolGuid
diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
index 65b8343ade61..5a300a7295db 100644
--- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
+++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
@@ -19,6 +19,8 @@
#define ARM_SVC_ID_FFA_VERSION_AARCH32 0x84000063
#define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH64 0xC400006F
#define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH64 0xC4000070
+#define ARM_SVC_ID_FFA_SUCCESS_AARCH64 0xC4000061
+#define ARM_SVC_ID_FFA_SUCCESS_AARCH32 0x84000060
#define SPM_MAJOR_VERSION_FFA 1
#define SPM_MINOR_VERSION_FFA 0
diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
index b1e309580988..ff15903473ad 100644
--- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
@@ -18,6 +18,7 @@
#include <Protocol/MmCommunication2.h>
+#include <IndustryStandard/ArmFfaSvc.h>
#include <IndustryStandard/ArmStdSmc.h>
#include "MmCommunicate.h"
@@ -73,6 +74,7 @@ MmCommunication2Communicate (
ARM_SMC_ARGS CommunicateSmcArgs;
EFI_STATUS Status;
UINTN BufferSize;
+ UINTN Ret;
Status = EFI_ACCESS_DENIED;
BufferSize = 0;
@@ -124,26 +126,55 @@ MmCommunication2Communicate (
return EFI_BAD_BUFFER_SIZE;
}
- // SMC Function ID
- CommunicateSmcArgs.Arg0 = ARM_SMC_ID_MM_COMMUNICATE_AARCH64;
-
- // Cookie
- CommunicateSmcArgs.Arg1 = 0;
-
// Copy Communication Payload
CopyMem ((VOID *)mNsCommBuffMemRegion.VirtualBase, CommBufferVirtual, BufferSize);
- // comm_buffer_address (64-bit physical address)
- CommunicateSmcArgs.Arg2 = (UINTN)mNsCommBuffMemRegion.PhysicalBase;
+ // Use the FF-A interface if enabled.
+ if (FeaturePcdGet (PcdFfaEnable)) {
+ // FF-A Interface ID for direct message communication
+ CommunicateSmcArgs.Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH64;
- // comm_size_address (not used, indicated by setting to zero)
- CommunicateSmcArgs.Arg3 = 0;
+ // FF-A Destination EndPoint ID, not used as of now
+ CommunicateSmcArgs.Arg1 = 0x0;
+
+ // Reserved for future use(MBZ)
+ CommunicateSmcArgs.Arg2 = 0x0;
+
+ // Arg3 onwards are the IMPLEMENTATION DEFINED FF-A parameters
+ // SMC Function ID
+ CommunicateSmcArgs.Arg3 = ARM_SMC_ID_MM_COMMUNICATE_AARCH64;
+
+ // Cookie
+ CommunicateSmcArgs.Arg4 = 0x0;
+
+ // comm_buffer_address (64-bit physical address)
+ CommunicateSmcArgs.Arg5 = (UINTN)mNsCommBuffMemRegion.PhysicalBase;
+
+ // comm_size_address (not used, indicated by setting to zero)
+ CommunicateSmcArgs.Arg6 = 0;
+ } else {
+ // SMC Function ID
+ CommunicateSmcArgs.Arg0 = ARM_SMC_ID_MM_COMMUNICATE_AARCH64;
+
+ // Cookie
+ CommunicateSmcArgs.Arg1 = 0;
+
+ // comm_buffer_address (64-bit physical address)
+ CommunicateSmcArgs.Arg2 = (UINTN)mNsCommBuffMemRegion.PhysicalBase;
+
+ // comm_size_address (not used, indicated by setting to zero)
+ CommunicateSmcArgs.Arg3 = 0;
+ }
// Call the Standalone MM environment.
ArmCallSmc (&CommunicateSmcArgs);
- switch (CommunicateSmcArgs.Arg0) {
- case ARM_SMC_MM_RET_SUCCESS:
+ Ret = CommunicateSmcArgs.Arg0;
+
+ if ((FeaturePcdGet (PcdFfaEnable) &&
+ (Ret == ARM_SVC_ID_FFA_SUCCESS_AARCH64)) ||
+ (Ret == ARM_SMC_MM_RET_SUCCESS))
+ {
ZeroMem (CommBufferVirtual, BufferSize);
// On successful return, the size of data being returned is inferred from
// MessageLength + Header.
@@ -158,8 +189,14 @@ MmCommunication2Communicate (
BufferSize
);
Status = EFI_SUCCESS;
- break;
+ return Status;
+ }
+ if (FeaturePcdGet (PcdFfaEnable))
+ Ret = CommunicateSmcArgs.Arg2;
+
+ // Error Codes are same for FF-A and SMC interface
+ switch (Ret) {
case ARM_SMC_MM_RET_INVALID_PARAMS:
Status = EFI_INVALID_PARAMETER;
break;
@@ -233,8 +270,14 @@ GetMmCompatibility ()
UINT32 MmVersion;
ARM_SMC_ARGS MmVersionArgs;
- // MM_VERSION uses SMC32 calling conventions
- MmVersionArgs.Arg0 = ARM_SMC_ID_MM_VERSION_AARCH32;
+ if (FeaturePcdGet (PcdFfaEnable)) {
+ MmVersionArgs.Arg0 = ARM_SVC_ID_FFA_VERSION_AARCH32;
+ MmVersionArgs.Arg1 = MM_CALLER_MAJOR_VER << MM_MAJOR_VER_SHIFT;
+ MmVersionArgs.Arg1 |= MM_CALLER_MINOR_VER;
+ } else {
+ // MM_VERSION uses SMC32 calling conventions
+ MmVersionArgs.Arg0 = ARM_SMC_ID_MM_VERSION_AARCH32;
+ }
ArmCallSmc (&MmVersionArgs);
--
2.17.1
reply other threads:[~2021-06-16 5:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210616053403.30312-1-sayanta.pattanayak@arm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox