From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.10407.1603280009826641938 for ; Wed, 21 Oct 2020 04:33:30 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=softfail (domain: linaro.org, ip: 217.140.110.172, mailfrom: sughosh.ganu@linaro.org) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 81CFAD6E; Wed, 21 Oct 2020 04:33:29 -0700 (PDT) Received: from a076522.blr.arm.com (a076522.blr.arm.com [10.162.16.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C7DA33F66E; Wed, 21 Oct 2020 04:33:27 -0700 (PDT) From: "Sughosh Ganu" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar , Jiewen Yao , Achin Gupta Subject: [PATCH v1 07/12] StandaloneMmPkg: Add option to use FF-A calls for communication with SPM Date: Wed, 21 Oct 2020 17:02:28 +0530 Message-Id: <20201021113233.25548-8-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201021113233.25548-1-sughosh.ganu@linaro.org> References: <20201021113233.25548-1-sughosh.ganu@linaro.org> From: Achin Gupta Add support for reporting completion of a MM request using either the Firmware Framework(FF-A) ABI transport or through the earlier used SVC calls. Signed-off-by: Achin Gupta Co-developed-by: Sughosh Ganu --- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c | 68 ++++++++++++++++---- 1 file changed, 54 insertions(+), 14 deletions(-) diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c index 7d1e3c4d7c..06a8f487f9 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c @@ -112,6 +112,7 @@ DelegatedEventLoop ( IN ARM_SVC_ARGS *EventCompleteSvcArgs ) { + BOOLEAN FfaEnabled; EFI_STATUS Status; UINTN SvcStatus; @@ -123,16 +124,32 @@ DelegatedEventLoop ( DEBUG ((DEBUG_INFO, "X1 : 0x%x\n", (UINT32) EventCompleteSvcArgs->Arg1)); DEBUG ((DEBUG_INFO, "X2 : 0x%x\n", (UINT32) EventCompleteSvcArgs->Arg2)); DEBUG ((DEBUG_INFO, "X3 : 0x%x\n", (UINT32) EventCompleteSvcArgs->Arg3)); - - Status = CpuDriverEntryPoint ( - EventCompleteSvcArgs->Arg0, - EventCompleteSvcArgs->Arg3, - EventCompleteSvcArgs->Arg1 - ); - - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "Failed delegated event 0x%x, Status 0x%x\n", - EventCompleteSvcArgs->Arg0, Status)); + DEBUG ((DEBUG_INFO, "X4 : 0x%x\n", (UINT32) EventCompleteSvcArgs->Arg4)); + DEBUG ((DEBUG_INFO, "X5 : 0x%x\n", (UINT32) EventCompleteSvcArgs->Arg5)); + DEBUG ((DEBUG_INFO, "X6 : 0x%x\n", (UINT32) EventCompleteSvcArgs->Arg6)); + DEBUG ((DEBUG_INFO, "X7 : 0x%x\n", (UINT32) EventCompleteSvcArgs->Arg7)); + + FfaEnabled = FeaturePcdGet (PcdFfaEnable); + if (FfaEnabled) { + Status = CpuDriverEntryPoint ( + EventCompleteSvcArgs->Arg0, + EventCompleteSvcArgs->Arg6, + EventCompleteSvcArgs->Arg3 + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed delegated event 0x%x, Status 0x%x\n", + EventCompleteSvcArgs->Arg3, Status)); + } + } else { + Status = CpuDriverEntryPoint ( + EventCompleteSvcArgs->Arg0, + EventCompleteSvcArgs->Arg3, + EventCompleteSvcArgs->Arg1 + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed delegated event 0x%x, Status 0x%x\n", + EventCompleteSvcArgs->Arg0, Status)); + } } switch (Status) { @@ -156,8 +173,16 @@ DelegatedEventLoop ( break; } - EventCompleteSvcArgs->Arg0 = ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64; - EventCompleteSvcArgs->Arg1 = SvcStatus; + if (FfaEnabled) { + EventCompleteSvcArgs->Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH64; + EventCompleteSvcArgs->Arg1 = 0; + EventCompleteSvcArgs->Arg2 = 0; + EventCompleteSvcArgs->Arg3 = ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64; + EventCompleteSvcArgs->Arg4 = SvcStatus; + } else { + EventCompleteSvcArgs->Arg0 = ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64; + EventCompleteSvcArgs->Arg1 = SvcStatus; + } } } @@ -216,6 +241,22 @@ GetSpmVersion (VOID) return Status; } +STATIC +VOID +InitArmSvcArgs (ARM_SVC_ARGS *InitMmFoundationSvcArgs, EFI_STATUS *Status) +{ + if (FeaturePcdGet (PcdFfaEnable)) { + InitMmFoundationSvcArgs->Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH64; + InitMmFoundationSvcArgs->Arg1 = 0; + InitMmFoundationSvcArgs->Arg2 = 0; + InitMmFoundationSvcArgs->Arg3 = ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64; + InitMmFoundationSvcArgs->Arg4 = *Status; + } else { + InitMmFoundationSvcArgs->Arg0 = ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64; + InitMmFoundationSvcArgs->Arg1 = *Status; + } +} + /** The entry point of Standalone MM Foundation. @@ -329,7 +370,6 @@ _ModuleEntryPoint ( finish: ZeroMem (&InitMmFoundationSvcArgs, sizeof(InitMmFoundationSvcArgs)); - InitMmFoundationSvcArgs.Arg0 = ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64; - InitMmFoundationSvcArgs.Arg1 = Status; + InitArmSvcArgs(&InitMmFoundationSvcArgs, &Status); DelegatedEventLoop (&InitMmFoundationSvcArgs); } -- 2.17.1