summaryrefslogtreecommitdiffstats
path: root/StandaloneMmPkg/Library
diff options
context:
space:
mode:
authorlevi.yun <yeoreum.yun@arm.com>2024-01-25 16:48:05 +0000
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2025-01-17 14:55:42 +0000
commit6087382c62686130a6cb8bd397afe23bad9c4e67 (patch)
tree1a60924a24e17df87a8c75f94fcc6f75657b0cce /StandaloneMmPkg/Library
parent62127dfbc72e3303c58bd05a5995feaf5d0fd91c (diff)
downloadedk2-6087382c62686130a6cb8bd397afe23bad9c4e67.tar.gz
StandaloneMmPkg: Introduce PI_MM_CPU_DRIVER_EP protocol.
This patch introduces a PI_MM_CPU_DRIVER_EP protocol to handle Mmcommunication request based on the CPU driver. Previously the CPU driver entry point was retrieved using the gEfiArmTfCpuDriverEntryPoint HOB. However, this practice is incorrect as StandaloneMM must be a HOB consumer and not a HOB producer. Therefore, remove the CPU entry HOB gEfiArmTfCpuDriverEntryPoint, and replace it with the CPU driver entry protocol EDKII_PI_MM_CPU_DRIVER_EP_PROTOCOL. The EDKII_PI_MM_CPU_DRIVER_EP_PROTOCOL installed in StandaloneMmCpuInitialize() will be used by the code in Arm/StandaloneMmCoreEntryPoint. This protocol is used like below: +=====+ |StandaloneMmCore| +=====+ | CEntryPoint() =================== | ProcessModuleEntryPointList() | +--> StandaloneMmMain() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | // Load StandaloneMmCpu driver which implements | // CpuDriverEntryPoint used by DelegatedEventLoop(). | // and install the gEdkiiPiMmCpuDriverEpProtocolGuid. -------------- | ... // Get CpuDriverEntryPoint implemented by // StandaloneMmCpu driver with gEdkiiPiMmCpuDriverEpProtocolGuid | DelegatedEventLoop() // Handle request by delegating it to // CpuDriverEntryPoint. Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
Diffstat (limited to 'StandaloneMmPkg/Library')
-rw-r--r--StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c12
-rw-r--r--StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c63
-rw-r--r--StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf4
3 files changed, 48 insertions, 31 deletions
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c
index 80ed532352..658d55a8d0 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c
@@ -53,7 +53,6 @@ extern EFI_GUID gEfiMmCpuDriverEpDescriptorGuid;
**/
VOID *
CreateHobListFromBootInfo (
- IN OUT PI_MM_CPU_DRIVER_ENTRYPOINT *CpuDriverEntryPoint,
IN EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo
)
{
@@ -68,7 +67,6 @@ CreateHobListFromBootInfo (
MP_INFORMATION_HOB_DATA *MpInformationHobData;
EFI_PROCESSOR_INFORMATION *ProcInfoBuffer;
EFI_SECURE_PARTITION_CPU_INFO *CpuInfo;
- MM_CPU_DRIVER_EP_DESCRIPTOR *CpuDriverEntryPointDesc;
// Create a hoblist with a PHIT and EOH
HobStart = HobConstructor (
@@ -143,16 +141,6 @@ CreateHobListFromBootInfo (
NsCommBufMmramRange->PhysicalSize = PayloadBootInfo->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 = (MM_CPU_DRIVER_EP_DESCRIPTOR *)BuildGuidHob (
- &gEfiMmCpuDriverEpDescriptorGuid,
- sizeof (MM_CPU_DRIVER_EP_DESCRIPTOR)
- );
-
- *CpuDriverEntryPoint = NULL;
- CpuDriverEntryPointDesc->MmCpuDriverEpPtr = CpuDriverEntryPoint;
-
// Find the size of the GUIDed HOB with SRAM ranges
BufferSize = sizeof (EFI_MMRAM_HOB_DESCRIPTOR_BLOCK);
BufferSize += PayloadBootInfo->NumSpMemRegions * sizeof (EFI_MMRAM_DESCRIPTOR);
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
index 2e4a73fe25..153cf91050 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c
@@ -38,21 +38,23 @@
#include <IndustryStandard/ArmMmSvc.h>
#include <IndustryStandard/ArmFfaSvc.h>
+#include <Protocol/PiMmCpuDriverEp.h>
+
#define SPM_MAJOR_VER_MASK 0xFFFF0000
#define SPM_MINOR_VER_MASK 0x0000FFFF
#define SPM_MAJOR_VER_SHIFT 16
#define FFA_NOT_SUPPORTED -1
+#define BOOT_PAYLOAD_VERSION 1
+
+extern EFI_MM_SYSTEM_TABLE gMmCoreMmst;
+
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 BOOT_PAYLOAD_VERSION 1
-
-PI_MM_CPU_DRIVER_ENTRYPOINT CpuDriverEntryPoint = NULL;
-
/**
Retrieve a pointer to and print the boot information passed by privileged
secure firmware.
@@ -216,13 +218,15 @@ SetEventCompleteSvcArgs (
/**
A loop to delegated events.
+ @param [in] CpuDriverEntryPoint Entry point to handle request.
@param [in] EventCompleteSvcArgs Pointer to the event completion arguments.
**/
VOID
EFIAPI
DelegatedEventLoop (
- IN ARM_SVC_ARGS *EventCompleteSvcArgs
+ IN EDKII_PI_MM_CPU_DRIVER_ENTRYPOINT CpuDriverEntryPoint,
+ IN ARM_SVC_ARGS *EventCompleteSvcArgs
)
{
BOOLEAN FfaEnabled;
@@ -381,16 +385,20 @@ _ModuleEntryPoint (
IN UINT64 cookie2
)
{
- PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
- EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo;
- ARM_SVC_ARGS EventCompleteSvcArgs;
- EFI_STATUS Status;
- UINT32 SectionHeaderOffset;
- UINT16 NumberOfSections;
- VOID *HobStart;
- VOID *TeData;
- UINTN TeDataSize;
- EFI_PHYSICAL_ADDRESS ImageBase;
+ PE_COFF_LOADER_IMAGE_CONTEXT ImageContext;
+ EFI_SECURE_PARTITION_BOOT_INFO *PayloadBootInfo;
+ ARM_SVC_ARGS EventCompleteSvcArgs;
+ EFI_STATUS Status;
+ UINT32 SectionHeaderOffset;
+ UINT16 NumberOfSections;
+ VOID *HobStart;
+ VOID *TeData;
+ UINTN TeDataSize;
+ EFI_PHYSICAL_ADDRESS ImageBase;
+ EDKII_PI_MM_CPU_DRIVER_EP_PROTOCOL *PiMmCpuDriverEpProtocol;
+ EDKII_PI_MM_CPU_DRIVER_ENTRYPOINT CpuDriverEntryPoint;
+
+ CpuDriverEntryPoint = NULL;
// Get Secure Partition Manager Version Information
Status = GetSpmVersion ();
@@ -466,14 +474,33 @@ _ModuleEntryPoint (
//
// Create Hoblist based upon boot information passed by privileged software
//
- HobStart = CreateHobListFromBootInfo (&CpuDriverEntryPoint, PayloadBootInfo);
+ HobStart = CreateHobListFromBootInfo (PayloadBootInfo);
//
// Call the MM Core entry point
//
ProcessModuleEntryPointList (HobStart);
- DEBUG ((DEBUG_INFO, "Shared Cpu Driver EP %p\n", (VOID *)CpuDriverEntryPoint));
+ //
+ // Find out cpu driver entry point used in DelegatedEventLoop
+ // to handle MMI request.
+ //
+ Status = gMmCoreMmst.MmLocateProtocol (
+ &gEdkiiPiMmCpuDriverEpProtocolGuid,
+ NULL,
+ (VOID **)&PiMmCpuDriverEpProtocol
+ );
+ if (EFI_ERROR (Status)) {
+ goto finish;
+ }
+
+ CpuDriverEntryPoint = PiMmCpuDriverEpProtocol->PiMmCpuDriverEntryPoint;
+
+ DEBUG ((
+ DEBUG_INFO,
+ "Shared Cpu Driver EP %p\n",
+ CpuDriverEntryPoint
+ ));
finish:
ZeroMem (&EventCompleteSvcArgs, sizeof (EventCompleteSvcArgs));
@@ -482,5 +509,5 @@ finish:
Status,
&EventCompleteSvcArgs
);
- DelegatedEventLoop (&EventCompleteSvcArgs);
+ DelegatedEventLoop (CpuDriverEntryPoint, t&EventCompleteSvcArgs);
}
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
index d41d7630b6..fe048cc34b 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
@@ -49,7 +49,9 @@
gMpInformationHobGuid
gEfiMmPeiMmramMemoryReserveGuid
gEfiStandaloneMmNonSecureBufferGuid
- gEfiMmCpuDriverEpDescriptorGuid
+
+[Protocols.ARM, Protocols.AARCH64]
+ gEdkiiPiMmCpuDriverEpProtocolGuid
[FeaturePcd.ARM, FeaturePcd.AARCH64]
gArmTokenSpaceGuid.PcdFfaEnable