34BOOLEAN mLocked =
FALSE;
57 DEBUG ((DEBUG_ERROR,
"SmmLockBox Locked!\n"));
58 LockBoxParameterSave->Header.ReturnStatus = (UINT64)EFI_ACCESS_DENIED;
68 DEBUG ((DEBUG_ERROR,
"SmmLockBox Save address in SMRAM or buffer overflow!\n"));
69 LockBoxParameterSave->Header.ReturnStatus = (UINT64)EFI_ACCESS_DENIED;
83 &TempLockBoxParameterSave.Guid,
84 (VOID *)(
UINTN)TempLockBoxParameterSave.Buffer,
85 (
UINTN)TempLockBoxParameterSave.Length
87 LockBoxParameterSave->Header.ReturnStatus = (UINT64)Status;
108 DEBUG ((DEBUG_ERROR,
"SmmLockBox Locked!\n"));
109 LockBoxParameterSetAttributes->Header.ReturnStatus = (UINT64)EFI_ACCESS_DENIED;
119 &TempLockBoxParameterSetAttributes.Guid,
120 TempLockBoxParameterSetAttributes.Attributes
122 LockBoxParameterSetAttributes->Header.ReturnStatus = (UINT64)Status;
147 DEBUG ((DEBUG_ERROR,
"SmmLockBox Locked!\n"));
148 LockBoxParameterUpdate->Header.ReturnStatus = (UINT64)EFI_ACCESS_DENIED;
158 DEBUG ((DEBUG_ERROR,
"SmmLockBox Update address in SMRAM or buffer overflow!\n"));
159 LockBoxParameterUpdate->Header.ReturnStatus = (UINT64)EFI_ACCESS_DENIED;
173 &TempLockBoxParameterUpdate.Guid,
174 (
UINTN)TempLockBoxParameterUpdate.Offset,
175 (VOID *)(
UINTN)TempLockBoxParameterUpdate.Buffer,
176 (
UINTN)TempLockBoxParameterUpdate.Length
178 LockBoxParameterUpdate->Header.ReturnStatus = (UINT64)Status;
205 DEBUG ((DEBUG_ERROR,
"SmmLockBox Restore address in SMRAM or buffer overflow!\n"));
206 LockBoxParameterRestore->Header.ReturnStatus = (UINT64)EFI_ACCESS_DENIED;
213 if ((TempLockBoxParameterRestore.Length == 0) && (TempLockBoxParameterRestore.Buffer == 0)) {
215 &TempLockBoxParameterRestore.Guid,
221 &TempLockBoxParameterRestore.Guid,
222 (VOID *)(
UINTN)TempLockBoxParameterRestore.Buffer,
223 (
UINTN *)&TempLockBoxParameterRestore.Length
225 if ((Status == EFI_BUFFER_TOO_SMALL) || (Status ==
EFI_SUCCESS)) {
229 LockBoxParameterRestore->Length = TempLockBoxParameterRestore.Length;
233 LockBoxParameterRestore->Header.ReturnStatus = (UINT64)Status;
250 LockBoxParameterRestoreAllInPlace->Header.ReturnStatus = (UINT64)Status;
274 IN CONST VOID *Context OPTIONAL,
275 IN OUT VOID *CommBuffer OPTIONAL,
280 UINTN TempCommBufferSize;
282 DEBUG ((DEBUG_INFO,
"SmmLockBox SmmLockBoxHandler Enter\n"));
287 if ((CommBuffer ==
NULL) || (CommBufferSize ==
NULL)) {
291 TempCommBufferSize = *CommBufferSize;
297 DEBUG ((DEBUG_ERROR,
"SmmLockBox Command Buffer Size invalid!\n"));
302 DEBUG ((DEBUG_ERROR,
"SmmLockBox Command Buffer in SMRAM or overflow!\n"));
308 LockBoxParameterHeader->ReturnStatus = (UINT64)-1;
310 DEBUG ((DEBUG_INFO,
"SmmLockBox LockBoxParameterHeader - %x\n", (
UINTN)LockBoxParameterHeader));
312 DEBUG ((DEBUG_INFO,
"SmmLockBox Command - %x\n", (
UINTN)LockBoxParameterHeader->Command));
314 switch (LockBoxParameterHeader->Command) {
315 case EFI_SMM_LOCK_BOX_COMMAND_SAVE:
317 DEBUG ((DEBUG_ERROR,
"SmmLockBox Command Buffer Size for SAVE invalid!\n"));
323 case EFI_SMM_LOCK_BOX_COMMAND_UPDATE:
325 DEBUG ((DEBUG_ERROR,
"SmmLockBox Command Buffer Size for UPDATE invalid!\n"));
331 case EFI_SMM_LOCK_BOX_COMMAND_RESTORE:
333 DEBUG ((DEBUG_ERROR,
"SmmLockBox Command Buffer Size for RESTORE invalid!\n"));
339 case EFI_SMM_LOCK_BOX_COMMAND_SET_ATTRIBUTES:
341 DEBUG ((DEBUG_ERROR,
"SmmLockBox Command Buffer Size for SET_ATTRIBUTES invalid!\n"));
347 case EFI_SMM_LOCK_BOX_COMMAND_RESTORE_ALL_IN_PLACE:
349 DEBUG ((DEBUG_ERROR,
"SmmLockBox Command Buffer Size for RESTORE_ALL_IN_PLACE invalid!\n"));
356 DEBUG ((DEBUG_ERROR,
"SmmLockBox Command invalid!\n"));
360 LockBoxParameterHeader->Command = (UINT32)-1;
362 DEBUG ((DEBUG_INFO,
"SmmLockBox SmmLockBoxHandler Exit\n"));
413 Status =
gSmst->SmiHandlerRegister (
415 &gEfiSmmLockBoxCommunicationGuid,
423 Status =
gSmst->SmmRegisterProtocolNotify (
424 &gEfiSmmReadyToLockProtocolGuid,
434 Status =
gBS->InstallProtocolInterface (
436 &gEfiLockBoxProtocolGuid,
VOID EFIAPI SpeculationBarrier(VOID)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
RETURN_STATUS EFIAPI SetLockBoxAttributes(IN GUID *Guid, IN UINT64 Attributes)
RETURN_STATUS EFIAPI RestoreLockBox(IN GUID *Guid, IN VOID *Buffer OPTIONAL, IN OUT UINTN *Length OPTIONAL)
RETURN_STATUS EFIAPI RestoreAllLockBoxInPlace(VOID)
RETURN_STATUS EFIAPI UpdateLockBox(IN GUID *Guid, IN UINTN Offset, IN VOID *Buffer, IN UINTN Length)
RETURN_STATUS EFIAPI SaveLockBox(IN GUID *Guid, IN VOID *Buffer, IN UINTN Length)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
EFI_SMM_SYSTEM_TABLE2 * gSmst
EFI_STATUS EFIAPI SmmLockBoxHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
VOID SmmLockBoxRestoreAllInPlace(IN EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE *LockBoxParameterRestoreAllInPlace)
VOID SmmLockBoxUpdate(IN EFI_SMM_LOCK_BOX_PARAMETER_UPDATE *LockBoxParameterUpdate)
EFI_STATUS EFIAPI SmmReadyToLockEventNotify(IN CONST EFI_GUID *Protocol, IN VOID *Interface, IN EFI_HANDLE Handle)
VOID SmmLockBoxSetAttributes(IN EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES *LockBoxParameterSetAttributes)
VOID SmmLockBoxRestore(IN EFI_SMM_LOCK_BOX_PARAMETER_RESTORE *LockBoxParameterRestore)
EFI_STATUS EFIAPI SmmLockBoxEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
VOID SmmLockBoxSave(IN EFI_SMM_LOCK_BOX_PARAMETER_SAVE *LockBoxParameterSave)
BOOLEAN EFIAPI SmmIsBufferOutsideSmmValid(IN EFI_PHYSICAL_ADDRESS Buffer, IN UINT64 Length)