3 Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
12 #include <Library/PeiServicesTablePointerLib.h>
13 #include <Library/PeiServicesLib.h>
14 #include <Library/BaseLib.h>
15 #include <Library/BaseMemoryLib.h>
16 #include <Library/LockBoxLib.h>
17 #include <Library/HobLib.h>
18 #include <Library/DebugLib.h>
19 #include <Library/PcdLib.h>
20 #include <Protocol/SmmCommunication.h>
21 #include <Ppi/SmmCommunication.h>
22 #include <Ppi/SmmAccess.h>
23 #include <Guid/AcpiS3Context.h>
24 #include <Guid/SmmLockBox.h>
26 #include "SmmLockBoxLibPrivate.h"
28 #if defined (MDE_CPU_IA32)
29 typedef struct _LIST_ENTRY64 LIST_ENTRY64
;
30 struct _LIST_ENTRY64
{
31 LIST_ENTRY64
*ForwardLink
;
33 LIST_ENTRY64
*BackLink
;
39 UINT64 SmmFirmwareVendor
;
40 UINT64 SmmFirmwareRevision
;
41 UINT64 SmmInstallConfigurationTable
;
46 UINT64 SmmAllocatePool
;
48 UINT64 SmmAllocatePages
;
50 UINT64 SmmStartupThisAp
;
51 UINT64 CurrentlyExecutingCpu
;
53 UINT64 CpuSaveStateSize
;
55 UINT64 NumberOfTableEntries
;
56 UINT64 SmmConfigurationTable
;
57 } EFI_SMM_SYSTEM_TABLE2_64
;
62 } EFI_CONFIGURATION_TABLE64
;
65 #if defined (MDE_CPU_X64)
66 typedef LIST_ENTRY LIST_ENTRY64
;
67 typedef EFI_SMM_SYSTEM_TABLE2 EFI_SMM_SYSTEM_TABLE2_64
;
68 typedef EFI_CONFIGURATION_TABLE EFI_CONFIGURATION_TABLE64
;
72 This function return first node of LinkList queue.
74 @param LockBoxQueue LinkList queue
76 @return first node of LinkList queue
80 IN LIST_ENTRY
*LinkList
83 if ((sizeof(UINTN
) == sizeof(UINT32
)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode
)) ) {
87 return (LIST_ENTRY
*)(((LIST_ENTRY64
*)LinkList
)->ForwardLink
);
89 return LinkList
->ForwardLink
;
94 This function return next node of LinkList.
96 @param Link LinkList node
98 @return next node of LinkList
101 InternalNextLinkDxe (
105 if ((sizeof(UINTN
) == sizeof(UINT32
)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode
)) ) {
109 return (LIST_ENTRY
*)(((LIST_ENTRY64
*)Link
)->ForwardLink
);
111 return Link
->ForwardLink
;
116 This function find LockBox by GUID from SMRAM.
118 @param LockBoxQueue The LockBox queue in SMRAM
119 @param Guid The guid to indentify the LockBox
124 InternalFindLockBoxByGuidFromSmram (
125 IN LIST_ENTRY
*LockBoxQueue
,
130 SMM_LOCK_BOX_DATA
*LockBox
;
132 for (Link
= InternalInitLinkDxe (LockBoxQueue
);
133 Link
!= LockBoxQueue
;
134 Link
= InternalNextLinkDxe (Link
)) {
140 if (CompareGuid (&LockBox
->Guid
, Guid
)) {
148 Get VendorTable by VendorGuid in Smst.
150 @param Signature Signature of SMM_S3_RESUME_STATE
151 @param Smst SMM system table
152 @param VendorGuid vendor guid
154 @return vendor table.
157 InternalSmstGetVendorTableByGuid (
159 IN EFI_SMM_SYSTEM_TABLE2
*Smst
,
160 IN EFI_GUID
*VendorGuid
163 EFI_CONFIGURATION_TABLE
*SmmConfigurationTable
;
164 UINTN NumberOfTableEntries
;
166 EFI_SMM_SYSTEM_TABLE2_64
*Smst64
;
167 EFI_CONFIGURATION_TABLE64
*SmmConfigurationTable64
;
169 if ((sizeof(UINTN
) == sizeof(UINT32
)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode
))) {
173 Smst64
= (EFI_SMM_SYSTEM_TABLE2_64
*)Smst
;
174 SmmConfigurationTable64
= (EFI_CONFIGURATION_TABLE64
*)(UINTN
)Smst64
->SmmConfigurationTable
;
175 NumberOfTableEntries
= (UINTN
)Smst64
->NumberOfTableEntries
;
176 for (Index
= 0; Index
< NumberOfTableEntries
; Index
++) {
177 if (CompareGuid (&SmmConfigurationTable64
[Index
].VendorGuid
, VendorGuid
)) {
178 return (VOID
*)(UINTN
)SmmConfigurationTable64
[Index
].VendorTable
;
183 SmmConfigurationTable
= Smst
->SmmConfigurationTable
;
184 NumberOfTableEntries
= Smst
->NumberOfTableEntries
;
185 for (Index
= 0; Index
< NumberOfTableEntries
; Index
++) {
186 if (CompareGuid (&SmmConfigurationTable
[Index
].VendorGuid
, VendorGuid
)) {
187 return (VOID
*)SmmConfigurationTable
[Index
].VendorTable
;
195 Get SMM LockBox context.
197 @return SMM LockBox context.
199 SMM_LOCK_BOX_CONTEXT
*
200 InternalGetSmmLockBoxContext (
204 EFI_SMRAM_DESCRIPTOR
*SmramDescriptor
;
205 SMM_S3_RESUME_STATE
*SmmS3ResumeState
;
207 SMM_LOCK_BOX_CONTEXT
*SmmLockBoxContext
;
209 GuidHob
= GetFirstGuidHob (&gEfiAcpiVariableGuid
);
210 ASSERT (GuidHob
!= NULL
);
211 SmramDescriptor
= (EFI_SMRAM_DESCRIPTOR
*) GET_GUID_HOB_DATA (GuidHob
);
212 SmmS3ResumeState
= (SMM_S3_RESUME_STATE
*)(UINTN
)SmramDescriptor
->CpuStart
;
214 SmmLockBoxContext
= (SMM_LOCK_BOX_CONTEXT
*)InternalSmstGetVendorTableByGuid (
215 SmmS3ResumeState
->Signature
,
216 (EFI_SMM_SYSTEM_TABLE2
*)(UINTN
)SmmS3ResumeState
->Smst
,
217 &gEfiSmmLockBoxCommunicationGuid
219 ASSERT (SmmLockBoxContext
!= NULL
);
221 return SmmLockBoxContext
;
225 This function will restore confidential information from lockbox in SMRAM directly.
227 @param Guid the guid to identify the confidential information
228 @param Buffer the address of the restored confidential information
229 NULL means restored to original address, Length MUST be NULL at same time.
230 @param Length the length of the restored confidential information
232 @retval RETURN_SUCCESS the information is restored successfully.
233 @retval RETURN_WRITE_PROTECTED Buffer and Length are NULL, but the LockBox has no
234 LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE attribute.
235 @retval RETURN_BUFFER_TOO_SMALL the Length is too small to hold the confidential information.
236 @retval RETURN_NOT_FOUND the requested GUID not found.
239 InternalRestoreLockBoxFromSmram (
241 IN VOID
*Buffer
, OPTIONAL
242 IN OUT UINTN
*Length OPTIONAL
245 PEI_SMM_ACCESS_PPI
*SmmAccess
;
248 SMM_LOCK_BOX_CONTEXT
*SmmLockBoxContext
;
249 LIST_ENTRY
*LockBoxQueue
;
250 SMM_LOCK_BOX_DATA
*LockBox
;
254 // Get needed resource
256 Status
= PeiServicesLocatePpi (
257 &gPeiSmmAccessPpiGuid
,
262 if (!EFI_ERROR (Status
)) {
263 for (Index
= 0; !EFI_ERROR (Status
); Index
++) {
264 Status
= SmmAccess
->Open ((EFI_PEI_SERVICES
**)GetPeiServicesTablePointer (), SmmAccess
, Index
);
269 // Get LockBox context
271 SmmLockBoxContext
= InternalGetSmmLockBoxContext ();
272 LockBoxQueue
= (LIST_ENTRY
*)(UINTN
)SmmLockBoxContext
->LockBoxDataAddress
;
275 // We do NOT check Buffer address in SMRAM, because if SMRAM not locked, we trust the caller.
279 // Restore this, Buffer and Length MUST be both NULL or both non-NULL
285 LockBox
= InternalFindLockBoxByGuidFromSmram (LockBoxQueue
, Guid
);
286 if (LockBox
== NULL
) {
290 return EFI_NOT_FOUND
;
296 if (Buffer
!= NULL
) {
298 // restore to new buffer
300 RestoreBuffer
= Buffer
;
303 // restore to original buffer
305 if ((LockBox
->Attributes
& LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE
) == 0) {
306 return EFI_WRITE_PROTECTED
;
308 RestoreBuffer
= (VOID
*)(UINTN
)LockBox
->Buffer
;
314 if (Length
!= NULL
) {
315 if (*Length
< (UINTN
)LockBox
->Length
) {
317 // Input buffer is too small to hold all data.
319 *Length
= (UINTN
)LockBox
->Length
;
320 return EFI_BUFFER_TOO_SMALL
;
322 *Length
= (UINTN
)LockBox
->Length
;
328 CopyMem (RestoreBuffer
, (VOID
*)(UINTN
)LockBox
->SmramBuffer
, (UINTN
)LockBox
->Length
);
337 This function will restore confidential information from all lockbox which have RestoreInPlace attribute.
339 @retval RETURN_SUCCESS the information is restored successfully.
342 InternalRestoreAllLockBoxInPlaceFromSmram (
346 PEI_SMM_ACCESS_PPI
*SmmAccess
;
349 SMM_LOCK_BOX_CONTEXT
*SmmLockBoxContext
;
350 LIST_ENTRY
*LockBoxQueue
;
351 SMM_LOCK_BOX_DATA
*LockBox
;
355 // Get needed resource
357 Status
= PeiServicesLocatePpi (
358 &gPeiSmmAccessPpiGuid
,
363 if (!EFI_ERROR (Status
)) {
364 for (Index
= 0; !EFI_ERROR (Status
); Index
++) {
365 Status
= SmmAccess
->Open ((EFI_PEI_SERVICES
**)GetPeiServicesTablePointer (), SmmAccess
, Index
);
370 // Get LockBox context
372 SmmLockBoxContext
= InternalGetSmmLockBoxContext ();
373 LockBoxQueue
= (LIST_ENTRY
*)(UINTN
)SmmLockBoxContext
->LockBoxDataAddress
;
376 // We do NOT check Buffer address in SMRAM, because if SMRAM not locked, we trust the caller.
380 // Restore all, Buffer and Length MUST be NULL
382 for (Link
= InternalInitLinkDxe (LockBoxQueue
);
383 Link
!= LockBoxQueue
;
384 Link
= InternalNextLinkDxe (Link
)) {
390 if ((LockBox
->Attributes
& LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE
) != 0) {
394 CopyMem ((VOID
*)(UINTN
)LockBox
->Buffer
, (VOID
*)(UINTN
)LockBox
->SmramBuffer
, (UINTN
)LockBox
->Length
);
404 This function will save confidential information to lockbox.
406 @param Guid the guid to identify the confidential information
407 @param Buffer the address of the confidential information
408 @param Length the length of the confidential information
410 @retval RETURN_SUCCESS the information is saved successfully.
411 @retval RETURN_INVALID_PARAMETER the Guid is NULL, or Buffer is NULL, or Length is 0
412 @retval RETURN_ALREADY_STARTED the requested GUID already exist.
413 @retval RETURN_OUT_OF_RESOURCES no enough resource to save the information.
414 @retval RETURN_ACCESS_DENIED it is too late to invoke this interface
415 @retval RETURN_NOT_STARTED it is too early to invoke this interface
416 @retval RETURN_UNSUPPORTED the service is not supported by implementaion.
429 // No support to save at PEI phase
431 return RETURN_UNSUPPORTED
;
435 This function will set lockbox attributes.
437 @param Guid the guid to identify the confidential information
438 @param Attributes the attributes of the lockbox
440 @retval RETURN_SUCCESS the information is saved successfully.
441 @retval RETURN_INVALID_PARAMETER attributes is invalid.
442 @retval RETURN_NOT_FOUND the requested GUID not found.
443 @retval RETURN_ACCESS_DENIED it is too late to invoke this interface
444 @retval RETURN_NOT_STARTED it is too early to invoke this interface
445 @retval RETURN_UNSUPPORTED the service is not supported by implementaion.
449 SetLockBoxAttributes (
457 // No support to save at PEI phase
459 return RETURN_UNSUPPORTED
;
463 This function will update confidential information to lockbox.
465 @param Guid the guid to identify the original confidential information
466 @param Offset the offset of the original confidential information
467 @param Buffer the address of the updated confidential information
468 @param Length the length of the updated confidential information
470 @retval RETURN_SUCCESS the information is saved successfully.
471 @retval RETURN_INVALID_PARAMETER the Guid is NULL, or Buffer is NULL, or Length is 0.
472 @retval RETURN_NOT_FOUND the requested GUID not found.
473 @retval RETURN_BUFFER_TOO_SMALL for lockbox without attribute LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY,
474 the original buffer to too small to hold new information.
475 @retval RETURN_OUT_OF_RESOURCES for lockbox with attribute LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY,
476 no enough resource to save the information.
477 @retval RETURN_ACCESS_DENIED it is too late to invoke this interface
478 @retval RETURN_NOT_STARTED it is too early to invoke this interface
479 @retval RETURN_UNSUPPORTED the service is not supported by implementaion.
493 // No support to update at PEI phase
495 return RETURN_UNSUPPORTED
;
499 This function will restore confidential information from lockbox.
501 @param Guid the guid to identify the confidential information
502 @param Buffer the address of the restored confidential information
503 NULL means restored to original address, Length MUST be NULL at same time.
504 @param Length the length of the restored confidential information
506 @retval RETURN_SUCCESS the information is restored successfully.
507 @retval RETURN_INVALID_PARAMETER the Guid is NULL, or one of Buffer and Length is NULL.
508 @retval RETURN_WRITE_PROTECTED Buffer and Length are NULL, but the LockBox has no
509 LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE attribute.
510 @retval RETURN_BUFFER_TOO_SMALL the Length is too small to hold the confidential information.
511 @retval RETURN_NOT_FOUND the requested GUID not found.
512 @retval RETURN_NOT_STARTED it is too early to invoke this interface
513 @retval RETURN_ACCESS_DENIED not allow to restore to the address
514 @retval RETURN_UNSUPPORTED the service is not supported by implementaion.
520 IN VOID
*Buffer
, OPTIONAL
521 IN OUT UINTN
*Length OPTIONAL
525 EFI_PEI_SMM_COMMUNICATION_PPI
*SmmCommunicationPpi
;
526 EFI_SMM_LOCK_BOX_PARAMETER_RESTORE
*LockBoxParameterRestore
;
527 EFI_SMM_COMMUNICATE_HEADER
*CommHeader
;
528 UINT8 CommBuffer
[sizeof(EFI_GUID
) + sizeof(UINT64
) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_RESTORE
)];
530 UINT64 MessageLength
;
533 // Please aware that there is UINTN in EFI_SMM_COMMUNICATE_HEADER. It might be UINT64 in DXE, while it is UINT32 in PEI.
535 // EFI_GUID HeaderGuid;
536 // UINTN MessageLength;
538 // } EFI_SMM_COMMUNICATE_HEADER;
541 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib RestoreLockBox - Enter\n"));
546 if ((Guid
== NULL
) ||
547 ((Buffer
== NULL
) && (Length
!= NULL
)) ||
548 ((Buffer
!= NULL
) && (Length
== NULL
))) {
549 return EFI_INVALID_PARAMETER
;
553 // Get needed resource
555 Status
= PeiServicesLocatePpi (
556 &gEfiPeiSmmCommunicationPpiGuid
,
559 (VOID
**)&SmmCommunicationPpi
561 if (EFI_ERROR (Status
)) {
562 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib LocatePpi - (%r)\n", Status
));
563 Status
= InternalRestoreLockBoxFromSmram (Guid
, Buffer
, Length
);
564 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib RestoreLockBox - Exit (%r)\n", Status
));
571 CommHeader
= (EFI_SMM_COMMUNICATE_HEADER
*)&CommBuffer
[0];
572 CopyMem (&CommHeader
->HeaderGuid
, &gEfiSmmLockBoxCommunicationGuid
, sizeof(gEfiSmmLockBoxCommunicationGuid
));
573 if ((sizeof(UINTN
) == sizeof(UINT32
)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode
)) ) {
574 MessageLength
= sizeof(*LockBoxParameterRestore
);
575 CopyMem (&CommBuffer
[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER
, MessageLength
)], &MessageLength
, sizeof(MessageLength
));
577 CommHeader
->MessageLength
= sizeof(*LockBoxParameterRestore
);
580 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib CommBuffer - %x\n", &CommBuffer
[0]));
581 if ((sizeof(UINTN
) == sizeof(UINT32
)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode
)) ) {
582 LockBoxParameterRestore
= (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE
*)&CommBuffer
[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER
, MessageLength
) + sizeof(UINT64
)];
584 LockBoxParameterRestore
= (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE
*)&CommBuffer
[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER
, MessageLength
) + sizeof(UINTN
)];
586 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib LockBoxParameterRestore - %x\n", LockBoxParameterRestore
));
587 LockBoxParameterRestore
->Header
.Command
= EFI_SMM_LOCK_BOX_COMMAND_RESTORE
;
588 LockBoxParameterRestore
->Header
.DataLength
= sizeof(*LockBoxParameterRestore
);
589 LockBoxParameterRestore
->Header
.ReturnStatus
= (UINT64
)-1;
591 CopyMem (&LockBoxParameterRestore
->Guid
, Guid
, sizeof(*Guid
));
593 ZeroMem (&LockBoxParameterRestore
->Guid
, sizeof(*Guid
));
595 LockBoxParameterRestore
->Buffer
= (EFI_PHYSICAL_ADDRESS
)(UINTN
)Buffer
;
596 if (Length
!= NULL
) {
597 LockBoxParameterRestore
->Length
= (EFI_PHYSICAL_ADDRESS
)*Length
;
599 LockBoxParameterRestore
->Length
= 0;
605 CommSize
= sizeof(CommBuffer
);
606 Status
= SmmCommunicationPpi
->Communicate (
611 if (Status
== EFI_NOT_STARTED
) {
613 // Pei SMM communication not ready yet, so we access SMRAM directly
615 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib Communicate - (%r)\n", Status
));
616 Status
= InternalRestoreLockBoxFromSmram (Guid
, Buffer
, Length
);
617 LockBoxParameterRestore
->Header
.ReturnStatus
= (UINT64
)Status
;
618 if (Length
!= NULL
) {
619 LockBoxParameterRestore
->Length
= (UINT64
)*Length
;
623 if (Length
!= NULL
) {
624 *Length
= (UINTN
)LockBoxParameterRestore
->Length
;
627 Status
= (EFI_STATUS
)LockBoxParameterRestore
->Header
.ReturnStatus
;
628 if (Status
!= EFI_SUCCESS
) {
629 // Need or MAX_BIT, because there might be case that SMM is X64 while PEI is IA32.
633 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib RestoreLockBox - Exit (%r)\n", Status
));
642 This function will restore confidential information from all lockbox which have RestoreInPlace attribute.
644 @retval RETURN_SUCCESS the information is restored successfully.
645 @retval RETURN_NOT_STARTED it is too early to invoke this interface
646 @retval RETURN_UNSUPPORTED the service is not supported by implementaion.
650 RestoreAllLockBoxInPlace (
655 EFI_PEI_SMM_COMMUNICATION_PPI
*SmmCommunicationPpi
;
656 EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE
*LockBoxParameterRestoreAllInPlace
;
657 EFI_SMM_COMMUNICATE_HEADER
*CommHeader
;
658 UINT8 CommBuffer
[sizeof(EFI_GUID
) + sizeof(UINT64
) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE
)];
660 UINT64 MessageLength
;
663 // Please aware that there is UINTN in EFI_SMM_COMMUNICATE_HEADER. It might be UINT64 in DXE, while it is UINT32 in PEI.
665 // EFI_GUID HeaderGuid;
666 // UINTN MessageLength;
668 // } EFI_SMM_COMMUNICATE_HEADER;
671 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib RestoreAllLockBoxInPlace - Enter\n"));
674 // Get needed resource
676 Status
= PeiServicesLocatePpi (
677 &gEfiPeiSmmCommunicationPpiGuid
,
680 (VOID
**)&SmmCommunicationPpi
682 if (EFI_ERROR (Status
)) {
683 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib LocatePpi - (%r)\n", Status
));
684 Status
= InternalRestoreAllLockBoxInPlaceFromSmram ();
685 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib RestoreAllLockBoxInPlace - Exit (%r)\n", Status
));
692 CommHeader
= (EFI_SMM_COMMUNICATE_HEADER
*)&CommBuffer
[0];
693 CopyMem (&CommHeader
->HeaderGuid
, &gEfiSmmLockBoxCommunicationGuid
, sizeof(gEfiSmmLockBoxCommunicationGuid
));
694 if ((sizeof(UINTN
) == sizeof(UINT32
)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode
)) ) {
695 MessageLength
= sizeof(*LockBoxParameterRestoreAllInPlace
);
696 CopyMem (&CommBuffer
[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER
, MessageLength
)], &MessageLength
, sizeof(MessageLength
));
698 CommHeader
->MessageLength
= sizeof(*LockBoxParameterRestoreAllInPlace
);
701 if ((sizeof(UINTN
) == sizeof(UINT32
)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode
)) ) {
702 LockBoxParameterRestoreAllInPlace
= (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE
*)&CommBuffer
[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER
, MessageLength
) + sizeof(UINT64
)];
704 LockBoxParameterRestoreAllInPlace
= (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE
*)&CommBuffer
[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER
, MessageLength
) + sizeof(UINTN
)];
706 LockBoxParameterRestoreAllInPlace
->Header
.Command
= EFI_SMM_LOCK_BOX_COMMAND_RESTORE_ALL_IN_PLACE
;
707 LockBoxParameterRestoreAllInPlace
->Header
.DataLength
= sizeof(*LockBoxParameterRestoreAllInPlace
);
708 LockBoxParameterRestoreAllInPlace
->Header
.ReturnStatus
= (UINT64
)-1;
713 CommSize
= sizeof(CommBuffer
);
714 Status
= SmmCommunicationPpi
->Communicate (
719 if (Status
== EFI_NOT_STARTED
) {
721 // Pei SMM communication not ready yet, so we access SMRAM directly
723 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib Communicate - (%r)\n", Status
));
724 Status
= InternalRestoreAllLockBoxInPlaceFromSmram ();
725 LockBoxParameterRestoreAllInPlace
->Header
.ReturnStatus
= (UINT64
)Status
;
727 ASSERT_EFI_ERROR (Status
);
729 Status
= (EFI_STATUS
)LockBoxParameterRestoreAllInPlace
->Header
.ReturnStatus
;
730 if (Status
!= EFI_SUCCESS
) {
731 // Need or MAX_BIT, because there might be case that SMM is X64 while PEI is IA32.
735 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib RestoreAllLockBoxInPlace - Exit (%r)\n", Status
));