* [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework
@ 2023-07-11 14:36 Nishant Sharma
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 01/20] ArmPkg: Change PcdFfaEnable flag datatype Nishant Sharma
` (20 more replies)
0 siblings, 21 replies; 41+ messages in thread
From: Nishant Sharma @ 2023-07-11 14:36 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
V1 :
Following patchset add the support of ARM Firmware Framework protocol to
MM communication.
Following chagnes are made to enable the support
1> Changed the FFA enable flag(PcdFfaEnable) to integer to enable it
use in assembly.
2> Add the support to Reserved SP stack space and program in startup
code.
3> Added ABI for enabling FFA protocol
4> Added conditional support in Standalone MM to parse DTB and
populated configuration info required for FFA.
5> Added FFA support in MmCommunicationDxe module.
Patches are pushed to
https://github.com/nissha03/edk2/tree/ArmFirmwareFramework
ARM Firmware Framework Protocol:
https://developer.arm.com/documentation/den0077/latest/
Achin Gupta (19):
StandaloneMmPkg: Allocate and initialise SP stack from internal memory
StandaloneMmPkg: Include libfdt in the StMM
ArmPkg: Add data structures to receive FF-A boot information
ArmPkg/ArmFfaSvc: Add helper macros and fids
ArmPkg: Add support for FFA_MEM_PERM_GET/SET ABIs
StandaloneMmPkg: define new data structure to stage FF-A boot
information
StandaloneMmPkg: Add backwards compatible support to detect FF-A v1.1
StandaloneMmPkg: parse SP manifest and populate new boot information
StandaloneMmPkg: Populate Hoblist for SP init from StMM boot
information
StandaloneMmPkg: Skip zero sized sections while tweaking page
permissions
StandaloneMmPkg: Add global check for FF-A abis
ArmPkg: Bump the StMM SP FF-A minor version to 1
ArmPkg/MmCommunicationDxe: Introduce FF-A version check
ArmPkg/MmCommunicationDxe: Add support for obtaining FF-A partition ID
ArmPkg/MmCommunicationDxe: Register FF-A RX/TX buffers
ArmPkg/MmCommunicationDxe: Unmap FF-A RX/TX buffers during
ExitBootServices
ArmPkg/MmCommunicationDxe: Discover the StMM SP
ArmPkg/MmCommunicationDxe: Use the FF-A transport for MM requests
StandaloneMmPkg: Add support for MM requests as FF-A direct messages
Nishant Sharma (1):
ArmPkg: Change PcdFfaEnable flag datatype
ArmPkg/ArmPkg.dec | 14 +-
StandaloneMmPkg/StandaloneMmPkg.dsc | 3 +-
ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf | 3 +
ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf | 4 +-
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf | 8 +-
ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h | 7 +-
ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 133 ++++-
StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h | 39 +-
ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 332 ++++++++++--
ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c | 140 ++++-
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c | 186 ++++++-
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/SetPermissions.c | 18 +-
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c | 561 +++++++++++++++++---
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/AArch64/ModuleEntryPoint.S | 68 +++
14 files changed, 1367 insertions(+), 149 deletions(-)
create mode 100644 StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/AArch64/ModuleEntryPoint.S
--
2.34.1
^ permalink raw reply [flat|nested] 41+ messages in thread
* [edk2-platforms][PATCH V1 01/20] ArmPkg: Change PcdFfaEnable flag datatype
2023-07-11 14:36 [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Nishant Sharma
@ 2023-07-11 14:36 ` Nishant Sharma
2023-07-12 17:21 ` [edk2-devel] " Oliver Smith-Denny
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 02/20] StandaloneMmPkg: Allocate and initialise SP stack from internal memory Nishant Sharma
` (19 subsequent siblings)
20 siblings, 1 reply; 41+ messages in thread
From: Nishant Sharma @ 2023-07-11 14:36 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
FeatureFlag type PCD flags are declared by typecasting an integer value
to BOOLEAN. These flags cannot be use in assembly code as assembler does
not recognise C primitive types. Change the flag data type from BOOLEAN
to UINT32.
Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
---
ArmPkg/ArmPkg.dec | 14 +++++++-------
ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf | 4 ++--
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf | 4 ++--
ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c | 8 ++++----
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c | 8 ++++----
5 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
index 1a16d044c94b..c36c23e2e059 100644
--- a/ArmPkg/ArmPkg.dec
+++ b/ArmPkg/ArmPkg.dec
@@ -155,13 +155,6 @@
# hardware coherency (i.e., no virtualization or cache coherent DMA)
gArmTokenSpaceGuid.PcdNormalMemoryNonshareableOverride|FALSE|BOOLEAN|0x00000043
-[PcdsFeatureFlag.AARCH64, PcdsFeatureFlag.ARM]
- ## Used to select method for requesting services from S-EL1.<BR><BR>
- # TRUE - Selects FF-A calls for communication between S-EL0 and SPMC.<BR>
- # FALSE - Selects SVC calls for communication between S-EL0 and SPMC.<BR>
- # @Prompt Enable FF-A support.
- gArmTokenSpaceGuid.PcdFfaEnable|FALSE|BOOLEAN|0x0000005B
-
[PcdsFixedAtBuild.common]
gArmTokenSpaceGuid.PcdTrustzoneSupport|FALSE|BOOLEAN|0x00000006
@@ -298,6 +291,13 @@
# not currently supported.
gArmTokenSpaceGuid.PcdArmNonSecModeTransition|0x3c9|UINT32|0x0000003E
+ ## Used to select method for requesting services from S-EL1.<BR><BR>
+ # 1 - Selects FF-A calls for communication between S-EL0 and SPMC.<BR>
+ # 0 - Selects SVC calls for communication between S-EL0 and SPMC.<BR>
+ # Using unsigned integer as boolean does not work on assembler.
+ # @Prompt Enable FF-A support.
+ gArmTokenSpaceGuid.PcdFfaEnable|0|UINT32|0x0000005B
+
#
# These PCDs are also defined as 'PcdsDynamic' or 'PcdsPatchableInModule' to be
diff --git a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
index ff20e5898051..3c733585f573 100644
--- a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
+++ b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
@@ -1,6 +1,6 @@
#/** @file
#
-# Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.<BR>
+# Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -23,7 +23,7 @@
ArmPkg/ArmPkg.dec
MdePkg/MdePkg.dec
-[FeaturePcd.ARM, FeaturePcd.AARCH64]
+[FixedPcd]
gArmTokenSpaceGuid.PcdFfaEnable
[LibraryClasses]
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
index 75cfb98c0e75..dc6d3d859911 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
@@ -1,7 +1,7 @@
## @file
# Module entry point library for DXE core.
#
-# Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.<BR>
+# Copyright (c) 2017 - 2023, Arm Ltd. All rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -51,7 +51,7 @@
gEfiStandaloneMmNonSecureBufferGuid
gEfiArmTfCpuDriverEpDescriptorGuid
-[FeaturePcd.ARM, FeaturePcd.AARCH64]
+[FixedPcd]
gArmTokenSpaceGuid.PcdFfaEnable
#
diff --git a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
index d55aff76201e..1a41a289ef17 100644
--- a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
+++ b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
@@ -1,7 +1,7 @@
/** @file
File managing the MMU for ARMv8 architecture in S-EL0
- Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.<BR>
+ Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.
Copyright (c) 2021, Linaro Limited
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -54,7 +54,7 @@ SendMemoryPermissionRequest (
}
ArmCallSvc (SvcArgs);
- if (FeaturePcdGet (PcdFfaEnable)) {
+ if (FixedPcdGet32 (PcdFfaEnable) != 0) {
// Get/Set memory attributes is an atomic call, with
// StandaloneMm at S-EL0 being the caller and the SPM
// core being the callee. Thus there won't be a
@@ -163,7 +163,7 @@ GetMemoryPermissions (
// Prepare the message parameters.
// See [1], Section 13.5.5.1 MM_SP_MEMORY_ATTRIBUTES_GET_AARCH64.
ZeroMem (&SvcArgs, sizeof (ARM_SVC_ARGS));
- if (FeaturePcdGet (PcdFfaEnable)) {
+ if (FixedPcdGet32 (PcdFfaEnable) != 0) {
// See [2], Section 10.2 FFA_MSG_SEND_DIRECT_REQ.
SvcArgs.Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ;
SvcArgs.Arg1 = ARM_FFA_DESTINATION_ENDPOINT_ID;
@@ -218,7 +218,7 @@ RequestMemoryPermissionChange (
// Prepare the message parameters.
// See [1], Section 13.5.5.2 MM_SP_MEMORY_ATTRIBUTES_SET_AARCH64.
ZeroMem (&SvcArgs, sizeof (ARM_SVC_ARGS));
- if (FeaturePcdGet (PcdFfaEnable)) {
+ if (FixedPcdGet32 (PcdFfaEnable) != 0) {
// See [2], Section 10.2 FFA_MSG_SEND_DIRECT_REQ.
SvcArgs.Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ;
SvcArgs.Arg1 = ARM_FFA_DESTINATION_ENDPOINT_ID;
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
index 96de10405af8..5dd1d9747995 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
@@ -2,7 +2,7 @@
Entry point to the Standalone MM Foundation when initialized during the SEC
phase on ARM platforms
-Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.<BR>
+Copyright (c) 2017 - 2023, Arm Ltd. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -140,7 +140,7 @@ DelegatedEventLoop (
DEBUG ((DEBUG_INFO, "X6 : 0x%x\n", (UINT32)EventCompleteSvcArgs->Arg6));
DEBUG ((DEBUG_INFO, "X7 : 0x%x\n", (UINT32)EventCompleteSvcArgs->Arg7));
- FfaEnabled = FeaturePcdGet (PcdFfaEnable);
+ FfaEnabled = FixedPcdGet32 (PcdFfaEnable != 0);
if (FfaEnabled) {
Status = CpuDriverEntryPoint (
EventCompleteSvcArgs->Arg0,
@@ -225,7 +225,7 @@ GetSpmVersion (
UINT32 SpmVersion;
ARM_SVC_ARGS SpmVersionArgs;
- if (FeaturePcdGet (PcdFfaEnable)) {
+ if (FixedPcdGet32 (PcdFfaEnable) != 0) {
SpmVersionArgs.Arg0 = ARM_SVC_ID_FFA_VERSION_AARCH32;
SpmVersionArgs.Arg1 = mSpmMajorVerFfa << SPM_MAJOR_VER_SHIFT;
SpmVersionArgs.Arg1 |= mSpmMinorVerFfa;
@@ -293,7 +293,7 @@ InitArmSvcArgs (
OUT INT32 *Ret
)
{
- if (FeaturePcdGet (PcdFfaEnable)) {
+ if (FixedPcdGet32 (PcdFfaEnable) != 0) {
InitMmFoundationSvcArgs->Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP;
InitMmFoundationSvcArgs->Arg1 = 0;
InitMmFoundationSvcArgs->Arg2 = 0;
--
2.34.1
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [edk2-platforms][PATCH V1 02/20] StandaloneMmPkg: Allocate and initialise SP stack from internal memory
2023-07-11 14:36 [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Nishant Sharma
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 01/20] ArmPkg: Change PcdFfaEnable flag datatype Nishant Sharma
@ 2023-07-11 14:36 ` Nishant Sharma
2023-07-12 17:47 ` [edk2-devel] " Chris Fernald
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 03/20] StandaloneMmPkg: Include libfdt in the StMM Nishant Sharma
` (18 subsequent siblings)
20 siblings, 1 reply; 41+ messages in thread
From: Nishant Sharma @ 2023-07-11 14:36 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
From: Achin Gupta <achin.gupta@arm.com>
This patch removes the dependency on the SPM to allocate and initialise
stack memory for the StMM SP. This is done by reserving 8K worth of memory
in the StMM image at a page aligned address in the data section. Then,
instead of jumping directly to the C entrypoint, an assembler entrypoint is
invoked. This entrypoint locates the stack memory, changes its permissions
using FF-A ABIs, sets the stack pointer and invokes the C entrypoint.
Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
---
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf | 1 +
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c | 2 +-
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/AArch64/ModuleEntryPoint.S | 68 ++++++++++++++++++++
3 files changed, 70 insertions(+), 1 deletion(-)
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
index dc6d3d859911..10fafa43ce59 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
@@ -25,6 +25,7 @@
Arm/StandaloneMmCoreEntryPoint.c
Arm/SetPermissions.c
Arm/CreateHobList.c
+ Arm/AArch64/ModuleEntryPoint.S
[Sources.X64]
X64/StandaloneMmCoreEntryPoint.c
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
index 5dd1d9747995..ce867fe85158 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
@@ -316,7 +316,7 @@ InitArmSvcArgs (
**/
VOID
EFIAPI
-_ModuleEntryPoint (
+ModuleEntryPoint (
IN VOID *SharedBufAddress,
IN UINT64 SharedBufSize,
IN UINT64 cookie1,
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/AArch64/ModuleEntryPoint.S b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/AArch64/ModuleEntryPoint.S
new file mode 100644
index 000000000000..174bc83ebd64
--- /dev/null
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/AArch64/ModuleEntryPoint.S
@@ -0,0 +1,68 @@
+//
+// Copyright (c) 2023, ARM Limited. All rights reserved.
+//
+// SPDX-License-Identifier: BSD-2-Clause-Patent
+//
+//
+
+#include <AsmMacroIoLibV8.h>
+
+#define FFA_DATA_RW 0x1
+
+.align 12
+StackBase:
+.space 8192
+StackEnd:
+
+.macro FfaMemPermSet start:req end:req perm:req
+adrp x29, \start
+add x29, x29, :lo12: \start
+
+adrp x30, \end
+add x30, x30, :lo12:\end
+
+/* x30 = end - begin */
+sub x30, x30, x29
+/* x28 = x30 >> 12 (number of pages) */
+mov x28, #12
+lsrv x28, x30, x28
+
+mov w0, #0x89
+movk w0, #0x8400, lsl #16
+mov x1, x29
+mov x2, x28
+mov w3, #\perm
+
+svc #0
+
+mov w1, #0x61
+movk w1, #0x8400, lsl #16
+cmp w1, w0
+b.ne .
+.endm
+
+ ASM_FUNC(_ModuleEntryPoint)
+MOV32 (w8, FixedPcdGet32(PcdFfaEnable))
+ cbz w8, FfaNotEnabled
+ // Stash boot information registers from the SPMC
+ mov x8, x0
+ mov x9, x1
+ mov x10, x2
+ mov x11, x3
+
+ // Set the correct permissions on stack memory
+ FfaMemPermSet StackBase StackEnd FFA_DATA_RW
+
+ // Initialise SP
+ adr x0, StackEnd
+ mov sp, x0
+
+ // Restore boot information registers from the SPMC
+ mov x0, x8
+ mov x1, x9
+ mov x2, x10
+ mov x3, x11
+
+ // Invoke the C entrypoint
+ FfaNotEnabled:
+ b ModuleEntryPoint
--
2.34.1
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [edk2-platforms][PATCH V1 03/20] StandaloneMmPkg: Include libfdt in the StMM
2023-07-11 14:36 [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Nishant Sharma
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 01/20] ArmPkg: Change PcdFfaEnable flag datatype Nishant Sharma
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 02/20] StandaloneMmPkg: Allocate and initialise SP stack from internal memory Nishant Sharma
@ 2023-07-11 14:36 ` Nishant Sharma
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 04/20] ArmPkg: Add data structures to receive FF-A boot information Nishant Sharma
` (17 subsequent siblings)
20 siblings, 0 replies; 41+ messages in thread
From: Nishant Sharma @ 2023-07-11 14:36 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
From: Achin Gupta <achin.gupta@arm.com>
The StMM SP will extract boot information from its manifest instead of a C
data structure populated by the SPM. The manifest will be passed by the
SPM. This patch includes support for libfdt to prepare for parsing the
manifest in future patches.
Signed-off-by: Sayanta Pattanayak <sayanta.pattanayak@arm.com>
Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
---
StandaloneMmPkg/StandaloneMmPkg.dsc | 3 ++-
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf | 3 +++
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c | 1 +
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/StandaloneMmPkg/StandaloneMmPkg.dsc b/StandaloneMmPkg/StandaloneMmPkg.dsc
index 8012f93b7dcc..0060eddb900c 100644
--- a/StandaloneMmPkg/StandaloneMmPkg.dsc
+++ b/StandaloneMmPkg/StandaloneMmPkg.dsc
@@ -2,7 +2,7 @@
# Standalone MM Platform.
#
# Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>
-# Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.<BR>
+# Copyright (c) 2016 - 2023, Arm Limited. All rights reserved.<BR>
# Copyright (C) Microsoft Corporation<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -49,6 +49,7 @@
HobLib|StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf
IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
MemLib|StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf
+ FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
MemoryAllocationLib|StandaloneMmPkg/Library/StandaloneMmCoreMemoryAllocationLib/StandaloneMmCoreMemoryAllocationLib.inf
MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
index 10fafa43ce59..80af62450e22 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
@@ -31,6 +31,7 @@
X64/StandaloneMmCoreEntryPoint.c
[Packages]
+ EmbeddedPkg/EmbeddedPkg.dec
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
StandaloneMmPkg/StandaloneMmPkg.dec
@@ -41,10 +42,12 @@
[LibraryClasses]
BaseLib
DebugLib
+ FdtLib
[LibraryClasses.ARM, LibraryClasses.AARCH64]
StandaloneMmMmuLib
ArmSvcLib
+ FdtLib
[Guids]
gMpInformationHobGuid
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
index ce867fe85158..682b55b5478a 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
@@ -15,6 +15,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Guid/MmramMemoryReserve.h>
#include <Guid/MpInformation.h>
+#include <libfdt.h>
#include <Library/ArmSvcLib.h>
#include <Library/DebugLib.h>
#include <Library/HobLib.h>
--
2.34.1
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [edk2-platforms][PATCH V1 04/20] ArmPkg: Add data structures to receive FF-A boot information
2023-07-11 14:36 [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Nishant Sharma
` (2 preceding siblings ...)
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 03/20] StandaloneMmPkg: Include libfdt in the StMM Nishant Sharma
@ 2023-07-11 14:36 ` Nishant Sharma
2023-07-12 17:27 ` [edk2-devel] " Oliver Smith-Denny
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 05/20] ArmPkg/ArmFfaSvc: Add helper macros and fids Nishant Sharma
` (16 subsequent siblings)
20 siblings, 1 reply; 41+ messages in thread
From: Nishant Sharma @ 2023-07-11 14:36 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
From: Achin Gupta <achin.gupta@arm.com>
The SPMC will pass the manifest to the StMM SP which contains the boot
information required for SP initialisation. This patch defines the data
structures defined in Section 5.4 of the FF-A v1.1 BETA0 spec to enable
this support. The manifest is identified by the TF-A UUID_TOS_FW_CONFIG.
Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
---
ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 69 +++++++++++++++++++-
1 file changed, 68 insertions(+), 1 deletion(-)
diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
index 4126a4985bb2..54cc96598032 100644
--- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
+++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
@@ -3,7 +3,7 @@
communication between S-EL0 and the Secure Partition
Manager(SPM)
- Copyright (c) 2020, ARM Limited. All rights reserved.
+ Copyright (c) 2020 - 2023, ARM Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -53,4 +53,71 @@
// https://github.com/OP-TEE/optee_os/blob/master/core/arch/arm/kernel/stmm_sp.c#L66
#define ARM_FFA_DESTINATION_ENDPOINT_ID 3
+/******************************************************************************
+ * Boot information protocol as per the FF-A v1.1 spec.
+ *****************************************************************************/
+#define FFA_INIT_DESC_SIGNATURE 0x00000FFA
+
+/* Boot information type. */
+#define FFA_BOOT_INFO_TYPE_STD 0x0U
+#define FFA_BOOT_INFO_TYPE_IMPL 0x1U
+
+#define FFA_BOOT_INFO_TYPE_MASK 0x1U
+#define FFA_BOOT_INFO_TYPE_SHIFT 0x7U
+#define FFA_BOOT_INFO_TYPE(type) \
+ (((type) & FFA_BOOT_INFO_TYPE_MASK) \
+ << FFA_BOOT_INFO_TYPE_SHIFT)
+
+/* Boot information identifier. */
+#define FFA_BOOT_INFO_TYPE_ID_FDT 0x0U
+#define FFA_BOOT_INFO_TYPE_ID_HOB 0x1U
+
+#define FFA_BOOT_INFO_TYPE_ID_MASK 0x3FU
+#define FFA_BOOT_INFO_TYPE_ID_SHIFT 0x0U
+#define FFA_BOOT_INFO_TYPE_ID(type) \
+ (((type) & FFA_BOOT_INFO_TYPE_ID_MASK) \
+ << FFA_BOOT_INFO_TYPE_ID_SHIFT)
+
+/* Format of Flags Name field. */
+#define FFA_BOOT_INFO_FLAG_NAME_STRING 0x0U
+#define FFA_BOOT_INFO_FLAG_NAME_UUID 0x1U
+
+#define FFA_BOOT_INFO_FLAG_NAME_MASK 0x3U
+#define FFA_BOOT_INFO_FLAG_NAME_SHIFT 0x0U
+#define FFA_BOOT_INFO_FLAG_NAME(type) \
+ (((type) & FFA_BOOT_INFO_FLAG_NAME_MASK) \
+ << FFA_BOOT_INFO_FLAG_NAME_SHIFT)
+
+/* Format of Flags Contents field. */
+#define FFA_BOOT_INFO_FLAG_CONTENT_ADR 0x0U
+#define FFA_BOOT_INFO_FLAG_CONTENT_VAL 0x1U
+
+#define FFA_BOOT_INFO_FLAG_CONTENT_MASK 0x1U
+#define FFA_BOOT_INFO_FLAG_CONTENT_SHIFT 0x2U
+#define FFA_BOOT_INFO_FLAG_CONTENT(content) \
+ (((content) & FFA_BOOT_INFO_FLAG_CONTENT_MASK) \
+ << FFA_BOOT_INFO_FLAG_CONTENT_SHIFT)
+
+// Descriptor to pass boot information as per the FF-A v1.1 spec.
+typedef struct {
+ UINT32 Name[4];
+ UINT8 Type;
+ UINT8 Reserved;
+ UINT16 Flags;
+ UINT32 SizeBotInfo;
+ UINT64 Content;
+} EFI_FFA_BOOT_INFO_DESC;
+
+// Descriptor that contains boot info blobs size, number of desc it cointains
+// size of each descriptor and offset to the first descriptor.
+typedef struct {
+ UINT32 Magic; // 0xFFA^M
+ UINT32 Version;
+ UINT32 SizeBootInfoBlob;
+ UINT32 SizeBootInfoDesc;
+ UINT32 CountBootInfoDesc;
+ UINT32 OffsetBootInfoDesc;
+ UINT64 Reserved;
+} EFI_FFA_BOOT_INFO_HEADER;
+
#endif // ARM_FFA_SVC_H_
--
2.34.1
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [edk2-platforms][PATCH V1 05/20] ArmPkg/ArmFfaSvc: Add helper macros and fids
2023-07-11 14:36 [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Nishant Sharma
` (3 preceding siblings ...)
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 04/20] ArmPkg: Add data structures to receive FF-A boot information Nishant Sharma
@ 2023-07-11 14:36 ` Nishant Sharma
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 06/20] ArmPkg: Add support for FFA_MEM_PERM_GET/SET ABIs Nishant Sharma
` (15 subsequent siblings)
20 siblings, 0 replies; 41+ messages in thread
From: Nishant Sharma @ 2023-07-11 14:36 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
From: Achin Gupta <achin.gupta@arm.com>
Add new fid for Success, error and wait. Also add macro to generate FFA
verions.
Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
---
ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 21 +++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
index 54cc96598032..c80d783fad3f 100644
--- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
+++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
@@ -21,6 +21,11 @@
#define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH32 0x84000070
#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_AARCH32 0x84000061
+#define ARM_SVC_ID_FFA_SUCCESS_AARCH64 0xC4000061
+#define ARM_SVC_ID_FFA_ERROR_AARCH32 0x84000060
+#define ARM_SVC_ID_FFA_ERROR_AARCH64 0xC4000060
+#define ARM_SVC_ID_FFA_MSG_WAIT_AARCH32 0x8400006B
/* Generic IDs when using AArch32 or AArch64 execution state */
#ifdef MDE_CPU_AARCH64
@@ -35,7 +40,7 @@
#define SPM_MAJOR_VERSION_FFA 1
#define SPM_MINOR_VERSION_FFA 0
-#define ARM_FFA_SPM_RET_SUCCESS 0
+#define ARM_FFA_SPM_RET_SUCCESS 0
#define ARM_FFA_SPM_RET_NOT_SUPPORTED -1
#define ARM_FFA_SPM_RET_INVALID_PARAMETERS -2
#define ARM_FFA_SPM_RET_NO_MEMORY -3
@@ -45,6 +50,20 @@
#define ARM_FFA_SPM_RET_RETRY -7
#define ARM_FFA_SPM_RET_ABORTED -8
+// FF-A version helper macros
+#define FFA_VERSION_MAJOR_SHIFT 16
+#define FFA_VERSION_MAJOR_MASK 0x7FFF
+#define FFA_VERSION_MINOR_SHIFT 0
+#define FFA_VERSION_MINOR_MASK 0xFFFF
+#define FFA_VERSION_BIT31_MASK (0x1u << 31)
+
+#define MAKE_FFA_VERSION(major, minor) \
+ ((((major) & FFA_VERSION_MAJOR_MASK) << FFA_VERSION_MAJOR_SHIFT) | \
+ (((minor) & FFA_VERSION_MINOR_MASK) << FFA_VERSION_MINOR_SHIFT))
+
+#define FFA_VERSION_COMPILED MAKE_FFA_VERSION(SPM_MAJOR_VERSION_FFA, \
+ SPM_MINOR_VERSION_FFA)
+
// For now, the destination id to be used in the FF-A calls
// is being hard-coded. Subsequently, support will be added
// to get the endpoint id's dynamically
--
2.34.1
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [edk2-platforms][PATCH V1 06/20] ArmPkg: Add support for FFA_MEM_PERM_GET/SET ABIs
2023-07-11 14:36 [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Nishant Sharma
` (4 preceding siblings ...)
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 05/20] ArmPkg/ArmFfaSvc: Add helper macros and fids Nishant Sharma
@ 2023-07-11 14:36 ` Nishant Sharma
2023-07-12 17:43 ` [edk2-devel] " Oliver Smith-Denny
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 07/20] StandaloneMmPkg: define new data structure to stage FF-A boot information Nishant Sharma
` (14 subsequent siblings)
20 siblings, 1 reply; 41+ messages in thread
From: Nishant Sharma @ 2023-07-11 14:36 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
From: Achin Gupta <achin.gupta@arm.com>
This patch uses the FFA_MEM_PERM_GET/SET ABIs to tweak the permissions of a
set of pages if FF-A v1.1 and above is supported by the SPMC. For FF-A v1.0
the previous method through FFA_MSG_SEND_DIRECT_REQ/RESP is used.
Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
---
ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 2 +
ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c | 132 +++++++++++++++++---
2 files changed, 120 insertions(+), 14 deletions(-)
diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
index c80d783fad3f..7987678c996e 100644
--- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
+++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
@@ -23,6 +23,8 @@
#define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH64 0xC4000070
#define ARM_SVC_ID_FFA_SUCCESS_AARCH32 0x84000061
#define ARM_SVC_ID_FFA_SUCCESS_AARCH64 0xC4000061
+#define ARM_SVC_ID_FFA_MEM_PERM_SET_AARCH32 0x84000089
+#define ARM_SVC_ID_FFA_MEM_PERM_GET_AARCH32 0x84000088
#define ARM_SVC_ID_FFA_ERROR_AARCH32 0x84000060
#define ARM_SVC_ID_FFA_ERROR_AARCH64 0xC4000060
#define ARM_SVC_ID_FFA_MSG_WAIT_AARCH32 0x8400006B
diff --git a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
index 1a41a289ef17..76ef214bcb85 100644
--- a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
+++ b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
@@ -25,6 +25,66 @@
#include <Library/DebugLib.h>
#include <Library/PcdLib.h>
+
+/**
+ Utility function to determine whether ABIs in FF-A v1.1 to set and get
+ memory permissions can be used. Ideally, this should be invoked once in the
+ library constructor and set a flag that can be used at runtime. However, the
+ StMM Core invokes this library before constructors are called and before the
+ StMM image itself is relocated.
+
+ @retval EFI_SUCCESS The availability of ABIs was correctly determined.
+ @retval Other value Software stack is misconfigured.
+
+**/
+STATIC
+BOOLEAN
+UseFfaMemPermAbis (
+ VOID
+ )
+{
+ ARM_SVC_ARGS SvcArgs;
+ UINT32 SpmcFfaVersion;
+ STATIC UINT16 SpmcMajorVer = 0;
+ STATIC UINT16 SpmcMinorVer = 0;
+
+ // Use prefetched version info. if either is not 0, then the version is
+ // already fetched.
+ if ((SpmcMajorVer | SpmcMinorVer) != 0) {
+ return (SpmcMajorVer == SPM_MAJOR_VERSION_FFA) && (SpmcMinorVer >= SPM_MINOR_VERSION_FFA);
+ }
+
+ // Nothing to do if FF-A has not be enabled
+ if (FixedPcdGet32 (PcdFfaEnable) == 0) {
+ return FALSE;
+ }
+
+ // Prepare the message parameters.
+ ZeroMem (&SvcArgs, sizeof (ARM_SVC_ARGS));
+ SvcArgs.Arg0 = ARM_SVC_ID_FFA_VERSION_AARCH32;
+ SvcArgs.Arg1 = FFA_VERSION_COMPILED;
+
+ // Invoke the ABI
+ ArmCallSvc (&SvcArgs);
+
+ // Check if FF-A is supported and what version
+ SpmcFfaVersion = SvcArgs.Arg0;
+
+ // Damn! FF-A is not supported at all even though we specified v1.0 as our
+ // version. However, the feature flag has been turned on. This is a
+ // misconfigured software stack. So, return an error and assert in a debug build.
+ if (SpmcFfaVersion == ARM_FFA_SPM_RET_NOT_SUPPORTED) {
+ ASSERT (0);
+ return FALSE;
+ }
+
+ SpmcMajorVer = (SpmcFfaVersion >> FFA_VERSION_MAJOR_SHIFT) & FFA_VERSION_MAJOR_MASK;
+ SpmcMinorVer = (SpmcFfaVersion >> FFA_VERSION_MINOR_SHIFT) & FFA_VERSION_MINOR_MASK;
+
+ return (SpmcMajorVer == SPM_MAJOR_VERSION_FFA) && (SpmcMinorVer >= SPM_MINOR_VERSION_FFA);
+}
+
+
/** Send memory permission request to target.
@param [in, out] SvcArgs Pointer to SVC arguments to send. On
@@ -55,6 +115,36 @@ SendMemoryPermissionRequest (
ArmCallSvc (SvcArgs);
if (FixedPcdGet32 (PcdFfaEnable) != 0) {
+
+ // Check if FF-A memory permission ABIs were used.
+ if (UseFfaMemPermAbis()) {
+ switch (SvcArgs->Arg0) {
+
+ case ARM_SVC_ID_FFA_ERROR_AARCH32:
+ case ARM_SVC_ID_FFA_ERROR_AARCH64:
+ switch (SvcArgs->Arg2) {
+ case ARM_FFA_SPM_RET_INVALID_PARAMETERS:
+ return EFI_INVALID_PARAMETER;
+ case ARM_FFA_SPM_RET_NOT_SUPPORTED:
+ return EFI_UNSUPPORTED;
+ default:
+ // Undefined error code received.
+ ASSERT (0);
+ return EFI_INVALID_PARAMETER;
+ }
+
+ case ARM_SVC_ID_FFA_SUCCESS_AARCH32:
+ case ARM_SVC_ID_FFA_SUCCESS_AARCH64:
+ *RetVal = SvcArgs->Arg2;
+ return EFI_SUCCESS;
+
+ default:
+ // Undefined error code received.
+ ASSERT (0);
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
// Get/Set memory attributes is an atomic call, with
// StandaloneMm at S-EL0 being the caller and the SPM
// core being the callee. Thus there won't be a
@@ -164,12 +254,18 @@ GetMemoryPermissions (
// See [1], Section 13.5.5.1 MM_SP_MEMORY_ATTRIBUTES_GET_AARCH64.
ZeroMem (&SvcArgs, sizeof (ARM_SVC_ARGS));
if (FixedPcdGet32 (PcdFfaEnable) != 0) {
- // See [2], Section 10.2 FFA_MSG_SEND_DIRECT_REQ.
- SvcArgs.Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ;
- SvcArgs.Arg1 = ARM_FFA_DESTINATION_ENDPOINT_ID;
- SvcArgs.Arg2 = 0;
- SvcArgs.Arg3 = ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES;
- SvcArgs.Arg4 = BaseAddress;
+ // Check if FF-A memory permission ABIs can be used.
+ if (UseFfaMemPermAbis()) {
+ SvcArgs.Arg0 = ARM_SVC_ID_FFA_MEM_PERM_GET_AARCH32;
+ SvcArgs.Arg1 = BaseAddress;
+ } else {
+ // See [2], Section 10.2 FFA_MSG_SEND_DIRECT_REQ.
+ SvcArgs.Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ;
+ SvcArgs.Arg1 = ARM_FFA_DESTINATION_ENDPOINT_ID;
+ SvcArgs.Arg2 = 0;
+ SvcArgs.Arg3 = ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES;
+ SvcArgs.Arg4 = BaseAddress;
+ }
} else {
SvcArgs.Arg0 = ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES;
SvcArgs.Arg1 = BaseAddress;
@@ -219,14 +315,22 @@ RequestMemoryPermissionChange (
// See [1], Section 13.5.5.2 MM_SP_MEMORY_ATTRIBUTES_SET_AARCH64.
ZeroMem (&SvcArgs, sizeof (ARM_SVC_ARGS));
if (FixedPcdGet32 (PcdFfaEnable) != 0) {
- // See [2], Section 10.2 FFA_MSG_SEND_DIRECT_REQ.
- SvcArgs.Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ;
- SvcArgs.Arg1 = ARM_FFA_DESTINATION_ENDPOINT_ID;
- SvcArgs.Arg2 = 0;
- SvcArgs.Arg3 = ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES;
- SvcArgs.Arg4 = BaseAddress;
- SvcArgs.Arg5 = EFI_SIZE_TO_PAGES (Length);
- SvcArgs.Arg6 = Permissions;
+ // Check if FF-A memory permission ABIs can be used.
+ if (UseFfaMemPermAbis()) {
+ SvcArgs.Arg0 = ARM_SVC_ID_FFA_MEM_PERM_SET_AARCH32;
+ SvcArgs.Arg1 = BaseAddress;
+ SvcArgs.Arg2 = EFI_SIZE_TO_PAGES (Length);
+ SvcArgs.Arg3 = Permissions;
+ } else {
+ // See [2], Section 10.2 FFA_MSG_SEND_DIRECT_REQ.
+ SvcArgs.Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ;
+ SvcArgs.Arg1 = ARM_FFA_DESTINATION_ENDPOINT_ID;
+ SvcArgs.Arg2 = 0;
+ SvcArgs.Arg3 = ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES;
+ SvcArgs.Arg4 = BaseAddress;
+ SvcArgs.Arg5 = EFI_SIZE_TO_PAGES (Length);
+ SvcArgs.Arg6 = Permissions;
+ }
} else {
SvcArgs.Arg0 = ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES;
SvcArgs.Arg1 = BaseAddress;
--
2.34.1
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [edk2-platforms][PATCH V1 07/20] StandaloneMmPkg: define new data structure to stage FF-A boot information
2023-07-11 14:36 [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Nishant Sharma
` (5 preceding siblings ...)
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 06/20] ArmPkg: Add support for FFA_MEM_PERM_GET/SET ABIs Nishant Sharma
@ 2023-07-11 14:36 ` Nishant Sharma
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 08/20] StandaloneMmPkg: Add backwards compatible support to detect FF-A v1.1 Nishant Sharma
` (13 subsequent siblings)
20 siblings, 0 replies; 41+ messages in thread
From: Nishant Sharma @ 2023-07-11 14:36 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
From: Achin Gupta <achin.gupta@arm.com>
With FF-A v1.1, the SPMC sends a reduced amount of boot information as
compared to the original SPM implementation. For example, the stack layout,
MP information etc. This information could be accommodated in the old data
structure but this is too complicated. This patch defines a new structure
to clearly separate FF-A v1.1 and other functionality.
Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
---
StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h | 21 ++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h
index 41bf0f132b4f..c965192c702e 100644
--- a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h
+++ b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h
@@ -47,6 +47,27 @@ typedef struct {
EFI_SECURE_PARTITION_CPU_INFO *CpuInfo;
} EFI_SECURE_PARTITION_BOOT_INFO;
+
+/**
+ This structure is used to stage boot information required to initialize the
+ standalone MM environment when FF-A is used as the interface between this
+ secure partition and the SPMC. This structure supersedes
+ EFI_SECURE_PARTITION_BOOT_INFO and reduces the amount of information that must
+ be passed by the SPMC for SP initialization.
+**/
+typedef struct {
+ UINT64 SpMemBase;
+ UINT64 SpMemSize;
+ UINT64 SpNsCommBufBase;
+ UINT64 SpNsCommBufSize;
+ UINT64 SpSharedBufBase;
+ UINT64 SpSharedBufSize;
+ UINT64 SpHeapBase;
+ UINT64 SpHeapSize;
+ /* UP migrate-able FF-A SP requires awareness of only 1 cpu */
+ EFI_SECURE_PARTITION_CPU_INFO CpuInfo;
+} EFI_STMM_BOOT_INFO;
+
typedef
EFI_STATUS
(*PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT) (
--
2.34.1
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [edk2-platforms][PATCH V1 08/20] StandaloneMmPkg: Add backwards compatible support to detect FF-A v1.1
2023-07-11 14:36 [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Nishant Sharma
` (6 preceding siblings ...)
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 07/20] StandaloneMmPkg: define new data structure to stage FF-A boot information Nishant Sharma
@ 2023-07-11 14:36 ` Nishant Sharma
2023-07-12 20:31 ` [edk2-devel] " Oliver Smith-Denny
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 09/20] StandaloneMmPkg: parse SP manifest and populate new boot information Nishant Sharma
` (12 subsequent siblings)
20 siblings, 1 reply; 41+ messages in thread
From: Nishant Sharma @ 2023-07-11 14:36 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
From: Achin Gupta <achin.gupta@arm.com>
For better or worse, an StMM SP can communicate with the SPM through one
of these interfaces.
1. SPM_MM interface
2. FF-A v1.0 interface
3. FF-A v1.1 interface
2) implements only minimal FF-A support. It reuses the initialisation ABI
defined by 1) and wraps the remaining communicaton in
FFA_MSG_SEND_DIRECT_REQ/RESP ABIs.
3) uses FF-A ABIs from the spec for both initialisation and communication.
Detecting these variations in the GetSpmVersion() function is tedious. This
patch restores the original function that discovered configuration
1). It defines a new function to discover presence of FF-A and
differentiate between v1.0 and v1.1.
Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
---
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c | 132 +++++++++++++-------
1 file changed, 87 insertions(+), 45 deletions(-)
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
index 682b55b5478a..9f6af55c86c4 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
@@ -32,13 +32,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define SPM_MAJOR_VER_MASK 0xFFFF0000
#define SPM_MINOR_VER_MASK 0x0000FFFF
#define SPM_MAJOR_VER_SHIFT 16
-#define FFA_NOT_SUPPORTED -1
-STATIC CONST UINT32 mSpmMajorVer = SPM_MAJOR_VERSION;
-STATIC CONST UINT32 mSpmMinorVer = SPM_MINOR_VERSION;
-
-STATIC CONST UINT32 mSpmMajorVerFfa = SPM_MAJOR_VERSION_FFA;
-STATIC CONST UINT32 mSpmMinorVerFfa = SPM_MINOR_VERSION_FFA;
+#define SPM_MAJOR_VER 0
+#define SPM_MINOR_VER 1
#define BOOT_PAYLOAD_VERSION 1
@@ -110,6 +106,70 @@ GetAndPrintBootinformation (
}
return PayloadBootInfo;
+
+/**
+ An StMM SP implements partial support for FF-A v1.0. The FF-A ABIs are used to
+ get and set permissions of memory pages in collaboration with the SPMC and
+ signalling completion of initialisation. The original Arm MM communication
+ interface is used for communication with the Normal world. A TF-A specific
+ interface is used for initialising the SP.
+
+ With FF-A v1.1, the StMM SP uses only FF-A ABIs for initialisation and
+ communication. This is subject to support for FF-A v1.1 in the SPMC. If this
+ is not the case, the StMM implementation reverts to the FF-A v1.0
+ behaviour. Any of this is applicable only if the feature flag PcdFfaEnable is
+ TRUE.
+
+ This function helps the caller determine whether FF-A v1.1 or v1.0 are
+ available and if only FF-A ABIs can be used at runtime.
+**/
+STATIC
+EFI_STATUS
+CheckFfaCompatibility (BOOLEAN *UseOnlyFfaAbis)
+{
+ UINT16 SpmcMajorVer;
+ UINT16 SpmcMinorVer;
+ UINT32 SpmcVersion;
+ ARM_SVC_ARGS SpmcVersionArgs = {0};
+
+ // Sanity check in case of a spurious call.
+ if (FixedPcdGet32 (PcdFfaEnable) == 0) {
+ return EFI_UNSUPPORTED;
+ }
+
+ // Send the SPMC our version to see whether it supports the same or not.
+ SpmcVersionArgs.Arg0 = ARM_SVC_ID_FFA_VERSION_AARCH32;
+ SpmcVersionArgs.Arg1 = FFA_VERSION_COMPILED;
+
+ ArmCallSvc (&SpmcVersionArgs);
+ SpmcVersion = SpmcVersionArgs.Arg0;
+
+ // If the SPMC barfs then bail.
+ if (SpmcVersion == ARM_FFA_SPM_RET_NOT_SUPPORTED) {
+ return EFI_UNSUPPORTED;
+ }
+
+ // Extract the SPMC version
+ SpmcMajorVer = (SpmcVersion >> FFA_VERSION_MAJOR_SHIFT) & FFA_VERSION_MAJOR_MASK;
+ SpmcMinorVer = (SpmcVersion >> FFA_VERSION_MINOR_SHIFT) & FFA_VERSION_MINOR_MASK;
+
+ // If the major versions differ then all bets are off.
+ if (SpmcMajorVer != SPM_MAJOR_VERSION_FFA) {
+ return EFI_UNSUPPORTED;
+ }
+
+ // We advertised v1.1 as our version. If the SPMC supports it, it must return
+ // the same or a compatible version. If it does not then FF-A ABIs cannot be
+ // used for all communication.
+ if (SpmcMinorVer >= SPM_MINOR_VERSION_FFA) {
+ *UseOnlyFfaAbis = TRUE;
+ } else {
+ *UseOnlyFfaAbis = FALSE;
+ }
+
+ // We have validated that there is a compatible FF-A
+ // implementation. So. return success.
+ return EFI_SUCCESS;
}
/**
@@ -219,34 +279,19 @@ GetSpmVersion (
)
{
EFI_STATUS Status;
- UINT16 CalleeSpmMajorVer;
- UINT16 CallerSpmMajorVer;
- UINT16 CalleeSpmMinorVer;
- UINT16 CallerSpmMinorVer;
+ UINT16 SpmMajorVersion;
+ UINT16 SpmMinorVersion;
UINT32 SpmVersion;
ARM_SVC_ARGS SpmVersionArgs;
- if (FixedPcdGet32 (PcdFfaEnable) != 0) {
- SpmVersionArgs.Arg0 = ARM_SVC_ID_FFA_VERSION_AARCH32;
- SpmVersionArgs.Arg1 = mSpmMajorVerFfa << SPM_MAJOR_VER_SHIFT;
- SpmVersionArgs.Arg1 |= mSpmMinorVerFfa;
- CallerSpmMajorVer = mSpmMajorVerFfa;
- CallerSpmMinorVer = mSpmMinorVerFfa;
- } else {
- SpmVersionArgs.Arg0 = ARM_SVC_ID_SPM_VERSION_AARCH32;
- CallerSpmMajorVer = mSpmMajorVer;
- CallerSpmMinorVer = mSpmMinorVer;
- }
+ SpmVersionArgs.Arg0 = ARM_SVC_ID_SPM_VERSION_AARCH32;
ArmCallSvc (&SpmVersionArgs);
SpmVersion = SpmVersionArgs.Arg0;
- if (SpmVersion == FFA_NOT_SUPPORTED) {
- return EFI_UNSUPPORTED;
- }
- CalleeSpmMajorVer = ((SpmVersion & SPM_MAJOR_VER_MASK) >> SPM_MAJOR_VER_SHIFT);
- CalleeSpmMinorVer = ((SpmVersion & SPM_MINOR_VER_MASK) >> 0);
+ SpmMajorVersion = ((SpmVersion & SPM_MAJOR_VER_MASK) >> SPM_MAJOR_VER_SHIFT);
+ SpmMinorVersion = ((SpmVersion & SPM_MINOR_VER_MASK) >> 0);
// Different major revision values indicate possibly incompatible functions.
// For two revisions, A and B, for which the major revision values are
@@ -255,25 +300,17 @@ GetSpmVersion (
// revision A must work in a compatible way with revision B.
// However, it is possible for revision B to have a higher
// function count than revision A.
- if ((CalleeSpmMajorVer == CallerSpmMajorVer) &&
- (CalleeSpmMinorVer >= CallerSpmMinorVer))
- {
- DEBUG ((
- DEBUG_INFO,
- "SPM Version: Major=0x%x, Minor=0x%x\n",
- CalleeSpmMajorVer,
- CalleeSpmMinorVer
- ));
+ if ((SpmMajorVersion == SPM_MAJOR_VER) &&
+ (SpmMinorVersion >= SPM_MINOR_VER)) {
+ DEBUG ((DEBUG_INFO, "SPM Version: Major=0x%x, Minor=0x%x\n",
+ SpmMajorVersion, SpmMinorVersion));
Status = EFI_SUCCESS;
} else {
- DEBUG ((
- DEBUG_INFO,
- "Incompatible SPM Versions.\n Callee Version: Major=0x%x, Minor=0x%x.\n Caller: Major=0x%x, Minor>=0x%x.\n",
- CalleeSpmMajorVer,
- CalleeSpmMinorVer,
- CallerSpmMajorVer,
- CallerSpmMinorVer
- ));
+ DEBUG ((DEBUG_INFO, "Incompatible SPM Versions.\n"));
+ DEBUG ((DEBUG_INFO, "Current Version: Major=0x%x, Minor=0x%x.\n",
+ SpmMajorVersion, SpmMinorVersion));
+ DEBUG ((DEBUG_INFO, "Expected: Major=0x%x, Minor>=0x%x.\n",
+ SPM_MAJOR_VER, SPM_MINOR_VER));
Status = EFI_UNSUPPORTED;
}
@@ -335,9 +372,14 @@ ModuleEntryPoint (
VOID *TeData;
UINTN TeDataSize;
EFI_PHYSICAL_ADDRESS ImageBase;
+ BOOLEAN UseOnlyFfaAbis = FALSE;
- // Get Secure Partition Manager Version Information
- Status = GetSpmVersion ();
+ if (FixedPcdGet32 (PcdFfaEnable) != 0) {
+ Status = CheckFfaCompatibility (&UseOnlyFfaAbis);
+ } else {
+ // Get Secure Partition Manager Version Information
+ Status = GetSpmVersion ();
+ }
if (EFI_ERROR (Status)) {
goto finish;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [edk2-platforms][PATCH V1 09/20] StandaloneMmPkg: parse SP manifest and populate new boot information
2023-07-11 14:36 [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Nishant Sharma
` (7 preceding siblings ...)
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 08/20] StandaloneMmPkg: Add backwards compatible support to detect FF-A v1.1 Nishant Sharma
@ 2023-07-11 14:36 ` Nishant Sharma
2023-07-13 15:24 ` [edk2-devel] " Girish Mahadevan
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 10/20] StandaloneMmPkg: Populate Hoblist for SP init from StMM " Nishant Sharma
` (11 subsequent siblings)
20 siblings, 1 reply; 41+ messages in thread
From: Nishant Sharma @ 2023-07-11 14:36 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
From: Achin Gupta <achin.gupta@arm.com>
This patch discovers the SP manifest in DT format passed by the SPMC. It
then parses it to obtain the boot information required to initialise the
SP.
Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Signed-off-by: Sayanta Pattanayak <sayanta.pattanayak@arm.com>
Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
---
StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h | 2 +-
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c | 389 +++++++++++++++++++-
2 files changed, 381 insertions(+), 10 deletions(-)
diff --git a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h
index c965192c702e..90d67a2f25b5 100644
--- a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h
+++ b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h
@@ -2,7 +2,7 @@
Entry point to the Standalone MM Foundation when initialized during the SEC
phase on ARM platforms
-Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.<BR>
+Copyright (c) 2017 - 2023, Arm Ltd. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
index 9f6af55c86c4..505786aff07c 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
@@ -38,6 +38,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define BOOT_PAYLOAD_VERSION 1
+#define FFA_PAGE_4K 0
+#define FFA_PAGE_16K 1
+#define FFA_PAGE_64K 2
+
PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT CpuDriverEntryPoint = NULL;
/**
@@ -106,6 +110,7 @@ GetAndPrintBootinformation (
}
return PayloadBootInfo;
+}
/**
An StMM SP implements partial support for FF-A v1.0. The FF-A ABIs are used to
@@ -266,6 +271,308 @@ DelegatedEventLoop (
}
}
+STATIC
+BOOLEAN
+CheckDescription (
+ IN VOID * DtbAddress,
+ IN INT32 Offset,
+ OUT CHAR8 * Description,
+ OUT UINT32 Size
+ )
+{
+ CONST CHAR8 * Property;
+ INT32 LenP;
+
+ Property = fdt_getprop (DtbAddress, Offset, "description", &LenP);
+ if (Property == NULL) {
+ return FALSE;
+ }
+
+ return CompareMem (Description, Property, MIN(Size, (UINT32)LenP)) == 0;
+
+}
+
+STATIC
+EFI_STATUS
+ReadProperty32 (
+ IN VOID * DtbAddress,
+ IN INT32 Offset,
+ IN CHAR8 * Property,
+ OUT UINT32 * Value
+ )
+{
+ CONST UINT32 * Property32;
+
+ Property32 = fdt_getprop (DtbAddress, Offset, Property, NULL);
+ if (Property32 == NULL) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%s: Missing in FF-A boot information manifest\n",
+ Property
+ ));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *Value = fdt32_to_cpu (*Property32);
+
+ return EFI_SUCCESS;
+}
+
+STATIC
+EFI_STATUS
+ReadProperty64 (
+ IN VOID * DtbAddress,
+ IN INT32 Offset,
+ IN CHAR8 * Property,
+ OUT UINT64 * Value
+ )
+{
+ CONST UINT64 * Property64;
+
+ Property64 = fdt_getprop (DtbAddress, Offset, Property, NULL);
+ if (Property64 == NULL) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%s: Missing in FF-A boot information manifest\n",
+ Property
+ ));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *Value = fdt64_to_cpu (*Property64);
+
+ return EFI_SUCCESS;
+}
+
+STATIC
+BOOLEAN
+ReadRegionInfo (
+ IN VOID *DtbAddress,
+ IN INT32 Node,
+ IN CHAR8 *Region,
+ IN UINTN RegionStrSize,
+ IN UINT32 PageSize,
+ OUT UINT64 *Address,
+ OUT UINT64 *Size
+ )
+{
+ BOOLEAN FoundBuffer;
+ INTN Status = 0;
+
+ FoundBuffer = CheckDescription (
+ DtbAddress,
+ Node,
+ Region,
+ RegionStrSize
+ );
+ if (!FoundBuffer) {
+ return FALSE;
+ }
+
+ DEBUG ((DEBUG_INFO, "Found Node: %a\n", Region));
+ Status = ReadProperty64 (
+ DtbAddress,
+ Node,
+ "base-address",
+ Address
+ );
+ if (Status != EFI_SUCCESS) {
+ DEBUG ((DEBUG_ERROR, "base-address missing in DTB"));
+ return FALSE;
+ }
+ DEBUG ((
+ DEBUG_INFO,
+ "base = 0x%llx\n",
+ *Address
+ ));
+
+ Status = ReadProperty32 (
+ DtbAddress,
+ Node,
+ "pages-count",
+ (UINT32*)Size
+ );
+ if (Status != EFI_SUCCESS) {
+ DEBUG ((DEBUG_ERROR, "pages-count missing in DTB"));
+ return FALSE;
+ }
+
+ DEBUG ((DEBUG_ERROR, "pages-count: 0x%lx\n", *Size));
+
+ *Size = *Size * PageSize;
+ DEBUG ((
+ DEBUG_INFO,
+ "Size = 0x%llx\n",
+ *Size
+ ));
+
+ return TRUE;
+}
+
+/**
+
+ Populates FF-A boot information structure.
+
+ This function receives the address of a DTB from which boot information defind
+ by FF-A and required to initialize the standalone environment is extracted.
+
+ @param [in, out] StmmBootInfo Pointer to a pre-allocated boot info structure to be
+ populated.
+ @param [in] DtbAddress Address of the Device tree from where boot
+ information will be fetched.
+**/
+STATIC
+EFI_STATUS
+PopulateBootinformation (
+ IN OUT EFI_STMM_BOOT_INFO *StmmBootInfo,
+ IN VOID *DtbAddress
+)
+{
+ INTN Status;
+ INT32 Offset;
+ INT32 Node;
+ BOOLEAN FoundNsCommBuffer = FALSE;
+ BOOLEAN FoundSharedBuffer = FALSE;
+ BOOLEAN FoundHeap = FALSE;
+ UINT32 PageSize;
+
+ Offset = fdt_node_offset_by_compatible (DtbAddress, -1, "arm,ffa-manifest-1.0");
+ DEBUG ((DEBUG_INFO, "Offset = %d \n", Offset));
+ if (Offset < 0) {
+ DEBUG ((DEBUG_ERROR, "Missing FF-A boot information in manifest\n"));
+ return EFI_NOT_FOUND;
+ }
+
+ Status = ReadProperty64 (
+ DtbAddress,
+ Offset,
+ "load-address",
+ &StmmBootInfo->SpMemBase
+ );
+ if (Status != EFI_SUCCESS) {
+ return Status;
+ }
+ DEBUG ((DEBUG_INFO, "sp mem base = 0x%llx\n", StmmBootInfo->SpMemBase));
+
+ Status = ReadProperty64 (
+ DtbAddress,
+ Offset,
+ "image-size",
+ &StmmBootInfo->SpMemSize
+ );
+ if (Status != EFI_SUCCESS) {
+ return Status;
+ }
+ DEBUG ((DEBUG_INFO, "sp mem size = 0x%llx\n", StmmBootInfo->SpMemSize));
+
+ Status = ReadProperty32 (DtbAddress, Offset, "xlat-granule", &PageSize);
+ if (Status != EFI_SUCCESS) {
+ return Status;
+ }
+
+ /* EFI_PAGE_SIZE is 4KB */
+ switch (PageSize) {
+ case FFA_PAGE_4K:
+ PageSize = EFI_PAGE_SIZE;
+ break;
+
+ case FFA_PAGE_16K:
+ PageSize = 4 * EFI_PAGE_SIZE;
+ break;
+
+ case FFA_PAGE_64K:
+ PageSize = 16 * EFI_PAGE_SIZE;
+ break;
+
+ default:
+ DEBUG ((DEBUG_ERROR, "Invalid page type = %lu\n", PageSize));
+ return EFI_INVALID_PARAMETER;
+ break;
+ };
+
+ DEBUG ((DEBUG_INFO, "Page Size = 0x%lx\n", PageSize));
+
+ Offset = fdt_subnode_offset_namelen (
+ DtbAddress,
+ Offset,
+ "memory-regions",
+ sizeof("memory-regions") - 1
+ );
+ if (Offset < 1) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%s: Missing in FF-A boot information manifest\n",
+ "memory-regions"
+ ));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ for (
+ Node = fdt_first_subnode (DtbAddress, Offset);
+ Node > 0;
+ Node = fdt_next_subnode (DtbAddress, Node)) {
+ if (!FoundNsCommBuffer) {
+ FoundNsCommBuffer = ReadRegionInfo (
+ DtbAddress,
+ Node,
+ "ns-comm",
+ sizeof ("ns-comm") - 1,
+ PageSize,
+ &StmmBootInfo->SpNsCommBufBase,
+ &StmmBootInfo->SpNsCommBufSize
+ );
+ }
+
+ if (!FoundHeap) {
+ FoundHeap = ReadRegionInfo (
+ DtbAddress,
+ Node,
+ "heap",
+ sizeof ("heap") - 1,
+ PageSize,
+ &StmmBootInfo->SpHeapBase,
+ &StmmBootInfo->SpHeapSize
+ );
+ }
+
+ if (!FoundSharedBuffer) {
+ FoundSharedBuffer = ReadRegionInfo (
+ DtbAddress,
+ Node,
+ "shared-buff",
+ sizeof ("shared-buff") - 1,
+ PageSize,
+ &StmmBootInfo->SpSharedBufBase,
+ &StmmBootInfo->SpSharedBufSize
+ );
+ }
+ }
+
+ if (!FoundNsCommBuffer) {
+ DEBUG ((DEBUG_ERROR, "Failed to find ns-comm buffer info\n"));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (!FoundHeap) {
+ DEBUG ((DEBUG_ERROR, "Failed to find heap buffer info\n"));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (!FoundSharedBuffer) {
+ DEBUG ((DEBUG_ERROR, "Failed to find shared buffer info\n"));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ // Populate CPU information under the assumption made in the FF-A spec that
+ // this is a uniprocessor SP that is capable of migration. So, it is fine if
+ // it sees 0 as both its physical and linear cpu id
+ StmmBootInfo->CpuInfo.Mpidr = 0;
+ StmmBootInfo->CpuInfo.LinearId = 0;
+ StmmBootInfo->CpuInfo.Flags = 0;
+
+ return EFI_SUCCESS;
+}
+
/**
Query the SPM version, check compatibility and return success if compatible.
@@ -343,6 +650,49 @@ InitArmSvcArgs (
}
}
+
+STATIC
+EFI_STATUS
+GetSpManifest (
+ IN OUT UINT64 **SpManifestAddr,
+ IN VOID *BootInfoAddr
+ )
+{
+ EFI_FFA_BOOT_INFO_HEADER *FfaBootInfo;
+ EFI_FFA_BOOT_INFO_DESC *FfaBootInfoDesc;
+
+ // Paranoid check to avoid an inadvertent NULL pointer dereference.
+ if (BootInfoAddr == NULL) {
+ DEBUG ((DEBUG_ERROR, "FF-A Boot information is NULL\n"));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ // Check boot information magic number.
+ FfaBootInfo = (EFI_FFA_BOOT_INFO_HEADER *) BootInfoAddr;
+ if (FfaBootInfo->Magic != FFA_INIT_DESC_SIGNATURE) {
+ DEBUG ((
+ DEBUG_ERROR, "FfaBootInfo Magic no. is invalid 0x%ux\n",
+ FfaBootInfo->Magic
+ ));
+ return EFI_INVALID_PARAMETER;
+ }
+
+
+ FfaBootInfoDesc =
+ (EFI_FFA_BOOT_INFO_DESC *)((UINT8 *)BootInfoAddr +
+ FfaBootInfo->OffsetBootInfoDesc);
+
+ if (FfaBootInfoDesc->Type ==
+ (FFA_BOOT_INFO_TYPE(FFA_BOOT_INFO_TYPE_STD) |
+ FFA_BOOT_INFO_TYPE_ID(FFA_BOOT_INFO_TYPE_ID_FDT))) {
+ *SpManifestAddr = (UINT64 *) FfaBootInfoDesc->Content;
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_ERROR, "SP manifest not found \n"));
+ return EFI_NOT_FOUND;
+}
+
/**
The entry point of Standalone MM Foundation.
@@ -363,6 +713,7 @@ ModuleEntryPoint (
{
PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo;
+ EFI_STMM_BOOT_INFO StmmBootInfo = {0};
ARM_SVC_ARGS InitMmFoundationSvcArgs;
EFI_STATUS Status;
INT32 Ret;
@@ -372,6 +723,8 @@ ModuleEntryPoint (
VOID *TeData;
UINTN TeDataSize;
EFI_PHYSICAL_ADDRESS ImageBase;
+ UINT64 *DtbAddress;
+ EFI_FIRMWARE_VOLUME_HEADER *BfvAddress;
BOOLEAN UseOnlyFfaAbis = FALSE;
if (FixedPcdGet32 (PcdFfaEnable) != 0) {
@@ -384,18 +737,36 @@ ModuleEntryPoint (
goto finish;
}
- PayloadBootInfo = GetAndPrintBootinformation (SharedBufAddress);
- if (PayloadBootInfo == NULL) {
- Status = EFI_UNSUPPORTED;
- goto finish;
+ // If only FF-A is used, the DTB address is passed in the Boot information
+ // structure. Else, the Boot info is copied from Sharedbuffer.
+ if (UseOnlyFfaAbis) {
+ Status = GetSpManifest (&DtbAddress, SharedBufAddress);
+ if (Status != EFI_SUCCESS) {
+ goto finish;
+ }
+
+ // Extract boot information from the DTB
+ Status = PopulateBootinformation (&StmmBootInfo, (VOID *) DtbAddress);
+ if (Status != EFI_SUCCESS) {
+ goto finish;
+ }
+
+ // Stash the base address of the boot firmware volume
+ BfvAddress = (EFI_FIRMWARE_VOLUME_HEADER *) StmmBootInfo.SpMemBase;
+ } else {
+ PayloadBootInfo = GetAndPrintBootinformation (SharedBufAddress);
+ if (PayloadBootInfo == NULL) {
+ Status = EFI_UNSUPPORTED;
+ goto finish;
+ }
+
+ // Stash the base address of the boot firmware volume
+ BfvAddress = (EFI_FIRMWARE_VOLUME_HEADER *) PayloadBootInfo->SpImageBase;
}
+
// Locate PE/COFF File information for the Standalone MM core module
- Status = LocateStandaloneMmCorePeCoffData (
- (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PayloadBootInfo->SpImageBase,
- &TeData,
- &TeDataSize
- );
+ Status = LocateStandaloneMmCorePeCoffData (BfvAddress, &TeData, &TeDataSize);
if (EFI_ERROR (Status)) {
goto finish;
--
2.34.1
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [edk2-platforms][PATCH V1 10/20] StandaloneMmPkg: Populate Hoblist for SP init from StMM boot information
2023-07-11 14:36 [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Nishant Sharma
` (8 preceding siblings ...)
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 09/20] StandaloneMmPkg: parse SP manifest and populate new boot information Nishant Sharma
@ 2023-07-11 14:36 ` Nishant Sharma
2023-07-12 20:52 ` [edk2-devel] " Oliver Smith-Denny
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 11/20] StandaloneMmPkg: Skip zero sized sections while tweaking page permissions Nishant Sharma
` (10 subsequent siblings)
20 siblings, 1 reply; 41+ messages in thread
From: Nishant Sharma @ 2023-07-11 14:36 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
From: Achin Gupta <achin.gupta@arm.com>
This patch adds support for creating a hoblist from the reduced boot
information retrieved from the SP manifest.
Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
---
StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h | 16 ++
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c | 186 +++++++++++++++++++-
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c | 6 +-
3 files changed, 206 insertions(+), 2 deletions(-)
diff --git a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h
index 90d67a2f25b5..9daa76324221 100644
--- a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h
+++ b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h
@@ -170,6 +170,22 @@ CreateHobListFromBootInfo (
IN EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo
);
+/**
+ Use the boot information passed by the SPMC to populate a HOB list
+ suitable for consumption by the MM Core and drivers.
+
+ @param [in, out] CpuDriverEntryPoint Address of MM CPU driver entrypoint
+ @param [in] StmmBootInfo Boot information passed by privileged
+ firmware
+
+**/
+VOID *
+EFIAPI
+CreateHobListFromStmmBootInfo (
+ IN OUT PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT *CpuDriverEntryPoint,
+ IN EFI_STMM_BOOT_INFO *StmmBootInfo
+ );
+
/**
The entry point of Standalone MM Foundation.
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c
index 2ac2d354f06a..4592089a6020 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c
@@ -2,7 +2,7 @@
Creates HOB during Standalone MM Foundation entry point
on ARM platforms.
-Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.<BR>
+Copyright (c) 2017 - 2023, Arm Ltd. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -203,3 +203,187 @@ CreateHobListFromBootInfo (
return HobStart;
}
+
+STATIC
+VOID
+CreateMmramInformationHobFromImageLayout (
+ IN EFI_STMM_BOOT_INFO *StmmBootInfo,
+ IN EFI_HOB_HANDOFF_INFO_TABLE *HobStart
+)
+{
+ UINT32 *Idx;
+ UINT32 BufferSize;
+ EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *MmramRangesHob;
+ EFI_MMRAM_DESCRIPTOR *MmramRanges;
+
+ // Find the size of the GUIDed HOB with SRAM ranges. This excludes any memory
+ // shared with the normal world or the SPMC. It includes the memory allocated
+ // to the SP image, used and unused heap.
+ BufferSize = sizeof (EFI_MMRAM_HOB_DESCRIPTOR_BLOCK);
+ BufferSize += 4 * sizeof (EFI_MMRAM_DESCRIPTOR);
+
+ // Create a GUIDed HOB with SRAM ranges
+ MmramRangesHob = BuildGuidHob (&gEfiMmPeiMmramMemoryReserveGuid, BufferSize);
+
+ // Initialise the number of MMRAM memory regions
+ MmramRangesHob->NumberOfMmReservedRegions = 0;
+ Idx = &MmramRangesHob->NumberOfMmReservedRegions ;
+
+ // Fill up the MMRAM ranges
+ MmramRanges = &MmramRangesHob->Descriptor[0];
+
+ // Base and size of memory occupied by the Standalone MM image
+ MmramRanges[*Idx].PhysicalStart = StmmBootInfo->SpMemBase;
+ MmramRanges[*Idx].CpuStart = StmmBootInfo->SpMemBase;
+ MmramRanges[*Idx].PhysicalSize = StmmBootInfo->SpMemSize;
+ MmramRanges[*Idx].RegionState = EFI_CACHEABLE | EFI_ALLOCATED;
+ (*Idx)++;
+
+ // Base and size of memory occupied by the Standalone MM image
+ MmramRanges[*Idx].PhysicalStart = StmmBootInfo->SpSharedBufBase;
+ MmramRanges[*Idx].CpuStart = StmmBootInfo->SpSharedBufBase;
+ MmramRanges[*Idx].PhysicalSize = StmmBootInfo->SpSharedBufSize;
+ MmramRanges[*Idx].RegionState = EFI_CACHEABLE | EFI_ALLOCATED;
+ (*Idx)++;
+
+ // Base and size of memory occupied by the hoblist
+ MmramRanges[*Idx].PhysicalStart = (EFI_PHYSICAL_ADDRESS) (UINTN) HobStart;
+ MmramRanges[*Idx].CpuStart = (EFI_PHYSICAL_ADDRESS) (UINTN) HobStart;
+ MmramRanges[*Idx].PhysicalSize = HobStart->EfiFreeMemoryBottom - (EFI_PHYSICAL_ADDRESS) (UINTN) HobStart;
+ MmramRanges[*Idx].RegionState = EFI_CACHEABLE | EFI_ALLOCATED;
+ (*Idx)++;
+
+ // Base and size of heap memory shared by all cpus
+ MmramRanges[*Idx].PhysicalStart = HobStart->EfiFreeMemoryBottom;
+ MmramRanges[*Idx].CpuStart = HobStart->EfiFreeMemoryBottom;
+ MmramRanges[*Idx].PhysicalSize = HobStart->EfiFreeMemoryTop - HobStart->EfiFreeMemoryBottom;
+ MmramRanges[*Idx].RegionState = EFI_CACHEABLE;
+ (*Idx)++;
+
+ // Sanity check number of MMRAM regions
+ ASSERT (MmramRangesHob->NumberOfMmReservedRegions == 3);
+
+ return;
+}
+
+STATIC
+VOID
+CreateMpInformationHobFromCpuInfo (
+ IN EFI_SECURE_PARTITION_CPU_INFO *CpuInfo
+)
+{
+ MP_INFORMATION_HOB_DATA *MpInformationHobData;
+ EFI_PROCESSOR_INFORMATION *ProcInfoBuffer;
+ UINT32 BufferSize;
+ UINT32 Flags;
+
+ // Find the size of the GUIDed HOB with MP information
+ BufferSize = sizeof (MP_INFORMATION_HOB_DATA);
+ BufferSize += sizeof (EFI_PROCESSOR_INFORMATION);
+
+ // Create a Guided MP information HOB to enable the ARM TF CPU driver to
+ // perform per-cpu allocations.
+ MpInformationHobData = BuildGuidHob (&gMpInformationHobGuid, BufferSize);
+
+ // Populate the MP information HOB under the assumption that this is a
+ // uniprocessor partition. Hence, only a single CPU is exposed to the MM Core.
+ MpInformationHobData->NumberOfProcessors = 1;
+ MpInformationHobData->NumberOfEnabledProcessors = 1;
+
+ // Populate the processor information
+ ProcInfoBuffer = MpInformationHobData->ProcessorInfoBuffer;
+ ProcInfoBuffer[0].ProcessorId = CpuInfo[0].Mpidr;
+ ProcInfoBuffer[0].Location.Package = GET_CLUSTER_ID(CpuInfo[0].Mpidr);
+ ProcInfoBuffer[0].Location.Core = GET_CORE_ID(CpuInfo[0].Mpidr);
+ ProcInfoBuffer[0].Location.Thread = GET_CORE_ID(CpuInfo[0].Mpidr);
+
+ // Populate the processor information flags
+ Flags = PROCESSOR_ENABLED_BIT | PROCESSOR_HEALTH_STATUS_BIT | PROCESSOR_AS_BSP_BIT;
+ ProcInfoBuffer[0].StatusFlag = Flags;
+
+ return;
+}
+
+/**
+ Use the FF-A boot information passed by the SPMC to populate a HOB list
+ suitable for consumption by the MM Core and drivers.
+
+ @param [in, out] CpuDriverEntryPoint Address of MM CPU driver entrypoint
+ @param [in] StmmBootInfo Boot information passed by the SPMC
+
+**/
+VOID *
+CreateHobListFromStmmBootInfo (
+ IN OUT PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT *CpuDriverEntryPoint,
+ IN EFI_STMM_BOOT_INFO *StmmBootInfo
+)
+{
+ EFI_HOB_HANDOFF_INFO_TABLE *HobStart;
+ EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;
+ EFI_MMRAM_DESCRIPTOR *NsCommBufMmramRange;
+ ARM_TF_CPU_DRIVER_EP_DESCRIPTOR *CpuDriverEntryPointDesc;
+
+ // Create a hoblist with a PHIT and EOH
+ HobStart = HobConstructor (
+ (VOID *) (UINTN) StmmBootInfo->SpMemBase,
+ (UINTN) StmmBootInfo->SpMemSize,
+ (VOID *) (UINTN) StmmBootInfo->SpHeapBase,
+ (VOID *) (UINTN) (StmmBootInfo->SpHeapBase + StmmBootInfo->SpHeapSize)
+ );
+
+ // Check that the Hoblist starts at the bottom of the Heap
+ ASSERT (HobStart == (VOID *) (UINTN) StmmBootInfo->SpHeapBase);
+
+ // Build a Boot Firmware Volume HOB
+ BuildFvHob (StmmBootInfo->SpMemBase, StmmBootInfo->SpMemSize);
+
+ // Build a resource descriptor Hob that describes the available physical
+ // memory range
+ Attributes = (
+ EFI_RESOURCE_ATTRIBUTE_PRESENT |
+ EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
+ EFI_RESOURCE_ATTRIBUTE_TESTED |
+ EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
+ EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
+ EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
+ EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
+ );
+
+ BuildResourceDescriptorHob (
+ EFI_RESOURCE_SYSTEM_MEMORY,
+ Attributes,
+ (UINTN) StmmBootInfo->SpMemBase,
+ StmmBootInfo->SpMemSize
+ );
+
+ // Create an MP information hob from cpu information passed in the boot
+ // information structure
+ CreateMpInformationHobFromCpuInfo(&StmmBootInfo->CpuInfo);
+
+ // Create a Guided HOB to tell the ARM TF CPU driver the location and length
+ // of the communication buffer shared with the Normal world.
+ NsCommBufMmramRange = (EFI_MMRAM_DESCRIPTOR *) BuildGuidHob (
+ &gEfiStandaloneMmNonSecureBufferGuid,
+ sizeof (EFI_MMRAM_DESCRIPTOR)
+ );
+ NsCommBufMmramRange->PhysicalStart = StmmBootInfo->SpNsCommBufBase;
+ NsCommBufMmramRange->CpuStart = StmmBootInfo->SpNsCommBufBase;
+ NsCommBufMmramRange->PhysicalSize = StmmBootInfo->SpNsCommBufSize;
+ NsCommBufMmramRange->RegionState = EFI_CACHEABLE | EFI_ALLOCATED;
+
+ // Create a Guided HOB to enable the ARM TF CPU driver to share its entry
+ // point and populate it with the address of the shared buffer
+ CpuDriverEntryPointDesc =
+ (ARM_TF_CPU_DRIVER_EP_DESCRIPTOR *) BuildGuidHob (
+ &gEfiArmTfCpuDriverEpDescriptorGuid,
+ sizeof (ARM_TF_CPU_DRIVER_EP_DESCRIPTOR)
+ );
+
+ *CpuDriverEntryPoint = NULL;
+ CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr = CpuDriverEntryPoint;
+
+ // Create Mmram range hob from SP image layout
+ CreateMmramInformationHobFromImageLayout(StmmBootInfo, HobStart);
+
+ return HobStart;
+}
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
index 505786aff07c..8131b1984969 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
@@ -823,7 +823,11 @@ ModuleEntryPoint (
//
// Create Hoblist based upon boot information passed by privileged software
//
- HobStart = CreateHobListFromBootInfo (&CpuDriverEntryPoint, PayloadBootInfo);
+ if (UseOnlyFfaAbis) {
+ HobStart = CreateHobListFromStmmBootInfo (&CpuDriverEntryPoint, &StmmBootInfo);
+ } else {
+ HobStart = CreateHobListFromBootInfo (&CpuDriverEntryPoint, PayloadBootInfo);
+ }
//
// Call the MM Core entry point
--
2.34.1
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [edk2-platforms][PATCH V1 11/20] StandaloneMmPkg: Skip zero sized sections while tweaking page permissions
2023-07-11 14:36 [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Nishant Sharma
` (9 preceding siblings ...)
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 10/20] StandaloneMmPkg: Populate Hoblist for SP init from StMM " Nishant Sharma
@ 2023-07-11 14:36 ` Nishant Sharma
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 12/20] StandaloneMmPkg: Add global check for FF-A abis Nishant Sharma
` (9 subsequent siblings)
20 siblings, 0 replies; 41+ messages in thread
From: Nishant Sharma @ 2023-07-11 14:36 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
From: Achin Gupta <achin.gupta@arm.com>
This patch skips zero sized sections in the StMM SP image e.g. .reloc since
there is no point in attempting to change their permissions.
Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
---
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/SetPermissions.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/SetPermissions.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/SetPermissions.c
index 5c6bd0e1d7d2..891e79b32b6f 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/SetPermissions.c
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/SetPermissions.c
@@ -2,7 +2,7 @@
Locate, get and update PE/COFF permissions during Standalone MM
Foundation Entry point on ARM platforms.
-Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.<BR>
+Copyright (c) 2017 - 2023, Arm Ltd. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -118,6 +118,22 @@ UpdateMmFoundationPeCoffPermissions (
ImageContext->ImageAddress,
SectionHeader.PointerToRawData
));
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: Section %d of image at 0x%lx has %d bytes size\n",
+ __func__, Index,
+ ImageContext->ImageAddress,
+ SectionHeader.Misc.VirtualSize
+ ));
+
+ // Skip sections with a size of 0
+ if (SectionHeader.Misc.VirtualSize == 0) {
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: Skipping section %a \n", __func__, SectionHeader.Name
+ ));
+ continue;
+ }
//
// If the section is marked as XN then remove the X attribute. Furthermore,
--
2.34.1
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [edk2-platforms][PATCH V1 12/20] StandaloneMmPkg: Add global check for FF-A abis
2023-07-11 14:36 [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Nishant Sharma
` (10 preceding siblings ...)
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 11/20] StandaloneMmPkg: Skip zero sized sections while tweaking page permissions Nishant Sharma
@ 2023-07-11 14:36 ` Nishant Sharma
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 13/20] ArmPkg: Bump the StMM SP FF-A minor version to 1 Nishant Sharma
` (8 subsequent siblings)
20 siblings, 0 replies; 41+ messages in thread
From: Nishant Sharma @ 2023-07-11 14:36 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
From: Achin Gupta <achin.gupta@arm.com>
This patch copies the value of the corresponding stack variable to a global
variable so that it can be used to determine whether FF-A v1.1 or earlier
ABIs should be used for communication with the SPMC.
Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
---
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
index 8131b1984969..a763bf8509b2 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
@@ -42,6 +42,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define FFA_PAGE_16K 1
#define FFA_PAGE_64K 2
+// Local variable to help Standalone MM Core decide whether FF-A ABIs can be
+// used for all communication. This variable is usable only after the StMM image
+// has been relocated and all image section permissions have been correctly
+// updated.
+STATIC BOOLEAN mUseOnlyFfaAbis = FALSE;
+
PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT CpuDriverEntryPoint = NULL;
/**
@@ -639,6 +645,13 @@ InitArmSvcArgs (
)
{
if (FixedPcdGet32 (PcdFfaEnable) != 0) {
+
+ // With FF-A v1.1 invoke FFA_MSG_WAIT to signal completion of SP init.
+ if (mUseOnlyFfaAbis) {
+ InitMmFoundationSvcArgs->Arg0 = ARM_SVC_ID_FFA_MSG_WAIT_AARCH32;
+ return;
+ }
+
InitMmFoundationSvcArgs->Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP;
InitMmFoundationSvcArgs->Arg1 = 0;
InitMmFoundationSvcArgs->Arg2 = 0;
@@ -820,6 +833,9 @@ ModuleEntryPoint (
ASSERT_EFI_ERROR (Status);
}
+ // Update the global copy now that the image has been relocated.
+ mUseOnlyFfaAbis = UseOnlyFfaAbis;
+
//
// Create Hoblist based upon boot information passed by privileged software
//
--
2.34.1
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [edk2-platforms][PATCH V1 13/20] ArmPkg: Bump the StMM SP FF-A minor version to 1
2023-07-11 14:36 [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Nishant Sharma
` (11 preceding siblings ...)
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 12/20] StandaloneMmPkg: Add global check for FF-A abis Nishant Sharma
@ 2023-07-11 14:36 ` Nishant Sharma
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 14/20] ArmPkg/MmCommunicationDxe: Introduce FF-A version check Nishant Sharma
` (7 subsequent siblings)
20 siblings, 0 replies; 41+ messages in thread
From: Nishant Sharma @ 2023-07-11 14:36 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
From: Achin Gupta <achin.gupta@arm.com>
Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
---
ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
index 7987678c996e..4a51f9fb56af 100644
--- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
+++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
@@ -40,7 +40,7 @@
#endif
#define SPM_MAJOR_VERSION_FFA 1
-#define SPM_MINOR_VERSION_FFA 0
+#define SPM_MINOR_VERSION_FFA 1
#define ARM_FFA_SPM_RET_SUCCESS 0
#define ARM_FFA_SPM_RET_NOT_SUPPORTED -1
--
2.34.1
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [edk2-platforms][PATCH V1 14/20] ArmPkg/MmCommunicationDxe: Introduce FF-A version check
2023-07-11 14:36 [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Nishant Sharma
` (12 preceding siblings ...)
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 13/20] ArmPkg: Bump the StMM SP FF-A minor version to 1 Nishant Sharma
@ 2023-07-11 14:36 ` Nishant Sharma
2023-07-13 16:56 ` [edk2-devel] " Chris Fernald
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 15/20] ArmPkg/MmCommunicationDxe: Add support for obtaining FF-A partition ID Nishant Sharma
` (6 subsequent siblings)
20 siblings, 1 reply; 41+ messages in thread
From: Nishant Sharma @ 2023-07-11 14:36 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
From: Achin Gupta <achin.gupta@arm.com>
This patch adds support for querying whether FF-A v1.1 is supported by the
FF-A impplementation.
Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
---
ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf | 3 +++
ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h | 7 ++++++-
ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 17 ++++++++++++-----
3 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
index 05b6de73ff34..c15b1a7a86ae 100644
--- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
@@ -31,6 +31,9 @@
ArmPkg/ArmPkg.dec
MdePkg/MdePkg.dec
+[FixedPcd]
+ gArmTokenSpaceGuid.PcdFfaEnable
+
[LibraryClasses]
ArmLib
ArmSmcLib
diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
index 5c5fcb576856..71edf7f49174 100644
--- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
@@ -16,7 +16,12 @@
#define MM_MAJOR_VER(x) (((x) & MM_MAJOR_VER_MASK) >> MM_MAJOR_VER_SHIFT)
#define MM_MINOR_VER(x) ((x) & MM_MINOR_VER_MASK)
+#if (FixedPcdGet32 (PcdFfaEnable) == 1)
#define MM_CALLER_MAJOR_VER 0x1UL
-#define MM_CALLER_MINOR_VER 0x0
+#define MM_CALLER_MINOR_VER 0x1UL
+#else
+#define MM_CALLER_MAJOR_VER 0x1UL
+#define MM_CALLER_MINOR_VER 0x0UL
+#endif
#endif /* MM_COMMUNICATE_H_ */
diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
index 85d9034555f0..a6fcd590a65b 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"
@@ -250,14 +251,20 @@ GetMmCompatibility (
{
EFI_STATUS Status;
UINT32 MmVersion;
- ARM_SMC_ARGS MmVersionArgs;
+ ARM_SMC_ARGS SmcArgs = {0};
- // MM_VERSION uses SMC32 calling conventions
- MmVersionArgs.Arg0 = ARM_SMC_ID_MM_VERSION_AARCH32;
+ if (FixedPcdGet32 (PcdFfaEnable) != 0) {
+ SmcArgs.Arg0 = ARM_SVC_ID_FFA_VERSION_AARCH32;
+ SmcArgs.Arg1 = MM_CALLER_MAJOR_VER << MM_MAJOR_VER_SHIFT;
+ SmcArgs.Arg1 |= MM_CALLER_MINOR_VER;
+ } else {
+ // MM_VERSION uses SMC32 calling conventions
+ SmcArgs.Arg0 = ARM_SMC_ID_MM_VERSION_AARCH32;
+ }
- ArmCallSmc (&MmVersionArgs);
+ ArmCallSmc (&SmcArgs);
- MmVersion = MmVersionArgs.Arg0;
+ MmVersion = SmcArgs.Arg0;
if ((MM_MAJOR_VER (MmVersion) == MM_CALLER_MAJOR_VER) &&
(MM_MINOR_VER (MmVersion) >= MM_CALLER_MINOR_VER))
--
2.34.1
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [edk2-platforms][PATCH V1 15/20] ArmPkg/MmCommunicationDxe: Add support for obtaining FF-A partition ID
2023-07-11 14:36 [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Nishant Sharma
` (13 preceding siblings ...)
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 14/20] ArmPkg/MmCommunicationDxe: Introduce FF-A version check Nishant Sharma
@ 2023-07-11 14:36 ` Nishant Sharma
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 16/20] ArmPkg/MmCommunicationDxe: Register FF-A RX/TX buffers Nishant Sharma
` (5 subsequent siblings)
20 siblings, 0 replies; 41+ messages in thread
From: Nishant Sharma @ 2023-07-11 14:36 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
From: Achin Gupta <achin.gupta@arm.com>
This patch invokes the FFA_ID_GET to obtain and stash the ID of the the
FF-A partition that implements the DXE MM communication driver. This ID
is used in subsequent patches for sending and receiving MM communication
protocol requests and responses that are packaged as FF-A messages.
Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
---
ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 1 +
ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 22 ++++++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
index 4a51f9fb56af..20eeb822ea56 100644
--- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
+++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
@@ -17,6 +17,7 @@
#define ARM_FFA_SVC_H_
#define ARM_SVC_ID_FFA_VERSION_AARCH32 0x84000063
+#define ARM_SVC_ID_FFA_ID_GET_AARCH32 0x84000069
#define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH32 0x8400006F
#define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH32 0x84000070
#define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH64 0xC400006F
diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
index a6fcd590a65b..f907ccf7349f 100644
--- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
@@ -23,6 +23,11 @@
#include "MmCommunicate.h"
+//
+// Partition ID if FF-A support is enabled
+//
+STATIC UINT16 mFfaPartId;
+
//
// Address, Length of the pre-allocated buffer for communication with the secure
// world.
@@ -288,6 +293,23 @@ GetMmCompatibility (
Status = EFI_UNSUPPORTED;
}
+ // If FF-A is supported then discover our ID.
+ if (FixedPcdGet32 (PcdFfaEnable) != 0) {
+
+ // Get our ID
+ ZeroMem(&SmcArgs, sizeof(SmcArgs));
+ SmcArgs.Arg0 = ARM_SVC_ID_FFA_ID_GET_AARCH32;
+ ArmCallSmc (&SmcArgs);
+ if (SmcArgs.Arg0 == ARM_SVC_ID_FFA_ERROR_AARCH32) {
+ DEBUG ((DEBUG_ERROR, "Unable to retrieve FF-A partition ID (%d).\n", SmcArgs.Arg2));
+ return EFI_UNSUPPORTED;
+ }
+ DEBUG ((DEBUG_INFO, "FF-A partition ID = 0x%lx.\n", SmcArgs.Arg2));
+ mFfaPartId = SmcArgs.Arg2;
+
+ return EFI_SUCCESS;
+ }
+
return Status;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [edk2-platforms][PATCH V1 16/20] ArmPkg/MmCommunicationDxe: Register FF-A RX/TX buffers
2023-07-11 14:36 [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Nishant Sharma
` (14 preceding siblings ...)
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 15/20] ArmPkg/MmCommunicationDxe: Add support for obtaining FF-A partition ID Nishant Sharma
@ 2023-07-11 14:36 ` Nishant Sharma
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 17/20] ArmPkg/MmCommunicationDxe: Unmap FF-A RX/TX buffers during ExitBootServices Nishant Sharma
` (4 subsequent siblings)
20 siblings, 0 replies; 41+ messages in thread
From: Nishant Sharma @ 2023-07-11 14:36 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
From: Achin Gupta <achin.gupta@arm.com>
This patch statically allocates an FF-A RX/TX buffer pair and registers
them with the framework. This enables discovery of the StMM SP in a
subsequent patch.
Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
---
ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 2 ++
ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 20 ++++++++++++++++++--
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
index 20eeb822ea56..ebdf29e8d69a 100644
--- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
+++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
@@ -17,6 +17,8 @@
#define ARM_FFA_SVC_H_
#define ARM_SVC_ID_FFA_VERSION_AARCH32 0x84000063
+#define ARM_SVC_ID_FFA_RXTX_MAP_AARCH32 0x84000066
+#define ARM_SVC_ID_FFA_RXTX_MAP_AARCH64 0xC4000066
#define ARM_SVC_ID_FFA_ID_GET_AARCH32 0x84000069
#define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH32 0x8400006F
#define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH32 0x84000070
diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
index f907ccf7349f..8a4d46e4f80a 100644
--- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
@@ -28,6 +28,12 @@
//
STATIC UINT16 mFfaPartId;
+//
+// RX/TX pair if FF-A support is enabled
+//
+STATIC UINT8 FfaRxBuf[EFI_PAGE_SIZE] __attribute__ ((aligned (EFI_PAGE_SIZE)));
+STATIC UINT8 FfaTxBuf[EFI_PAGE_SIZE] __attribute__ ((aligned (EFI_PAGE_SIZE)));
+
//
// Address, Length of the pre-allocated buffer for communication with the secure
// world.
@@ -293,9 +299,8 @@ GetMmCompatibility (
Status = EFI_UNSUPPORTED;
}
- // If FF-A is supported then discover our ID.
+ // If FF-A is supported then discover our ID and register our RX/TX buffers.
if (FixedPcdGet32 (PcdFfaEnable) != 0) {
-
// Get our ID
ZeroMem(&SmcArgs, sizeof(SmcArgs));
SmcArgs.Arg0 = ARM_SVC_ID_FFA_ID_GET_AARCH32;
@@ -307,6 +312,17 @@ GetMmCompatibility (
DEBUG ((DEBUG_INFO, "FF-A partition ID = 0x%lx.\n", SmcArgs.Arg2));
mFfaPartId = SmcArgs.Arg2;
+ // Register our RX/TX pair
+ SmcArgs.Arg0 = ARM_SVC_ID_FFA_RXTX_MAP_AARCH64;
+ SmcArgs.Arg1 = (UINTN) FfaTxBuf;
+ SmcArgs.Arg2 = (UINTN) FfaRxBuf;
+ SmcArgs.Arg3 = EFI_PAGE_SIZE / SIZE_4KB;
+ ArmCallSmc (&SmcArgs);
+ if (SmcArgs.Arg0 == ARM_SVC_ID_FFA_ERROR_AARCH32) {
+ DEBUG ((DEBUG_ERROR, "Unable to register FF-A RX/TX buffers (%d).\n", SmcArgs.Arg2));
+ return EFI_UNSUPPORTED;
+ }
+
return EFI_SUCCESS;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [edk2-platforms][PATCH V1 17/20] ArmPkg/MmCommunicationDxe: Unmap FF-A RX/TX buffers during ExitBootServices
2023-07-11 14:36 [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Nishant Sharma
` (15 preceding siblings ...)
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 16/20] ArmPkg/MmCommunicationDxe: Register FF-A RX/TX buffers Nishant Sharma
@ 2023-07-11 14:36 ` Nishant Sharma
2023-07-12 20:59 ` [edk2-devel] " Oliver Smith-Denny
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 18/20] ArmPkg/MmCommunicationDxe: Discover the StMM SP Nishant Sharma
` (3 subsequent siblings)
20 siblings, 1 reply; 41+ messages in thread
From: Nishant Sharma @ 2023-07-11 14:36 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
From: Achin Gupta <achin.gupta@arm.com>
An FF-A partition can map only a single RX/TX buffer pair with the
framework. The DXE MM communication driver maps its pair before
ExitBootServices is called. The OS cannot re-use this pair once it boots
subsequently and loads its own FF-A driver. This patch ensures that the
DXE MM communication driver unmaps its buffer pair when ExitBootServices
is called so that the OS can register its own pair if required.
Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
---
ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 10 ++++
ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 49 ++++++++++++++++++++
2 files changed, 59 insertions(+)
diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
index ebdf29e8d69a..f78442a465e1 100644
--- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
+++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
@@ -122,6 +122,16 @@
(((content) & FFA_BOOT_INFO_FLAG_CONTENT_MASK) \
<< FFA_BOOT_INFO_FLAG_CONTENT_SHIFT)
+/* Fromat SP ID info. */
+#define FFA_PARTITION_ID_SHIFT 16
+#define FFA_PARTITION_ID_WIDTH 16
+#define FFA_PARTITION_ID_MASK \
+ (((1U << FFA_PARTITION_ID_WIDTH) - 1) \
+ << FFA_PARTITION_ID_SHIFT)
+#define FFA_PARTITION_ID(partid) \
+ ((partid << FFA_PARTITION_ID_SHIFT) & \
+ FFA_PARTITION_ID_MASK)
+
// Descriptor to pass boot information as per the FF-A v1.1 spec.
typedef struct {
UINT32 Name[4];
diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
index 8a4d46e4f80a..39a1b329b9ea 100644
--- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
@@ -43,6 +43,9 @@ STATIC ARM_MEMORY_REGION_DESCRIPTOR mNsCommBuffMemRegion;
// Notification event when virtual address map is set.
STATIC EFI_EVENT mSetVirtualAddressMapEvent;
+// Notification event when exit boot services is called.
+STATIC EFI_EVENT mExitBootServicesEvent;
+
//
// Handle to install the MM Communication Protocol
//
@@ -255,6 +258,39 @@ NotifySetVirtualAddressMap (
}
}
+/**
+ Notification callback on ExitBootServices event.
+
+ This function notifies the MM communication protocol interface on
+ ExitBootServices event and releases the FF-A RX/TX buffer.
+
+ @param Event ExitBootServices event.
+ @param Context A context when the ExitBootServices triggered.
+
+ @retval EFI_SUCCESS The function executed successfully.
+ @retval Other Some error occurred when executing this function.
+
+**/
+STATIC
+VOID
+EFIAPI
+NotifyExitBootServices (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ ARM_SMC_ARGS SmcArgs = {0};
+
+ SmcArgs.Arg0 = ARM_SVC_ID_FFA_RXTX_UNMAP_AARCH32;
+ SmcArgs.Arg1 = FFA_PARTITION_ID(mFfaPartId);
+ ArmCallSmc (&SmcArgs);
+
+ // We do not bother checking the error code of the RXTX_UNMAP invocation
+ // since we did map the buffers and this call must succeed.
+ return;
+
+}
+
STATIC
EFI_STATUS
GetMmCompatibility (
@@ -452,6 +488,19 @@ MmCommunication2Initialize (
goto CleanAddedMemorySpace;
}
+ // Register notification callback when ExitBootservices is called to
+ // unregister the FF-A RX/TX buffer pair. This allows the OS to register its
+ // own buffer pair.
+ if (FixedPcdGet32 (PcdFfaEnable) != 0) {
+ Status = gBS->CreateEvent (
+ EVT_SIGNAL_EXIT_BOOT_SERVICES,
+ TPL_NOTIFY,
+ NotifyExitBootServices,
+ NULL,
+ &mExitBootServicesEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
// Register notification callback when virtual address is associated
// with the physical address.
// Create a Set Virtual Address Map event.
--
2.34.1
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [edk2-platforms][PATCH V1 18/20] ArmPkg/MmCommunicationDxe: Discover the StMM SP
2023-07-11 14:36 [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Nishant Sharma
` (16 preceding siblings ...)
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 17/20] ArmPkg/MmCommunicationDxe: Unmap FF-A RX/TX buffers during ExitBootServices Nishant Sharma
@ 2023-07-11 14:36 ` Nishant Sharma
2023-07-12 21:10 ` [edk2-devel] " Oliver Smith-Denny
` (2 more replies)
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 19/20] ArmPkg/MmCommunicationDxe: Use the FF-A transport for MM requests Nishant Sharma
` (2 subsequent siblings)
20 siblings, 3 replies; 41+ messages in thread
From: Nishant Sharma @ 2023-07-11 14:36 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
From: Achin Gupta <achin.gupta@arm.com>
This patch adds support for discovering the presence of the SP using the
EFI_MM_COMMUNICATION_PROTOCOL GUID that implements Standalone MM
drivers. This is done by querying the framework through
FFA_PARTITION_INFO_GET whether any partition that implements the
EFI_MM_COMMUNICATION_PROTOCOL is present or not. The partition ID and
its properties are stashed for use in subsequent communication with the
StMM SP.
Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
---
ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 24 +++++
ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 93 +++++++++++++++++++-
2 files changed, 114 insertions(+), 3 deletions(-)
diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
index f78442a465e1..530af8bd3c2e 100644
--- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
+++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
@@ -19,6 +19,9 @@
#define ARM_SVC_ID_FFA_VERSION_AARCH32 0x84000063
#define ARM_SVC_ID_FFA_RXTX_MAP_AARCH32 0x84000066
#define ARM_SVC_ID_FFA_RXTX_MAP_AARCH64 0xC4000066
+#define ARM_SVC_ID_FFA_RX_RELEASE_AARCH32 0x84000065
+#define ARM_SVC_ID_FFA_RXTX_UNMAP_AARCH32 0x84000067
+#define ARM_SVC_ID_FFA_PARTITION_INFO_GET_AARCH32 0x84000068
#define ARM_SVC_ID_FFA_ID_GET_AARCH32 0x84000069
#define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH32 0x8400006F
#define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH32 0x84000070
@@ -154,4 +157,25 @@ typedef struct {
UINT64 Reserved;
} EFI_FFA_BOOT_INFO_HEADER;
+// FF-A partition information descriptor
+typedef struct {
+ UINT16 PartId;
+ UINT16 EcCnt;
+ UINT32 PartProps;
+ UINT32 PartGuid[4];
+} EFI_FFA_PART_INFO_DESC;
+
+#define PART_INFO_PROP_MASK 0x3f
+#define PART_INFO_PROP_SHIFT 0
+#define PART_INFO_PROP_DIR_MSG_RECV_BIT (1u << 0)
+#define PART_INFO_PROP_DIR_MSG_SEND_BIT (1u << 1)
+#define PART_INFO_PROP_INDIR_MSG_BIT (1u << 2)
+#define PART_INFO_PROP_NOTIFICATIONS_BIT (1u << 3)
+#define PART_INFO_PROP_EP_TYPE_MASK 0x3
+#define PART_INFO_PROP_EP_TYPE_SHIFT 4
+#define PART_INFO_PROP_EP_PE 0
+#define PART_INFO_PROP_EP_SEPID_IND 1
+#define PART_INFO_PROP_EP_SEPID_DEP 2
+#define PART_INFO_PROP_EP_AUX 3
+
#endif // ARM_FFA_SVC_H_
diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
index 39a1b329b9ea..94a5d96c051d 100644
--- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
@@ -8,6 +8,7 @@
#include <Library/ArmLib.h>
#include <Library/ArmSmcLib.h>
+#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/DxeServicesTableLib.h>
@@ -28,6 +29,11 @@
//
STATIC UINT16 mFfaPartId;
+// Partition information of the StMM SP if FF-A support is enabled
+// TODO: Revisit assumption that there is only a single StMM SP
+//
+STATIC EFI_FFA_PART_INFO_DESC mStmmPartInfo;
+
//
// RX/TX pair if FF-A support is enabled
//
@@ -298,7 +304,9 @@ GetMmCompatibility (
{
EFI_STATUS Status;
UINT32 MmVersion;
+ UINT32 SmccUuid[4];
ARM_SMC_ARGS SmcArgs = {0};
+ EFI_GUID MmCommProtGuid = EFI_MM_COMMUNICATION_PROTOCOL_GUID;
if (FixedPcdGet32 (PcdFfaEnable) != 0) {
SmcArgs.Arg0 = ARM_SVC_ID_FFA_VERSION_AARCH32;
@@ -335,14 +343,21 @@ GetMmCompatibility (
Status = EFI_UNSUPPORTED;
}
- // If FF-A is supported then discover our ID and register our RX/TX buffers.
+ // If FF-A is supported then discover the StMM SP's presence, ID, our ID and
+ // register our RX/TX buffers.
if (FixedPcdGet32 (PcdFfaEnable) != 0) {
+ EFI_FFA_PART_INFO_DESC *StmmPartInfo;
+
// Get our ID
ZeroMem(&SmcArgs, sizeof(SmcArgs));
SmcArgs.Arg0 = ARM_SVC_ID_FFA_ID_GET_AARCH32;
ArmCallSmc (&SmcArgs);
if (SmcArgs.Arg0 == ARM_SVC_ID_FFA_ERROR_AARCH32) {
- DEBUG ((DEBUG_ERROR, "Unable to retrieve FF-A partition ID (%d).\n", SmcArgs.Arg2));
+ DEBUG ((
+ DEBUG_ERROR,
+ "Unable to retrieve FF-A partition ID (%d).\n",
+ SmcArgs.Arg2
+ ));
return EFI_UNSUPPORTED;
}
DEBUG ((DEBUG_INFO, "FF-A partition ID = 0x%lx.\n", SmcArgs.Arg2));
@@ -355,11 +370,83 @@ GetMmCompatibility (
SmcArgs.Arg3 = EFI_PAGE_SIZE / SIZE_4KB;
ArmCallSmc (&SmcArgs);
if (SmcArgs.Arg0 == ARM_SVC_ID_FFA_ERROR_AARCH32) {
- DEBUG ((DEBUG_ERROR, "Unable to register FF-A RX/TX buffers (%d).\n", SmcArgs.Arg2));
+ DEBUG ((
+ DEBUG_ERROR,
+ "Unable to register FF-A RX/TX buffers (%d).\n",
+ SmcArgs.Arg2
+ ));
return EFI_UNSUPPORTED;
}
+ // Discover the StMM SP after converting the EFI_GUID to a format TF-A will
+ // understand.
+ SmcArgs.Arg0 = ARM_SVC_ID_FFA_PARTITION_INFO_GET_AARCH32;
+ MmCommProtGuid.Data2 += MmCommProtGuid.Data3;
+ MmCommProtGuid.Data3 = MmCommProtGuid.Data2 - MmCommProtGuid.Data3;
+ MmCommProtGuid.Data2 = MmCommProtGuid.Data2 - MmCommProtGuid.Data3;
+ CopyMem ((VOID *) SmccUuid, (VOID *) &MmCommProtGuid, sizeof(EFI_GUID));
+ SmcArgs.Arg1 = SmccUuid[0];
+ SmcArgs.Arg2 = SmccUuid[1];
+ SmcArgs.Arg3 = SmccUuid[2];
+ SmcArgs.Arg3 = SwapBytes32(SmcArgs.Arg3);
+ SmcArgs.Arg4 = SmccUuid[3];
+ SmcArgs.Arg4 = SwapBytes32(SmcArgs.Arg4);
+ ArmCallSmc (&SmcArgs);
+ if (SmcArgs.Arg0 == ARM_SVC_ID_FFA_ERROR_AARCH32) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "Unable to discover FF-A StMM SP (%d).\n",
+ SmcArgs.Arg2
+ ));
+ goto ffa_init_error;
+ }
+
+ // Retrieve the partition information from the RX buffer
+ StmmPartInfo = (EFI_FFA_PART_INFO_DESC *) FfaRxBuf;
+
+ // TODO: Sanity check the partition type.
+ DEBUG ((DEBUG_INFO, "Discovered FF-A StMM SP."));
+ DEBUG ((
+ DEBUG_INFO,
+ "ID = 0x%lx, Execution contexts = %d, Properties = 0x%lx. \n",
+ StmmPartInfo->PartId,
+ StmmPartInfo->EcCnt,
+ StmmPartInfo->PartProps
+ ));
+
+ // Make a local copy
+ mStmmPartInfo = *StmmPartInfo;
+
+ // Release the RX buffer
+ ZeroMem(&SmcArgs, sizeof(SmcArgs));
+ SmcArgs.Arg0 = ARM_SVC_ID_FFA_RX_RELEASE_AARCH32;
+ SmcArgs.Arg1 = mFfaPartId;
+ ArmCallSmc (&SmcArgs);
+
+ // This should really never fail since there is only a single CPU booting
+ // and another CPU could not have released the RX buffer before us.
+ if (SmcArgs.Arg0 == ARM_SVC_ID_FFA_ERROR_AARCH32) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "Unable to release FF-A RX buffer (%d).\n",
+ SmcArgs.Arg2
+ ));
+ ASSERT (0);
+ goto ffa_init_error;
+ }
+
return EFI_SUCCESS;
+
+ ffa_init_error:
+ // Release the RX/TX pair before exiting.
+ ZeroMem(&SmcArgs, sizeof(SmcArgs));
+ SmcArgs.Arg0 = ARM_SVC_ID_FFA_RXTX_UNMAP_AARCH32;
+ SmcArgs.Arg1 = mFfaPartId << 16; // TODO: Use a macro for shift
+ ArmCallSmc (&SmcArgs);
+
+ // We do not bother checking the error code of the RXTX_UNMAP invocation
+ // since we did map the buffers and this call must succeed.
+ return EFI_UNSUPPORTED;
}
return Status;
--
2.34.1
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [edk2-platforms][PATCH V1 19/20] ArmPkg/MmCommunicationDxe: Use the FF-A transport for MM requests
2023-07-11 14:36 [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Nishant Sharma
` (17 preceding siblings ...)
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 18/20] ArmPkg/MmCommunicationDxe: Discover the StMM SP Nishant Sharma
@ 2023-07-11 14:36 ` Nishant Sharma
2023-07-11 19:22 ` [edk2-devel] " Kun Qin
2023-07-12 21:49 ` Girish Mahadevan
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 20/20] StandaloneMmPkg: Add support for MM requests as FF-A direct messages Nishant Sharma
2023-07-12 21:13 ` [edk2-devel] [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Oliver Smith-Denny
20 siblings, 2 replies; 41+ messages in thread
From: Nishant Sharma @ 2023-07-11 14:36 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta, Aditya Angadi
From: Achin Gupta <achin.gupta@arm.com>
This patch packages requests for accessing a Standalone MM driver
through the MM communication protocol as FF-A direct messages.
Corresponding changes in Standalone MM Core ensure that responses are
packaged in the same way.
Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Co-developed-by: Aditya Angadi <aditya.angadi@arm.com>
Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
---
ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 2 +
ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 141 +++++++++++++-------
2 files changed, 97 insertions(+), 46 deletions(-)
diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
index 530af8bd3c2e..493997346143 100644
--- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
+++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
@@ -23,6 +23,7 @@
#define ARM_SVC_ID_FFA_RXTX_UNMAP_AARCH32 0x84000067
#define ARM_SVC_ID_FFA_PARTITION_INFO_GET_AARCH32 0x84000068
#define ARM_SVC_ID_FFA_ID_GET_AARCH32 0x84000069
+#define ARM_SVC_ID_FFA_RUN_AARCH32 0x8400006D
#define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH32 0x8400006F
#define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH32 0x84000070
#define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH64 0xC400006F
@@ -31,6 +32,7 @@
#define ARM_SVC_ID_FFA_SUCCESS_AARCH64 0xC4000061
#define ARM_SVC_ID_FFA_MEM_PERM_SET_AARCH32 0x84000089
#define ARM_SVC_ID_FFA_MEM_PERM_GET_AARCH32 0x84000088
+#define ARM_SVC_ID_FFA_INTERRUPT_AARCH32 0x84000062
#define ARM_SVC_ID_FFA_ERROR_AARCH32 0x84000060
#define ARM_SVC_ID_FFA_ERROR_AARCH64 0xC4000060
#define ARM_SVC_ID_FFA_MSG_WAIT_AARCH32 0x8400006B
diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
index 94a5d96c051d..a70318581bd2 100644
--- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
@@ -100,6 +100,7 @@ MmCommunication2Communicate (
ARM_SMC_ARGS CommunicateSmcArgs;
EFI_STATUS Status;
UINTN BufferSize;
+ UINTN Ret;
Status = EFI_ACCESS_DENIED;
BufferSize = 0;
@@ -160,60 +161,108 @@ MmCommunication2Communicate (
return Status;
}
- // 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 (FixedPcdGet32 (PcdFfaEnable) != 0) {
+ // 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 = mFfaPartId << 16 | mStmmPartInfo.PartId;
+ // Reserved for future use(MBZ)
+ CommunicateSmcArgs.Arg2 = 0x0;
+
+ // comm_buffer_address (64-bit physical address)
+ CommunicateSmcArgs.Arg3 = (UINTN)mNsCommBuffMemRegion.PhysicalBase;
+
+ // Cookie
+ CommunicateSmcArgs.Arg4 = 0x0;
+
+ // Not Used
+ CommunicateSmcArgs.Arg5 = 0;
+
+ // 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;
+ }
+
+ffa_intr_loop:
// Call the Standalone MM environment.
ArmCallSmc (&CommunicateSmcArgs);
- switch (CommunicateSmcArgs.Arg0) {
- case ARM_SMC_MM_RET_SUCCESS:
- ZeroMem (CommBufferVirtual, BufferSize);
- // On successful return, the size of data being returned is inferred from
- // MessageLength + Header.
- CommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)mNsCommBuffMemRegion.VirtualBase;
- BufferSize = CommunicateHeader->MessageLength +
- sizeof (CommunicateHeader->HeaderGuid) +
- sizeof (CommunicateHeader->MessageLength);
-
- CopyMem (
- CommBufferVirtual,
- (VOID *)mNsCommBuffMemRegion.VirtualBase,
- BufferSize
- );
- Status = EFI_SUCCESS;
- break;
-
- case ARM_SMC_MM_RET_INVALID_PARAMS:
- Status = EFI_INVALID_PARAMETER;
- break;
-
- case ARM_SMC_MM_RET_DENIED:
- Status = EFI_ACCESS_DENIED;
- break;
-
- case ARM_SMC_MM_RET_NO_MEMORY:
- // Unexpected error since the CommSize was checked for zero length
- // prior to issuing the SMC
- Status = EFI_OUT_OF_RESOURCES;
- ASSERT (0);
- break;
-
- default:
- Status = EFI_ACCESS_DENIED;
- ASSERT (0);
+ Ret = CommunicateSmcArgs.Arg0;
+
+ if (FixedPcdGet32 (PcdFfaEnable) != 0) {
+ if (Ret == ARM_SVC_ID_FFA_INTERRUPT_AARCH32) {
+ DEBUG ((DEBUG_INFO, "Resuming interrupted FF-A call \n"));
+
+ // FF-A Interface ID for running the interrupted partition
+ CommunicateSmcArgs.Arg0 = ARM_SVC_ID_FFA_RUN_AARCH32;
+
+ // FF-A Destination EndPoint and vCPU ID, TODO: We are assuming vCPU0 of the
+ // StMM SP since it is UP.
+ CommunicateSmcArgs.Arg1 = mStmmPartInfo.PartId << 16;
+
+ // Loop if the call was interrupted
+ goto ffa_intr_loop;
+ }
+ }
+
+ if (((FixedPcdGet32 (PcdFfaEnable) != 0) &&
+ (Ret == ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP)) ||
+ (Ret == ARM_SMC_MM_RET_SUCCESS)) {
+ ZeroMem (CommBufferVirtual, BufferSize);
+ // On successful return, the size of data being returned is inferred from
+ // MessageLength + Header.
+ CommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)mNsCommBuffMemRegion.VirtualBase;
+ BufferSize = CommunicateHeader->MessageLength +
+ sizeof (CommunicateHeader->HeaderGuid) +
+ sizeof (CommunicateHeader->MessageLength);
+
+ CopyMem (CommBufferVirtual, (VOID *)mNsCommBuffMemRegion.VirtualBase,
+ BufferSize);
+ Status = EFI_SUCCESS;
+ return Status;
+ }
+
+ if (FixedPcdGet32 (PcdFfaEnable) != 0) {
+ 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;
+
+ case ARM_SMC_MM_RET_DENIED:
+ Status = EFI_ACCESS_DENIED;
+ break;
+
+ case ARM_SMC_MM_RET_NO_MEMORY:
+ // Unexpected error since the CommSize was checked for zero length
+ // prior to issuing the SMC
+ Status = EFI_OUT_OF_RESOURCES;
+ ASSERT (0);
+ break;
+
+ default:
+ Status = EFI_ACCESS_DENIED;
+ ASSERT (0);
}
return Status;
--
2.34.1
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [edk2-platforms][PATCH V1 20/20] StandaloneMmPkg: Add support for MM requests as FF-A direct messages
2023-07-11 14:36 [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Nishant Sharma
` (18 preceding siblings ...)
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 19/20] ArmPkg/MmCommunicationDxe: Use the FF-A transport for MM requests Nishant Sharma
@ 2023-07-11 14:36 ` Nishant Sharma
2023-07-12 21:13 ` [edk2-devel] [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Oliver Smith-Denny
20 siblings, 0 replies; 41+ messages in thread
From: Nishant Sharma @ 2023-07-11 14:36 UTC (permalink / raw)
To: devel
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
From: Achin Gupta <achin.gupta@arm.com>
This patch adds support for correctly receiving a request for a
Standalome MM driver service using the MM communication protocol
packaged as an FF-A direct request message.
Signed-off-by: Achin Gupta <achin.gupta@arm.com>
Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
---
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
index a763bf8509b2..e0987cba21f9 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
@@ -198,6 +198,8 @@ DelegatedEventLoop (
BOOLEAN FfaEnabled;
EFI_STATUS Status;
UINTN SvcStatus;
+ UINT16 SenderPartId;
+ UINT16 ReceiverPartId;
while (TRUE) {
ArmCallSvc (EventCompleteSvcArgs);
@@ -214,9 +216,12 @@ DelegatedEventLoop (
FfaEnabled = FixedPcdGet32 (PcdFfaEnable != 0);
if (FfaEnabled) {
+ SenderPartId = EventCompleteSvcArgs->Arg1 >> 16;
+ ReceiverPartId = EventCompleteSvcArgs->Arg1 & 0xffff;
Status = CpuDriverEntryPoint (
EventCompleteSvcArgs->Arg0,
- EventCompleteSvcArgs->Arg6,
+ // Assume CPU number 0
+ 0,
EventCompleteSvcArgs->Arg3
);
if (EFI_ERROR (Status)) {
@@ -266,7 +271,7 @@ DelegatedEventLoop (
if (FfaEnabled) {
EventCompleteSvcArgs->Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP;
- EventCompleteSvcArgs->Arg1 = 0;
+ EventCompleteSvcArgs->Arg1 = ReceiverPartId << 16 | SenderPartId;
EventCompleteSvcArgs->Arg2 = 0;
EventCompleteSvcArgs->Arg3 = ARM_SVC_ID_SP_EVENT_COMPLETE;
EventCompleteSvcArgs->Arg4 = SvcStatus;
--
2.34.1
^ permalink raw reply related [flat|nested] 41+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH V1 19/20] ArmPkg/MmCommunicationDxe: Use the FF-A transport for MM requests
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 19/20] ArmPkg/MmCommunicationDxe: Use the FF-A transport for MM requests Nishant Sharma
@ 2023-07-11 19:22 ` Kun Qin
2023-07-12 14:21 ` achin.gupta
2023-07-12 21:49 ` Girish Mahadevan
1 sibling, 1 reply; 41+ messages in thread
From: Kun Qin @ 2023-07-11 19:22 UTC (permalink / raw)
To: devel, nishant.sharma
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta, Aditya Angadi
Hi Nishant,
Thank you for sending out the patch. Can you please evaluate how much
effort it would be
to support the same for MmCommunicatePei? I think it would provide
better coverage for
the FFA support if we can have that change.
Thanks,
Kun
On 7/11/2023 7:36 AM, Nishant Sharma wrote:
> From: Achin Gupta <achin.gupta@arm.com>
>
> This patch packages requests for accessing a Standalone MM driver
> through the MM communication protocol as FF-A direct messages.
> Corresponding changes in Standalone MM Core ensure that responses are
> packaged in the same way.
>
> Signed-off-by: Achin Gupta <achin.gupta@arm.com>
> Co-developed-by: Aditya Angadi <aditya.angadi@arm.com>
> Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
> ---
> ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 2 +
> ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 141 +++++++++++++-------
> 2 files changed, 97 insertions(+), 46 deletions(-)
>
> diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> index 530af8bd3c2e..493997346143 100644
> --- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> +++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> @@ -23,6 +23,7 @@
> #define ARM_SVC_ID_FFA_RXTX_UNMAP_AARCH32 0x84000067
> #define ARM_SVC_ID_FFA_PARTITION_INFO_GET_AARCH32 0x84000068
> #define ARM_SVC_ID_FFA_ID_GET_AARCH32 0x84000069
> +#define ARM_SVC_ID_FFA_RUN_AARCH32 0x8400006D
> #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH32 0x8400006F
> #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH32 0x84000070
> #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH64 0xC400006F
> @@ -31,6 +32,7 @@
> #define ARM_SVC_ID_FFA_SUCCESS_AARCH64 0xC4000061
> #define ARM_SVC_ID_FFA_MEM_PERM_SET_AARCH32 0x84000089
> #define ARM_SVC_ID_FFA_MEM_PERM_GET_AARCH32 0x84000088
> +#define ARM_SVC_ID_FFA_INTERRUPT_AARCH32 0x84000062
> #define ARM_SVC_ID_FFA_ERROR_AARCH32 0x84000060
> #define ARM_SVC_ID_FFA_ERROR_AARCH64 0xC4000060
> #define ARM_SVC_ID_FFA_MSG_WAIT_AARCH32 0x8400006B
> diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> index 94a5d96c051d..a70318581bd2 100644
> --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> @@ -100,6 +100,7 @@ MmCommunication2Communicate (
> ARM_SMC_ARGS CommunicateSmcArgs;
> EFI_STATUS Status;
> UINTN BufferSize;
> + UINTN Ret;
>
> Status = EFI_ACCESS_DENIED;
> BufferSize = 0;
> @@ -160,60 +161,108 @@ MmCommunication2Communicate (
> return Status;
> }
>
> - // 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 (FixedPcdGet32 (PcdFfaEnable) != 0) {
> + // 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 = mFfaPartId << 16 | mStmmPartInfo.PartId;
>
> + // Reserved for future use(MBZ)
> + CommunicateSmcArgs.Arg2 = 0x0;
> +
> + // comm_buffer_address (64-bit physical address)
> + CommunicateSmcArgs.Arg3 = (UINTN)mNsCommBuffMemRegion.PhysicalBase;
> +
> + // Cookie
> + CommunicateSmcArgs.Arg4 = 0x0;
> +
> + // Not Used
> + CommunicateSmcArgs.Arg5 = 0;
> +
> + // 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;
> + }
> +
> +ffa_intr_loop:
> // Call the Standalone MM environment.
> ArmCallSmc (&CommunicateSmcArgs);
>
> - switch (CommunicateSmcArgs.Arg0) {
> - case ARM_SMC_MM_RET_SUCCESS:
> - ZeroMem (CommBufferVirtual, BufferSize);
> - // On successful return, the size of data being returned is inferred from
> - // MessageLength + Header.
> - CommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)mNsCommBuffMemRegion.VirtualBase;
> - BufferSize = CommunicateHeader->MessageLength +
> - sizeof (CommunicateHeader->HeaderGuid) +
> - sizeof (CommunicateHeader->MessageLength);
> -
> - CopyMem (
> - CommBufferVirtual,
> - (VOID *)mNsCommBuffMemRegion.VirtualBase,
> - BufferSize
> - );
> - Status = EFI_SUCCESS;
> - break;
> -
> - case ARM_SMC_MM_RET_INVALID_PARAMS:
> - Status = EFI_INVALID_PARAMETER;
> - break;
> -
> - case ARM_SMC_MM_RET_DENIED:
> - Status = EFI_ACCESS_DENIED;
> - break;
> -
> - case ARM_SMC_MM_RET_NO_MEMORY:
> - // Unexpected error since the CommSize was checked for zero length
> - // prior to issuing the SMC
> - Status = EFI_OUT_OF_RESOURCES;
> - ASSERT (0);
> - break;
> -
> - default:
> - Status = EFI_ACCESS_DENIED;
> - ASSERT (0);
> + Ret = CommunicateSmcArgs.Arg0;
> +
> + if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> + if (Ret == ARM_SVC_ID_FFA_INTERRUPT_AARCH32) {
> + DEBUG ((DEBUG_INFO, "Resuming interrupted FF-A call \n"));
> +
> + // FF-A Interface ID for running the interrupted partition
> + CommunicateSmcArgs.Arg0 = ARM_SVC_ID_FFA_RUN_AARCH32;
> +
> + // FF-A Destination EndPoint and vCPU ID, TODO: We are assuming vCPU0 of the
> + // StMM SP since it is UP.
> + CommunicateSmcArgs.Arg1 = mStmmPartInfo.PartId << 16;
> +
> + // Loop if the call was interrupted
> + goto ffa_intr_loop;
> + }
> + }
> +
> + if (((FixedPcdGet32 (PcdFfaEnable) != 0) &&
> + (Ret == ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP)) ||
> + (Ret == ARM_SMC_MM_RET_SUCCESS)) {
> + ZeroMem (CommBufferVirtual, BufferSize);
> + // On successful return, the size of data being returned is inferred from
> + // MessageLength + Header.
> + CommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)mNsCommBuffMemRegion.VirtualBase;
> + BufferSize = CommunicateHeader->MessageLength +
> + sizeof (CommunicateHeader->HeaderGuid) +
> + sizeof (CommunicateHeader->MessageLength);
> +
> + CopyMem (CommBufferVirtual, (VOID *)mNsCommBuffMemRegion.VirtualBase,
> + BufferSize);
> + Status = EFI_SUCCESS;
> + return Status;
> + }
> +
> + if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> + 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;
> +
> + case ARM_SMC_MM_RET_DENIED:
> + Status = EFI_ACCESS_DENIED;
> + break;
> +
> + case ARM_SMC_MM_RET_NO_MEMORY:
> + // Unexpected error since the CommSize was checked for zero length
> + // prior to issuing the SMC
> + Status = EFI_OUT_OF_RESOURCES;
> + ASSERT (0);
> + break;
> +
> + default:
> + Status = EFI_ACCESS_DENIED;
> + ASSERT (0);
> }
>
> return Status;
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH V1 19/20] ArmPkg/MmCommunicationDxe: Use the FF-A transport for MM requests
2023-07-11 19:22 ` [edk2-devel] " Kun Qin
@ 2023-07-12 14:21 ` achin.gupta
2023-07-12 17:13 ` Kun Qin
0 siblings, 1 reply; 41+ messages in thread
From: achin.gupta @ 2023-07-12 14:21 UTC (permalink / raw)
To: Kun Qin, devel@edk2.groups.io, Nishant Sharma
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Aditya Angadi, nd
[-- Attachment #1: Type: text/plain, Size: 9101 bytes --]
Hi Kun,
IIUC, not much happens during the PEI phase on Arm platforms. Hence the patches focus on DXE in the Normal world. It would be difficult to provide an effort estimate as we do not see a use case and consequently this is not on the to-do list. Would you be able to provide more detail about the scenarios you have in mind?
cheers,
Achin
________________________________
From: Kun Qin <kuqin12@gmail.com>
Sent: 11 July 2023 20:22
To: devel@edk2.groups.io <devel@edk2.groups.io>; Nishant Sharma <Nishant.Sharma@arm.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>; Sami Mujawar <Sami.Mujawar@arm.com>; Thomas Abraham <thomas.abraham@arm.com>; Sayanta Pattanayak <Sayanta.Pattanayak@arm.com>; Achin Gupta <Achin.Gupta@arm.com>; Aditya Angadi <Aditya.Angadi@arm.com>
Subject: Re: [edk2-devel] [edk2-platforms][PATCH V1 19/20] ArmPkg/MmCommunicationDxe: Use the FF-A transport for MM requests
Hi Nishant,
Thank you for sending out the patch. Can you please evaluate how much
effort it would be
to support the same for MmCommunicatePei? I think it would provide
better coverage for
the FFA support if we can have that change.
Thanks,
Kun
On 7/11/2023 7:36 AM, Nishant Sharma wrote:
> From: Achin Gupta <achin.gupta@arm.com>
>
> This patch packages requests for accessing a Standalone MM driver
> through the MM communication protocol as FF-A direct messages.
> Corresponding changes in Standalone MM Core ensure that responses are
> packaged in the same way.
>
> Signed-off-by: Achin Gupta <achin.gupta@arm.com>
> Co-developed-by: Aditya Angadi <aditya.angadi@arm.com>
> Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
> ---
> ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 2 +
> ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 141 +++++++++++++-------
> 2 files changed, 97 insertions(+), 46 deletions(-)
>
> diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> index 530af8bd3c2e..493997346143 100644
> --- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> +++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> @@ -23,6 +23,7 @@
> #define ARM_SVC_ID_FFA_RXTX_UNMAP_AARCH32 0x84000067
> #define ARM_SVC_ID_FFA_PARTITION_INFO_GET_AARCH32 0x84000068
> #define ARM_SVC_ID_FFA_ID_GET_AARCH32 0x84000069
> +#define ARM_SVC_ID_FFA_RUN_AARCH32 0x8400006D
> #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH32 0x8400006F
> #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH32 0x84000070
> #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH64 0xC400006F
> @@ -31,6 +32,7 @@
> #define ARM_SVC_ID_FFA_SUCCESS_AARCH64 0xC4000061
> #define ARM_SVC_ID_FFA_MEM_PERM_SET_AARCH32 0x84000089
> #define ARM_SVC_ID_FFA_MEM_PERM_GET_AARCH32 0x84000088
> +#define ARM_SVC_ID_FFA_INTERRUPT_AARCH32 0x84000062
> #define ARM_SVC_ID_FFA_ERROR_AARCH32 0x84000060
> #define ARM_SVC_ID_FFA_ERROR_AARCH64 0xC4000060
> #define ARM_SVC_ID_FFA_MSG_WAIT_AARCH32 0x8400006B
> diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> index 94a5d96c051d..a70318581bd2 100644
> --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> @@ -100,6 +100,7 @@ MmCommunication2Communicate (
> ARM_SMC_ARGS CommunicateSmcArgs;
> EFI_STATUS Status;
> UINTN BufferSize;
> + UINTN Ret;
>
> Status = EFI_ACCESS_DENIED;
> BufferSize = 0;
> @@ -160,60 +161,108 @@ MmCommunication2Communicate (
> return Status;
> }
>
> - // 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 (FixedPcdGet32 (PcdFfaEnable) != 0) {
> + // 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 = mFfaPartId << 16 | mStmmPartInfo.PartId;
>
> + // Reserved for future use(MBZ)
> + CommunicateSmcArgs.Arg2 = 0x0;
> +
> + // comm_buffer_address (64-bit physical address)
> + CommunicateSmcArgs.Arg3 = (UINTN)mNsCommBuffMemRegion.PhysicalBase;
> +
> + // Cookie
> + CommunicateSmcArgs.Arg4 = 0x0;
> +
> + // Not Used
> + CommunicateSmcArgs.Arg5 = 0;
> +
> + // 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;
> + }
> +
> +ffa_intr_loop:
> // Call the Standalone MM environment.
> ArmCallSmc (&CommunicateSmcArgs);
>
> - switch (CommunicateSmcArgs.Arg0) {
> - case ARM_SMC_MM_RET_SUCCESS:
> - ZeroMem (CommBufferVirtual, BufferSize);
> - // On successful return, the size of data being returned is inferred from
> - // MessageLength + Header.
> - CommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)mNsCommBuffMemRegion.VirtualBase;
> - BufferSize = CommunicateHeader->MessageLength +
> - sizeof (CommunicateHeader->HeaderGuid) +
> - sizeof (CommunicateHeader->MessageLength);
> -
> - CopyMem (
> - CommBufferVirtual,
> - (VOID *)mNsCommBuffMemRegion.VirtualBase,
> - BufferSize
> - );
> - Status = EFI_SUCCESS;
> - break;
> -
> - case ARM_SMC_MM_RET_INVALID_PARAMS:
> - Status = EFI_INVALID_PARAMETER;
> - break;
> -
> - case ARM_SMC_MM_RET_DENIED:
> - Status = EFI_ACCESS_DENIED;
> - break;
> -
> - case ARM_SMC_MM_RET_NO_MEMORY:
> - // Unexpected error since the CommSize was checked for zero length
> - // prior to issuing the SMC
> - Status = EFI_OUT_OF_RESOURCES;
> - ASSERT (0);
> - break;
> -
> - default:
> - Status = EFI_ACCESS_DENIED;
> - ASSERT (0);
> + Ret = CommunicateSmcArgs.Arg0;
> +
> + if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> + if (Ret == ARM_SVC_ID_FFA_INTERRUPT_AARCH32) {
> + DEBUG ((DEBUG_INFO, "Resuming interrupted FF-A call \n"));
> +
> + // FF-A Interface ID for running the interrupted partition
> + CommunicateSmcArgs.Arg0 = ARM_SVC_ID_FFA_RUN_AARCH32;
> +
> + // FF-A Destination EndPoint and vCPU ID, TODO: We are assuming vCPU0 of the
> + // StMM SP since it is UP.
> + CommunicateSmcArgs.Arg1 = mStmmPartInfo.PartId << 16;
> +
> + // Loop if the call was interrupted
> + goto ffa_intr_loop;
> + }
> + }
> +
> + if (((FixedPcdGet32 (PcdFfaEnable) != 0) &&
> + (Ret == ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP)) ||
> + (Ret == ARM_SMC_MM_RET_SUCCESS)) {
> + ZeroMem (CommBufferVirtual, BufferSize);
> + // On successful return, the size of data being returned is inferred from
> + // MessageLength + Header.
> + CommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)mNsCommBuffMemRegion.VirtualBase;
> + BufferSize = CommunicateHeader->MessageLength +
> + sizeof (CommunicateHeader->HeaderGuid) +
> + sizeof (CommunicateHeader->MessageLength);
> +
> + CopyMem (CommBufferVirtual, (VOID *)mNsCommBuffMemRegion.VirtualBase,
> + BufferSize);
> + Status = EFI_SUCCESS;
> + return Status;
> + }
> +
> + if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> + 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;
> +
> + case ARM_SMC_MM_RET_DENIED:
> + Status = EFI_ACCESS_DENIED;
> + break;
> +
> + case ARM_SMC_MM_RET_NO_MEMORY:
> + // Unexpected error since the CommSize was checked for zero length
> + // prior to issuing the SMC
> + Status = EFI_OUT_OF_RESOURCES;
> + ASSERT (0);
> + break;
> +
> + default:
> + Status = EFI_ACCESS_DENIED;
> + ASSERT (0);
> }
>
> return Status;
[-- Attachment #2: Type: text/html, Size: 15933 bytes --]
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH V1 19/20] ArmPkg/MmCommunicationDxe: Use the FF-A transport for MM requests
2023-07-12 14:21 ` achin.gupta
@ 2023-07-12 17:13 ` Kun Qin
0 siblings, 0 replies; 41+ messages in thread
From: Kun Qin @ 2023-07-12 17:13 UTC (permalink / raw)
To: Achin Gupta, devel@edk2.groups.io, Nishant Sharma
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Aditya Angadi, nd
[-- Attachment #1: Type: text/plain, Size: 10620 bytes --]
Hi Achin,
The main MM communicate usage in PEI we have today is the variable service,
because non secure UEFI cannot access flash directly.
We had a few use cases where we need to check the variable from the previous
boot in PEI, update some configuration data and consume it for the rest
of the
boot. I think it will break as is if we switch over to FFA aware framework?
Please let me know how you think about the potential support in PEI.
Regards,
Kun
On 7/12/2023 7:21 AM, Achin Gupta wrote:
> Hi Kun,
>
> IIUC, not much happens during the PEI phase on Arm platforms. Hence
> the patches focus on DXE in the Normal world. It would be difficult to
> provide an effort estimate as we do not see a use case and
> consequently this is not on the to-do list. Would you be able to
> provide more detail about the scenarios you have in mind?
>
> cheers,
> Achin
> ------------------------------------------------------------------------
> *From:* Kun Qin <kuqin12@gmail.com>
> *Sent:* 11 July 2023 20:22
> *To:* devel@edk2.groups.io <devel@edk2.groups.io>; Nishant Sharma
> <Nishant.Sharma@arm.com>
> *Cc:* Ard Biesheuvel <ardb+tianocore@kernel.org>; Sami Mujawar
> <Sami.Mujawar@arm.com>; Thomas Abraham <thomas.abraham@arm.com>;
> Sayanta Pattanayak <Sayanta.Pattanayak@arm.com>; Achin Gupta
> <Achin.Gupta@arm.com>; Aditya Angadi <Aditya.Angadi@arm.com>
> *Subject:* Re: [edk2-devel] [edk2-platforms][PATCH V1 19/20]
> ArmPkg/MmCommunicationDxe: Use the FF-A transport for MM requests
> Hi Nishant,
>
> Thank you for sending out the patch. Can you please evaluate how much
> effort it would be
> to support the same for MmCommunicatePei? I think it would provide
> better coverage for
> the FFA support if we can have that change.
>
> Thanks,
> Kun
>
> On 7/11/2023 7:36 AM, Nishant Sharma wrote:
> > From: Achin Gupta <achin.gupta@arm.com>
> >
> > This patch packages requests for accessing a Standalone MM driver
> > through the MM communication protocol as FF-A direct messages.
> > Corresponding changes in Standalone MM Core ensure that responses are
> > packaged in the same way.
> >
> > Signed-off-by: Achin Gupta <achin.gupta@arm.com>
> > Co-developed-by: Aditya Angadi <aditya.angadi@arm.com>
> > Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
> > ---
> > ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 2 +
> > ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 141
> +++++++++++++-------
> > 2 files changed, 97 insertions(+), 46 deletions(-)
> >
> > diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> > index 530af8bd3c2e..493997346143 100644
> > --- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> > +++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> > @@ -23,6 +23,7 @@
> > #define ARM_SVC_ID_FFA_RXTX_UNMAP_AARCH32 0x84000067
> > #define ARM_SVC_ID_FFA_PARTITION_INFO_GET_AARCH32 0x84000068
> > #define ARM_SVC_ID_FFA_ID_GET_AARCH32 0x84000069
> > +#define ARM_SVC_ID_FFA_RUN_AARCH32 0x8400006D
> > #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH32 0x8400006F
> > #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH32 0x84000070
> > #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH64 0xC400006F
> > @@ -31,6 +32,7 @@
> > #define ARM_SVC_ID_FFA_SUCCESS_AARCH64 0xC4000061
> > #define ARM_SVC_ID_FFA_MEM_PERM_SET_AARCH32 0x84000089
> > #define ARM_SVC_ID_FFA_MEM_PERM_GET_AARCH32 0x84000088
> > +#define ARM_SVC_ID_FFA_INTERRUPT_AARCH32 0x84000062
> > #define ARM_SVC_ID_FFA_ERROR_AARCH32 0x84000060
> > #define ARM_SVC_ID_FFA_ERROR_AARCH64 0xC4000060
> > #define ARM_SVC_ID_FFA_MSG_WAIT_AARCH32 0x8400006B
> > diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> > index 94a5d96c051d..a70318581bd2 100644
> > --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> > +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> > @@ -100,6 +100,7 @@ MmCommunication2Communicate (
> > ARM_SMC_ARGS CommunicateSmcArgs;
> > EFI_STATUS Status;
> > UINTN BufferSize;
> > + UINTN Ret;
> >
> > Status = EFI_ACCESS_DENIED;
> > BufferSize = 0;
> > @@ -160,60 +161,108 @@ MmCommunication2Communicate (
> > return Status;
> > }
> >
> > - // 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 (FixedPcdGet32 (PcdFfaEnable) != 0) {
> > + // 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 = mFfaPartId << 16 | mStmmPartInfo.PartId;
> >
> > + // Reserved for future use(MBZ)
> > + CommunicateSmcArgs.Arg2 = 0x0;
> > +
> > + // comm_buffer_address (64-bit physical address)
> > + CommunicateSmcArgs.Arg3 = (UINTN)mNsCommBuffMemRegion.PhysicalBase;
> > +
> > + // Cookie
> > + CommunicateSmcArgs.Arg4 = 0x0;
> > +
> > + // Not Used
> > + CommunicateSmcArgs.Arg5 = 0;
> > +
> > + // 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;
> > + }
> > +
> > +ffa_intr_loop:
> > // Call the Standalone MM environment.
> > ArmCallSmc (&CommunicateSmcArgs);
> >
> > - switch (CommunicateSmcArgs.Arg0) {
> > - case ARM_SMC_MM_RET_SUCCESS:
> > - ZeroMem (CommBufferVirtual, BufferSize);
> > - // On successful return, the size of data being returned is
> inferred from
> > - // MessageLength + Header.
> > - CommunicateHeader = (EFI_MM_COMMUNICATE_HEADER
> *)mNsCommBuffMemRegion.VirtualBase;
> > - BufferSize = CommunicateHeader->MessageLength +
> > - sizeof (CommunicateHeader->HeaderGuid) +
> > - sizeof (CommunicateHeader->MessageLength);
> > -
> > - CopyMem (
> > - CommBufferVirtual,
> > - (VOID *)mNsCommBuffMemRegion.VirtualBase,
> > - BufferSize
> > - );
> > - Status = EFI_SUCCESS;
> > - break;
> > -
> > - case ARM_SMC_MM_RET_INVALID_PARAMS:
> > - Status = EFI_INVALID_PARAMETER;
> > - break;
> > -
> > - case ARM_SMC_MM_RET_DENIED:
> > - Status = EFI_ACCESS_DENIED;
> > - break;
> > -
> > - case ARM_SMC_MM_RET_NO_MEMORY:
> > - // Unexpected error since the CommSize was checked for zero
> length
> > - // prior to issuing the SMC
> > - Status = EFI_OUT_OF_RESOURCES;
> > - ASSERT (0);
> > - break;
> > -
> > - default:
> > - Status = EFI_ACCESS_DENIED;
> > - ASSERT (0);
> > + Ret = CommunicateSmcArgs.Arg0;
> > +
> > + if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> > + if (Ret == ARM_SVC_ID_FFA_INTERRUPT_AARCH32) {
> > + DEBUG ((DEBUG_INFO, "Resuming interrupted FF-A call \n"));
> > +
> > + // FF-A Interface ID for running the interrupted partition
> > + CommunicateSmcArgs.Arg0 = ARM_SVC_ID_FFA_RUN_AARCH32;
> > +
> > + // FF-A Destination EndPoint and vCPU ID, TODO: We are
> assuming vCPU0 of the
> > + // StMM SP since it is UP.
> > + CommunicateSmcArgs.Arg1 = mStmmPartInfo.PartId << 16;
> > +
> > + // Loop if the call was interrupted
> > + goto ffa_intr_loop;
> > + }
> > + }
> > +
> > + if (((FixedPcdGet32 (PcdFfaEnable) != 0) &&
> > + (Ret == ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP)) ||
> > + (Ret == ARM_SMC_MM_RET_SUCCESS)) {
> > + ZeroMem (CommBufferVirtual, BufferSize);
> > + // On successful return, the size of data being returned is
> inferred from
> > + // MessageLength + Header.
> > + CommunicateHeader = (EFI_MM_COMMUNICATE_HEADER
> *)mNsCommBuffMemRegion.VirtualBase;
> > + BufferSize = CommunicateHeader->MessageLength +
> > + sizeof (CommunicateHeader->HeaderGuid) +
> > + sizeof (CommunicateHeader->MessageLength);
> > +
> > + CopyMem (CommBufferVirtual, (VOID
> *)mNsCommBuffMemRegion.VirtualBase,
> > + BufferSize);
> > + Status = EFI_SUCCESS;
> > + return Status;
> > + }
> > +
> > + if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> > + 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;
> > +
> > + case ARM_SMC_MM_RET_DENIED:
> > + Status = EFI_ACCESS_DENIED;
> > + break;
> > +
> > + case ARM_SMC_MM_RET_NO_MEMORY:
> > + // Unexpected error since the CommSize was checked for zero length
> > + // prior to issuing the SMC
> > + Status = EFI_OUT_OF_RESOURCES;
> > + ASSERT (0);
> > + break;
> > +
> > + default:
> > + Status = EFI_ACCESS_DENIED;
> > + ASSERT (0);
> > }
> >
> > return Status;
[-- Attachment #2: Type: text/html, Size: 18830 bytes --]
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH V1 01/20] ArmPkg: Change PcdFfaEnable flag datatype
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 01/20] ArmPkg: Change PcdFfaEnable flag datatype Nishant Sharma
@ 2023-07-12 17:21 ` Oliver Smith-Denny
2023-07-12 17:23 ` Chris Fernald
0 siblings, 1 reply; 41+ messages in thread
From: Oliver Smith-Denny @ 2023-07-12 17:21 UTC (permalink / raw)
To: devel, nishant.sharma
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
On 7/11/2023 7:36 AM, Nishant Sharma wrote:
> FeatureFlag type PCD flags are declared by typecasting an integer value
> to BOOLEAN. These flags cannot be use in assembly code as assembler does
> not recognise C primitive types. Change the flag data type from BOOLEAN
> to UINT32.
>
> Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
> ---
> ArmPkg/ArmPkg.dec | 14 +++++++-------
> ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf | 4 ++--
> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf | 4 ++--
> ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c | 8 ++++----
> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c | 8 ++++----
> 5 files changed, 19 insertions(+), 19 deletions(-)
>
> diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
> index 1a16d044c94b..c36c23e2e059 100644
> --- a/ArmPkg/ArmPkg.dec
> +++ b/ArmPkg/ArmPkg.dec
> @@ -155,13 +155,6 @@
> # hardware coherency (i.e., no virtualization or cache coherent DMA)
> gArmTokenSpaceGuid.PcdNormalMemoryNonshareableOverride|FALSE|BOOLEAN|0x00000043
>
> -[PcdsFeatureFlag.AARCH64, PcdsFeatureFlag.ARM]
> - ## Used to select method for requesting services from S-EL1.<BR><BR>
> - # TRUE - Selects FF-A calls for communication between S-EL0 and SPMC.<BR>
> - # FALSE - Selects SVC calls for communication between S-EL0 and SPMC.<BR>
> - # @Prompt Enable FF-A support.
> - gArmTokenSpaceGuid.PcdFfaEnable|FALSE|BOOLEAN|0x0000005B
> -
> [PcdsFixedAtBuild.common]
> gArmTokenSpaceGuid.PcdTrustzoneSupport|FALSE|BOOLEAN|0x00000006
>
> @@ -298,6 +291,13 @@
> # not currently supported.
> gArmTokenSpaceGuid.PcdArmNonSecModeTransition|0x3c9|UINT32|0x0000003E
>
> + ## Used to select method for requesting services from S-EL1.<BR><BR>
> + # 1 - Selects FF-A calls for communication between S-EL0 and SPMC.<BR>
> + # 0 - Selects SVC calls for communication between S-EL0 and SPMC.<BR>
> + # Using unsigned integer as boolean does not work on assembler.
> + # @Prompt Enable FF-A support.
> + gArmTokenSpaceGuid.PcdFfaEnable|0|UINT32|0x0000005B
> +
A small nit: any reason not to go to UINT8 from BOOLEAN? It would seem
the logical conversion, unless you envision it extending greatly in the
future.
Thanks,
Oliver
>
> #
> # These PCDs are also defined as 'PcdsDynamic' or 'PcdsPatchableInModule' to be
> diff --git a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
> index ff20e5898051..3c733585f573 100644
> --- a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
> +++ b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
> @@ -1,6 +1,6 @@
> #/** @file
> #
> -# Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.<BR>
> +# Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.
> #
> # SPDX-License-Identifier: BSD-2-Clause-Patent
> #
> @@ -23,7 +23,7 @@
> ArmPkg/ArmPkg.dec
> MdePkg/MdePkg.dec
>
> -[FeaturePcd.ARM, FeaturePcd.AARCH64]
> +[FixedPcd]
> gArmTokenSpaceGuid.PcdFfaEnable
>
> [LibraryClasses]
> diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
> index 75cfb98c0e75..dc6d3d859911 100644
> --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
> +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
> @@ -1,7 +1,7 @@
> ## @file
> # Module entry point library for DXE core.
> #
> -# Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.<BR>
> +# Copyright (c) 2017 - 2023, Arm Ltd. All rights reserved.
> #
> # SPDX-License-Identifier: BSD-2-Clause-Patent
> #
> @@ -51,7 +51,7 @@
> gEfiStandaloneMmNonSecureBufferGuid
> gEfiArmTfCpuDriverEpDescriptorGuid
>
> -[FeaturePcd.ARM, FeaturePcd.AARCH64]
> +[FixedPcd]
> gArmTokenSpaceGuid.PcdFfaEnable
>
> #
> diff --git a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
> index d55aff76201e..1a41a289ef17 100644
> --- a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
> +++ b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
> @@ -1,7 +1,7 @@
> /** @file
> File managing the MMU for ARMv8 architecture in S-EL0
>
> - Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.<BR>
> + Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.
> Copyright (c) 2021, Linaro Limited
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> @@ -54,7 +54,7 @@ SendMemoryPermissionRequest (
> }
>
> ArmCallSvc (SvcArgs);
> - if (FeaturePcdGet (PcdFfaEnable)) {
> + if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> // Get/Set memory attributes is an atomic call, with
> // StandaloneMm at S-EL0 being the caller and the SPM
> // core being the callee. Thus there won't be a
> @@ -163,7 +163,7 @@ GetMemoryPermissions (
> // Prepare the message parameters.
> // See [1], Section 13.5.5.1 MM_SP_MEMORY_ATTRIBUTES_GET_AARCH64.
> ZeroMem (&SvcArgs, sizeof (ARM_SVC_ARGS));
> - if (FeaturePcdGet (PcdFfaEnable)) {
> + if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> // See [2], Section 10.2 FFA_MSG_SEND_DIRECT_REQ.
> SvcArgs.Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ;
> SvcArgs.Arg1 = ARM_FFA_DESTINATION_ENDPOINT_ID;
> @@ -218,7 +218,7 @@ RequestMemoryPermissionChange (
> // Prepare the message parameters.
> // See [1], Section 13.5.5.2 MM_SP_MEMORY_ATTRIBUTES_SET_AARCH64.
> ZeroMem (&SvcArgs, sizeof (ARM_SVC_ARGS));
> - if (FeaturePcdGet (PcdFfaEnable)) {
> + if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> // See [2], Section 10.2 FFA_MSG_SEND_DIRECT_REQ.
> SvcArgs.Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ;
> SvcArgs.Arg1 = ARM_FFA_DESTINATION_ENDPOINT_ID;
> diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
> index 96de10405af8..5dd1d9747995 100644
> --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
> +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
> @@ -2,7 +2,7 @@
> Entry point to the Standalone MM Foundation when initialized during the SEC
> phase on ARM platforms
>
> -Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.<BR>
> +Copyright (c) 2017 - 2023, Arm Ltd. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> **/
> @@ -140,7 +140,7 @@ DelegatedEventLoop (
> DEBUG ((DEBUG_INFO, "X6 : 0x%x\n", (UINT32)EventCompleteSvcArgs->Arg6));
> DEBUG ((DEBUG_INFO, "X7 : 0x%x\n", (UINT32)EventCompleteSvcArgs->Arg7));
>
> - FfaEnabled = FeaturePcdGet (PcdFfaEnable);
> + FfaEnabled = FixedPcdGet32 (PcdFfaEnable != 0);
> if (FfaEnabled) {
> Status = CpuDriverEntryPoint (
> EventCompleteSvcArgs->Arg0,
> @@ -225,7 +225,7 @@ GetSpmVersion (
> UINT32 SpmVersion;
> ARM_SVC_ARGS SpmVersionArgs;
>
> - if (FeaturePcdGet (PcdFfaEnable)) {
> + if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> SpmVersionArgs.Arg0 = ARM_SVC_ID_FFA_VERSION_AARCH32;
> SpmVersionArgs.Arg1 = mSpmMajorVerFfa << SPM_MAJOR_VER_SHIFT;
> SpmVersionArgs.Arg1 |= mSpmMinorVerFfa;
> @@ -293,7 +293,7 @@ InitArmSvcArgs (
> OUT INT32 *Ret
> )
> {
> - if (FeaturePcdGet (PcdFfaEnable)) {
> + if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> InitMmFoundationSvcArgs->Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP;
> InitMmFoundationSvcArgs->Arg1 = 0;
> InitMmFoundationSvcArgs->Arg2 = 0;
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH V1 01/20] ArmPkg: Change PcdFfaEnable flag datatype
2023-07-12 17:21 ` [edk2-devel] " Oliver Smith-Denny
@ 2023-07-12 17:23 ` Chris Fernald
0 siblings, 0 replies; 41+ messages in thread
From: Chris Fernald @ 2023-07-12 17:23 UTC (permalink / raw)
To: devel, osde, nishant.sharma
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
On top of Oliver's question, in the changes
to|||StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf,
we should probably leave the .ARM and .AARCH64 specifiers since that is
not an ARM specific INF.
|
-Chris
On 7/12/2023 10:21 AM, Oliver Smith-Denny wrote:
> On 7/11/2023 7:36 AM, Nishant Sharma wrote:
>> FeatureFlag type PCD flags are declared by typecasting an integer value
>> to BOOLEAN. These flags cannot be use in assembly code as assembler does
>> not recognise C primitive types. Change the flag data type from BOOLEAN
>> to UINT32.
>>
>> Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
>> ---
>> ArmPkg/ArmPkg.dec | 14 +++++++-------
>> ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf | 4 ++--
>> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
>> | 4 ++--
>> ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c | 8 ++++----
>> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
>> | 8 ++++----
>> 5 files changed, 19 insertions(+), 19 deletions(-)
>>
>> diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
>> index 1a16d044c94b..c36c23e2e059 100644
>> --- a/ArmPkg/ArmPkg.dec
>> +++ b/ArmPkg/ArmPkg.dec
>> @@ -155,13 +155,6 @@
>> # hardware coherency (i.e., no virtualization or cache coherent DMA)
>> gArmTokenSpaceGuid.PcdNormalMemoryNonshareableOverride|FALSE|BOOLEAN|0x00000043
>> -[PcdsFeatureFlag.AARCH64, PcdsFeatureFlag.ARM]
>> - ## Used to select method for requesting services from S-EL1.<BR><BR>
>> - # TRUE - Selects FF-A calls for communication between S-EL0 and
>> SPMC.<BR>
>> - # FALSE - Selects SVC calls for communication between S-EL0 and
>> SPMC.<BR>
>> - # @Prompt Enable FF-A support.
>> - gArmTokenSpaceGuid.PcdFfaEnable|FALSE|BOOLEAN|0x0000005B
>> -
>> [PcdsFixedAtBuild.common]
>> gArmTokenSpaceGuid.PcdTrustzoneSupport|FALSE|BOOLEAN|0x00000006
>> @@ -298,6 +291,13 @@
>> # not currently supported.
>> gArmTokenSpaceGuid.PcdArmNonSecModeTransition|0x3c9|UINT32|0x0000003E
>> + ## Used to select method for requesting services from
>> S-EL1.<BR><BR>
>> + # 1 - Selects FF-A calls for communication between S-EL0 and
>> SPMC.<BR>
>> + # 0 - Selects SVC calls for communication between S-EL0 and
>> SPMC.<BR>
>> + # Using unsigned integer as boolean does not work on assembler.
>> + # @Prompt Enable FF-A support.
>> + gArmTokenSpaceGuid.PcdFfaEnable|0|UINT32|0x0000005B
>> +
>
> A small nit: any reason not to go to UINT8 from BOOLEAN? It would seem
> the logical conversion, unless you envision it extending greatly in the
> future.
>
> Thanks,
> Oliver
>
>> #
>> # These PCDs are also defined as 'PcdsDynamic' or
>> 'PcdsPatchableInModule' to be
>> diff --git
>> a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
>> b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
>> index ff20e5898051..3c733585f573 100644
>> --- a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
>> +++ b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
>> @@ -1,6 +1,6 @@
>> #/** @file
>> #
>> -# Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.<BR>
>> +# Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.
>> #
>> # SPDX-License-Identifier: BSD-2-Clause-Patent
>> #
>> @@ -23,7 +23,7 @@
>> ArmPkg/ArmPkg.dec
>> MdePkg/MdePkg.dec
>> -[FeaturePcd.ARM, FeaturePcd.AARCH64]
>> +[FixedPcd]
>> gArmTokenSpaceGuid.PcdFfaEnable
>> [LibraryClasses]
>> diff --git
>> a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
>> b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
>>
>> index 75cfb98c0e75..dc6d3d859911 100644
>> ---
>> a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
>> +++
>> b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
>> @@ -1,7 +1,7 @@
>> ## @file
>> # Module entry point library for DXE core.
>> #
>> -# Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.<BR>
>> +# Copyright (c) 2017 - 2023, Arm Ltd. All rights reserved.
>> #
>> # SPDX-License-Identifier: BSD-2-Clause-Patent
>> #
>> @@ -51,7 +51,7 @@
>> gEfiStandaloneMmNonSecureBufferGuid
>> gEfiArmTfCpuDriverEpDescriptorGuid
>> -[FeaturePcd.ARM, FeaturePcd.AARCH64]
>> +[FixedPcd]
>> gArmTokenSpaceGuid.PcdFfaEnable
>> #
>> diff --git
>> a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
>> b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
>> index d55aff76201e..1a41a289ef17 100644
>> --- a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
>> +++ b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
>> @@ -1,7 +1,7 @@
>> /** @file
>> File managing the MMU for ARMv8 architecture in S-EL0
>> - Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.<BR>
>> + Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.
>> Copyright (c) 2021, Linaro Limited
>> SPDX-License-Identifier: BSD-2-Clause-Patent
>> @@ -54,7 +54,7 @@ SendMemoryPermissionRequest (
>> }
>> ArmCallSvc (SvcArgs);
>> - if (FeaturePcdGet (PcdFfaEnable)) {
>> + if (FixedPcdGet32 (PcdFfaEnable) != 0) {
>> // Get/Set memory attributes is an atomic call, with
>> // StandaloneMm at S-EL0 being the caller and the SPM
>> // core being the callee. Thus there won't be a
>> @@ -163,7 +163,7 @@ GetMemoryPermissions (
>> // Prepare the message parameters.
>> // See [1], Section 13.5.5.1 MM_SP_MEMORY_ATTRIBUTES_GET_AARCH64.
>> ZeroMem (&SvcArgs, sizeof (ARM_SVC_ARGS));
>> - if (FeaturePcdGet (PcdFfaEnable)) {
>> + if (FixedPcdGet32 (PcdFfaEnable) != 0) {
>> // See [2], Section 10.2 FFA_MSG_SEND_DIRECT_REQ.
>> SvcArgs.Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ;
>> SvcArgs.Arg1 = ARM_FFA_DESTINATION_ENDPOINT_ID;
>> @@ -218,7 +218,7 @@ RequestMemoryPermissionChange (
>> // Prepare the message parameters.
>> // See [1], Section 13.5.5.2 MM_SP_MEMORY_ATTRIBUTES_SET_AARCH64.
>> ZeroMem (&SvcArgs, sizeof (ARM_SVC_ARGS));
>> - if (FeaturePcdGet (PcdFfaEnable)) {
>> + if (FixedPcdGet32 (PcdFfaEnable) != 0) {
>> // See [2], Section 10.2 FFA_MSG_SEND_DIRECT_REQ.
>> SvcArgs.Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ;
>> SvcArgs.Arg1 = ARM_FFA_DESTINATION_ENDPOINT_ID;
>> diff --git
>> a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
>> b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
>>
>> index 96de10405af8..5dd1d9747995 100644
>> ---
>> a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
>> +++
>> b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
>> @@ -2,7 +2,7 @@
>> Entry point to the Standalone MM Foundation when initialized
>> during the SEC
>> phase on ARM platforms
>> -Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.<BR>
>> +Copyright (c) 2017 - 2023, Arm Ltd. All rights reserved.
>> SPDX-License-Identifier: BSD-2-Clause-Patent
>> **/
>> @@ -140,7 +140,7 @@ DelegatedEventLoop (
>> DEBUG ((DEBUG_INFO, "X6 : 0x%x\n",
>> (UINT32)EventCompleteSvcArgs->Arg6));
>> DEBUG ((DEBUG_INFO, "X7 : 0x%x\n",
>> (UINT32)EventCompleteSvcArgs->Arg7));
>> - FfaEnabled = FeaturePcdGet (PcdFfaEnable);
>> + FfaEnabled = FixedPcdGet32 (PcdFfaEnable != 0);
>> if (FfaEnabled) {
>> Status = CpuDriverEntryPoint (
>> EventCompleteSvcArgs->Arg0,
>> @@ -225,7 +225,7 @@ GetSpmVersion (
>> UINT32 SpmVersion;
>> ARM_SVC_ARGS SpmVersionArgs;
>> - if (FeaturePcdGet (PcdFfaEnable)) {
>> + if (FixedPcdGet32 (PcdFfaEnable) != 0) {
>> SpmVersionArgs.Arg0 = ARM_SVC_ID_FFA_VERSION_AARCH32;
>> SpmVersionArgs.Arg1 = mSpmMajorVerFfa << SPM_MAJOR_VER_SHIFT;
>> SpmVersionArgs.Arg1 |= mSpmMinorVerFfa;
>> @@ -293,7 +293,7 @@ InitArmSvcArgs (
>> OUT INT32 *Ret
>> )
>> {
>> - if (FeaturePcdGet (PcdFfaEnable)) {
>> + if (FixedPcdGet32 (PcdFfaEnable) != 0) {
>> InitMmFoundationSvcArgs->Arg0 =
>> ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP;
>> InitMmFoundationSvcArgs->Arg1 = 0;
>> InitMmFoundationSvcArgs->Arg2 = 0;
>
>
>
>
>
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH V1 04/20] ArmPkg: Add data structures to receive FF-A boot information
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 04/20] ArmPkg: Add data structures to receive FF-A boot information Nishant Sharma
@ 2023-07-12 17:27 ` Oliver Smith-Denny
0 siblings, 0 replies; 41+ messages in thread
From: Oliver Smith-Denny @ 2023-07-12 17:27 UTC (permalink / raw)
To: devel, nishant.sharma
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
On 7/11/2023 7:36 AM, Nishant Sharma wrote:
> From: Achin Gupta <achin.gupta@arm.com>
>
> The SPMC will pass the manifest to the StMM SP which contains the boot
> information required for SP initialisation. This patch defines the data
> structures defined in Section 5.4 of the FF-A v1.1 BETA0 spec to enable
> this support. The manifest is identified by the TF-A UUID_TOS_FW_CONFIG.
>
> Signed-off-by: Achin Gupta <achin.gupta@arm.com>
> Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
> ---
> ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 69 +++++++++++++++++++-
> 1 file changed, 68 insertions(+), 1 deletion(-)
>
> diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> index 4126a4985bb2..54cc96598032 100644
> --- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> +++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> @@ -3,7 +3,7 @@
> communication between S-EL0 and the Secure Partition
> Manager(SPM)
>
> - Copyright (c) 2020, ARM Limited. All rights reserved.
> + Copyright (c) 2020 - 2023, ARM Limited. All rights reserved.
>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> @@ -53,4 +53,71 @@
> // https://github.com/OP-TEE/optee_os/blob/master/core/arch/arm/kernel/stmm_sp.c#L66
> #define ARM_FFA_DESTINATION_ENDPOINT_ID 3
>
> +/******************************************************************************
> + * Boot information protocol as per the FF-A v1.1 spec.
> + *****************************************************************************/
> +#define FFA_INIT_DESC_SIGNATURE 0x00000FFA
> +
> +/* Boot information type. */
> +#define FFA_BOOT_INFO_TYPE_STD 0x0U
> +#define FFA_BOOT_INFO_TYPE_IMPL 0x1U
> +
> +#define FFA_BOOT_INFO_TYPE_MASK 0x1U
> +#define FFA_BOOT_INFO_TYPE_SHIFT 0x7U
> +#define FFA_BOOT_INFO_TYPE(type) \
> + (((type) & FFA_BOOT_INFO_TYPE_MASK) \
> + << FFA_BOOT_INFO_TYPE_SHIFT)
> +
> +/* Boot information identifier. */
> +#define FFA_BOOT_INFO_TYPE_ID_FDT 0x0U
> +#define FFA_BOOT_INFO_TYPE_ID_HOB 0x1U
> +
> +#define FFA_BOOT_INFO_TYPE_ID_MASK 0x3FU
> +#define FFA_BOOT_INFO_TYPE_ID_SHIFT 0x0U
> +#define FFA_BOOT_INFO_TYPE_ID(type) \
> + (((type) & FFA_BOOT_INFO_TYPE_ID_MASK) \
> + << FFA_BOOT_INFO_TYPE_ID_SHIFT)
> +
> +/* Format of Flags Name field. */
> +#define FFA_BOOT_INFO_FLAG_NAME_STRING 0x0U
> +#define FFA_BOOT_INFO_FLAG_NAME_UUID 0x1U
> +
> +#define FFA_BOOT_INFO_FLAG_NAME_MASK 0x3U
> +#define FFA_BOOT_INFO_FLAG_NAME_SHIFT 0x0U
> +#define FFA_BOOT_INFO_FLAG_NAME(type) \
> + (((type) & FFA_BOOT_INFO_FLAG_NAME_MASK) \
> + << FFA_BOOT_INFO_FLAG_NAME_SHIFT)
> +
> +/* Format of Flags Contents field. */
> +#define FFA_BOOT_INFO_FLAG_CONTENT_ADR 0x0U
> +#define FFA_BOOT_INFO_FLAG_CONTENT_VAL 0x1U
> +
> +#define FFA_BOOT_INFO_FLAG_CONTENT_MASK 0x1U
> +#define FFA_BOOT_INFO_FLAG_CONTENT_SHIFT 0x2U
> +#define FFA_BOOT_INFO_FLAG_CONTENT(content) \
> + (((content) & FFA_BOOT_INFO_FLAG_CONTENT_MASK) \
> + << FFA_BOOT_INFO_FLAG_CONTENT_SHIFT)
> +
> +// Descriptor to pass boot information as per the FF-A v1.1 spec.
> +typedef struct {
> + UINT32 Name[4];
> + UINT8 Type;
> + UINT8 Reserved;
> + UINT16 Flags;
> + UINT32 SizeBotInfo;
> + UINT64 Content;
> +} EFI_FFA_BOOT_INFO_DESC;
> +
> +// Descriptor that contains boot info blobs size, number of desc it cointains
typo, should be "contains"
> +// size of each descriptor and offset to the first descriptor.
> +typedef struct {
> + UINT32 Magic; // 0xFFA^M
caught a copy paste "^M" here.
Thanks,
Oliver
> + UINT32 Version;
> + UINT32 SizeBootInfoBlob;
> + UINT32 SizeBootInfoDesc;
> + UINT32 CountBootInfoDesc;
> + UINT32 OffsetBootInfoDesc;
> + UINT64 Reserved;
> +} EFI_FFA_BOOT_INFO_HEADER;
> +
> #endif // ARM_FFA_SVC_H_
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH V1 06/20] ArmPkg: Add support for FFA_MEM_PERM_GET/SET ABIs
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 06/20] ArmPkg: Add support for FFA_MEM_PERM_GET/SET ABIs Nishant Sharma
@ 2023-07-12 17:43 ` Oliver Smith-Denny
0 siblings, 0 replies; 41+ messages in thread
From: Oliver Smith-Denny @ 2023-07-12 17:43 UTC (permalink / raw)
To: devel, nishant.sharma
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
On 7/11/2023 7:36 AM, Nishant Sharma wrote:
> From: Achin Gupta <achin.gupta@arm.com>
>
> This patch uses the FFA_MEM_PERM_GET/SET ABIs to tweak the permissions of a
> set of pages if FF-A v1.1 and above is supported by the SPMC. For FF-A v1.0
> the previous method through FFA_MSG_SEND_DIRECT_REQ/RESP is used.
>
> Signed-off-by: Achin Gupta <achin.gupta@arm.com>
> Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
> ---
> ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 2 +
> ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c | 132 +++++++++++++++++---
> 2 files changed, 120 insertions(+), 14 deletions(-)
>
> diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> index c80d783fad3f..7987678c996e 100644
> --- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> +++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> @@ -23,6 +23,8 @@
> #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH64 0xC4000070
> #define ARM_SVC_ID_FFA_SUCCESS_AARCH32 0x84000061
> #define ARM_SVC_ID_FFA_SUCCESS_AARCH64 0xC4000061
> +#define ARM_SVC_ID_FFA_MEM_PERM_SET_AARCH32 0x84000089
> +#define ARM_SVC_ID_FFA_MEM_PERM_GET_AARCH32 0x84000088
> #define ARM_SVC_ID_FFA_ERROR_AARCH32 0x84000060
> #define ARM_SVC_ID_FFA_ERROR_AARCH64 0xC4000060
> #define ARM_SVC_ID_FFA_MSG_WAIT_AARCH32 0x8400006B
> diff --git a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
> index 1a41a289ef17..76ef214bcb85 100644
> --- a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
> +++ b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
> @@ -25,6 +25,66 @@
> #include <Library/DebugLib.h>
> #include <Library/PcdLib.h>
>
> +
> +/**
> + Utility function to determine whether ABIs in FF-A v1.1 to set and get
> + memory permissions can be used. Ideally, this should be invoked once in the
> + library constructor and set a flag that can be used at runtime. However, the
> + StMM Core invokes this library before constructors are called and before the
> + StMM image itself is relocated.
> +
> + @retval EFI_SUCCESS The availability of ABIs was correctly determined.
> + @retval Other value Software stack is misconfigured.
> +
> +**/
> +STATIC
> +BOOLEAN
> +UseFfaMemPermAbis (
> + VOID
> + )
> +{
> + ARM_SVC_ARGS SvcArgs;
> + UINT32 SpmcFfaVersion;
> + STATIC UINT16 SpmcMajorVer = 0;
> + STATIC UINT16 SpmcMinorVer = 0;
> +
> + // Use prefetched version info. if either is not 0, then the version is
> + // already fetched.
> + if ((SpmcMajorVer | SpmcMinorVer) != 0) {
> + return (SpmcMajorVer == SPM_MAJOR_VERSION_FFA) && (SpmcMinorVer >= SPM_MINOR_VERSION_FFA);
> + }
> +
> + // Nothing to do if FF-A has not be enabled
nit: "been enabled"
> + if (FixedPcdGet32 (PcdFfaEnable) == 0) {
> + return FALSE;
> + }
> +
> + // Prepare the message parameters.
> + ZeroMem (&SvcArgs, sizeof (ARM_SVC_ARGS));
> + SvcArgs.Arg0 = ARM_SVC_ID_FFA_VERSION_AARCH32;
> + SvcArgs.Arg1 = FFA_VERSION_COMPILED;
> +
> + // Invoke the ABI
> + ArmCallSvc (&SvcArgs);
> +
> + // Check if FF-A is supported and what version
> + SpmcFfaVersion = SvcArgs.Arg0;
> +
> + // Damn! FF-A is not supported at all even though we specified v1.0 as our
> + // version. However, the feature flag has been turned on. This is a > + // misconfigured software stack. So, return an error and assert in
a debug build.
> + if (SpmcFfaVersion == ARM_FFA_SPM_RET_NOT_SUPPORTED) {
> + ASSERT (0);
It would be nice to either have the assert be self documenting
(ASSERT (SpmcFfaVersion == ARM_FFA_SPM_RET_NOT_SUPPORTED)) or
to add a print here.
> + return FALSE;
> + }
> +
> + SpmcMajorVer = (SpmcFfaVersion >> FFA_VERSION_MAJOR_SHIFT) & FFA_VERSION_MAJOR_MASK;
> + SpmcMinorVer = (SpmcFfaVersion >> FFA_VERSION_MINOR_SHIFT) & FFA_VERSION_MINOR_MASK;
> +
> + return (SpmcMajorVer == SPM_MAJOR_VERSION_FFA) && (SpmcMinorVer >= SPM_MINOR_VERSION_FFA);
> +}
> +
> +
> /** Send memory permission request to target.
>
> @param [in, out] SvcArgs Pointer to SVC arguments to send. On
> @@ -55,6 +115,36 @@ SendMemoryPermissionRequest (
>
> ArmCallSvc (SvcArgs);
> if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> +
> + // Check if FF-A memory permission ABIs were used.
> + if (UseFfaMemPermAbis()) {
> + switch (SvcArgs->Arg0) {
> +
> + case ARM_SVC_ID_FFA_ERROR_AARCH32:
> + case ARM_SVC_ID_FFA_ERROR_AARCH64:
> + switch (SvcArgs->Arg2) {
> + case ARM_FFA_SPM_RET_INVALID_PARAMETERS:
> + return EFI_INVALID_PARAMETER;
> + case ARM_FFA_SPM_RET_NOT_SUPPORTED:
> + return EFI_UNSUPPORTED;
> + default:
> + // Undefined error code received.
> + ASSERT (0);
For these two default cases, can we print out what
error code we received?
Thanks,
Oliver
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + case ARM_SVC_ID_FFA_SUCCESS_AARCH32:
> + case ARM_SVC_ID_FFA_SUCCESS_AARCH64:
> + *RetVal = SvcArgs->Arg2;
> + return EFI_SUCCESS;
> +
> + default:
> + // Undefined error code received.
> + ASSERT (0);
> + return EFI_INVALID_PARAMETER;
> + }
> + }
> +
> // Get/Set memory attributes is an atomic call, with
> // StandaloneMm at S-EL0 being the caller and the SPM
> // core being the callee. Thus there won't be a
> @@ -164,12 +254,18 @@ GetMemoryPermissions (
> // See [1], Section 13.5.5.1 MM_SP_MEMORY_ATTRIBUTES_GET_AARCH64.
> ZeroMem (&SvcArgs, sizeof (ARM_SVC_ARGS));
> if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> - // See [2], Section 10.2 FFA_MSG_SEND_DIRECT_REQ.
> - SvcArgs.Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ;
> - SvcArgs.Arg1 = ARM_FFA_DESTINATION_ENDPOINT_ID;
> - SvcArgs.Arg2 = 0;
> - SvcArgs.Arg3 = ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES;
> - SvcArgs.Arg4 = BaseAddress;
> + // Check if FF-A memory permission ABIs can be used.
> + if (UseFfaMemPermAbis()) {
> + SvcArgs.Arg0 = ARM_SVC_ID_FFA_MEM_PERM_GET_AARCH32;
> + SvcArgs.Arg1 = BaseAddress;
> + } else {
> + // See [2], Section 10.2 FFA_MSG_SEND_DIRECT_REQ.
> + SvcArgs.Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ;
> + SvcArgs.Arg1 = ARM_FFA_DESTINATION_ENDPOINT_ID;
> + SvcArgs.Arg2 = 0;
> + SvcArgs.Arg3 = ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES;
> + SvcArgs.Arg4 = BaseAddress;
> + }
> } else {
> SvcArgs.Arg0 = ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES;
> SvcArgs.Arg1 = BaseAddress;
> @@ -219,14 +315,22 @@ RequestMemoryPermissionChange (
> // See [1], Section 13.5.5.2 MM_SP_MEMORY_ATTRIBUTES_SET_AARCH64.
> ZeroMem (&SvcArgs, sizeof (ARM_SVC_ARGS));
> if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> - // See [2], Section 10.2 FFA_MSG_SEND_DIRECT_REQ.
> - SvcArgs.Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ;
> - SvcArgs.Arg1 = ARM_FFA_DESTINATION_ENDPOINT_ID;
> - SvcArgs.Arg2 = 0;
> - SvcArgs.Arg3 = ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES;
> - SvcArgs.Arg4 = BaseAddress;
> - SvcArgs.Arg5 = EFI_SIZE_TO_PAGES (Length);
> - SvcArgs.Arg6 = Permissions;
> + // Check if FF-A memory permission ABIs can be used.
> + if (UseFfaMemPermAbis()) {
> + SvcArgs.Arg0 = ARM_SVC_ID_FFA_MEM_PERM_SET_AARCH32;
> + SvcArgs.Arg1 = BaseAddress;
> + SvcArgs.Arg2 = EFI_SIZE_TO_PAGES (Length);
> + SvcArgs.Arg3 = Permissions;
> + } else {
> + // See [2], Section 10.2 FFA_MSG_SEND_DIRECT_REQ.
> + SvcArgs.Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ;
> + SvcArgs.Arg1 = ARM_FFA_DESTINATION_ENDPOINT_ID;
> + SvcArgs.Arg2 = 0;
> + SvcArgs.Arg3 = ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES;
> + SvcArgs.Arg4 = BaseAddress;
> + SvcArgs.Arg5 = EFI_SIZE_TO_PAGES (Length);
> + SvcArgs.Arg6 = Permissions;
> + }
> } else {
> SvcArgs.Arg0 = ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES;
> SvcArgs.Arg1 = BaseAddress;
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH V1 02/20] StandaloneMmPkg: Allocate and initialise SP stack from internal memory
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 02/20] StandaloneMmPkg: Allocate and initialise SP stack from internal memory Nishant Sharma
@ 2023-07-12 17:47 ` Chris Fernald
0 siblings, 0 replies; 41+ messages in thread
From: Chris Fernald @ 2023-07-12 17:47 UTC (permalink / raw)
To: devel, nishant.sharma
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
Would it be possible to make the stack size configurable in a way that
doesn't require an silicon/platform vendor to customize the assembly
code? Perhaps through a fixed PCD if its not problematic to do so with
the .space directive.
Thanks,
Chris
On 7/11/2023 7:36 AM, Nishant Sharma wrote:
> From: Achin Gupta <achin.gupta@arm.com>
>
> This patch removes the dependency on the SPM to allocate and initialise
> stack memory for the StMM SP. This is done by reserving 8K worth of memory
> in the StMM image at a page aligned address in the data section. Then,
> instead of jumping directly to the C entrypoint, an assembler entrypoint is
> invoked. This entrypoint locates the stack memory, changes its permissions
> using FF-A ABIs, sets the stack pointer and invokes the C entrypoint.
>
> Signed-off-by: Achin Gupta <achin.gupta@arm.com>
> Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
> ---
> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf | 1 +
> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c | 2 +-
> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/AArch64/ModuleEntryPoint.S | 68 ++++++++++++++++++++
> 3 files changed, 70 insertions(+), 1 deletion(-)
>
> diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
> index dc6d3d859911..10fafa43ce59 100644
> --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
> +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
> @@ -25,6 +25,7 @@
> Arm/StandaloneMmCoreEntryPoint.c
> Arm/SetPermissions.c
> Arm/CreateHobList.c
> + Arm/AArch64/ModuleEntryPoint.S
>
> [Sources.X64]
> X64/StandaloneMmCoreEntryPoint.c
> diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
> index 5dd1d9747995..ce867fe85158 100644
> --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
> +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
> @@ -316,7 +316,7 @@ InitArmSvcArgs (
> **/
> VOID
> EFIAPI
> -_ModuleEntryPoint (
> +ModuleEntryPoint (
> IN VOID *SharedBufAddress,
> IN UINT64 SharedBufSize,
> IN UINT64 cookie1,
> diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/AArch64/ModuleEntryPoint.S b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/AArch64/ModuleEntryPoint.S
> new file mode 100644
> index 000000000000..174bc83ebd64
> --- /dev/null
> +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/AArch64/ModuleEntryPoint.S
> @@ -0,0 +1,68 @@
> +//
> +// Copyright (c) 2023, ARM Limited. All rights reserved.
> +//
> +// SPDX-License-Identifier: BSD-2-Clause-Patent
> +//
> +//
> +
> +#include <AsmMacroIoLibV8.h>
> +
> +#define FFA_DATA_RW 0x1
> +
> +.align 12
> +StackBase:
> +.space 8192
> +StackEnd:
> +
> +.macro FfaMemPermSet start:req end:req perm:req
> +adrp x29, \start
> +add x29, x29, :lo12: \start
> +
> +adrp x30, \end
> +add x30, x30, :lo12:\end
> +
> +/* x30 = end - begin */
> +sub x30, x30, x29
> +/* x28 = x30 >> 12 (number of pages) */
> +mov x28, #12
> +lsrv x28, x30, x28
> +
> +mov w0, #0x89
> +movk w0, #0x8400, lsl #16
> +mov x1, x29
> +mov x2, x28
> +mov w3, #\perm
> +
> +svc #0
> +
> +mov w1, #0x61
> +movk w1, #0x8400, lsl #16
> +cmp w1, w0
> +b.ne .
> +.endm
> +
> + ASM_FUNC(_ModuleEntryPoint)
> +MOV32 (w8, FixedPcdGet32(PcdFfaEnable))
> + cbz w8, FfaNotEnabled
> + // Stash boot information registers from the SPMC
> + mov x8, x0
> + mov x9, x1
> + mov x10, x2
> + mov x11, x3
> +
> + // Set the correct permissions on stack memory
> + FfaMemPermSet StackBase StackEnd FFA_DATA_RW
> +
> + // Initialise SP
> + adr x0, StackEnd
> + mov sp, x0
> +
> + // Restore boot information registers from the SPMC
> + mov x0, x8
> + mov x1, x9
> + mov x2, x10
> + mov x3, x11
> +
> + // Invoke the C entrypoint
> + FfaNotEnabled:
> + b ModuleEntryPoint
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH V1 08/20] StandaloneMmPkg: Add backwards compatible support to detect FF-A v1.1
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 08/20] StandaloneMmPkg: Add backwards compatible support to detect FF-A v1.1 Nishant Sharma
@ 2023-07-12 20:31 ` Oliver Smith-Denny
0 siblings, 0 replies; 41+ messages in thread
From: Oliver Smith-Denny @ 2023-07-12 20:31 UTC (permalink / raw)
To: devel, nishant.sharma
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
On 7/11/2023 7:36 AM, Nishant Sharma wrote:
> From: Achin Gupta <achin.gupta@arm.com>
>
> For better or worse, an StMM SP can communicate with the SPM through one
> of these interfaces.
>
> 1. SPM_MM interface
> 2. FF-A v1.0 interface
> 3. FF-A v1.1 interface
>
> 2) implements only minimal FF-A support. It reuses the initialisation ABI
> defined by 1) and wraps the remaining communicaton in
> FFA_MSG_SEND_DIRECT_REQ/RESP ABIs.
> 3) uses FF-A ABIs from the spec for both initialisation and communication.
>
> Detecting these variations in the GetSpmVersion() function is tedious. This
> patch restores the original function that discovered configuration
> 1). It defines a new function to discover presence of FF-A and
> differentiate between v1.0 and v1.1.
>
> Signed-off-by: Achin Gupta <achin.gupta@arm.com>
> Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
> ---
> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c | 132 +++++++++++++-------
> 1 file changed, 87 insertions(+), 45 deletions(-)
>
> diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
> index 682b55b5478a..9f6af55c86c4 100644
> --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
> +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
> @@ -32,13 +32,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> #define SPM_MAJOR_VER_MASK 0xFFFF0000
> #define SPM_MINOR_VER_MASK 0x0000FFFF
> #define SPM_MAJOR_VER_SHIFT 16
> -#define FFA_NOT_SUPPORTED -1
>
> -STATIC CONST UINT32 mSpmMajorVer = SPM_MAJOR_VERSION;
> -STATIC CONST UINT32 mSpmMinorVer = SPM_MINOR_VERSION;
> -
> -STATIC CONST UINT32 mSpmMajorVerFfa = SPM_MAJOR_VERSION_FFA;
> -STATIC CONST UINT32 mSpmMinorVerFfa = SPM_MINOR_VERSION_FFA;
> +#define SPM_MAJOR_VER 0
> +#define SPM_MINOR_VER 1
>
> #define BOOT_PAYLOAD_VERSION 1
>
> @@ -110,6 +106,70 @@ GetAndPrintBootinformation (
> }
>
> return PayloadBootInfo;
> +
> +/**
> + An StMM SP implements partial support for FF-A v1.0. The FF-A ABIs are used to
> + get and set permissions of memory pages in collaboration with the SPMC and
> + signalling completion of initialisation. The original Arm MM communication
> + interface is used for communication with the Normal world. A TF-A specific
> + interface is used for initialising the SP.
> +
> + With FF-A v1.1, the StMM SP uses only FF-A ABIs for initialisation and
> + communication. This is subject to support for FF-A v1.1 in the SPMC. If this
> + is not the case, the StMM implementation reverts to the FF-A v1.0
> + behaviour. Any of this is applicable only if the feature flag PcdFfaEnable is
> + TRUE.
This should now be if the FixedAtBuild PcdFfaEnable is 1.
Thanks,
Oliver
> +
> + This function helps the caller determine whether FF-A v1.1 or v1.0 are
> + available and if only FF-A ABIs can be used at runtime.
> +**/
> +STATIC
> +EFI_STATUS
> +CheckFfaCompatibility (BOOLEAN *UseOnlyFfaAbis)
> +{
> + UINT16 SpmcMajorVer;
> + UINT16 SpmcMinorVer;
> + UINT32 SpmcVersion;
> + ARM_SVC_ARGS SpmcVersionArgs = {0};
> +
> + // Sanity check in case of a spurious call.
> + if (FixedPcdGet32 (PcdFfaEnable) == 0) {
> + return EFI_UNSUPPORTED;
> + }
> +
> + // Send the SPMC our version to see whether it supports the same or not.
> + SpmcVersionArgs.Arg0 = ARM_SVC_ID_FFA_VERSION_AARCH32;
> + SpmcVersionArgs.Arg1 = FFA_VERSION_COMPILED;
> +
> + ArmCallSvc (&SpmcVersionArgs);
> + SpmcVersion = SpmcVersionArgs.Arg0;
> +
> + // If the SPMC barfs then bail.
> + if (SpmcVersion == ARM_FFA_SPM_RET_NOT_SUPPORTED) {
> + return EFI_UNSUPPORTED;
> + }
> +
> + // Extract the SPMC version
> + SpmcMajorVer = (SpmcVersion >> FFA_VERSION_MAJOR_SHIFT) & FFA_VERSION_MAJOR_MASK;
> + SpmcMinorVer = (SpmcVersion >> FFA_VERSION_MINOR_SHIFT) & FFA_VERSION_MINOR_MASK;
> +
> + // If the major versions differ then all bets are off.
> + if (SpmcMajorVer != SPM_MAJOR_VERSION_FFA) {
> + return EFI_UNSUPPORTED;
> + }
> +
> + // We advertised v1.1 as our version. If the SPMC supports it, it must return
> + // the same or a compatible version. If it does not then FF-A ABIs cannot be
> + // used for all communication.
> + if (SpmcMinorVer >= SPM_MINOR_VERSION_FFA) {
> + *UseOnlyFfaAbis = TRUE;
> + } else {
> + *UseOnlyFfaAbis = FALSE;
> + }
> +
> + // We have validated that there is a compatible FF-A
> + // implementation. So. return success.
> + return EFI_SUCCESS;
> }
>
> /**
> @@ -219,34 +279,19 @@ GetSpmVersion (
> )
> {
> EFI_STATUS Status;
> - UINT16 CalleeSpmMajorVer;
> - UINT16 CallerSpmMajorVer;
> - UINT16 CalleeSpmMinorVer;
> - UINT16 CallerSpmMinorVer;
> + UINT16 SpmMajorVersion;
> + UINT16 SpmMinorVersion;
> UINT32 SpmVersion;
> ARM_SVC_ARGS SpmVersionArgs;
>
> - if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> - SpmVersionArgs.Arg0 = ARM_SVC_ID_FFA_VERSION_AARCH32;
> - SpmVersionArgs.Arg1 = mSpmMajorVerFfa << SPM_MAJOR_VER_SHIFT;
> - SpmVersionArgs.Arg1 |= mSpmMinorVerFfa;
> - CallerSpmMajorVer = mSpmMajorVerFfa;
> - CallerSpmMinorVer = mSpmMinorVerFfa;
> - } else {
> - SpmVersionArgs.Arg0 = ARM_SVC_ID_SPM_VERSION_AARCH32;
> - CallerSpmMajorVer = mSpmMajorVer;
> - CallerSpmMinorVer = mSpmMinorVer;
> - }
> + SpmVersionArgs.Arg0 = ARM_SVC_ID_SPM_VERSION_AARCH32;
>
> ArmCallSvc (&SpmVersionArgs);
>
> SpmVersion = SpmVersionArgs.Arg0;
> - if (SpmVersion == FFA_NOT_SUPPORTED) {
> - return EFI_UNSUPPORTED;
> - }
>
> - CalleeSpmMajorVer = ((SpmVersion & SPM_MAJOR_VER_MASK) >> SPM_MAJOR_VER_SHIFT);
> - CalleeSpmMinorVer = ((SpmVersion & SPM_MINOR_VER_MASK) >> 0);
> + SpmMajorVersion = ((SpmVersion & SPM_MAJOR_VER_MASK) >> SPM_MAJOR_VER_SHIFT);
> + SpmMinorVersion = ((SpmVersion & SPM_MINOR_VER_MASK) >> 0);
>
> // Different major revision values indicate possibly incompatible functions.
> // For two revisions, A and B, for which the major revision values are
> @@ -255,25 +300,17 @@ GetSpmVersion (
> // revision A must work in a compatible way with revision B.
> // However, it is possible for revision B to have a higher
> // function count than revision A.
> - if ((CalleeSpmMajorVer == CallerSpmMajorVer) &&
> - (CalleeSpmMinorVer >= CallerSpmMinorVer))
> - {
> - DEBUG ((
> - DEBUG_INFO,
> - "SPM Version: Major=0x%x, Minor=0x%x\n",
> - CalleeSpmMajorVer,
> - CalleeSpmMinorVer
> - ));
> + if ((SpmMajorVersion == SPM_MAJOR_VER) &&
> + (SpmMinorVersion >= SPM_MINOR_VER)) {
> + DEBUG ((DEBUG_INFO, "SPM Version: Major=0x%x, Minor=0x%x\n",
> + SpmMajorVersion, SpmMinorVersion));
> Status = EFI_SUCCESS;
> } else {
> - DEBUG ((
> - DEBUG_INFO,
> - "Incompatible SPM Versions.\n Callee Version: Major=0x%x, Minor=0x%x.\n Caller: Major=0x%x, Minor>=0x%x.\n",
> - CalleeSpmMajorVer,
> - CalleeSpmMinorVer,
> - CallerSpmMajorVer,
> - CallerSpmMinorVer
> - ));
> + DEBUG ((DEBUG_INFO, "Incompatible SPM Versions.\n"));
> + DEBUG ((DEBUG_INFO, "Current Version: Major=0x%x, Minor=0x%x.\n",
> + SpmMajorVersion, SpmMinorVersion));
> + DEBUG ((DEBUG_INFO, "Expected: Major=0x%x, Minor>=0x%x.\n",
> + SPM_MAJOR_VER, SPM_MINOR_VER));
> Status = EFI_UNSUPPORTED;
> }
>
> @@ -335,9 +372,14 @@ ModuleEntryPoint (
> VOID *TeData;
> UINTN TeDataSize;
> EFI_PHYSICAL_ADDRESS ImageBase;
> + BOOLEAN UseOnlyFfaAbis = FALSE;
>
> - // Get Secure Partition Manager Version Information
> - Status = GetSpmVersion ();
> + if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> + Status = CheckFfaCompatibility (&UseOnlyFfaAbis);
> + } else {
> + // Get Secure Partition Manager Version Information
> + Status = GetSpmVersion ();
> + }
> if (EFI_ERROR (Status)) {
> goto finish;
> }
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH V1 10/20] StandaloneMmPkg: Populate Hoblist for SP init from StMM boot information
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 10/20] StandaloneMmPkg: Populate Hoblist for SP init from StMM " Nishant Sharma
@ 2023-07-12 20:52 ` Oliver Smith-Denny
0 siblings, 0 replies; 41+ messages in thread
From: Oliver Smith-Denny @ 2023-07-12 20:52 UTC (permalink / raw)
To: devel, nishant.sharma
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
On 7/11/2023 7:36 AM, Nishant Sharma wrote:
> From: Achin Gupta <achin.gupta@arm.com>
>
> This patch adds support for creating a hoblist from the reduced boot
> information retrieved from the SP manifest.
>
> Signed-off-by: Achin Gupta <achin.gupta@arm.com>
> Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
> ---
> StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h | 16 ++
> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c | 186 +++++++++++++++++++-
> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c | 6 +-
> 3 files changed, 206 insertions(+), 2 deletions(-)
>
> diff --git a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h
> index 90d67a2f25b5..9daa76324221 100644
> --- a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h
> +++ b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h
> @@ -170,6 +170,22 @@ CreateHobListFromBootInfo (
> IN EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo
> );
>
> +/**
> + Use the boot information passed by the SPMC to populate a HOB list
> + suitable for consumption by the MM Core and drivers.
> +
> + @param [in, out] CpuDriverEntryPoint Address of MM CPU driver entrypoint
> + @param [in] StmmBootInfo Boot information passed by privileged
> + firmware
> +
> +**/
> +VOID *
> +EFIAPI
> +CreateHobListFromStmmBootInfo (
> + IN OUT PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT *CpuDriverEntryPoint,
> + IN EFI_STMM_BOOT_INFO *StmmBootInfo
> + );
> +
> /**
> The entry point of Standalone MM Foundation.
>
> diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c
> index 2ac2d354f06a..4592089a6020 100644
> --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c
> +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c
> @@ -2,7 +2,7 @@
> Creates HOB during Standalone MM Foundation entry point
> on ARM platforms.
>
> -Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.<BR>
> +Copyright (c) 2017 - 2023, Arm Ltd. All rights reserved.<BR>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> **/
> @@ -203,3 +203,187 @@ CreateHobListFromBootInfo (
>
> return HobStart;
> }
> +
> +STATIC
> +VOID
> +CreateMmramInformationHobFromImageLayout (
> + IN EFI_STMM_BOOT_INFO *StmmBootInfo,
> + IN EFI_HOB_HANDOFF_INFO_TABLE *HobStart
> +)
> +{
> + UINT32 *Idx;
> + UINT32 BufferSize;
> + EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *MmramRangesHob;
> + EFI_MMRAM_DESCRIPTOR *MmramRanges;
> +
> + // Find the size of the GUIDed HOB with SRAM ranges. This excludes any memory
> + // shared with the normal world or the SPMC. It includes the memory allocated
> + // to the SP image, used and unused heap.
> + BufferSize = sizeof (EFI_MMRAM_HOB_DESCRIPTOR_BLOCK);
> + BufferSize += 4 * sizeof (EFI_MMRAM_DESCRIPTOR);
> +
> + // Create a GUIDed HOB with SRAM ranges
> + MmramRangesHob = BuildGuidHob (&gEfiMmPeiMmramMemoryReserveGuid, BufferSize);
> +
BuildGuidHob can return NULL, we should check MmramRangesHob before
using it. Same for the other cases below.
> + // Initialise the number of MMRAM memory regions
> + MmramRangesHob->NumberOfMmReservedRegions = 0;
> + Idx = &MmramRangesHob->NumberOfMmReservedRegions ;
> +
> + // Fill up the MMRAM ranges
> + MmramRanges = &MmramRangesHob->Descriptor[0];
> +
> + // Base and size of memory occupied by the Standalone MM image
> + MmramRanges[*Idx].PhysicalStart = StmmBootInfo->SpMemBase;
> + MmramRanges[*Idx].CpuStart = StmmBootInfo->SpMemBase;
> + MmramRanges[*Idx].PhysicalSize = StmmBootInfo->SpMemSize;
> + MmramRanges[*Idx].RegionState = EFI_CACHEABLE | EFI_ALLOCATED;
> + (*Idx)++;
> +
> + // Base and size of memory occupied by the Standalone MM image
> + MmramRanges[*Idx].PhysicalStart = StmmBootInfo->SpSharedBufBase;
> + MmramRanges[*Idx].CpuStart = StmmBootInfo->SpSharedBufBase;
> + MmramRanges[*Idx].PhysicalSize = StmmBootInfo->SpSharedBufSize;
> + MmramRanges[*Idx].RegionState = EFI_CACHEABLE | EFI_ALLOCATED;
> + (*Idx)++;
> +
> + // Base and size of memory occupied by the hoblist
> + MmramRanges[*Idx].PhysicalStart = (EFI_PHYSICAL_ADDRESS) (UINTN) HobStart;
> + MmramRanges[*Idx].CpuStart = (EFI_PHYSICAL_ADDRESS) (UINTN) HobStart;
> + MmramRanges[*Idx].PhysicalSize = HobStart->EfiFreeMemoryBottom - (EFI_PHYSICAL_ADDRESS) (UINTN) HobStart;
> + MmramRanges[*Idx].RegionState = EFI_CACHEABLE | EFI_ALLOCATED;
> + (*Idx)++;
> +
> + // Base and size of heap memory shared by all cpus
> + MmramRanges[*Idx].PhysicalStart = HobStart->EfiFreeMemoryBottom;
> + MmramRanges[*Idx].CpuStart = HobStart->EfiFreeMemoryBottom;
> + MmramRanges[*Idx].PhysicalSize = HobStart->EfiFreeMemoryTop - HobStart->EfiFreeMemoryBottom;
> + MmramRanges[*Idx].RegionState = EFI_CACHEABLE;
> + (*Idx)++;
> +
> + // Sanity check number of MMRAM regions
> + ASSERT (MmramRangesHob->NumberOfMmReservedRegions == 3);
> +
> + return;
> +}
> +
> +STATIC
> +VOID
> +CreateMpInformationHobFromCpuInfo (
> + IN EFI_SECURE_PARTITION_CPU_INFO *CpuInfo
> +)
> +{
> + MP_INFORMATION_HOB_DATA *MpInformationHobData;
> + EFI_PROCESSOR_INFORMATION *ProcInfoBuffer;
> + UINT32 BufferSize;
> + UINT32 Flags;
> +
> + // Find the size of the GUIDed HOB with MP information
> + BufferSize = sizeof (MP_INFORMATION_HOB_DATA);
> + BufferSize += sizeof (EFI_PROCESSOR_INFORMATION);
> +
> + // Create a Guided MP information HOB to enable the ARM TF CPU driver to
> + // perform per-cpu allocations.
> + MpInformationHobData = BuildGuidHob (&gMpInformationHobGuid, BufferSize);
> +
> + // Populate the MP information HOB under the assumption that this is a
> + // uniprocessor partition. Hence, only a single CPU is exposed to the MM Core.
> + MpInformationHobData->NumberOfProcessors = 1;
> + MpInformationHobData->NumberOfEnabledProcessors = 1;
> +
> + // Populate the processor information
> + ProcInfoBuffer = MpInformationHobData->ProcessorInfoBuffer;
> + ProcInfoBuffer[0].ProcessorId = CpuInfo[0].Mpidr;
> + ProcInfoBuffer[0].Location.Package = GET_CLUSTER_ID(CpuInfo[0].Mpidr);
> + ProcInfoBuffer[0].Location.Core = GET_CORE_ID(CpuInfo[0].Mpidr);
> + ProcInfoBuffer[0].Location.Thread = GET_CORE_ID(CpuInfo[0].Mpidr);
> +
> + // Populate the processor information flags
> + Flags = PROCESSOR_ENABLED_BIT | PROCESSOR_HEALTH_STATUS_BIT | PROCESSOR_AS_BSP_BIT;
> + ProcInfoBuffer[0].StatusFlag = Flags;
> +
> + return;
> +}
> +
> +/**
> + Use the FF-A boot information passed by the SPMC to populate a HOB list
> + suitable for consumption by the MM Core and drivers.
> +
> + @param [in, out] CpuDriverEntryPoint Address of MM CPU driver entrypoint
> + @param [in] StmmBootInfo Boot information passed by the SPMC
> +
> +**/
> +VOID *
> +CreateHobListFromStmmBootInfo (
> + IN OUT PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT *CpuDriverEntryPoint,
> + IN EFI_STMM_BOOT_INFO *StmmBootInfo
> +)
> +{
> + EFI_HOB_HANDOFF_INFO_TABLE *HobStart;
> + EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;
> + EFI_MMRAM_DESCRIPTOR *NsCommBufMmramRange;
> + ARM_TF_CPU_DRIVER_EP_DESCRIPTOR *CpuDriverEntryPointDesc;
> +
> + // Create a hoblist with a PHIT and EOH
> + HobStart = HobConstructor (
> + (VOID *) (UINTN) StmmBootInfo->SpMemBase,
> + (UINTN) StmmBootInfo->SpMemSize,
> + (VOID *) (UINTN) StmmBootInfo->SpHeapBase,
> + (VOID *) (UINTN) (StmmBootInfo->SpHeapBase + StmmBootInfo->SpHeapSize)
> + );
> +
> + // Check that the Hoblist starts at the bottom of the Heap
> + ASSERT (HobStart == (VOID *) (UINTN) StmmBootInfo->SpHeapBase);
> +
> + // Build a Boot Firmware Volume HOB
> + BuildFvHob (StmmBootInfo->SpMemBase, StmmBootInfo->SpMemSize);
> +
> + // Build a resource descriptor Hob that describes the available physical
> + // memory range
> + Attributes = (
> + EFI_RESOURCE_ATTRIBUTE_PRESENT |
> + EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
> + EFI_RESOURCE_ATTRIBUTE_TESTED |
> + EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
> + EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
> + EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
> + EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
> + );
Should we also put EFI_RESOURCE_ATTRIBUTE_READ_PROTECTABLE,
EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTABLE, and
EFI_RESOURCE_ATTRIBUTE_READ_ONLY_PROTECTABLE, too, so that
in the future we can add these memory protections in StMM?
Thanks,
Oliver
> +
> + BuildResourceDescriptorHob (
> + EFI_RESOURCE_SYSTEM_MEMORY,
> + Attributes,
> + (UINTN) StmmBootInfo->SpMemBase,
> + StmmBootInfo->SpMemSize
> + );
> +
> + // Create an MP information hob from cpu information passed in the boot
> + // information structure
> + CreateMpInformationHobFromCpuInfo(&StmmBootInfo->CpuInfo);
> +
> + // Create a Guided HOB to tell the ARM TF CPU driver the location and length
> + // of the communication buffer shared with the Normal world.
> + NsCommBufMmramRange = (EFI_MMRAM_DESCRIPTOR *) BuildGuidHob (
> + &gEfiStandaloneMmNonSecureBufferGuid,
> + sizeof (EFI_MMRAM_DESCRIPTOR)
> + );
> + NsCommBufMmramRange->PhysicalStart = StmmBootInfo->SpNsCommBufBase;
> + NsCommBufMmramRange->CpuStart = StmmBootInfo->SpNsCommBufBase;
> + NsCommBufMmramRange->PhysicalSize = StmmBootInfo->SpNsCommBufSize;
> + NsCommBufMmramRange->RegionState = EFI_CACHEABLE | EFI_ALLOCATED;
> +
> + // Create a Guided HOB to enable the ARM TF CPU driver to share its entry
> + // point and populate it with the address of the shared buffer
> + CpuDriverEntryPointDesc =
> + (ARM_TF_CPU_DRIVER_EP_DESCRIPTOR *) BuildGuidHob (
> + &gEfiArmTfCpuDriverEpDescriptorGuid,
> + sizeof (ARM_TF_CPU_DRIVER_EP_DESCRIPTOR)
> + );
> +
> + *CpuDriverEntryPoint = NULL;
> + CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr = CpuDriverEntryPoint;
> +
> + // Create Mmram range hob from SP image layout
> + CreateMmramInformationHobFromImageLayout(StmmBootInfo, HobStart);
> +
> + return HobStart;
> +}
> diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
> index 505786aff07c..8131b1984969 100644
> --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
> +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
> @@ -823,7 +823,11 @@ ModuleEntryPoint (
> //
> // Create Hoblist based upon boot information passed by privileged software
> //
> - HobStart = CreateHobListFromBootInfo (&CpuDriverEntryPoint, PayloadBootInfo);
> + if (UseOnlyFfaAbis) {
> + HobStart = CreateHobListFromStmmBootInfo (&CpuDriverEntryPoint, &StmmBootInfo);
> + } else {
> + HobStart = CreateHobListFromBootInfo (&CpuDriverEntryPoint, PayloadBootInfo);
> + }
>
> //
> // Call the MM Core entry point
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH V1 17/20] ArmPkg/MmCommunicationDxe: Unmap FF-A RX/TX buffers during ExitBootServices
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 17/20] ArmPkg/MmCommunicationDxe: Unmap FF-A RX/TX buffers during ExitBootServices Nishant Sharma
@ 2023-07-12 20:59 ` Oliver Smith-Denny
0 siblings, 0 replies; 41+ messages in thread
From: Oliver Smith-Denny @ 2023-07-12 20:59 UTC (permalink / raw)
To: devel, nishant.sharma
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
On 7/11/2023 7:36 AM, Nishant Sharma wrote:
> From: Achin Gupta <achin.gupta@arm.com>
>
> An FF-A partition can map only a single RX/TX buffer pair with the
> framework. The DXE MM communication driver maps its pair before
> ExitBootServices is called. The OS cannot re-use this pair once it boots
> subsequently and loads its own FF-A driver. This patch ensures that the
> DXE MM communication driver unmaps its buffer pair when ExitBootServices
> is called so that the OS can register its own pair if required.
>
> Signed-off-by: Achin Gupta <achin.gupta@arm.com>
> Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
> ---
> ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 10 ++++
> ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 49 ++++++++++++++++++++
> 2 files changed, 59 insertions(+)
>
> diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> index ebdf29e8d69a..f78442a465e1 100644
> --- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> +++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> @@ -122,6 +122,16 @@
> (((content) & FFA_BOOT_INFO_FLAG_CONTENT_MASK) \
> << FFA_BOOT_INFO_FLAG_CONTENT_SHIFT)
>
> +/* Fromat SP ID info. */
> +#define FFA_PARTITION_ID_SHIFT 16
> +#define FFA_PARTITION_ID_WIDTH 16
> +#define FFA_PARTITION_ID_MASK \
> + (((1U << FFA_PARTITION_ID_WIDTH) - 1) \
> + << FFA_PARTITION_ID_SHIFT)
> +#define FFA_PARTITION_ID(partid) \
> + ((partid << FFA_PARTITION_ID_SHIFT) & \
> + FFA_PARTITION_ID_MASK)
> +
> // Descriptor to pass boot information as per the FF-A v1.1 spec.
> typedef struct {
> UINT32 Name[4];
> diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> index 8a4d46e4f80a..39a1b329b9ea 100644
> --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> @@ -43,6 +43,9 @@ STATIC ARM_MEMORY_REGION_DESCRIPTOR mNsCommBuffMemRegion;
> // Notification event when virtual address map is set.
> STATIC EFI_EVENT mSetVirtualAddressMapEvent;
>
> +// Notification event when exit boot services is called.
> +STATIC EFI_EVENT mExitBootServicesEvent;
> +
> //
> // Handle to install the MM Communication Protocol
> //
> @@ -255,6 +258,39 @@ NotifySetVirtualAddressMap (
> }
> }
>
> +/**
> + Notification callback on ExitBootServices event.
> +
> + This function notifies the MM communication protocol interface on
> + ExitBootServices event and releases the FF-A RX/TX buffer.
> +
> + @param Event ExitBootServices event.
> + @param Context A context when the ExitBootServices triggered.
> +
> + @retval EFI_SUCCESS The function executed successfully.
> + @retval Other Some error occurred when executing this function.
> +
> +**/
> +STATIC
> +VOID
> +EFIAPI
> +NotifyExitBootServices (
> + IN EFI_EVENT Event,
> + IN VOID *Context
> + )
> +{
> + ARM_SMC_ARGS SmcArgs = {0};
> +
> + SmcArgs.Arg0 = ARM_SVC_ID_FFA_RXTX_UNMAP_AARCH32;
If I am reading this correctly, this SVC macro does not
get added until patch 18. We need it here, otherwise
bisecting to this commit will have a build break, right?
Thanks,
Oliver
> + SmcArgs.Arg1 = FFA_PARTITION_ID(mFfaPartId);
> + ArmCallSmc (&SmcArgs);
> +
> + // We do not bother checking the error code of the RXTX_UNMAP invocation
> + // since we did map the buffers and this call must succeed.
> + return;
> +
> +}
> +
> STATIC
> EFI_STATUS
> GetMmCompatibility (
> @@ -452,6 +488,19 @@ MmCommunication2Initialize (
> goto CleanAddedMemorySpace;
> }
>
> + // Register notification callback when ExitBootservices is called to
> + // unregister the FF-A RX/TX buffer pair. This allows the OS to register its
> + // own buffer pair.
> + if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> + Status = gBS->CreateEvent (
> + EVT_SIGNAL_EXIT_BOOT_SERVICES,
> + TPL_NOTIFY,
> + NotifyExitBootServices,
> + NULL,
> + &mExitBootServicesEvent
> + );
> + ASSERT_EFI_ERROR (Status);
> + }
> // Register notification callback when virtual address is associated
> // with the physical address.
> // Create a Set Virtual Address Map event.
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH V1 18/20] ArmPkg/MmCommunicationDxe: Discover the StMM SP
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 18/20] ArmPkg/MmCommunicationDxe: Discover the StMM SP Nishant Sharma
@ 2023-07-12 21:10 ` Oliver Smith-Denny
2023-07-12 21:48 ` Girish Mahadevan
2023-07-13 17:16 ` Chris Fernald
2 siblings, 0 replies; 41+ messages in thread
From: Oliver Smith-Denny @ 2023-07-12 21:10 UTC (permalink / raw)
To: devel, nishant.sharma
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
On 7/11/2023 7:36 AM, Nishant Sharma wrote:
> From: Achin Gupta <achin.gupta@arm.com>
>
> This patch adds support for discovering the presence of the SP using the
> EFI_MM_COMMUNICATION_PROTOCOL GUID that implements Standalone MM
> drivers. This is done by querying the framework through
> FFA_PARTITION_INFO_GET whether any partition that implements the
> EFI_MM_COMMUNICATION_PROTOCOL is present or not. The partition ID and
> its properties are stashed for use in subsequent communication with the
> StMM SP.
>
> Signed-off-by: Achin Gupta <achin.gupta@arm.com>
> Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
> ---
> ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 24 +++++
> ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 93 +++++++++++++++++++-
> 2 files changed, 114 insertions(+), 3 deletions(-)
>
> diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> index f78442a465e1..530af8bd3c2e 100644
> --- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> +++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> @@ -19,6 +19,9 @@
> #define ARM_SVC_ID_FFA_VERSION_AARCH32 0x84000063
> #define ARM_SVC_ID_FFA_RXTX_MAP_AARCH32 0x84000066
> #define ARM_SVC_ID_FFA_RXTX_MAP_AARCH64 0xC4000066
> +#define ARM_SVC_ID_FFA_RX_RELEASE_AARCH32 0x84000065
> +#define ARM_SVC_ID_FFA_RXTX_UNMAP_AARCH32 0x84000067
> +#define ARM_SVC_ID_FFA_PARTITION_INFO_GET_AARCH32 0x84000068
> #define ARM_SVC_ID_FFA_ID_GET_AARCH32 0x84000069
> #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH32 0x8400006F
> #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH32 0x84000070
> @@ -154,4 +157,25 @@ typedef struct {
> UINT64 Reserved;
> } EFI_FFA_BOOT_INFO_HEADER;
>
> +// FF-A partition information descriptor
> +typedef struct {
> + UINT16 PartId;
> + UINT16 EcCnt;
> + UINT32 PartProps;
> + UINT32 PartGuid[4];
> +} EFI_FFA_PART_INFO_DESC;
> +
> +#define PART_INFO_PROP_MASK 0x3f
> +#define PART_INFO_PROP_SHIFT 0
> +#define PART_INFO_PROP_DIR_MSG_RECV_BIT (1u << 0)
> +#define PART_INFO_PROP_DIR_MSG_SEND_BIT (1u << 1)
> +#define PART_INFO_PROP_INDIR_MSG_BIT (1u << 2)
> +#define PART_INFO_PROP_NOTIFICATIONS_BIT (1u << 3)
> +#define PART_INFO_PROP_EP_TYPE_MASK 0x3
> +#define PART_INFO_PROP_EP_TYPE_SHIFT 4
> +#define PART_INFO_PROP_EP_PE 0
> +#define PART_INFO_PROP_EP_SEPID_IND 1
> +#define PART_INFO_PROP_EP_SEPID_DEP 2
> +#define PART_INFO_PROP_EP_AUX 3
> +
> #endif // ARM_FFA_SVC_H_
> diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> index 39a1b329b9ea..94a5d96c051d 100644
> --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> @@ -8,6 +8,7 @@
>
> #include <Library/ArmLib.h>
> #include <Library/ArmSmcLib.h>
> +#include <Library/BaseLib.h>
> #include <Library/BaseMemoryLib.h>
> #include <Library/DebugLib.h>
> #include <Library/DxeServicesTableLib.h>
> @@ -28,6 +29,11 @@
> //
> STATIC UINT16 mFfaPartId;
>
> +// Partition information of the StMM SP if FF-A support is enabled
> +// TODO: Revisit assumption that there is only a single StMM SP
> +//
> +STATIC EFI_FFA_PART_INFO_DESC mStmmPartInfo;
> +
> //
> // RX/TX pair if FF-A support is enabled
> //
> @@ -298,7 +304,9 @@ GetMmCompatibility (
> {
> EFI_STATUS Status;
> UINT32 MmVersion;
> + UINT32 SmccUuid[4];
> ARM_SMC_ARGS SmcArgs = {0};
> + EFI_GUID MmCommProtGuid = EFI_MM_COMMUNICATION_PROTOCOL_GUID;
>
> if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> SmcArgs.Arg0 = ARM_SVC_ID_FFA_VERSION_AARCH32;
> @@ -335,14 +343,21 @@ GetMmCompatibility (
> Status = EFI_UNSUPPORTED;
> }
>
> - // If FF-A is supported then discover our ID and register our RX/TX buffers.
> + // If FF-A is supported then discover the StMM SP's presence, ID, our ID and
> + // register our RX/TX buffers.
> if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> + EFI_FFA_PART_INFO_DESC *StmmPartInfo;
> +
> // Get our ID
> ZeroMem(&SmcArgs, sizeof(SmcArgs));
> SmcArgs.Arg0 = ARM_SVC_ID_FFA_ID_GET_AARCH32;
> ArmCallSmc (&SmcArgs);
> if (SmcArgs.Arg0 == ARM_SVC_ID_FFA_ERROR_AARCH32) {
> - DEBUG ((DEBUG_ERROR, "Unable to retrieve FF-A partition ID (%d).\n", SmcArgs.Arg2));
> + DEBUG ((
> + DEBUG_ERROR,
> + "Unable to retrieve FF-A partition ID (%d).\n",
> + SmcArgs.Arg2
> + ));
> return EFI_UNSUPPORTED;
> }
> DEBUG ((DEBUG_INFO, "FF-A partition ID = 0x%lx.\n", SmcArgs.Arg2));
> @@ -355,11 +370,83 @@ GetMmCompatibility (
> SmcArgs.Arg3 = EFI_PAGE_SIZE / SIZE_4KB;
> ArmCallSmc (&SmcArgs);
> if (SmcArgs.Arg0 == ARM_SVC_ID_FFA_ERROR_AARCH32) {
> - DEBUG ((DEBUG_ERROR, "Unable to register FF-A RX/TX buffers (%d).\n", SmcArgs.Arg2));
> + DEBUG ((
> + DEBUG_ERROR,
> + "Unable to register FF-A RX/TX buffers (%d).\n",
> + SmcArgs.Arg2
> + ));
> return EFI_UNSUPPORTED;
> }
>
> + // Discover the StMM SP after converting the EFI_GUID to a format TF-A will
> + // understand.
> + SmcArgs.Arg0 = ARM_SVC_ID_FFA_PARTITION_INFO_GET_AARCH32;
> + MmCommProtGuid.Data2 += MmCommProtGuid.Data3;
> + MmCommProtGuid.Data3 = MmCommProtGuid.Data2 - MmCommProtGuid.Data3;
> + MmCommProtGuid.Data2 = MmCommProtGuid.Data2 - MmCommProtGuid.Data3;
> + CopyMem ((VOID *) SmccUuid, (VOID *) &MmCommProtGuid, sizeof(EFI_GUID));
> + SmcArgs.Arg1 = SmccUuid[0];
> + SmcArgs.Arg2 = SmccUuid[1];
> + SmcArgs.Arg3 = SmccUuid[2];
> + SmcArgs.Arg3 = SwapBytes32(SmcArgs.Arg3);
> + SmcArgs.Arg4 = SmccUuid[3];
> + SmcArgs.Arg4 = SwapBytes32(SmcArgs.Arg4);
> + ArmCallSmc (&SmcArgs);
> + if (SmcArgs.Arg0 == ARM_SVC_ID_FFA_ERROR_AARCH32) {
> + DEBUG ((
> + DEBUG_ERROR,
> + "Unable to discover FF-A StMM SP (%d).\n",
> + SmcArgs.Arg2
> + ));
> + goto ffa_init_error;
> + }
> +
> + // Retrieve the partition information from the RX buffer
> + StmmPartInfo = (EFI_FFA_PART_INFO_DESC *) FfaRxBuf;
> +
> + // TODO: Sanity check the partition type.
> + DEBUG ((DEBUG_INFO, "Discovered FF-A StMM SP."));
> + DEBUG ((
> + DEBUG_INFO,
> + "ID = 0x%lx, Execution contexts = %d, Properties = 0x%lx. \n",
> + StmmPartInfo->PartId,
> + StmmPartInfo->EcCnt,
> + StmmPartInfo->PartProps
> + ));
> +
> + // Make a local copy
> + mStmmPartInfo = *StmmPartInfo;
> +
> + // Release the RX buffer
> + ZeroMem(&SmcArgs, sizeof(SmcArgs));
> + SmcArgs.Arg0 = ARM_SVC_ID_FFA_RX_RELEASE_AARCH32;
> + SmcArgs.Arg1 = mFfaPartId;
> + ArmCallSmc (&SmcArgs);
> +
> + // This should really never fail since there is only a single CPU booting
> + // and another CPU could not have released the RX buffer before us.
> + if (SmcArgs.Arg0 == ARM_SVC_ID_FFA_ERROR_AARCH32) {
> + DEBUG ((
> + DEBUG_ERROR,
> + "Unable to release FF-A RX buffer (%d).\n",
> + SmcArgs.Arg2
> + ));
> + ASSERT (0);
> + goto ffa_init_error;
> + }
> +
> return EFI_SUCCESS;
> +
> + ffa_init_error:
> + // Release the RX/TX pair before exiting.
> + ZeroMem(&SmcArgs, sizeof(SmcArgs));
> + SmcArgs.Arg0 = ARM_SVC_ID_FFA_RXTX_UNMAP_AARCH32;
> + SmcArgs.Arg1 = mFfaPartId << 16; // TODO: Use a macro for shift
This macro would be nice to have, especially as the next patch uses it a
lot.
Thanks,
Oliver
> + ArmCallSmc (&SmcArgs);
> +
> + // We do not bother checking the error code of the RXTX_UNMAP invocation
> + // since we did map the buffers and this call must succeed.
> + return EFI_UNSUPPORTED;
> }
>
> return Status;
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework
2023-07-11 14:36 [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Nishant Sharma
` (19 preceding siblings ...)
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 20/20] StandaloneMmPkg: Add support for MM requests as FF-A direct messages Nishant Sharma
@ 2023-07-12 21:13 ` Oliver Smith-Denny
20 siblings, 0 replies; 41+ messages in thread
From: Oliver Smith-Denny @ 2023-07-12 21:13 UTC (permalink / raw)
To: devel, nishant.sharma
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
Thanks for sending out the patchset!
I may be missing it, where is the StMM FF-A partition manifest as part
of this? I see where it gets parsed, but not the actual information. My
understanding, which may be flawed, is that there should be a separate
file defining the StMM manifest. Is that going in TF-A?
This seems mostly complete, I agree with Kun that extending support
to MmCommunicatePei would seem to be necessary.
Thanks,
Oliver
On 7/11/2023 7:36 AM, Nishant Sharma wrote:
> V1 :
>
> Following patchset add the support of ARM Firmware Framework protocol to
> MM communication.
>
> Following chagnes are made to enable the support
> 1> Changed the FFA enable flag(PcdFfaEnable) to integer to enable it
> use in assembly.
> 2> Add the support to Reserved SP stack space and program in startup
> code.
> 3> Added ABI for enabling FFA protocol
> 4> Added conditional support in Standalone MM to parse DTB and
> populated configuration info required for FFA.
> 5> Added FFA support in MmCommunicationDxe module.
>
> Patches are pushed to
> https://github.com/nissha03/edk2/tree/ArmFirmwareFramework
>
> ARM Firmware Framework Protocol:
> https://developer.arm.com/documentation/den0077/latest/
>
> Achin Gupta (19):
> StandaloneMmPkg: Allocate and initialise SP stack from internal memory
> StandaloneMmPkg: Include libfdt in the StMM
> ArmPkg: Add data structures to receive FF-A boot information
> ArmPkg/ArmFfaSvc: Add helper macros and fids
> ArmPkg: Add support for FFA_MEM_PERM_GET/SET ABIs
> StandaloneMmPkg: define new data structure to stage FF-A boot
> information
> StandaloneMmPkg: Add backwards compatible support to detect FF-A v1.1
> StandaloneMmPkg: parse SP manifest and populate new boot information
> StandaloneMmPkg: Populate Hoblist for SP init from StMM boot
> information
> StandaloneMmPkg: Skip zero sized sections while tweaking page
> permissions
> StandaloneMmPkg: Add global check for FF-A abis
> ArmPkg: Bump the StMM SP FF-A minor version to 1
> ArmPkg/MmCommunicationDxe: Introduce FF-A version check
> ArmPkg/MmCommunicationDxe: Add support for obtaining FF-A partition ID
> ArmPkg/MmCommunicationDxe: Register FF-A RX/TX buffers
> ArmPkg/MmCommunicationDxe: Unmap FF-A RX/TX buffers during
> ExitBootServices
> ArmPkg/MmCommunicationDxe: Discover the StMM SP
> ArmPkg/MmCommunicationDxe: Use the FF-A transport for MM requests
> StandaloneMmPkg: Add support for MM requests as FF-A direct messages
>
> Nishant Sharma (1):
> ArmPkg: Change PcdFfaEnable flag datatype
>
> ArmPkg/ArmPkg.dec | 14 +-
> StandaloneMmPkg/StandaloneMmPkg.dsc | 3 +-
> ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf | 3 +
> ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf | 4 +-
> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf | 8 +-
> ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h | 7 +-
> ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 133 ++++-
> StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h | 39 +-
> ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 332 ++++++++++--
> ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c | 140 ++++-
> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c | 186 ++++++-
> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/SetPermissions.c | 18 +-
> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c | 561 +++++++++++++++++---
> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/AArch64/ModuleEntryPoint.S | 68 +++
> 14 files changed, 1367 insertions(+), 149 deletions(-)
> create mode 100644 StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/AArch64/ModuleEntryPoint.S
>
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH V1 18/20] ArmPkg/MmCommunicationDxe: Discover the StMM SP
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 18/20] ArmPkg/MmCommunicationDxe: Discover the StMM SP Nishant Sharma
2023-07-12 21:10 ` [edk2-devel] " Oliver Smith-Denny
@ 2023-07-12 21:48 ` Girish Mahadevan
2023-07-13 17:16 ` Chris Fernald
2 siblings, 0 replies; 41+ messages in thread
From: Girish Mahadevan @ 2023-07-12 21:48 UTC (permalink / raw)
To: devel, nishant.sharma
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
A few comments in line. (Prefixed with [GM])
Best Regards
Girish
On 7/11/2023 8:36 AM, Nishant Sharma via groups.io wrote:
> External email: Use caution opening links or attachments
>
>
> From: Achin Gupta <achin.gupta@arm.com>
>
> This patch adds support for discovering the presence of the SP using the
> EFI_MM_COMMUNICATION_PROTOCOL GUID that implements Standalone MM
> drivers. This is done by querying the framework through
> FFA_PARTITION_INFO_GET whether any partition that implements the
> EFI_MM_COMMUNICATION_PROTOCOL is present or not. The partition ID and
> its properties are stashed for use in subsequent communication with the
> StMM SP.
>
> Signed-off-by: Achin Gupta <achin.gupta@arm.com>
> Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
> ---
> ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 24 +++++
> ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 93 +++++++++++++++++++-
> 2 files changed, 114 insertions(+), 3 deletions(-)
>
> diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> index f78442a465e1..530af8bd3c2e 100644
> --- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> +++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> @@ -19,6 +19,9 @@
> #define ARM_SVC_ID_FFA_VERSION_AARCH32 0x84000063
> #define ARM_SVC_ID_FFA_RXTX_MAP_AARCH32 0x84000066
> #define ARM_SVC_ID_FFA_RXTX_MAP_AARCH64 0xC4000066
> +#define ARM_SVC_ID_FFA_RX_RELEASE_AARCH32 0x84000065
> +#define ARM_SVC_ID_FFA_RXTX_UNMAP_AARCH32 0x84000067
> +#define ARM_SVC_ID_FFA_PARTITION_INFO_GET_AARCH32 0x84000068
> #define ARM_SVC_ID_FFA_ID_GET_AARCH32 0x84000069
> #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH32 0x8400006F
> #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH32 0x84000070
> @@ -154,4 +157,25 @@ typedef struct {
> UINT64 Reserved;
> } EFI_FFA_BOOT_INFO_HEADER;
>
> +// FF-A partition information descriptor
> +typedef struct {
> + UINT16 PartId;
> + UINT16 EcCnt;
> + UINT32 PartProps;
> + UINT32 PartGuid[4];
> +} EFI_FFA_PART_INFO_DESC;
> +
> +#define PART_INFO_PROP_MASK 0x3f
> +#define PART_INFO_PROP_SHIFT 0
> +#define PART_INFO_PROP_DIR_MSG_RECV_BIT (1u << 0)
> +#define PART_INFO_PROP_DIR_MSG_SEND_BIT (1u << 1)
> +#define PART_INFO_PROP_INDIR_MSG_BIT (1u << 2)
> +#define PART_INFO_PROP_NOTIFICATIONS_BIT (1u << 3)
> +#define PART_INFO_PROP_EP_TYPE_MASK 0x3
> +#define PART_INFO_PROP_EP_TYPE_SHIFT 4
> +#define PART_INFO_PROP_EP_PE 0
> +#define PART_INFO_PROP_EP_SEPID_IND 1
> +#define PART_INFO_PROP_EP_SEPID_DEP 2
> +#define PART_INFO_PROP_EP_AUX 3
> +
> #endif // ARM_FFA_SVC_H_
> diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> index 39a1b329b9ea..94a5d96c051d 100644
> --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> @@ -8,6 +8,7 @@
>
> #include <Library/ArmLib.h>
> #include <Library/ArmSmcLib.h>
> +#include <Library/BaseLib.h>
> #include <Library/BaseMemoryLib.h>
> #include <Library/DebugLib.h>
> #include <Library/DxeServicesTableLib.h>
> @@ -28,6 +29,11 @@
> //
> STATIC UINT16 mFfaPartId;
>
> +// Partition information of the StMM SP if FF-A support is enabled
> +// TODO: Revisit assumption that there is only a single StMM SP
> +//
> +STATIC EFI_FFA_PART_INFO_DESC mStmmPartInfo;
> +
> //
> // RX/TX pair if FF-A support is enabled
> //
> @@ -298,7 +304,9 @@ GetMmCompatibility (
> {
> EFI_STATUS Status;
> UINT32 MmVersion;
> + UINT32 SmccUuid[4];
> ARM_SMC_ARGS SmcArgs = {0};
> + EFI_GUID MmCommProtGuid = EFI_MM_COMMUNICATION_PROTOCOL_GUID;
>
> if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> SmcArgs.Arg0 = ARM_SVC_ID_FFA_VERSION_AARCH32;
> @@ -335,14 +343,21 @@ GetMmCompatibility (
> Status = EFI_UNSUPPORTED;
> }
>
> - // If FF-A is supported then discover our ID and register our RX/TX buffers.
> + // If FF-A is supported then discover the StMM SP's presence, ID, our ID and
> + // register our RX/TX buffers.
> if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> + EFI_FFA_PART_INFO_DESC *StmmPartInfo;
> +
[GM]
Probably better off putting this entire thing (discovering the VMId in a
different function).
> // Get our ID
> ZeroMem(&SmcArgs, sizeof(SmcArgs));
> SmcArgs.Arg0 = ARM_SVC_ID_FFA_ID_GET_AARCH32;
> ArmCallSmc (&SmcArgs);
> if (SmcArgs.Arg0 == ARM_SVC_ID_FFA_ERROR_AARCH32) {
> - DEBUG ((DEBUG_ERROR, "Unable to retrieve FF-A partition ID (%d).\n", SmcArgs.Arg2));
> + DEBUG ((
> + DEBUG_ERROR,
> + "Unable to retrieve FF-A partition ID (%d).\n",
> + SmcArgs.Arg2
> + ));
> return EFI_UNSUPPORTED;
> }
> DEBUG ((DEBUG_INFO, "FF-A partition ID = 0x%lx.\n", SmcArgs.Arg2));
> @@ -355,11 +370,83 @@ GetMmCompatibility (
> SmcArgs.Arg3 = EFI_PAGE_SIZE / SIZE_4KB;
> ArmCallSmc (&SmcArgs);
> if (SmcArgs.Arg0 == ARM_SVC_ID_FFA_ERROR_AARCH32) {
> - DEBUG ((DEBUG_ERROR, "Unable to register FF-A RX/TX buffers (%d).\n", SmcArgs.Arg2));
> + DEBUG ((
> + DEBUG_ERROR,
> + "Unable to register FF-A RX/TX buffers (%d).\n",
> + SmcArgs.Arg2
> + ));
> return EFI_UNSUPPORTED;
> } >
> + // Discover the StMM SP after converting the EFI_GUID to a format TF-A will
> + // understand.
> + SmcArgs.Arg0 = ARM_SVC_ID_FFA_PARTITION_INFO_GET_AARCH32;
> + MmCommProtGuid.Data2 += MmCommProtGuid.Data3;
> + MmCommProtGuid.Data3 = MmCommProtGuid.Data2 - MmCommProtGuid.Data3;
> + MmCommProtGuid.Data2 = MmCommProtGuid.Data2 - MmCommProtGuid.Data3;
> + CopyMem ((VOID *) SmccUuid, (VOID *) &MmCommProtGuid, sizeof(EFI_GUID));
> + SmcArgs.Arg1 = SmccUuid[0];
> + SmcArgs.Arg2 = SmccUuid[1];
> + SmcArgs.Arg3 = SmccUuid[2];
> + SmcArgs.Arg3 = SwapBytes32(SmcArgs.Arg3);
> + SmcArgs.Arg4 = SmccUuid[3];
> + SmcArgs.Arg4 = SwapBytes32(SmcArgs.Arg4);
> + ArmCallSmc (&SmcArgs);
> + if (SmcArgs.Arg0 == ARM_SVC_ID_FFA_ERROR_AARCH32) {
> + DEBUG ((
> + DEBUG_ERROR,
> + "Unable to discover FF-A StMM SP (%d).\n",
> + SmcArgs.Arg2
> + ));
> + goto ffa_init_error;
> + }
> +
[GM]
Shouldn't you also check Arg2 to ensure you have discovered at least 1 SP.
> + // Retrieve the partition information from the RX buffer
> + StmmPartInfo = (EFI_FFA_PART_INFO_DESC *) FfaRxBuf;
> +
> + // TODO: Sanity check the partition type.
> + DEBUG ((DEBUG_INFO, "Discovered FF-A StMM SP."));
> + DEBUG ((
> + DEBUG_INFO,
> + "ID = 0x%lx, Execution contexts = %d, Properties = 0x%lx. \n",
> + StmmPartInfo->PartId,
> + StmmPartInfo->EcCnt,
> + StmmPartInfo->PartProps
> + ));
> +
> + // Make a local copy
> + mStmmPartInfo = *StmmPartInfo;
> +
> + // Release the RX buffer
> + ZeroMem(&SmcArgs, sizeof(SmcArgs));
> + SmcArgs.Arg0 = ARM_SVC_ID_FFA_RX_RELEASE_AARCH32;
> + SmcArgs.Arg1 = mFfaPartId;
> + ArmCallSmc (&SmcArgs);
> +
> + // This should really never fail since there is only a single CPU booting
> + // and another CPU could not have released the RX buffer before us.
> + if (SmcArgs.Arg0 == ARM_SVC_ID_FFA_ERROR_AARCH32) {
> + DEBUG ((
> + DEBUG_ERROR,
> + "Unable to release FF-A RX buffer (%d).\n",
> + SmcArgs.Arg2
> + ));
> + ASSERT (0);
> + goto ffa_init_error;
> + }
> +
> return EFI_SUCCESS;
> +
> + ffa_init_error:
> + // Release the RX/TX pair before exiting.
> + ZeroMem(&SmcArgs, sizeof(SmcArgs));
> + SmcArgs.Arg0 = ARM_SVC_ID_FFA_RXTX_UNMAP_AARCH32;
> + SmcArgs.Arg1 = mFfaPartId << 16; // TODO: Use a macro for shift
> + ArmCallSmc (&SmcArgs);
> +
> + // We do not bother checking the error code of the RXTX_UNMAP invocation
> + // since we did map the buffers and this call must succeed.
> + return EFI_UNSUPPORTED;
> }
>
> return Status;
> --
> 2.34.1
>
>
>
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#106810): https://edk2.groups.io/g/devel/message/106810
> Mute This Topic: https://groups.io/mt/100079892/6098446
> Group Owner: devel+owner@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [gmahadevan@nvidia.com]
> -=-=-=-=-=-=
>
>
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH V1 19/20] ArmPkg/MmCommunicationDxe: Use the FF-A transport for MM requests
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 19/20] ArmPkg/MmCommunicationDxe: Use the FF-A transport for MM requests Nishant Sharma
2023-07-11 19:22 ` [edk2-devel] " Kun Qin
@ 2023-07-12 21:49 ` Girish Mahadevan
1 sibling, 0 replies; 41+ messages in thread
From: Girish Mahadevan @ 2023-07-12 21:49 UTC (permalink / raw)
To: devel, nishant.sharma
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta, Aditya Angadi
Couple of comments/questions inline (prefixed by [GM])
Thanks
Girish
On 7/11/2023 8:36 AM, Nishant Sharma via groups.io wrote:
> External email: Use caution opening links or attachments
>
>
> From: Achin Gupta <achin.gupta@arm.com>
>
> This patch packages requests for accessing a Standalone MM driver
> through the MM communication protocol as FF-A direct messages.
> Corresponding changes in Standalone MM Core ensure that responses are
> packaged in the same way.
>
> Signed-off-by: Achin Gupta <achin.gupta@arm.com>
> Co-developed-by: Aditya Angadi <aditya.angadi@arm.com>
> Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
> ---
> ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 2 +
> ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 141 +++++++++++++-------
> 2 files changed, 97 insertions(+), 46 deletions(-)
>
> diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> index 530af8bd3c2e..493997346143 100644
> --- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> +++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> @@ -23,6 +23,7 @@
> #define ARM_SVC_ID_FFA_RXTX_UNMAP_AARCH32 0x84000067
> #define ARM_SVC_ID_FFA_PARTITION_INFO_GET_AARCH32 0x84000068
> #define ARM_SVC_ID_FFA_ID_GET_AARCH32 0x84000069
> +#define ARM_SVC_ID_FFA_RUN_AARCH32 0x8400006D
> #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH32 0x8400006F
> #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH32 0x84000070
> #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH64 0xC400006F
> @@ -31,6 +32,7 @@
> #define ARM_SVC_ID_FFA_SUCCESS_AARCH64 0xC4000061
> #define ARM_SVC_ID_FFA_MEM_PERM_SET_AARCH32 0x84000089
> #define ARM_SVC_ID_FFA_MEM_PERM_GET_AARCH32 0x84000088
> +#define ARM_SVC_ID_FFA_INTERRUPT_AARCH32 0x84000062
> #define ARM_SVC_ID_FFA_ERROR_AARCH32 0x84000060
> #define ARM_SVC_ID_FFA_ERROR_AARCH64 0xC4000060
> #define ARM_SVC_ID_FFA_MSG_WAIT_AARCH32 0x8400006B
> diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> index 94a5d96c051d..a70318581bd2 100644
> --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> @@ -100,6 +100,7 @@ MmCommunication2Communicate (
> ARM_SMC_ARGS CommunicateSmcArgs;
> EFI_STATUS Status;
> UINTN BufferSize;
> + UINTN Ret;
>
> Status = EFI_ACCESS_DENIED;
> BufferSize = 0;
> @@ -160,60 +161,108 @@ MmCommunication2Communicate (
> return Status;
> }
>
> - // 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;
[GM] Just out of curiosity, how are you figuring out this Address ?
Hardcoding it in the PCD ?
> + // Use the FF-A interface if enabled.
> + if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> + // 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 = mFfaPartId << 16 | mStmmPartInfo.PartId;
[GM] To be clear the Sender Id is 0. (so in FF-A anything from NS is 0 ?
Correct ?)
>
> + // Reserved for future use(MBZ)
> + CommunicateSmcArgs.Arg2 = 0x0;
> +
> + // comm_buffer_address (64-bit physical address)
> + CommunicateSmcArgs.Arg3 = (UINTN)mNsCommBuffMemRegion.PhysicalBase;
> +
> + // Cookie
> + CommunicateSmcArgs.Arg4 = 0x0;
> +
> + // Not Used
> + CommunicateSmcArgs.Arg5 = 0;
> +
> + // 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;
> + }
> +
> +ffa_intr_loop:
> // Call the Standalone MM environment.
> ArmCallSmc (&CommunicateSmcArgs);
>
> - switch (CommunicateSmcArgs.Arg0) {
> - case ARM_SMC_MM_RET_SUCCESS:
> - ZeroMem (CommBufferVirtual, BufferSize);
> - // On successful return, the size of data being returned is inferred from
> - // MessageLength + Header.
> - CommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)mNsCommBuffMemRegion.VirtualBase;
> - BufferSize = CommunicateHeader->MessageLength +
> - sizeof (CommunicateHeader->HeaderGuid) +
> - sizeof (CommunicateHeader->MessageLength);
> -
> - CopyMem (
> - CommBufferVirtual,
> - (VOID *)mNsCommBuffMemRegion.VirtualBase,
> - BufferSize
> - );
> - Status = EFI_SUCCESS;
> - break;
> -
> - case ARM_SMC_MM_RET_INVALID_PARAMS:
> - Status = EFI_INVALID_PARAMETER;
> - break;
> -
> - case ARM_SMC_MM_RET_DENIED:
> - Status = EFI_ACCESS_DENIED;
> - break;
> -
> - case ARM_SMC_MM_RET_NO_MEMORY:
> - // Unexpected error since the CommSize was checked for zero length
> - // prior to issuing the SMC
> - Status = EFI_OUT_OF_RESOURCES;
> - ASSERT (0);
> - break;
> -
> - default:
> - Status = EFI_ACCESS_DENIED;
> - ASSERT (0);
> + Ret = CommunicateSmcArgs.Arg0;
> +
> + if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> + if (Ret == ARM_SVC_ID_FFA_INTERRUPT_AARCH32) {
[GM] Can you clarify how we get here ?
> + DEBUG ((DEBUG_INFO, "Resuming interrupted FF-A call \n"));
> +
> + // FF-A Interface ID for running the interrupted partition
> + CommunicateSmcArgs.Arg0 = ARM_SVC_ID_FFA_RUN_AARCH32;
> +
> + // FF-A Destination EndPoint and vCPU ID, TODO: We are assuming vCPU0 of the
> + // StMM SP since it is UP.
> + CommunicateSmcArgs.Arg1 = mStmmPartInfo.PartId << 16;
[GM] Does the encoding of this argument change in this re-try loop ? I
thought destination was supposed to be lower 16 bits (like you'd done on
#173).
> +
> + // Loop if the call was interrupted
> + goto ffa_intr_loop;
> + }
> + }
> +
> + if (((FixedPcdGet32 (PcdFfaEnable) != 0) &&
> + (Ret == ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP)) ||
> + (Ret == ARM_SMC_MM_RET_SUCCESS)) {
> + ZeroMem (CommBufferVirtual, BufferSize);
> + // On successful return, the size of data being returned is inferred from
> + // MessageLength + Header.
> + CommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)mNsCommBuffMemRegion.VirtualBase;
> + BufferSize = CommunicateHeader->MessageLength +
> + sizeof (CommunicateHeader->HeaderGuid) +
> + sizeof (CommunicateHeader->MessageLength);
> +
> + CopyMem (CommBufferVirtual, (VOID *)mNsCommBuffMemRegion.VirtualBase,
> + BufferSize);
> + Status = EFI_SUCCESS;
> + return Status;
> + }
> +
> + if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> + 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;
> +
> + case ARM_SMC_MM_RET_DENIED:
> + Status = EFI_ACCESS_DENIED;
> + break;
> +
> + case ARM_SMC_MM_RET_NO_MEMORY:
> + // Unexpected error since the CommSize was checked for zero length
> + // prior to issuing the SMC
> + Status = EFI_OUT_OF_RESOURCES;
> + ASSERT (0);
> + break;
> +
> + default:
> + Status = EFI_ACCESS_DENIED;
> + ASSERT (0);
> }
>
> return Status;
> --
> 2.34.1
>
>
>
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#106811): https://edk2.groups.io/g/devel/message/106811
> Mute This Topic: https://groups.io/mt/100079893/6098446
> Group Owner: devel+owner@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [gmahadevan@nvidia.com]
> -=-=-=-=-=-=
>
>
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH V1 09/20] StandaloneMmPkg: parse SP manifest and populate new boot information
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 09/20] StandaloneMmPkg: parse SP manifest and populate new boot information Nishant Sharma
@ 2023-07-13 15:24 ` Girish Mahadevan
2023-07-13 16:48 ` Chris Fernald
0 siblings, 1 reply; 41+ messages in thread
From: Girish Mahadevan @ 2023-07-13 15:24 UTC (permalink / raw)
To: devel, nishant.sharma
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
I had one comment , in-line.
Thanks
Girish
On 7/11/2023 8:36 AM, Nishant Sharma via groups.io wrote:
> External email: Use caution opening links or attachments
>
>
> From: Achin Gupta <achin.gupta@arm.com>
>
> This patch discovers the SP manifest in DT format passed by the SPMC. It
> then parses it to obtain the boot information required to initialise the
> SP.
>
> Signed-off-by: Achin Gupta <achin.gupta@arm.com>
> Signed-off-by: Sayanta Pattanayak <sayanta.pattanayak@arm.com>
> Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
> ---
> StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h | 2 +-
> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c | 389 +++++++++++++++++++-
> 2 files changed, 381 insertions(+), 10 deletions(-)
>
> diff --git a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h
> index c965192c702e..90d67a2f25b5 100644
> --- a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h
> +++ b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h
> @@ -2,7 +2,7 @@
> Entry point to the Standalone MM Foundation when initialized during the SEC
> phase on ARM platforms
>
> -Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.<BR>
> +Copyright (c) 2017 - 2023, Arm Ltd. All rights reserved.<BR>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
> **/
> diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
> index 9f6af55c86c4..505786aff07c 100644
> --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
> +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
> @@ -38,6 +38,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
>
> #define BOOT_PAYLOAD_VERSION 1
>
> +#define FFA_PAGE_4K 0
> +#define FFA_PAGE_16K 1
> +#define FFA_PAGE_64K 2
> +
> PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT CpuDriverEntryPoint = NULL;
>
> /**
> @@ -106,6 +110,7 @@ GetAndPrintBootinformation (
> }
>
> return PayloadBootInfo;
> +}
>
> /**
> An StMM SP implements partial support for FF-A v1.0. The FF-A ABIs are used to
> @@ -266,6 +271,308 @@ DelegatedEventLoop (
> }
> }
>
> +STATIC
> +BOOLEAN
> +CheckDescription (
> + IN VOID * DtbAddress,
> + IN INT32 Offset,
> + OUT CHAR8 * Description,
> + OUT UINT32 Size
> + )
> +{
> + CONST CHAR8 * Property;
> + INT32 LenP;
> +
> + Property = fdt_getprop (DtbAddress, Offset, "description", &LenP);
> + if (Property == NULL) {
> + return FALSE;
> + }
> +
> + return CompareMem (Description, Property, MIN(Size, (UINT32)LenP)) == 0;
> +
> +}
> +
> +STATIC
> +EFI_STATUS
> +ReadProperty32 (
> + IN VOID * DtbAddress,
> + IN INT32 Offset,
> + IN CHAR8 * Property,
> + OUT UINT32 * Value
> + )
> +{
> + CONST UINT32 * Property32;
> +
> + Property32 = fdt_getprop (DtbAddress, Offset, Property, NULL);
> + if (Property32 == NULL) {
> + DEBUG ((
> + DEBUG_ERROR,
> + "%s: Missing in FF-A boot information manifest\n",
> + Property
> + ));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + *Value = fdt32_to_cpu (*Property32);
> +
> + return EFI_SUCCESS;
> +}
> +
> +STATIC
> +EFI_STATUS
> +ReadProperty64 (
> + IN VOID * DtbAddress,
> + IN INT32 Offset,
> + IN CHAR8 * Property,
> + OUT UINT64 * Value
> + )
> +{
> + CONST UINT64 * Property64;
> +
> + Property64 = fdt_getprop (DtbAddress, Offset, Property, NULL);
> + if (Property64 == NULL) {
> + DEBUG ((
> + DEBUG_ERROR,
> + "%s: Missing in FF-A boot information manifest\n",
> + Property
> + ));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + *Value = fdt64_to_cpu (*Property64);
> +
> + return EFI_SUCCESS;
> +}
> +
> +STATIC
> +BOOLEAN
> +ReadRegionInfo (
> + IN VOID *DtbAddress,
> + IN INT32 Node,
> + IN CHAR8 *Region,
> + IN UINTN RegionStrSize,
> + IN UINT32 PageSize,
> + OUT UINT64 *Address,
> + OUT UINT64 *Size
> + )
> +{
> + BOOLEAN FoundBuffer;
> + INTN Status = 0;
> +
> + FoundBuffer = CheckDescription (
> + DtbAddress,
> + Node,
> + Region,
> + RegionStrSize
> + );
> + if (!FoundBuffer) {
> + return FALSE;
> + }
> +
> + DEBUG ((DEBUG_INFO, "Found Node: %a\n", Region));
> + Status = ReadProperty64 (
> + DtbAddress,
> + Node,
> + "base-address",
> + Address
> + );
> + if (Status != EFI_SUCCESS) {
> + DEBUG ((DEBUG_ERROR, "base-address missing in DTB"));
> + return FALSE;
> + }
> + DEBUG ((
> + DEBUG_INFO,
> + "base = 0x%llx\n",
> + *Address
> + ));
> +
> + Status = ReadProperty32 (
> + DtbAddress,
> + Node,
> + "pages-count",
> + (UINT32*)Size
> + );
> + if (Status != EFI_SUCCESS) {
> + DEBUG ((DEBUG_ERROR, "pages-count missing in DTB"));
> + return FALSE;
> + }
> +
> + DEBUG ((DEBUG_ERROR, "pages-count: 0x%lx\n", *Size));
> +
> + *Size = *Size * PageSize;
> + DEBUG ((
> + DEBUG_INFO,
> + "Size = 0x%llx\n",
> + *Size
> + ));
> +
> + return TRUE;
> +}
> +
> +/**
> +
> + Populates FF-A boot information structure.
> +
> + This function receives the address of a DTB from which boot information defind
> + by FF-A and required to initialize the standalone environment is extracted.
> +
> + @param [in, out] StmmBootInfo Pointer to a pre-allocated boot info structure to be
> + populated.
> + @param [in] DtbAddress Address of the Device tree from where boot
> + information will be fetched.
> +**/
> +STATIC
> +EFI_STATUS
> +PopulateBootinformation (
> + IN OUT EFI_STMM_BOOT_INFO *StmmBootInfo,
> + IN VOID *DtbAddress
> +)
> +{
> + INTN Status;
> + INT32 Offset;
> + INT32 Node;
> + BOOLEAN FoundNsCommBuffer = FALSE;
> + BOOLEAN FoundSharedBuffer = FALSE;
> + BOOLEAN FoundHeap = FALSE;
> + UINT32 PageSize;
> +
> + Offset = fdt_node_offset_by_compatible (DtbAddress, -1, "arm,ffa-manifest-1.0");
> + DEBUG ((DEBUG_INFO, "Offset = %d \n", Offset));
> + if (Offset < 0) {
> + DEBUG ((DEBUG_ERROR, "Missing FF-A boot information in manifest\n"));
> + return EFI_NOT_FOUND;
> + }
> +
> + Status = ReadProperty64 (
> + DtbAddress,
> + Offset,
> + "load-address",
> + &StmmBootInfo->SpMemBase
> + );
> + if (Status != EFI_SUCCESS) {
> + return Status;
> + }
> + DEBUG ((DEBUG_INFO, "sp mem base = 0x%llx\n", StmmBootInfo->SpMemBase));
> +
> + Status = ReadProperty64 (
> + DtbAddress,
> + Offset,
> + "image-size",
> + &StmmBootInfo->SpMemSize
> + );
> + if (Status != EFI_SUCCESS) {
> + return Status;
> + }
> + DEBUG ((DEBUG_INFO, "sp mem size = 0x%llx\n", StmmBootInfo->SpMemSize));
> +
> + Status = ReadProperty32 (DtbAddress, Offset, "xlat-granule", &PageSize);
> + if (Status != EFI_SUCCESS) {
> + return Status;
> + }
> +
> + /* EFI_PAGE_SIZE is 4KB */
> + switch (PageSize) {
> + case FFA_PAGE_4K:
> + PageSize = EFI_PAGE_SIZE;
> + break;
> +
> + case FFA_PAGE_16K:
> + PageSize = 4 * EFI_PAGE_SIZE;
> + break;
> +
> + case FFA_PAGE_64K:
> + PageSize = 16 * EFI_PAGE_SIZE;
> + break;
> +
> + default:
> + DEBUG ((DEBUG_ERROR, "Invalid page type = %lu\n", PageSize));
> + return EFI_INVALID_PARAMETER;
> + break;
> + };
> +
> + DEBUG ((DEBUG_INFO, "Page Size = 0x%lx\n", PageSize));
> +
> + Offset = fdt_subnode_offset_namelen (
> + DtbAddress,
> + Offset,
> + "memory-regions",
> + sizeof("memory-regions") - 1
> + );
> + if (Offset < 1) {
> + DEBUG ((
> + DEBUG_ERROR,
> + "%s: Missing in FF-A boot information manifest\n",
> + "memory-regions"
> + ));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + for (
> + Node = fdt_first_subnode (DtbAddress, Offset);
> + Node > 0;
> + Node = fdt_next_subnode (DtbAddress, Node)) {
> + if (!FoundNsCommBuffer) {
> + FoundNsCommBuffer = ReadRegionInfo (
> + DtbAddress,
> + Node,
> + "ns-comm",
> + sizeof ("ns-comm") - 1,
> + PageSize,
> + &StmmBootInfo->SpNsCommBufBase,
> + &StmmBootInfo->SpNsCommBufSize
> + );
> + }
> +
> + if (!FoundHeap) {
> + FoundHeap = ReadRegionInfo (
> + DtbAddress,
> + Node,
> + "heap",
> + sizeof ("heap") - 1,
> + PageSize,
> + &StmmBootInfo->SpHeapBase,
> + &StmmBootInfo->SpHeapSize
> + );
> + }
> +
> + if (!FoundSharedBuffer) {
> + FoundSharedBuffer = ReadRegionInfo (
> + DtbAddress,
> + Node,
> + "shared-buff",
> + sizeof ("shared-buff") - 1,
> + PageSize,
> + &StmmBootInfo->SpSharedBufBase,
> + &StmmBootInfo->SpSharedBufSize
> + );
> + }
> + }
> +
> + if (!FoundNsCommBuffer) {
> + DEBUG ((DEBUG_ERROR, "Failed to find ns-comm buffer info\n"));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if (!FoundHeap) {
> + DEBUG ((DEBUG_ERROR, "Failed to find heap buffer info\n"));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + if (!FoundSharedBuffer) {
> + DEBUG ((DEBUG_ERROR, "Failed to find shared buffer info\n"));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + // Populate CPU information under the assumption made in the FF-A spec that
> + // this is a uniprocessor SP that is capable of migration. So, it is fine if
> + // it sees 0 as both its physical and linear cpu id
> + StmmBootInfo->CpuInfo.Mpidr = 0;
> + StmmBootInfo->CpuInfo.LinearId = 0;
> + StmmBootInfo->CpuInfo.Flags = 0;
> +
> + return EFI_SUCCESS;
> +}
[GM]
Outside of the mandatory properties, I expect that there could be some
custom fields in the dtb manifest. Can you add a means for a vendor to
hook in parsing properties that only apply to them. An OEM Library ?
> +
> /**
> Query the SPM version, check compatibility and return success if compatible.
>
> @@ -343,6 +650,49 @@ InitArmSvcArgs (
> }
> }
>
> +
> +STATIC
> +EFI_STATUS
> +GetSpManifest (
> + IN OUT UINT64 **SpManifestAddr,
> + IN VOID *BootInfoAddr
> + )
> +{
> + EFI_FFA_BOOT_INFO_HEADER *FfaBootInfo;
> + EFI_FFA_BOOT_INFO_DESC *FfaBootInfoDesc;
> +
> + // Paranoid check to avoid an inadvertent NULL pointer dereference.
> + if (BootInfoAddr == NULL) {
> + DEBUG ((DEBUG_ERROR, "FF-A Boot information is NULL\n"));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> + // Check boot information magic number.
> + FfaBootInfo = (EFI_FFA_BOOT_INFO_HEADER *) BootInfoAddr;
> + if (FfaBootInfo->Magic != FFA_INIT_DESC_SIGNATURE) {
> + DEBUG ((
> + DEBUG_ERROR, "FfaBootInfo Magic no. is invalid 0x%ux\n",
> + FfaBootInfo->Magic
> + ));
> + return EFI_INVALID_PARAMETER;
> + }
> +
> +
> + FfaBootInfoDesc =
> + (EFI_FFA_BOOT_INFO_DESC *)((UINT8 *)BootInfoAddr +
> + FfaBootInfo->OffsetBootInfoDesc);
> +
> + if (FfaBootInfoDesc->Type ==
> + (FFA_BOOT_INFO_TYPE(FFA_BOOT_INFO_TYPE_STD) |
> + FFA_BOOT_INFO_TYPE_ID(FFA_BOOT_INFO_TYPE_ID_FDT))) {
> + *SpManifestAddr = (UINT64 *) FfaBootInfoDesc->Content;
> + return EFI_SUCCESS;
> + }
> +
> + DEBUG ((DEBUG_ERROR, "SP manifest not found \n"));
> + return EFI_NOT_FOUND;
> +}
> +
> /**
> The entry point of Standalone MM Foundation.
>
> @@ -363,6 +713,7 @@ ModuleEntryPoint (
> {
> PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
> EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo;
> + EFI_STMM_BOOT_INFO StmmBootInfo = {0};
> ARM_SVC_ARGS InitMmFoundationSvcArgs;
> EFI_STATUS Status;
> INT32 Ret;
> @@ -372,6 +723,8 @@ ModuleEntryPoint (
> VOID *TeData;
> UINTN TeDataSize;
> EFI_PHYSICAL_ADDRESS ImageBase;
> + UINT64 *DtbAddress;
> + EFI_FIRMWARE_VOLUME_HEADER *BfvAddress;
> BOOLEAN UseOnlyFfaAbis = FALSE;
>
> if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> @@ -384,18 +737,36 @@ ModuleEntryPoint (
> goto finish;
> }
>
> - PayloadBootInfo = GetAndPrintBootinformation (SharedBufAddress);
> - if (PayloadBootInfo == NULL) {
> - Status = EFI_UNSUPPORTED;
> - goto finish;
> + // If only FF-A is used, the DTB address is passed in the Boot information
> + // structure. Else, the Boot info is copied from Sharedbuffer.
> + if (UseOnlyFfaAbis) {
> + Status = GetSpManifest (&DtbAddress, SharedBufAddress);
> + if (Status != EFI_SUCCESS) {
> + goto finish;
> + }
> +
> + // Extract boot information from the DTB
> + Status = PopulateBootinformation (&StmmBootInfo, (VOID *) DtbAddress);
> + if (Status != EFI_SUCCESS) {
> + goto finish;
> + }
> +
> + // Stash the base address of the boot firmware volume
> + BfvAddress = (EFI_FIRMWARE_VOLUME_HEADER *) StmmBootInfo.SpMemBase;
> + } else {
> + PayloadBootInfo = GetAndPrintBootinformation (SharedBufAddress);
> + if (PayloadBootInfo == NULL) {
> + Status = EFI_UNSUPPORTED;
> + goto finish;
> + }
> +
> + // Stash the base address of the boot firmware volume
> + BfvAddress = (EFI_FIRMWARE_VOLUME_HEADER *) PayloadBootInfo->SpImageBase;
> }
>
> +
> // Locate PE/COFF File information for the Standalone MM core module
> - Status = LocateStandaloneMmCorePeCoffData (
> - (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)PayloadBootInfo->SpImageBase,
> - &TeData,
> - &TeDataSize
> - );
> + Status = LocateStandaloneMmCorePeCoffData (BfvAddress, &TeData, &TeDataSize);
>
> if (EFI_ERROR (Status)) {
> goto finish;
> --
> 2.34.1
>
>
>
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#106801): https://edk2.groups.io/g/devel/message/106801
> Mute This Topic: https://groups.io/mt/100079881/6098446
> Group Owner: devel+owner@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [gmahadevan@nvidia.com]
> -=-=-=-=-=-=
>
>
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH V1 09/20] StandaloneMmPkg: parse SP manifest and populate new boot information
2023-07-13 15:24 ` [edk2-devel] " Girish Mahadevan
@ 2023-07-13 16:48 ` Chris Fernald
2023-07-13 20:49 ` Achin Gupta
0 siblings, 1 reply; 41+ messages in thread
From: Chris Fernald @ 2023-07-13 16:48 UTC (permalink / raw)
To: devel, gmahadevan, nishant.sharma
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
Achin/Nishant, could you explain the motivation behind falling back to
device tree for some of the secure partition information? It seems like
we have this large abstraction framework using FF-A and it seems a bit
odd to have the secure partition have to directly read device tree for
some of this information when everything else is query-able from the
framework itself.
Thanks,
Chris Fernald
On 7/13/2023 8:24 AM, Girish Mahadevan via groups.io wrote:
> I had one comment , in-line.
>
> Thanks
> Girish
>
> On 7/11/2023 8:36 AM, Nishant Sharma via groups.io wrote:
>> External email: Use caution opening links or attachments
>>
>>
>> From: Achin Gupta <achin.gupta@arm.com>
>>
>> This patch discovers the SP manifest in DT format passed by the SPMC. It
>> then parses it to obtain the boot information required to initialise the
>> SP.
>>
>> Signed-off-by: Achin Gupta <achin.gupta@arm.com>
>> Signed-off-by: Sayanta Pattanayak <sayanta.pattanayak@arm.com>
>> Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
>> ---
>> StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h |
>> 2 +-
>> StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
>> | 389 +++++++++++++++++++-
>> 2 files changed, 381 insertions(+), 10 deletions(-)
>>
>> diff --git
>> a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h
>> b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h
>> index c965192c702e..90d67a2f25b5 100644
>> --- a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h
>> +++ b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h
>> @@ -2,7 +2,7 @@
>> Entry point to the Standalone MM Foundation when initialized
>> during the SEC
>> phase on ARM platforms
>>
>> -Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.<BR>
>> +Copyright (c) 2017 - 2023, Arm Ltd. All rights reserved.<BR>
>> SPDX-License-Identifier: BSD-2-Clause-Patent
>>
>> **/
>> diff --git
>> a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
>> b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
>>
>> index 9f6af55c86c4..505786aff07c 100644
>> ---
>> a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
>> +++
>> b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
>> @@ -38,6 +38,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
>>
>> #define BOOT_PAYLOAD_VERSION 1
>>
>> +#define FFA_PAGE_4K 0
>> +#define FFA_PAGE_16K 1
>> +#define FFA_PAGE_64K 2
>> +
>> PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT CpuDriverEntryPoint = NULL;
>>
>> /**
>> @@ -106,6 +110,7 @@ GetAndPrintBootinformation (
>> }
>>
>> return PayloadBootInfo;
>> +}
>>
>> /**
>> An StMM SP implements partial support for FF-A v1.0. The FF-A
>> ABIs are used to
>> @@ -266,6 +271,308 @@ DelegatedEventLoop (
>> }
>> }
>>
>> +STATIC
>> +BOOLEAN
>> +CheckDescription (
>> + IN VOID * DtbAddress,
>> + IN INT32 Offset,
>> + OUT CHAR8 * Description,
>> + OUT UINT32 Size
>> + )
>> +{
>> + CONST CHAR8 * Property;
>> + INT32 LenP;
>> +
>> + Property = fdt_getprop (DtbAddress, Offset, "description", &LenP);
>> + if (Property == NULL) {
>> + return FALSE;
>> + }
>> +
>> + return CompareMem (Description, Property, MIN(Size, (UINT32)LenP))
>> == 0;
>> +
>> +}
>> +
>> +STATIC
>> +EFI_STATUS
>> +ReadProperty32 (
>> + IN VOID * DtbAddress,
>> + IN INT32 Offset,
>> + IN CHAR8 * Property,
>> + OUT UINT32 * Value
>> + )
>> +{
>> + CONST UINT32 * Property32;
>> +
>> + Property32 = fdt_getprop (DtbAddress, Offset, Property, NULL);
>> + if (Property32 == NULL) {
>> + DEBUG ((
>> + DEBUG_ERROR,
>> + "%s: Missing in FF-A boot information manifest\n",
>> + Property
>> + ));
>> + return EFI_INVALID_PARAMETER;
>> + }
>> +
>> + *Value = fdt32_to_cpu (*Property32);
>> +
>> + return EFI_SUCCESS;
>> +}
>> +
>> +STATIC
>> +EFI_STATUS
>> +ReadProperty64 (
>> + IN VOID * DtbAddress,
>> + IN INT32 Offset,
>> + IN CHAR8 * Property,
>> + OUT UINT64 * Value
>> + )
>> +{
>> + CONST UINT64 * Property64;
>> +
>> + Property64 = fdt_getprop (DtbAddress, Offset, Property, NULL);
>> + if (Property64 == NULL) {
>> + DEBUG ((
>> + DEBUG_ERROR,
>> + "%s: Missing in FF-A boot information manifest\n",
>> + Property
>> + ));
>> + return EFI_INVALID_PARAMETER;
>> + }
>> +
>> + *Value = fdt64_to_cpu (*Property64);
>> +
>> + return EFI_SUCCESS;
>> +}
>> +
>> +STATIC
>> +BOOLEAN
>> +ReadRegionInfo (
>> + IN VOID *DtbAddress,
>> + IN INT32 Node,
>> + IN CHAR8 *Region,
>> + IN UINTN RegionStrSize,
>> + IN UINT32 PageSize,
>> + OUT UINT64 *Address,
>> + OUT UINT64 *Size
>> + )
>> +{
>> + BOOLEAN FoundBuffer;
>> + INTN Status = 0;
>> +
>> + FoundBuffer = CheckDescription (
>> + DtbAddress,
>> + Node,
>> + Region,
>> + RegionStrSize
>> + );
>> + if (!FoundBuffer) {
>> + return FALSE;
>> + }
>> +
>> + DEBUG ((DEBUG_INFO, "Found Node: %a\n", Region));
>> + Status = ReadProperty64 (
>> + DtbAddress,
>> + Node,
>> + "base-address",
>> + Address
>> + );
>> + if (Status != EFI_SUCCESS) {
>> + DEBUG ((DEBUG_ERROR, "base-address missing in DTB"));
>> + return FALSE;
>> + }
>> + DEBUG ((
>> + DEBUG_INFO,
>> + "base = 0x%llx\n",
>> + *Address
>> + ));
>> +
>> + Status = ReadProperty32 (
>> + DtbAddress,
>> + Node,
>> + "pages-count",
>> + (UINT32*)Size
>> + );
>> + if (Status != EFI_SUCCESS) {
>> + DEBUG ((DEBUG_ERROR, "pages-count missing in DTB"));
>> + return FALSE;
>> + }
>> +
>> + DEBUG ((DEBUG_ERROR, "pages-count: 0x%lx\n", *Size));
>> +
>> + *Size = *Size * PageSize;
>> + DEBUG ((
>> + DEBUG_INFO,
>> + "Size = 0x%llx\n",
>> + *Size
>> + ));
>> +
>> + return TRUE;
>> +}
>> +
>> +/**
>> +
>> + Populates FF-A boot information structure.
>> +
>> + This function receives the address of a DTB from which boot
>> information defind
>> + by FF-A and required to initialize the standalone environment is
>> extracted.
>> +
>> + @param [in, out] StmmBootInfo Pointer to a pre-allocated boot
>> info structure to be
>> + populated.
>> + @param [in] DtbAddress Address of the Device tree from
>> where boot
>> + information will be fetched.
>> +**/
>> +STATIC
>> +EFI_STATUS
>> +PopulateBootinformation (
>> + IN OUT EFI_STMM_BOOT_INFO *StmmBootInfo,
>> + IN VOID *DtbAddress
>> +)
>> +{
>> + INTN Status;
>> + INT32 Offset;
>> + INT32 Node;
>> + BOOLEAN FoundNsCommBuffer = FALSE;
>> + BOOLEAN FoundSharedBuffer = FALSE;
>> + BOOLEAN FoundHeap = FALSE;
>> + UINT32 PageSize;
>> +
>> + Offset = fdt_node_offset_by_compatible (DtbAddress, -1,
>> "arm,ffa-manifest-1.0");
>> + DEBUG ((DEBUG_INFO, "Offset = %d \n", Offset));
>> + if (Offset < 0) {
>> + DEBUG ((DEBUG_ERROR, "Missing FF-A boot information in
>> manifest\n"));
>> + return EFI_NOT_FOUND;
>> + }
>> +
>> + Status = ReadProperty64 (
>> + DtbAddress,
>> + Offset,
>> + "load-address",
>> + &StmmBootInfo->SpMemBase
>> + );
>> + if (Status != EFI_SUCCESS) {
>> + return Status;
>> + }
>> + DEBUG ((DEBUG_INFO, "sp mem base = 0x%llx\n",
>> StmmBootInfo->SpMemBase));
>> +
>> + Status = ReadProperty64 (
>> + DtbAddress,
>> + Offset,
>> + "image-size",
>> + &StmmBootInfo->SpMemSize
>> + );
>> + if (Status != EFI_SUCCESS) {
>> + return Status;
>> + }
>> + DEBUG ((DEBUG_INFO, "sp mem size = 0x%llx\n",
>> StmmBootInfo->SpMemSize));
>> +
>> + Status = ReadProperty32 (DtbAddress, Offset, "xlat-granule",
>> &PageSize);
>> + if (Status != EFI_SUCCESS) {
>> + return Status;
>> + }
>> +
>> + /* EFI_PAGE_SIZE is 4KB */
>> + switch (PageSize) {
>> + case FFA_PAGE_4K:
>> + PageSize = EFI_PAGE_SIZE;
>> + break;
>> +
>> + case FFA_PAGE_16K:
>> + PageSize = 4 * EFI_PAGE_SIZE;
>> + break;
>> +
>> + case FFA_PAGE_64K:
>> + PageSize = 16 * EFI_PAGE_SIZE;
>> + break;
>> +
>> + default:
>> + DEBUG ((DEBUG_ERROR, "Invalid page type = %lu\n", PageSize));
>> + return EFI_INVALID_PARAMETER;
>> + break;
>> + };
>> +
>> + DEBUG ((DEBUG_INFO, "Page Size = 0x%lx\n", PageSize));
>> +
>> + Offset = fdt_subnode_offset_namelen (
>> + DtbAddress,
>> + Offset,
>> + "memory-regions",
>> + sizeof("memory-regions") - 1
>> + );
>> + if (Offset < 1) {
>> + DEBUG ((
>> + DEBUG_ERROR,
>> + "%s: Missing in FF-A boot information manifest\n",
>> + "memory-regions"
>> + ));
>> + return EFI_INVALID_PARAMETER;
>> + }
>> +
>> + for (
>> + Node = fdt_first_subnode (DtbAddress, Offset);
>> + Node > 0;
>> + Node = fdt_next_subnode (DtbAddress, Node)) {
>> + if (!FoundNsCommBuffer) {
>> + FoundNsCommBuffer = ReadRegionInfo (
>> + DtbAddress,
>> + Node,
>> + "ns-comm",
>> + sizeof ("ns-comm") - 1,
>> + PageSize,
>> + &StmmBootInfo->SpNsCommBufBase,
>> + &StmmBootInfo->SpNsCommBufSize
>> + );
>> + }
>> +
>> + if (!FoundHeap) {
>> + FoundHeap = ReadRegionInfo (
>> + DtbAddress,
>> + Node,
>> + "heap",
>> + sizeof ("heap") - 1,
>> + PageSize,
>> + &StmmBootInfo->SpHeapBase,
>> + &StmmBootInfo->SpHeapSize
>> + );
>> + }
>> +
>> + if (!FoundSharedBuffer) {
>> + FoundSharedBuffer = ReadRegionInfo (
>> + DtbAddress,
>> + Node,
>> + "shared-buff",
>> + sizeof ("shared-buff") - 1,
>> + PageSize,
>> + &StmmBootInfo->SpSharedBufBase,
>> + &StmmBootInfo->SpSharedBufSize
>> + );
>> + }
>> + }
>> +
>> + if (!FoundNsCommBuffer) {
>> + DEBUG ((DEBUG_ERROR, "Failed to find ns-comm buffer info\n"));
>> + return EFI_INVALID_PARAMETER;
>> + }
>> +
>> + if (!FoundHeap) {
>> + DEBUG ((DEBUG_ERROR, "Failed to find heap buffer info\n"));
>> + return EFI_INVALID_PARAMETER;
>> + }
>> +
>> + if (!FoundSharedBuffer) {
>> + DEBUG ((DEBUG_ERROR, "Failed to find shared buffer info\n"));
>> + return EFI_INVALID_PARAMETER;
>> + }
>> +
>> + // Populate CPU information under the assumption made in the FF-A
>> spec that
>> + // this is a uniprocessor SP that is capable of migration. So, it
>> is fine if
>> + // it sees 0 as both its physical and linear cpu id
>> + StmmBootInfo->CpuInfo.Mpidr = 0;
>> + StmmBootInfo->CpuInfo.LinearId = 0;
>> + StmmBootInfo->CpuInfo.Flags = 0;
>> +
>> + return EFI_SUCCESS;
>> +}
>
> [GM]
> Outside of the mandatory properties, I expect that there could be some
> custom fields in the dtb manifest. Can you add a means for a vendor to
> hook in parsing properties that only apply to them. An OEM Library ?
>> +
>> /**
>> Query the SPM version, check compatibility and return success if
>> compatible.
>>
>> @@ -343,6 +650,49 @@ InitArmSvcArgs (
>> }
>> }
>>
>> +
>> +STATIC
>> +EFI_STATUS
>> +GetSpManifest (
>> + IN OUT UINT64 **SpManifestAddr,
>> + IN VOID *BootInfoAddr
>> + )
>> +{
>> + EFI_FFA_BOOT_INFO_HEADER *FfaBootInfo;
>> + EFI_FFA_BOOT_INFO_DESC *FfaBootInfoDesc;
>> +
>> + // Paranoid check to avoid an inadvertent NULL pointer dereference.
>> + if (BootInfoAddr == NULL) {
>> + DEBUG ((DEBUG_ERROR, "FF-A Boot information is NULL\n"));
>> + return EFI_INVALID_PARAMETER;
>> + }
>> +
>> + // Check boot information magic number.
>> + FfaBootInfo = (EFI_FFA_BOOT_INFO_HEADER *) BootInfoAddr;
>> + if (FfaBootInfo->Magic != FFA_INIT_DESC_SIGNATURE) {
>> + DEBUG ((
>> + DEBUG_ERROR, "FfaBootInfo Magic no. is invalid 0x%ux\n",
>> + FfaBootInfo->Magic
>> + ));
>> + return EFI_INVALID_PARAMETER;
>> + }
>> +
>> +
>> + FfaBootInfoDesc =
>> + (EFI_FFA_BOOT_INFO_DESC *)((UINT8 *)BootInfoAddr +
>> + FfaBootInfo->OffsetBootInfoDesc);
>> +
>> + if (FfaBootInfoDesc->Type ==
>> + (FFA_BOOT_INFO_TYPE(FFA_BOOT_INFO_TYPE_STD) |
>> + FFA_BOOT_INFO_TYPE_ID(FFA_BOOT_INFO_TYPE_ID_FDT))) {
>> + *SpManifestAddr = (UINT64 *) FfaBootInfoDesc->Content;
>> + return EFI_SUCCESS;
>> + }
>> +
>> + DEBUG ((DEBUG_ERROR, "SP manifest not found \n"));
>> + return EFI_NOT_FOUND;
>> +}
>> +
>> /**
>> The entry point of Standalone MM Foundation.
>>
>> @@ -363,6 +713,7 @@ ModuleEntryPoint (
>> {
>> PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
>> EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo;
>> + EFI_STMM_BOOT_INFO StmmBootInfo = {0};
>> ARM_SVC_ARGS InitMmFoundationSvcArgs;
>> EFI_STATUS Status;
>> INT32 Ret;
>> @@ -372,6 +723,8 @@ ModuleEntryPoint (
>> VOID *TeData;
>> UINTN TeDataSize;
>> EFI_PHYSICAL_ADDRESS ImageBase;
>> + UINT64 *DtbAddress;
>> + EFI_FIRMWARE_VOLUME_HEADER *BfvAddress;
>> BOOLEAN UseOnlyFfaAbis = FALSE;
>>
>> if (FixedPcdGet32 (PcdFfaEnable) != 0) {
>> @@ -384,18 +737,36 @@ ModuleEntryPoint (
>> goto finish;
>> }
>>
>> - PayloadBootInfo = GetAndPrintBootinformation (SharedBufAddress);
>> - if (PayloadBootInfo == NULL) {
>> - Status = EFI_UNSUPPORTED;
>> - goto finish;
>> + // If only FF-A is used, the DTB address is passed in the Boot
>> information
>> + // structure. Else, the Boot info is copied from Sharedbuffer.
>> + if (UseOnlyFfaAbis) {
>> + Status = GetSpManifest (&DtbAddress, SharedBufAddress);
>> + if (Status != EFI_SUCCESS) {
>> + goto finish;
>> + }
>> +
>> + // Extract boot information from the DTB
>> + Status = PopulateBootinformation (&StmmBootInfo, (VOID *)
>> DtbAddress);
>> + if (Status != EFI_SUCCESS) {
>> + goto finish;
>> + }
>> +
>> + // Stash the base address of the boot firmware volume
>> + BfvAddress = (EFI_FIRMWARE_VOLUME_HEADER *) StmmBootInfo.SpMemBase;
>> + } else {
>> + PayloadBootInfo = GetAndPrintBootinformation (SharedBufAddress);
>> + if (PayloadBootInfo == NULL) {
>> + Status = EFI_UNSUPPORTED;
>> + goto finish;
>> + }
>> +
>> + // Stash the base address of the boot firmware volume
>> + BfvAddress = (EFI_FIRMWARE_VOLUME_HEADER *)
>> PayloadBootInfo->SpImageBase;
>> }
>>
>> +
>> // Locate PE/COFF File information for the Standalone MM core module
>> - Status = LocateStandaloneMmCorePeCoffData (
>> - (EFI_FIRMWARE_VOLUME_HEADER
>> *)(UINTN)PayloadBootInfo->SpImageBase,
>> - &TeData,
>> - &TeDataSize
>> - );
>> + Status = LocateStandaloneMmCorePeCoffData (BfvAddress, &TeData,
>> &TeDataSize);
>>
>> if (EFI_ERROR (Status)) {
>> goto finish;
>> --
>> 2.34.1
>>
>>
>>
>> -=-=-=-=-=-=
>> Groups.io Links: You receive all messages sent to this group.
>> View/Reply Online (#106801):
>> https://edk2.groups.io/g/devel/message/106801
>> Mute This Topic: https://groups.io/mt/100079881/6098446
>> Group Owner: devel+owner@edk2.groups.io
>> Unsubscribe: https://edk2.groups.io/g/devel/unsub
>> [gmahadevan@nvidia.com]
>> -=-=-=-=-=-=
>>
>>
>
>
>
>
>
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH V1 14/20] ArmPkg/MmCommunicationDxe: Introduce FF-A version check
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 14/20] ArmPkg/MmCommunicationDxe: Introduce FF-A version check Nishant Sharma
@ 2023-07-13 16:56 ` Chris Fernald
0 siblings, 0 replies; 41+ messages in thread
From: Chris Fernald @ 2023-07-13 16:56 UTC (permalink / raw)
To: devel, nishant.sharma
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
Might as well use MAKE_FFA_VERSION from ArmFfaSvc.h for consistency.
-Chris
On 7/11/2023 7:36 AM, Nishant Sharma wrote:
> From: Achin Gupta <achin.gupta@arm.com>
>
> This patch adds support for querying whether FF-A v1.1 is supported by the
> FF-A impplementation.
>
> Signed-off-by: Achin Gupta <achin.gupta@arm.com>
> Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
> ---
> ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf | 3 +++
> ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h | 7 ++++++-
> ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 17 ++++++++++++-----
> 3 files changed, 21 insertions(+), 6 deletions(-)
>
> diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
> index 05b6de73ff34..c15b1a7a86ae 100644
> --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
> +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
> @@ -31,6 +31,9 @@
> ArmPkg/ArmPkg.dec
> MdePkg/MdePkg.dec
>
> +[FixedPcd]
> + gArmTokenSpaceGuid.PcdFfaEnable
> +
> [LibraryClasses]
> ArmLib
> ArmSmcLib
> diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
> index 5c5fcb576856..71edf7f49174 100644
> --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
> +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h
> @@ -16,7 +16,12 @@
> #define MM_MAJOR_VER(x) (((x) & MM_MAJOR_VER_MASK) >> MM_MAJOR_VER_SHIFT)
> #define MM_MINOR_VER(x) ((x) & MM_MINOR_VER_MASK)
>
> +#if (FixedPcdGet32 (PcdFfaEnable) == 1)
> #define MM_CALLER_MAJOR_VER 0x1UL
> -#define MM_CALLER_MINOR_VER 0x0
> +#define MM_CALLER_MINOR_VER 0x1UL
> +#else
> +#define MM_CALLER_MAJOR_VER 0x1UL
> +#define MM_CALLER_MINOR_VER 0x0UL
> +#endif
>
> #endif /* MM_COMMUNICATE_H_ */
> diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> index 85d9034555f0..a6fcd590a65b 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"
> @@ -250,14 +251,20 @@ GetMmCompatibility (
> {
> EFI_STATUS Status;
> UINT32 MmVersion;
> - ARM_SMC_ARGS MmVersionArgs;
> + ARM_SMC_ARGS SmcArgs = {0};
>
> - // MM_VERSION uses SMC32 calling conventions
> - MmVersionArgs.Arg0 = ARM_SMC_ID_MM_VERSION_AARCH32;
> + if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> + SmcArgs.Arg0 = ARM_SVC_ID_FFA_VERSION_AARCH32;
> + SmcArgs.Arg1 = MM_CALLER_MAJOR_VER << MM_MAJOR_VER_SHIFT;
> + SmcArgs.Arg1 |= MM_CALLER_MINOR_VER;
> + } else {
> + // MM_VERSION uses SMC32 calling conventions
> + SmcArgs.Arg0 = ARM_SMC_ID_MM_VERSION_AARCH32;
> + }
>
> - ArmCallSmc (&MmVersionArgs);
> + ArmCallSmc (&SmcArgs);
>
> - MmVersion = MmVersionArgs.Arg0;
> + MmVersion = SmcArgs.Arg0;
>
> if ((MM_MAJOR_VER (MmVersion) == MM_CALLER_MAJOR_VER) &&
> (MM_MINOR_VER (MmVersion) >= MM_CALLER_MINOR_VER))
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH V1 18/20] ArmPkg/MmCommunicationDxe: Discover the StMM SP
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 18/20] ArmPkg/MmCommunicationDxe: Discover the StMM SP Nishant Sharma
2023-07-12 21:10 ` [edk2-devel] " Oliver Smith-Denny
2023-07-12 21:48 ` Girish Mahadevan
@ 2023-07-13 17:16 ` Chris Fernald
2 siblings, 0 replies; 41+ messages in thread
From: Chris Fernald @ 2023-07-13 17:16 UTC (permalink / raw)
To: devel, nishant.sharma
Cc: Ard Biesheuvel, Sami Mujawar, Thomas Abraham, Sayanta Pattanayak,
Achin Gupta
Should |EFI_FFA_PART_INFO_DESC be packed since its used across an ABI?
Also there are a few immediately actionable TODO's in this commit.
|
|-Chris
|
On 7/11/2023 7:36 AM, Nishant Sharma wrote:
> From: Achin Gupta <achin.gupta@arm.com>
>
> This patch adds support for discovering the presence of the SP using the
> EFI_MM_COMMUNICATION_PROTOCOL GUID that implements Standalone MM
> drivers. This is done by querying the framework through
> FFA_PARTITION_INFO_GET whether any partition that implements the
> EFI_MM_COMMUNICATION_PROTOCOL is present or not. The partition ID and
> its properties are stashed for use in subsequent communication with the
> StMM SP.
>
> Signed-off-by: Achin Gupta <achin.gupta@arm.com>
> Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
> ---
> ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 24 +++++
> ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 93 +++++++++++++++++++-
> 2 files changed, 114 insertions(+), 3 deletions(-)
>
> diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> index f78442a465e1..530af8bd3c2e 100644
> --- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> +++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h
> @@ -19,6 +19,9 @@
> #define ARM_SVC_ID_FFA_VERSION_AARCH32 0x84000063
> #define ARM_SVC_ID_FFA_RXTX_MAP_AARCH32 0x84000066
> #define ARM_SVC_ID_FFA_RXTX_MAP_AARCH64 0xC4000066
> +#define ARM_SVC_ID_FFA_RX_RELEASE_AARCH32 0x84000065
> +#define ARM_SVC_ID_FFA_RXTX_UNMAP_AARCH32 0x84000067
> +#define ARM_SVC_ID_FFA_PARTITION_INFO_GET_AARCH32 0x84000068
> #define ARM_SVC_ID_FFA_ID_GET_AARCH32 0x84000069
> #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH32 0x8400006F
> #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH32 0x84000070
> @@ -154,4 +157,25 @@ typedef struct {
> UINT64 Reserved;
> } EFI_FFA_BOOT_INFO_HEADER;
>
> +// FF-A partition information descriptor
> +typedef struct {
> + UINT16 PartId;
> + UINT16 EcCnt;
> + UINT32 PartProps;
> + UINT32 PartGuid[4];
> +} EFI_FFA_PART_INFO_DESC;
> +
> +#define PART_INFO_PROP_MASK 0x3f
> +#define PART_INFO_PROP_SHIFT 0
> +#define PART_INFO_PROP_DIR_MSG_RECV_BIT (1u << 0)
> +#define PART_INFO_PROP_DIR_MSG_SEND_BIT (1u << 1)
> +#define PART_INFO_PROP_INDIR_MSG_BIT (1u << 2)
> +#define PART_INFO_PROP_NOTIFICATIONS_BIT (1u << 3)
> +#define PART_INFO_PROP_EP_TYPE_MASK 0x3
> +#define PART_INFO_PROP_EP_TYPE_SHIFT 4
> +#define PART_INFO_PROP_EP_PE 0
> +#define PART_INFO_PROP_EP_SEPID_IND 1
> +#define PART_INFO_PROP_EP_SEPID_DEP 2
> +#define PART_INFO_PROP_EP_AUX 3
> +
> #endif // ARM_FFA_SVC_H_
> diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> index 39a1b329b9ea..94a5d96c051d 100644
> --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
> @@ -8,6 +8,7 @@
>
> #include <Library/ArmLib.h>
> #include <Library/ArmSmcLib.h>
> +#include <Library/BaseLib.h>
> #include <Library/BaseMemoryLib.h>
> #include <Library/DebugLib.h>
> #include <Library/DxeServicesTableLib.h>
> @@ -28,6 +29,11 @@
> //
> STATIC UINT16 mFfaPartId;
>
> +// Partition information of the StMM SP if FF-A support is enabled
> +// TODO: Revisit assumption that there is only a single StMM SP
> +//
> +STATIC EFI_FFA_PART_INFO_DESC mStmmPartInfo;
> +
> //
> // RX/TX pair if FF-A support is enabled
> //
> @@ -298,7 +304,9 @@ GetMmCompatibility (
> {
> EFI_STATUS Status;
> UINT32 MmVersion;
> + UINT32 SmccUuid[4];
> ARM_SMC_ARGS SmcArgs = {0};
> + EFI_GUID MmCommProtGuid = EFI_MM_COMMUNICATION_PROTOCOL_GUID;
>
> if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> SmcArgs.Arg0 = ARM_SVC_ID_FFA_VERSION_AARCH32;
> @@ -335,14 +343,21 @@ GetMmCompatibility (
> Status = EFI_UNSUPPORTED;
> }
>
> - // If FF-A is supported then discover our ID and register our RX/TX buffers.
> + // If FF-A is supported then discover the StMM SP's presence, ID, our ID and
> + // register our RX/TX buffers.
> if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> + EFI_FFA_PART_INFO_DESC *StmmPartInfo;
> +
> // Get our ID
> ZeroMem(&SmcArgs, sizeof(SmcArgs));
> SmcArgs.Arg0 = ARM_SVC_ID_FFA_ID_GET_AARCH32;
> ArmCallSmc (&SmcArgs);
> if (SmcArgs.Arg0 == ARM_SVC_ID_FFA_ERROR_AARCH32) {
> - DEBUG ((DEBUG_ERROR, "Unable to retrieve FF-A partition ID (%d).\n", SmcArgs.Arg2));
> + DEBUG ((
> + DEBUG_ERROR,
> + "Unable to retrieve FF-A partition ID (%d).\n",
> + SmcArgs.Arg2
> + ));
> return EFI_UNSUPPORTED;
> }
> DEBUG ((DEBUG_INFO, "FF-A partition ID = 0x%lx.\n", SmcArgs.Arg2));
> @@ -355,11 +370,83 @@ GetMmCompatibility (
> SmcArgs.Arg3 = EFI_PAGE_SIZE / SIZE_4KB;
> ArmCallSmc (&SmcArgs);
> if (SmcArgs.Arg0 == ARM_SVC_ID_FFA_ERROR_AARCH32) {
> - DEBUG ((DEBUG_ERROR, "Unable to register FF-A RX/TX buffers (%d).\n", SmcArgs.Arg2));
> + DEBUG ((
> + DEBUG_ERROR,
> + "Unable to register FF-A RX/TX buffers (%d).\n",
> + SmcArgs.Arg2
> + ));
> return EFI_UNSUPPORTED;
> }
>
> + // Discover the StMM SP after converting the EFI_GUID to a format TF-A will
> + // understand.
> + SmcArgs.Arg0 = ARM_SVC_ID_FFA_PARTITION_INFO_GET_AARCH32;
> + MmCommProtGuid.Data2 += MmCommProtGuid.Data3;
> + MmCommProtGuid.Data3 = MmCommProtGuid.Data2 - MmCommProtGuid.Data3;
> + MmCommProtGuid.Data2 = MmCommProtGuid.Data2 - MmCommProtGuid.Data3;
> + CopyMem ((VOID *) SmccUuid, (VOID *) &MmCommProtGuid, sizeof(EFI_GUID));
> + SmcArgs.Arg1 = SmccUuid[0];
> + SmcArgs.Arg2 = SmccUuid[1];
> + SmcArgs.Arg3 = SmccUuid[2];
> + SmcArgs.Arg3 = SwapBytes32(SmcArgs.Arg3);
> + SmcArgs.Arg4 = SmccUuid[3];
> + SmcArgs.Arg4 = SwapBytes32(SmcArgs.Arg4);
> + ArmCallSmc (&SmcArgs);
> + if (SmcArgs.Arg0 == ARM_SVC_ID_FFA_ERROR_AARCH32) {
> + DEBUG ((
> + DEBUG_ERROR,
> + "Unable to discover FF-A StMM SP (%d).\n",
> + SmcArgs.Arg2
> + ));
> + goto ffa_init_error;
> + }
> +
> + // Retrieve the partition information from the RX buffer
> + StmmPartInfo = (EFI_FFA_PART_INFO_DESC *) FfaRxBuf;
> +
> + // TODO: Sanity check the partition type.
> + DEBUG ((DEBUG_INFO, "Discovered FF-A StMM SP."));
> + DEBUG ((
> + DEBUG_INFO,
> + "ID = 0x%lx, Execution contexts = %d, Properties = 0x%lx. \n",
> + StmmPartInfo->PartId,
> + StmmPartInfo->EcCnt,
> + StmmPartInfo->PartProps
> + ));
> +
> + // Make a local copy
> + mStmmPartInfo = *StmmPartInfo;
> +
> + // Release the RX buffer
> + ZeroMem(&SmcArgs, sizeof(SmcArgs));
> + SmcArgs.Arg0 = ARM_SVC_ID_FFA_RX_RELEASE_AARCH32;
> + SmcArgs.Arg1 = mFfaPartId;
> + ArmCallSmc (&SmcArgs);
> +
> + // This should really never fail since there is only a single CPU booting
> + // and another CPU could not have released the RX buffer before us.
> + if (SmcArgs.Arg0 == ARM_SVC_ID_FFA_ERROR_AARCH32) {
> + DEBUG ((
> + DEBUG_ERROR,
> + "Unable to release FF-A RX buffer (%d).\n",
> + SmcArgs.Arg2
> + ));
> + ASSERT (0);
> + goto ffa_init_error;
> + }
> +
> return EFI_SUCCESS;
> +
> + ffa_init_error:
> + // Release the RX/TX pair before exiting.
> + ZeroMem(&SmcArgs, sizeof(SmcArgs));
> + SmcArgs.Arg0 = ARM_SVC_ID_FFA_RXTX_UNMAP_AARCH32;
> + SmcArgs.Arg1 = mFfaPartId << 16; // TODO: Use a macro for shift
> + ArmCallSmc (&SmcArgs);
> +
> + // We do not bother checking the error code of the RXTX_UNMAP invocation
> + // since we did map the buffers and this call must succeed.
> + return EFI_UNSUPPORTED;
> }
>
> return Status;
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [edk2-devel] [edk2-platforms][PATCH V1 09/20] StandaloneMmPkg: parse SP manifest and populate new boot information
2023-07-13 16:48 ` Chris Fernald
@ 2023-07-13 20:49 ` Achin Gupta
0 siblings, 0 replies; 41+ messages in thread
From: Achin Gupta @ 2023-07-13 20:49 UTC (permalink / raw)
To: Nishant Sharma, gmahadevan@nvidia.com, chris.fernald@outlook.com,
devel@edk2.groups.io
Cc: Sami Mujawar, Sayanta Pattanayak, Thomas Abraham,
ardb+tianocore@kernel.org
Hi Chris,
Prior to FF-A, an impdef structure populated by TF-A was passed to a
SPM_MM based StMM SP. The data structures used for this are
EFI_SECURE_PARTITION_BOOT_INFO and EFI_SECURE_PARTITION_CPU_INFO.
With FF-A, we have reduced the amount of information that is passed
e.g. the per-cpu information is not passed. The remaining information
has been generalized so that it is not specific to StMM SPs.
This information is only used at boot time. Hence, passing it once via
the FF-A boot information protocol made sense.
The FF-A spec does not specify the format in which boot information is
passed. An SP manifest is specified in a DT by default. So, this was
the natural choice. The same information could be passed using a HOB
list but that would require additional support in TF-A.
I hope this helps.
cheers,
Achin
On Thu, 2023-07-13 at 09:48 -0700, Chris Fernald wrote:
> Achin/Nishant, could you explain the motivation behind falling back
> to
> device tree for some of the secure partition information? It seems
> like
> we have this large abstraction framework using FF-A and it seems a
> bit
> odd to have the secure partition have to directly read device tree
> for
> some of this information when everything else is query-able from the
> framework itself.
>
> Thanks,
>
> Chris Fernald
>
> On 7/13/2023 8:24 AM, Girish Mahadevan via groups.io wrote:
> > I had one comment , in-line.
> >
> > Thanks
> > Girish
> >
> > On 7/11/2023 8:36 AM, Nishant Sharma via groups.io wrote:
> > > External email: Use caution opening links or attachments
> > >
> > >
> > > From: Achin Gupta <achin.gupta@arm.com>
> > >
> > > This patch discovers the SP manifest in DT format passed by the
> > > SPMC. It
> > > then parses it to obtain the boot information required to
> > > initialise the
> > > SP.
> > >
> > > Signed-off-by: Achin Gupta <achin.gupta@arm.com>
> > > Signed-off-by: Sayanta Pattanayak <sayanta.pattanayak@arm.com>
> > > Signed-off-by: Nishant Sharma <nishant.sharma@arm.com>
> > > ---
> > > StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.h
> > > |
> > > 2 +-
> > > StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/Standalone
> > > MmCoreEntryPoint.c
> > > > 389 +++++++++++++++++++-
> > > 2 files changed, 381 insertions(+), 10 deletions(-)
> > >
> > > diff --git
> > > a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.
> > > h
> > > b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.
> > > h
> > > index c965192c702e..90d67a2f25b5 100644
> > > ---
> > > a/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.
> > > h
> > > +++
> > > b/StandaloneMmPkg/Include/Library/Arm/StandaloneMmCoreEntryPoint.
> > > h
> > > @@ -2,7 +2,7 @@
> > > Entry point to the Standalone MM Foundation when initialized
> > > during the SEC
> > > phase on ARM platforms
> > >
> > > -Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.<BR>
> > > +Copyright (c) 2017 - 2023, Arm Ltd. All rights reserved.<BR>
> > > SPDX-License-Identifier: BSD-2-Clause-Patent
> > >
> > > **/
> > > diff --git
> > > a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/Standalo
> > > neMmCoreEntryPoint.c
> > > b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/Standalo
> > > neMmCoreEntryPoint.c
> > >
> > > index 9f6af55c86c4..505786aff07c 100644
> > > ---
> > > a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/Standalo
> > > neMmCoreEntryPoint.c
> > > +++
> > > b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/Standalo
> > > neMmCoreEntryPoint.c
> > > @@ -38,6 +38,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> > >
> > > #define BOOT_PAYLOAD_VERSION 1
> > >
> > > +#define FFA_PAGE_4K 0
> > > +#define FFA_PAGE_16K 1
> > > +#define FFA_PAGE_64K 2
> > > +
> > > PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT CpuDriverEntryPoint = NULL;
> > >
> > > /**
> > > @@ -106,6 +110,7 @@ GetAndPrintBootinformation (
> > > }
> > >
> > > return PayloadBootInfo;
> > > +}
> > >
> > > /**
> > > An StMM SP implements partial support for FF-A v1.0. The FF-A
> > > ABIs are used to
> > > @@ -266,6 +271,308 @@ DelegatedEventLoop (
> > > }
> > > }
> > >
> > > +STATIC
> > > +BOOLEAN
> > > +CheckDescription (
> > > + IN VOID * DtbAddress,
> > > + IN INT32 Offset,
> > > + OUT CHAR8 * Description,
> > > + OUT UINT32 Size
> > > + )
> > > +{
> > > + CONST CHAR8 * Property;
> > > + INT32 LenP;
> > > +
> > > + Property = fdt_getprop (DtbAddress, Offset, "description",
> > > &LenP);
> > > + if (Property == NULL) {
> > > + return FALSE;
> > > + }
> > > +
> > > + return CompareMem (Description, Property, MIN(Size,
> > > (UINT32)LenP))
> > > == 0;
> > > +
> > > +}
> > > +
> > > +STATIC
> > > +EFI_STATUS
> > > +ReadProperty32 (
> > > + IN VOID * DtbAddress,
> > > + IN INT32 Offset,
> > > + IN CHAR8 * Property,
> > > + OUT UINT32 * Value
> > > + )
> > > +{
> > > + CONST UINT32 * Property32;
> > > +
> > > + Property32 = fdt_getprop (DtbAddress, Offset, Property,
> > > NULL);
> > > + if (Property32 == NULL) {
> > > + DEBUG ((
> > > + DEBUG_ERROR,
> > > + "%s: Missing in FF-A boot information manifest\n",
> > > + Property
> > > + ));
> > > + return EFI_INVALID_PARAMETER;
> > > + }
> > > +
> > > + *Value = fdt32_to_cpu (*Property32);
> > > +
> > > + return EFI_SUCCESS;
> > > +}
> > > +
> > > +STATIC
> > > +EFI_STATUS
> > > +ReadProperty64 (
> > > + IN VOID * DtbAddress,
> > > + IN INT32 Offset,
> > > + IN CHAR8 * Property,
> > > + OUT UINT64 * Value
> > > + )
> > > +{
> > > + CONST UINT64 * Property64;
> > > +
> > > + Property64 = fdt_getprop (DtbAddress, Offset, Property,
> > > NULL);
> > > + if (Property64 == NULL) {
> > > + DEBUG ((
> > > + DEBUG_ERROR,
> > > + "%s: Missing in FF-A boot information manifest\n",
> > > + Property
> > > + ));
> > > + return EFI_INVALID_PARAMETER;
> > > + }
> > > +
> > > + *Value = fdt64_to_cpu (*Property64);
> > > +
> > > + return EFI_SUCCESS;
> > > +}
> > > +
> > > +STATIC
> > > +BOOLEAN
> > > +ReadRegionInfo (
> > > + IN VOID *DtbAddress,
> > > + IN INT32 Node,
> > > + IN CHAR8 *Region,
> > > + IN UINTN RegionStrSize,
> > > + IN UINT32 PageSize,
> > > + OUT UINT64 *Address,
> > > + OUT UINT64 *Size
> > > + )
> > > +{
> > > + BOOLEAN FoundBuffer;
> > > + INTN Status = 0;
> > > +
> > > + FoundBuffer = CheckDescription (
> > > + DtbAddress,
> > > + Node,
> > > + Region,
> > > + RegionStrSize
> > > + );
> > > + if (!FoundBuffer) {
> > > + return FALSE;
> > > + }
> > > +
> > > + DEBUG ((DEBUG_INFO, "Found Node: %a\n", Region));
> > > + Status = ReadProperty64 (
> > > + DtbAddress,
> > > + Node,
> > > + "base-address",
> > > + Address
> > > + );
> > > + if (Status != EFI_SUCCESS) {
> > > + DEBUG ((DEBUG_ERROR, "base-address missing in DTB"));
> > > + return FALSE;
> > > + }
> > > + DEBUG ((
> > > + DEBUG_INFO,
> > > + "base = 0x%llx\n",
> > > + *Address
> > > + ));
> > > +
> > > + Status = ReadProperty32 (
> > > + DtbAddress,
> > > + Node,
> > > + "pages-count",
> > > + (UINT32*)Size
> > > + );
> > > + if (Status != EFI_SUCCESS) {
> > > + DEBUG ((DEBUG_ERROR, "pages-count missing in DTB"));
> > > + return FALSE;
> > > + }
> > > +
> > > + DEBUG ((DEBUG_ERROR, "pages-count: 0x%lx\n", *Size));
> > > +
> > > + *Size = *Size * PageSize;
> > > + DEBUG ((
> > > + DEBUG_INFO,
> > > + "Size = 0x%llx\n",
> > > + *Size
> > > + ));
> > > +
> > > + return TRUE;
> > > +}
> > > +
> > > +/**
> > > +
> > > + Populates FF-A boot information structure.
> > > +
> > > + This function receives the address of a DTB from which boot
> > > information defind
> > > + by FF-A and required to initialize the standalone environment
> > > is
> > > extracted.
> > > +
> > > + @param [in, out] StmmBootInfo Pointer to a pre-allocated boot
> > > info structure to be
> > > + populated.
> > > + @param [in] DtbAddress Address of the Device tree from
> > > where boot
> > > + information will be fetched.
> > > +**/
> > > +STATIC
> > > +EFI_STATUS
> > > +PopulateBootinformation (
> > > + IN OUT EFI_STMM_BOOT_INFO *StmmBootInfo,
> > > + IN VOID *DtbAddress
> > > +)
> > > +{
> > > + INTN Status;
> > > + INT32 Offset;
> > > + INT32 Node;
> > > + BOOLEAN FoundNsCommBuffer = FALSE;
> > > + BOOLEAN FoundSharedBuffer = FALSE;
> > > + BOOLEAN FoundHeap = FALSE;
> > > + UINT32 PageSize;
> > > +
> > > + Offset = fdt_node_offset_by_compatible (DtbAddress, -1,
> > > "arm,ffa-manifest-1.0");
> > > + DEBUG ((DEBUG_INFO, "Offset = %d \n", Offset));
> > > + if (Offset < 0) {
> > > + DEBUG ((DEBUG_ERROR, "Missing FF-A boot information in
> > > manifest\n"));
> > > + return EFI_NOT_FOUND;
> > > + }
> > > +
> > > + Status = ReadProperty64 (
> > > + DtbAddress,
> > > + Offset,
> > > + "load-address",
> > > + &StmmBootInfo->SpMemBase
> > > + );
> > > + if (Status != EFI_SUCCESS) {
> > > + return Status;
> > > + }
> > > + DEBUG ((DEBUG_INFO, "sp mem base = 0x%llx\n",
> > > StmmBootInfo->SpMemBase));
> > > +
> > > + Status = ReadProperty64 (
> > > + DtbAddress,
> > > + Offset,
> > > + "image-size",
> > > + &StmmBootInfo->SpMemSize
> > > + );
> > > + if (Status != EFI_SUCCESS) {
> > > + return Status;
> > > + }
> > > + DEBUG ((DEBUG_INFO, "sp mem size = 0x%llx\n",
> > > StmmBootInfo->SpMemSize));
> > > +
> > > + Status = ReadProperty32 (DtbAddress, Offset, "xlat-granule",
> > > &PageSize);
> > > + if (Status != EFI_SUCCESS) {
> > > + return Status;
> > > + }
> > > +
> > > + /* EFI_PAGE_SIZE is 4KB */
> > > + switch (PageSize) {
> > > + case FFA_PAGE_4K:
> > > + PageSize = EFI_PAGE_SIZE;
> > > + break;
> > > +
> > > + case FFA_PAGE_16K:
> > > + PageSize = 4 * EFI_PAGE_SIZE;
> > > + break;
> > > +
> > > + case FFA_PAGE_64K:
> > > + PageSize = 16 * EFI_PAGE_SIZE;
> > > + break;
> > > +
> > > + default:
> > > + DEBUG ((DEBUG_ERROR, "Invalid page type = %lu\n",
> > > PageSize));
> > > + return EFI_INVALID_PARAMETER;
> > > + break;
> > > + };
> > > +
> > > + DEBUG ((DEBUG_INFO, "Page Size = 0x%lx\n", PageSize));
> > > +
> > > + Offset = fdt_subnode_offset_namelen (
> > > + DtbAddress,
> > > + Offset,
> > > + "memory-regions",
> > > + sizeof("memory-regions") - 1
> > > + );
> > > + if (Offset < 1) {
> > > + DEBUG ((
> > > + DEBUG_ERROR,
> > > + "%s: Missing in FF-A boot information manifest\n",
> > > + "memory-regions"
> > > + ));
> > > + return EFI_INVALID_PARAMETER;
> > > + }
> > > +
> > > + for (
> > > + Node = fdt_first_subnode (DtbAddress, Offset);
> > > + Node > 0;
> > > + Node = fdt_next_subnode (DtbAddress, Node)) {
> > > + if (!FoundNsCommBuffer) {
> > > + FoundNsCommBuffer = ReadRegionInfo (
> > > + DtbAddress,
> > > + Node,
> > > + "ns-comm",
> > > + sizeof ("ns-comm") - 1,
> > > + PageSize,
> > > + &StmmBootInfo->SpNsCommBufBase,
> > > + &StmmBootInfo->SpNsCommBufSize
> > > + );
> > > + }
> > > +
> > > + if (!FoundHeap) {
> > > + FoundHeap = ReadRegionInfo (
> > > + DtbAddress,
> > > + Node,
> > > + "heap",
> > > + sizeof ("heap") - 1,
> > > + PageSize,
> > > + &StmmBootInfo->SpHeapBase,
> > > + &StmmBootInfo->SpHeapSize
> > > + );
> > > + }
> > > +
> > > + if (!FoundSharedBuffer) {
> > > + FoundSharedBuffer = ReadRegionInfo (
> > > + DtbAddress,
> > > + Node,
> > > + "shared-buff",
> > > + sizeof ("shared-buff") - 1,
> > > + PageSize,
> > > + &StmmBootInfo->SpSharedBufBase,
> > > + &StmmBootInfo->SpSharedBufSize
> > > + );
> > > + }
> > > + }
> > > +
> > > + if (!FoundNsCommBuffer) {
> > > + DEBUG ((DEBUG_ERROR, "Failed to find ns-comm buffer
> > > info\n"));
> > > + return EFI_INVALID_PARAMETER;
> > > + }
> > > +
> > > + if (!FoundHeap) {
> > > + DEBUG ((DEBUG_ERROR, "Failed to find heap buffer info\n"));
> > > + return EFI_INVALID_PARAMETER;
> > > + }
> > > +
> > > + if (!FoundSharedBuffer) {
> > > + DEBUG ((DEBUG_ERROR, "Failed to find shared buffer
> > > info\n"));
> > > + return EFI_INVALID_PARAMETER;
> > > + }
> > > +
> > > + // Populate CPU information under the assumption made in the
> > > FF-A
> > > spec that
> > > + // this is a uniprocessor SP that is capable of migration. So,
> > > it
> > > is fine if
> > > + // it sees 0 as both its physical and linear cpu id
> > > + StmmBootInfo->CpuInfo.Mpidr = 0;
> > > + StmmBootInfo->CpuInfo.LinearId = 0;
> > > + StmmBootInfo->CpuInfo.Flags = 0;
> > > +
> > > + return EFI_SUCCESS;
> > > +}
> >
> > [GM]
> > Outside of the mandatory properties, I expect that there could be
> > some
> > custom fields in the dtb manifest. Can you add a means for a vendor
> > to
> > hook in parsing properties that only apply to them. An OEM Library
> > ?
> > > +
> > > /**
> > > Query the SPM version, check compatibility and return success
> > > if
> > > compatible.
> > >
> > > @@ -343,6 +650,49 @@ InitArmSvcArgs (
> > > }
> > > }
> > >
> > > +
> > > +STATIC
> > > +EFI_STATUS
> > > +GetSpManifest (
> > > + IN OUT UINT64 **SpManifestAddr,
> > > + IN VOID *BootInfoAddr
> > > + )
> > > +{
> > > + EFI_FFA_BOOT_INFO_HEADER *FfaBootInfo;
> > > + EFI_FFA_BOOT_INFO_DESC *FfaBootInfoDesc;
> > > +
> > > + // Paranoid check to avoid an inadvertent NULL pointer
> > > dereference.
> > > + if (BootInfoAddr == NULL) {
> > > + DEBUG ((DEBUG_ERROR, "FF-A Boot information is NULL\n"));
> > > + return EFI_INVALID_PARAMETER;
> > > + }
> > > +
> > > + // Check boot information magic number.
> > > + FfaBootInfo = (EFI_FFA_BOOT_INFO_HEADER *) BootInfoAddr;
> > > + if (FfaBootInfo->Magic != FFA_INIT_DESC_SIGNATURE) {
> > > + DEBUG ((
> > > + DEBUG_ERROR, "FfaBootInfo Magic no. is invalid
> > > 0x%ux\n",
> > > + FfaBootInfo->Magic
> > > + ));
> > > + return EFI_INVALID_PARAMETER;
> > > + }
> > > +
> > > +
> > > + FfaBootInfoDesc =
> > > + (EFI_FFA_BOOT_INFO_DESC *)((UINT8 *)BootInfoAddr +
> > > + FfaBootInfo->OffsetBootInfoDesc);
> > > +
> > > + if (FfaBootInfoDesc->Type ==
> > > + (FFA_BOOT_INFO_TYPE(FFA_BOOT_INFO_TYPE_STD) |
> > > + FFA_BOOT_INFO_TYPE_ID(FFA_BOOT_INFO_TYPE_ID_FDT))) {
> > > + *SpManifestAddr = (UINT64 *) FfaBootInfoDesc->Content;
> > > + return EFI_SUCCESS;
> > > + }
> > > +
> > > + DEBUG ((DEBUG_ERROR, "SP manifest not found \n"));
> > > + return EFI_NOT_FOUND;
> > > +}
> > > +
> > > /**
> > > The entry point of Standalone MM Foundation.
> > >
> > > @@ -363,6 +713,7 @@ ModuleEntryPoint (
> > > {
> > > PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
> > > EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo;
> > > + EFI_STMM_BOOT_INFO StmmBootInfo = {0};
> > > ARM_SVC_ARGS InitMmFoundationSvcArgs;
> > > EFI_STATUS Status;
> > > INT32 Ret;
> > > @@ -372,6 +723,8 @@ ModuleEntryPoint (
> > > VOID *TeData;
> > > UINTN TeDataSize;
> > > EFI_PHYSICAL_ADDRESS ImageBase;
> > > + UINT64 *DtbAddress;
> > > + EFI_FIRMWARE_VOLUME_HEADER *BfvAddress;
> > > BOOLEAN UseOnlyFfaAbis = FALSE;
> > >
> > > if (FixedPcdGet32 (PcdFfaEnable) != 0) {
> > > @@ -384,18 +737,36 @@ ModuleEntryPoint (
> > > goto finish;
> > > }
> > >
> > > - PayloadBootInfo = GetAndPrintBootinformation
> > > (SharedBufAddress);
> > > - if (PayloadBootInfo == NULL) {
> > > - Status = EFI_UNSUPPORTED;
> > > - goto finish;
> > > + // If only FF-A is used, the DTB address is passed in the Boot
> > > information
> > > + // structure. Else, the Boot info is copied from Sharedbuffer.
> > > + if (UseOnlyFfaAbis) {
> > > + Status = GetSpManifest (&DtbAddress, SharedBufAddress);
> > > + if (Status != EFI_SUCCESS) {
> > > + goto finish;
> > > + }
> > > +
> > > + // Extract boot information from the DTB
> > > + Status = PopulateBootinformation (&StmmBootInfo, (VOID *)
> > > DtbAddress);
> > > + if (Status != EFI_SUCCESS) {
> > > + goto finish;
> > > + }
> > > +
> > > + // Stash the base address of the boot firmware volume
> > > + BfvAddress = (EFI_FIRMWARE_VOLUME_HEADER *)
> > > StmmBootInfo.SpMemBase;
> > > + } else {
> > > + PayloadBootInfo = GetAndPrintBootinformation
> > > (SharedBufAddress);
> > > + if (PayloadBootInfo == NULL) {
> > > + Status = EFI_UNSUPPORTED;
> > > + goto finish;
> > > + }
> > > +
> > > + // Stash the base address of the boot firmware volume
> > > + BfvAddress = (EFI_FIRMWARE_VOLUME_HEADER *)
> > > PayloadBootInfo->SpImageBase;
> > > }
> > >
> > > +
> > > // Locate PE/COFF File information for the Standalone MM core
> > > module
> > > - Status = LocateStandaloneMmCorePeCoffData (
> > > - (EFI_FIRMWARE_VOLUME_HEADER
> > > *)(UINTN)PayloadBootInfo->SpImageBase,
> > > - &TeData,
> > > - &TeDataSize
> > > - );
> > > + Status = LocateStandaloneMmCorePeCoffData (BfvAddress,
> > > &TeData,
> > > &TeDataSize);
> > >
> > > if (EFI_ERROR (Status)) {
> > > goto finish;
> > > --
> > > 2.34.1
> > >
> > >
> > >
> > > -=-=-=-=-=-=
> > > Groups.io Links: You receive all messages sent to this group.
> > > View/Reply Online (#106801):
> > > https://edk2.groups.io/g/devel/message/106801
> > > Mute This Topic: https://groups.io/mt/100079881/6098446
> > > Group Owner: devel+owner@edk2.groups.io
> > > Unsubscribe: https://edk2.groups.io/g/devel/unsub
> > > [gmahadevan@nvidia.com]
> > > -=-=-=-=-=-=
> > >
> > >
> >
> >
> >
> >
> >
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 41+ messages in thread
end of thread, other threads:[~2023-07-13 20:49 UTC | newest]
Thread overview: 41+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-11 14:36 [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Nishant Sharma
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 01/20] ArmPkg: Change PcdFfaEnable flag datatype Nishant Sharma
2023-07-12 17:21 ` [edk2-devel] " Oliver Smith-Denny
2023-07-12 17:23 ` Chris Fernald
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 02/20] StandaloneMmPkg: Allocate and initialise SP stack from internal memory Nishant Sharma
2023-07-12 17:47 ` [edk2-devel] " Chris Fernald
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 03/20] StandaloneMmPkg: Include libfdt in the StMM Nishant Sharma
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 04/20] ArmPkg: Add data structures to receive FF-A boot information Nishant Sharma
2023-07-12 17:27 ` [edk2-devel] " Oliver Smith-Denny
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 05/20] ArmPkg/ArmFfaSvc: Add helper macros and fids Nishant Sharma
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 06/20] ArmPkg: Add support for FFA_MEM_PERM_GET/SET ABIs Nishant Sharma
2023-07-12 17:43 ` [edk2-devel] " Oliver Smith-Denny
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 07/20] StandaloneMmPkg: define new data structure to stage FF-A boot information Nishant Sharma
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 08/20] StandaloneMmPkg: Add backwards compatible support to detect FF-A v1.1 Nishant Sharma
2023-07-12 20:31 ` [edk2-devel] " Oliver Smith-Denny
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 09/20] StandaloneMmPkg: parse SP manifest and populate new boot information Nishant Sharma
2023-07-13 15:24 ` [edk2-devel] " Girish Mahadevan
2023-07-13 16:48 ` Chris Fernald
2023-07-13 20:49 ` Achin Gupta
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 10/20] StandaloneMmPkg: Populate Hoblist for SP init from StMM " Nishant Sharma
2023-07-12 20:52 ` [edk2-devel] " Oliver Smith-Denny
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 11/20] StandaloneMmPkg: Skip zero sized sections while tweaking page permissions Nishant Sharma
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 12/20] StandaloneMmPkg: Add global check for FF-A abis Nishant Sharma
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 13/20] ArmPkg: Bump the StMM SP FF-A minor version to 1 Nishant Sharma
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 14/20] ArmPkg/MmCommunicationDxe: Introduce FF-A version check Nishant Sharma
2023-07-13 16:56 ` [edk2-devel] " Chris Fernald
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 15/20] ArmPkg/MmCommunicationDxe: Add support for obtaining FF-A partition ID Nishant Sharma
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 16/20] ArmPkg/MmCommunicationDxe: Register FF-A RX/TX buffers Nishant Sharma
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 17/20] ArmPkg/MmCommunicationDxe: Unmap FF-A RX/TX buffers during ExitBootServices Nishant Sharma
2023-07-12 20:59 ` [edk2-devel] " Oliver Smith-Denny
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 18/20] ArmPkg/MmCommunicationDxe: Discover the StMM SP Nishant Sharma
2023-07-12 21:10 ` [edk2-devel] " Oliver Smith-Denny
2023-07-12 21:48 ` Girish Mahadevan
2023-07-13 17:16 ` Chris Fernald
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 19/20] ArmPkg/MmCommunicationDxe: Use the FF-A transport for MM requests Nishant Sharma
2023-07-11 19:22 ` [edk2-devel] " Kun Qin
2023-07-12 14:21 ` achin.gupta
2023-07-12 17:13 ` Kun Qin
2023-07-12 21:49 ` Girish Mahadevan
2023-07-11 14:36 ` [edk2-platforms][PATCH V1 20/20] StandaloneMmPkg: Add support for MM requests as FF-A direct messages Nishant Sharma
2023-07-12 21:13 ` [edk2-devel] [edk2-platforms][PATCH V1 00/20] Add the support for ARM Firmware First Framework Oliver Smith-Denny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox