Skip to content

Commit de3cf0c

Browse files
os-dProjectMuBot
authored andcommitted
StandaloneMmPkg: Arm/StandaloneMmCoreEntryPoint Remove Check for SMC ID
Today, StandaloneMmCoreEntryPoint checks for an SMC EventId of MM_COMMUNICATE or FF-A Direct and drops all other SMCs. However, the TCG ACPI spec dictates that a different SMC ID, platform defined, will be send to communicate with the TPM[1]. When a platform is using StandaloneMM and the SPM_MM configuration, this check causes this valid SMC to be dropped. This is an issue because TPM calls cannot be routed, including TPM calls originating from the OS. This patch drops the check to allow StandaloneMmCoreEntryPoint to route the calls to StandaloneMmCpu to decide whether it can handle the SMC (which on platforms with this TPM configuration it can). "This field provides the SMC/HVC call function ID that will invoke the TPM start method. Firmware SHALL implement the SMC call as an SMC32 or SMC64 Fast Call, compliant with the SMC Calling convention specification. The call takes no parameters, no client ID, no Secure OS ID, and no Session ID. The call SHALL return zero. The function ID SHALL be allocated from a Service Call Range over which the platform vendor has authority." [1]: https://trustedcomputinggroup.org/wp-content/uploads/ TCG_ACPIGeneralSpecification_v1p3_r6_14april2021.pdf Section 8.3.1 Signed-off-by: Oliver Smith-Denny <[email protected]>
1 parent 0c99d2b commit de3cf0c

File tree

1 file changed

+57
-69
lines changed

1 file changed

+57
-69
lines changed

ArmPkg/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c

+57-69
Original file line numberDiff line numberDiff line change
@@ -141,80 +141,68 @@ DelegatedEventLoop (
141141
DEBUG ((DEBUG_INFO, "X6 : 0x%x\n", (UINT32)EventCompleteSvcArgs->Arg6));
142142
DEBUG ((DEBUG_INFO, "X7 : 0x%x\n", (UINT32)EventCompleteSvcArgs->Arg7));
143143

144-
//
145-
// ARM TF passes SMC FID of the MM_COMMUNICATE interface as the Event ID upon
146-
// receipt of a synchronous MM request. Use the Event ID to distinguish
147-
// between synchronous and asynchronous events.
148-
//
149-
if ((ARM_SMC_ID_MM_COMMUNICATE != (UINT32)EventCompleteSvcArgs->Arg0) &&
150-
(ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ != (UINT32)EventCompleteSvcArgs->Arg0))
151-
{
152-
DEBUG ((DEBUG_ERROR, "UnRecognized Event - 0x%x\n", (UINT32)EventCompleteSvcArgs->Arg0));
153-
Status = EFI_INVALID_PARAMETER;
144+
FfaEnabled = FeaturePcdGet (PcdFfaEnable);
145+
if (FfaEnabled) {
146+
Status = CpuDriverEntryPoint (
147+
EventCompleteSvcArgs->Arg0,
148+
EventCompleteSvcArgs->Arg6,
149+
EventCompleteSvcArgs->Arg3
150+
);
151+
if (EFI_ERROR (Status)) {
152+
DEBUG ((
153+
DEBUG_ERROR,
154+
"Failed delegated event 0x%x, Status 0x%x\n",
155+
EventCompleteSvcArgs->Arg3,
156+
Status
157+
));
158+
}
154159
} else {
155-
FfaEnabled = FeaturePcdGet (PcdFfaEnable);
156-
if (FfaEnabled) {
157-
Status = CpuDriverEntryPoint (
158-
EventCompleteSvcArgs->Arg0,
159-
EventCompleteSvcArgs->Arg6,
160-
EventCompleteSvcArgs->Arg3
161-
);
162-
if (EFI_ERROR (Status)) {
163-
DEBUG ((
164-
DEBUG_ERROR,
165-
"Failed delegated event 0x%x, Status 0x%x\n",
166-
EventCompleteSvcArgs->Arg3,
167-
Status
168-
));
169-
}
170-
} else {
171-
Status = CpuDriverEntryPoint (
172-
EventCompleteSvcArgs->Arg0,
173-
EventCompleteSvcArgs->Arg3,
174-
EventCompleteSvcArgs->Arg1
175-
);
176-
if (EFI_ERROR (Status)) {
177-
DEBUG ((
178-
DEBUG_ERROR,
179-
"Failed delegated event 0x%x, Status 0x%x\n",
180-
EventCompleteSvcArgs->Arg0,
181-
Status
182-
));
183-
}
160+
Status = CpuDriverEntryPoint (
161+
EventCompleteSvcArgs->Arg0,
162+
EventCompleteSvcArgs->Arg3,
163+
EventCompleteSvcArgs->Arg1
164+
);
165+
if (EFI_ERROR (Status)) {
166+
DEBUG ((
167+
DEBUG_ERROR,
168+
"Failed delegated event 0x%x, Status 0x%x\n",
169+
EventCompleteSvcArgs->Arg0,
170+
Status
171+
));
184172
}
185173
}
174+
}
186175

187-
switch (Status) {
188-
case EFI_SUCCESS:
189-
SvcStatus = ARM_SVC_SPM_RET_SUCCESS;
190-
break;
191-
case EFI_INVALID_PARAMETER:
192-
SvcStatus = ARM_SVC_SPM_RET_INVALID_PARAMS;
193-
break;
194-
case EFI_ACCESS_DENIED:
195-
SvcStatus = ARM_SVC_SPM_RET_DENIED;
196-
break;
197-
case EFI_OUT_OF_RESOURCES:
198-
SvcStatus = ARM_SVC_SPM_RET_NO_MEMORY;
199-
break;
200-
case EFI_UNSUPPORTED:
201-
SvcStatus = ARM_SVC_SPM_RET_NOT_SUPPORTED;
202-
break;
203-
default:
204-
SvcStatus = ARM_SVC_SPM_RET_NOT_SUPPORTED;
205-
break;
206-
}
176+
switch (Status) {
177+
case EFI_SUCCESS:
178+
SvcStatus = ARM_SVC_SPM_RET_SUCCESS;
179+
break;
180+
case EFI_INVALID_PARAMETER:
181+
SvcStatus = ARM_SVC_SPM_RET_INVALID_PARAMS;
182+
break;
183+
case EFI_ACCESS_DENIED:
184+
SvcStatus = ARM_SVC_SPM_RET_DENIED;
185+
break;
186+
case EFI_OUT_OF_RESOURCES:
187+
SvcStatus = ARM_SVC_SPM_RET_NO_MEMORY;
188+
break;
189+
case EFI_UNSUPPORTED:
190+
SvcStatus = ARM_SVC_SPM_RET_NOT_SUPPORTED;
191+
break;
192+
default:
193+
SvcStatus = ARM_SVC_SPM_RET_NOT_SUPPORTED;
194+
break;
195+
}
207196

208-
if (FfaEnabled) {
209-
EventCompleteSvcArgs->Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP;
210-
EventCompleteSvcArgs->Arg1 = 0;
211-
EventCompleteSvcArgs->Arg2 = 0;
212-
EventCompleteSvcArgs->Arg3 = ARM_SVC_ID_SP_EVENT_COMPLETE;
213-
EventCompleteSvcArgs->Arg4 = SvcStatus;
214-
} else {
215-
EventCompleteSvcArgs->Arg0 = ARM_SVC_ID_SP_EVENT_COMPLETE;
216-
EventCompleteSvcArgs->Arg1 = SvcStatus;
217-
}
197+
if (FfaEnabled) {
198+
EventCompleteSvcArgs->Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP;
199+
EventCompleteSvcArgs->Arg1 = 0;
200+
EventCompleteSvcArgs->Arg2 = 0;
201+
EventCompleteSvcArgs->Arg3 = ARM_SVC_ID_SP_EVENT_COMPLETE;
202+
EventCompleteSvcArgs->Arg4 = SvcStatus;
203+
} else {
204+
EventCompleteSvcArgs->Arg0 = ARM_SVC_ID_SP_EVENT_COMPLETE;
205+
EventCompleteSvcArgs->Arg1 = SvcStatus;
218206
}
219207
}
220208

0 commit comments

Comments
 (0)