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
))
141 if (CompareGuid (&LockBox
->Guid
, Guid
)) {
150 Get VendorTable by VendorGuid in Smst.
152 @param Signature Signature of SMM_S3_RESUME_STATE
153 @param Smst SMM system table
154 @param VendorGuid vendor guid
156 @return vendor table.
159 InternalSmstGetVendorTableByGuid (
161 IN EFI_SMM_SYSTEM_TABLE2
*Smst
,
162 IN EFI_GUID
*VendorGuid
165 EFI_CONFIGURATION_TABLE
*SmmConfigurationTable
;
166 UINTN NumberOfTableEntries
;
168 EFI_SMM_SYSTEM_TABLE2_64
*Smst64
;
169 EFI_CONFIGURATION_TABLE64
*SmmConfigurationTable64
;
171 if ((sizeof (UINTN
) == sizeof (UINT32
)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode
))) {
175 Smst64
= (EFI_SMM_SYSTEM_TABLE2_64
*)Smst
;
176 SmmConfigurationTable64
= (EFI_CONFIGURATION_TABLE64
*)(UINTN
)Smst64
->SmmConfigurationTable
;
177 NumberOfTableEntries
= (UINTN
)Smst64
->NumberOfTableEntries
;
178 for (Index
= 0; Index
< NumberOfTableEntries
; Index
++) {
179 if (CompareGuid (&SmmConfigurationTable64
[Index
].VendorGuid
, VendorGuid
)) {
180 return (VOID
*)(UINTN
)SmmConfigurationTable64
[Index
].VendorTable
;
186 SmmConfigurationTable
= Smst
->SmmConfigurationTable
;
187 NumberOfTableEntries
= Smst
->NumberOfTableEntries
;
188 for (Index
= 0; Index
< NumberOfTableEntries
; Index
++) {
189 if (CompareGuid (&SmmConfigurationTable
[Index
].VendorGuid
, VendorGuid
)) {
190 return (VOID
*)SmmConfigurationTable
[Index
].VendorTable
;
199 Get SMM LockBox context.
201 @return SMM LockBox context.
203 SMM_LOCK_BOX_CONTEXT
*
204 InternalGetSmmLockBoxContext (
208 EFI_SMRAM_DESCRIPTOR
*SmramDescriptor
;
209 SMM_S3_RESUME_STATE
*SmmS3ResumeState
;
211 SMM_LOCK_BOX_CONTEXT
*SmmLockBoxContext
;
213 GuidHob
= GetFirstGuidHob (&gEfiAcpiVariableGuid
);
214 ASSERT (GuidHob
!= NULL
);
215 SmramDescriptor
= (EFI_SMRAM_DESCRIPTOR
*)GET_GUID_HOB_DATA (GuidHob
);
216 SmmS3ResumeState
= (SMM_S3_RESUME_STATE
*)(UINTN
)SmramDescriptor
->CpuStart
;
218 SmmLockBoxContext
= (SMM_LOCK_BOX_CONTEXT
*)InternalSmstGetVendorTableByGuid (
219 SmmS3ResumeState
->Signature
,
220 (EFI_SMM_SYSTEM_TABLE2
*)(UINTN
)SmmS3ResumeState
->Smst
,
221 &gEfiSmmLockBoxCommunicationGuid
223 ASSERT (SmmLockBoxContext
!= NULL
);
225 return SmmLockBoxContext
;
229 This function will restore confidential information from lockbox in SMRAM directly.
231 @param Guid the guid to identify the confidential information
232 @param Buffer the address of the restored confidential information
233 NULL means restored to original address, Length MUST be NULL at same time.
234 @param Length the length of the restored confidential information
236 @retval RETURN_SUCCESS the information is restored successfully.
237 @retval RETURN_WRITE_PROTECTED Buffer and Length are NULL, but the LockBox has no
238 LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE attribute.
239 @retval RETURN_BUFFER_TOO_SMALL the Length is too small to hold the confidential information.
240 @retval RETURN_NOT_FOUND the requested GUID not found.
243 InternalRestoreLockBoxFromSmram (
245 IN VOID
*Buffer OPTIONAL
,
246 IN OUT UINTN
*Length OPTIONAL
249 PEI_SMM_ACCESS_PPI
*SmmAccess
;
252 SMM_LOCK_BOX_CONTEXT
*SmmLockBoxContext
;
253 LIST_ENTRY
*LockBoxQueue
;
254 SMM_LOCK_BOX_DATA
*LockBox
;
258 // Get needed resource
260 Status
= PeiServicesLocatePpi (
261 &gPeiSmmAccessPpiGuid
,
266 if (!EFI_ERROR (Status
)) {
267 for (Index
= 0; !EFI_ERROR (Status
); Index
++) {
268 Status
= SmmAccess
->Open ((EFI_PEI_SERVICES
**)GetPeiServicesTablePointer (), SmmAccess
, Index
);
273 // Get LockBox context
275 SmmLockBoxContext
= InternalGetSmmLockBoxContext ();
276 LockBoxQueue
= (LIST_ENTRY
*)(UINTN
)SmmLockBoxContext
->LockBoxDataAddress
;
279 // We do NOT check Buffer address in SMRAM, because if SMRAM not locked, we trust the caller.
283 // Restore this, Buffer and Length MUST be both NULL or both non-NULL
289 LockBox
= InternalFindLockBoxByGuidFromSmram (LockBoxQueue
, Guid
);
290 if (LockBox
== NULL
) {
294 return EFI_NOT_FOUND
;
300 if (Buffer
!= NULL
) {
302 // restore to new buffer
304 RestoreBuffer
= Buffer
;
307 // restore to original buffer
309 if ((LockBox
->Attributes
& LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE
) == 0) {
310 return EFI_WRITE_PROTECTED
;
313 RestoreBuffer
= (VOID
*)(UINTN
)LockBox
->Buffer
;
319 if (Length
!= NULL
) {
320 if (*Length
< (UINTN
)LockBox
->Length
) {
322 // Input buffer is too small to hold all data.
324 *Length
= (UINTN
)LockBox
->Length
;
325 return EFI_BUFFER_TOO_SMALL
;
328 *Length
= (UINTN
)LockBox
->Length
;
334 CopyMem (RestoreBuffer
, (VOID
*)(UINTN
)LockBox
->SmramBuffer
, (UINTN
)LockBox
->Length
);
343 This function will restore confidential information from all lockbox which have RestoreInPlace attribute.
345 @retval RETURN_SUCCESS the information is restored successfully.
348 InternalRestoreAllLockBoxInPlaceFromSmram (
352 PEI_SMM_ACCESS_PPI
*SmmAccess
;
355 SMM_LOCK_BOX_CONTEXT
*SmmLockBoxContext
;
356 LIST_ENTRY
*LockBoxQueue
;
357 SMM_LOCK_BOX_DATA
*LockBox
;
361 // Get needed resource
363 Status
= PeiServicesLocatePpi (
364 &gPeiSmmAccessPpiGuid
,
369 if (!EFI_ERROR (Status
)) {
370 for (Index
= 0; !EFI_ERROR (Status
); Index
++) {
371 Status
= SmmAccess
->Open ((EFI_PEI_SERVICES
**)GetPeiServicesTablePointer (), SmmAccess
, Index
);
376 // Get LockBox context
378 SmmLockBoxContext
= InternalGetSmmLockBoxContext ();
379 LockBoxQueue
= (LIST_ENTRY
*)(UINTN
)SmmLockBoxContext
->LockBoxDataAddress
;
382 // We do NOT check Buffer address in SMRAM, because if SMRAM not locked, we trust the caller.
386 // Restore all, Buffer and Length MUST be NULL
388 for (Link
= InternalInitLinkDxe (LockBoxQueue
);
389 Link
!= LockBoxQueue
;
390 Link
= InternalNextLinkDxe (Link
))
397 if ((LockBox
->Attributes
& LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE
) != 0) {
401 CopyMem ((VOID
*)(UINTN
)LockBox
->Buffer
, (VOID
*)(UINTN
)LockBox
->SmramBuffer
, (UINTN
)LockBox
->Length
);
412 This function will save confidential information to lockbox.
414 @param Guid the guid to identify the confidential information
415 @param Buffer the address of the confidential information
416 @param Length the length of the confidential information
418 @retval RETURN_SUCCESS the information is saved successfully.
419 @retval RETURN_INVALID_PARAMETER the Guid is NULL, or Buffer is NULL, or Length is 0
420 @retval RETURN_ALREADY_STARTED the requested GUID already exist.
421 @retval RETURN_OUT_OF_RESOURCES no enough resource to save the information.
422 @retval RETURN_ACCESS_DENIED it is too late to invoke this interface
423 @retval RETURN_NOT_STARTED it is too early to invoke this interface
424 @retval RETURN_UNSUPPORTED the service is not supported by implementaion.
437 // No support to save at PEI phase
439 return RETURN_UNSUPPORTED
;
443 This function will set lockbox attributes.
445 @param Guid the guid to identify the confidential information
446 @param Attributes the attributes of the lockbox
448 @retval RETURN_SUCCESS the information is saved successfully.
449 @retval RETURN_INVALID_PARAMETER attributes is invalid.
450 @retval RETURN_NOT_FOUND the requested GUID not found.
451 @retval RETURN_ACCESS_DENIED it is too late to invoke this interface
452 @retval RETURN_NOT_STARTED it is too early to invoke this interface
453 @retval RETURN_UNSUPPORTED the service is not supported by implementaion.
457 SetLockBoxAttributes (
465 // No support to save at PEI phase
467 return RETURN_UNSUPPORTED
;
471 This function will update confidential information to lockbox.
473 @param Guid the guid to identify the original confidential information
474 @param Offset the offset of the original confidential information
475 @param Buffer the address of the updated confidential information
476 @param Length the length of the updated confidential information
478 @retval RETURN_SUCCESS the information is saved successfully.
479 @retval RETURN_INVALID_PARAMETER the Guid is NULL, or Buffer is NULL, or Length is 0.
480 @retval RETURN_NOT_FOUND the requested GUID not found.
481 @retval RETURN_BUFFER_TOO_SMALL for lockbox without attribute LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY,
482 the original buffer to too small to hold new information.
483 @retval RETURN_OUT_OF_RESOURCES for lockbox with attribute LOCK_BOX_ATTRIBUTE_RESTORE_IN_S3_ONLY,
484 no enough resource to save the information.
485 @retval RETURN_ACCESS_DENIED it is too late to invoke this interface
486 @retval RETURN_NOT_STARTED it is too early to invoke this interface
487 @retval RETURN_UNSUPPORTED the service is not supported by implementaion.
501 // No support to update at PEI phase
503 return RETURN_UNSUPPORTED
;
507 This function will restore confidential information from lockbox.
509 @param Guid the guid to identify the confidential information
510 @param Buffer the address of the restored confidential information
511 NULL means restored to original address, Length MUST be NULL at same time.
512 @param Length the length of the restored confidential information
514 @retval RETURN_SUCCESS the information is restored successfully.
515 @retval RETURN_INVALID_PARAMETER the Guid is NULL, or one of Buffer and Length is NULL.
516 @retval RETURN_WRITE_PROTECTED Buffer and Length are NULL, but the LockBox has no
517 LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE attribute.
518 @retval RETURN_BUFFER_TOO_SMALL the Length is too small to hold the confidential information.
519 @retval RETURN_NOT_FOUND the requested GUID not found.
520 @retval RETURN_NOT_STARTED it is too early to invoke this interface
521 @retval RETURN_ACCESS_DENIED not allow to restore to the address
522 @retval RETURN_UNSUPPORTED the service is not supported by implementaion.
528 IN VOID
*Buffer OPTIONAL
,
529 IN OUT UINTN
*Length OPTIONAL
533 EFI_PEI_SMM_COMMUNICATION_PPI
*SmmCommunicationPpi
;
534 EFI_SMM_LOCK_BOX_PARAMETER_RESTORE
*LockBoxParameterRestore
;
535 EFI_SMM_COMMUNICATE_HEADER
*CommHeader
;
536 UINT8 CommBuffer
[sizeof (EFI_GUID
) + sizeof (UINT64
) + sizeof (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE
)];
538 UINT64 MessageLength
;
541 // Please aware that there is UINTN in EFI_SMM_COMMUNICATE_HEADER. It might be UINT64 in DXE, while it is UINT32 in PEI.
543 // EFI_GUID HeaderGuid;
544 // UINTN MessageLength;
546 // } EFI_SMM_COMMUNICATE_HEADER;
549 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib RestoreLockBox - Enter\n"));
554 if ((Guid
== NULL
) ||
555 ((Buffer
== NULL
) && (Length
!= NULL
)) ||
556 ((Buffer
!= NULL
) && (Length
== NULL
)))
558 return EFI_INVALID_PARAMETER
;
562 // Get needed resource
564 Status
= PeiServicesLocatePpi (
565 &gEfiPeiSmmCommunicationPpiGuid
,
568 (VOID
**)&SmmCommunicationPpi
570 if (EFI_ERROR (Status
)) {
571 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib LocatePpi - (%r)\n", Status
));
572 Status
= InternalRestoreLockBoxFromSmram (Guid
, Buffer
, Length
);
573 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib RestoreLockBox - Exit (%r)\n", Status
));
580 CommHeader
= (EFI_SMM_COMMUNICATE_HEADER
*)&CommBuffer
[0];
581 CopyMem (&CommHeader
->HeaderGuid
, &gEfiSmmLockBoxCommunicationGuid
, sizeof (gEfiSmmLockBoxCommunicationGuid
));
582 if ((sizeof (UINTN
) == sizeof (UINT32
)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode
))) {
583 MessageLength
= sizeof (*LockBoxParameterRestore
);
584 CopyMem (&CommBuffer
[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER
, MessageLength
)], &MessageLength
, sizeof (MessageLength
));
586 CommHeader
->MessageLength
= sizeof (*LockBoxParameterRestore
);
589 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib CommBuffer - %x\n", &CommBuffer
[0]));
590 if ((sizeof (UINTN
) == sizeof (UINT32
)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode
))) {
591 LockBoxParameterRestore
= (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE
*)&CommBuffer
[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER
, MessageLength
) + sizeof (UINT64
)];
593 LockBoxParameterRestore
= (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE
*)&CommBuffer
[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER
, MessageLength
) + sizeof (UINTN
)];
596 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib LockBoxParameterRestore - %x\n", LockBoxParameterRestore
));
597 LockBoxParameterRestore
->Header
.Command
= EFI_SMM_LOCK_BOX_COMMAND_RESTORE
;
598 LockBoxParameterRestore
->Header
.DataLength
= sizeof (*LockBoxParameterRestore
);
599 LockBoxParameterRestore
->Header
.ReturnStatus
= (UINT64
)-1;
601 CopyMem (&LockBoxParameterRestore
->Guid
, Guid
, sizeof (*Guid
));
603 ZeroMem (&LockBoxParameterRestore
->Guid
, sizeof (*Guid
));
606 LockBoxParameterRestore
->Buffer
= (EFI_PHYSICAL_ADDRESS
)(UINTN
)Buffer
;
607 if (Length
!= NULL
) {
608 LockBoxParameterRestore
->Length
= (EFI_PHYSICAL_ADDRESS
)*Length
;
610 LockBoxParameterRestore
->Length
= 0;
616 CommSize
= sizeof (CommBuffer
);
617 Status
= SmmCommunicationPpi
->Communicate (
622 if (Status
== EFI_NOT_STARTED
) {
624 // Pei SMM communication not ready yet, so we access SMRAM directly
626 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib Communicate - (%r)\n", Status
));
627 Status
= InternalRestoreLockBoxFromSmram (Guid
, Buffer
, Length
);
628 LockBoxParameterRestore
->Header
.ReturnStatus
= (UINT64
)Status
;
629 if (Length
!= NULL
) {
630 LockBoxParameterRestore
->Length
= (UINT64
)*Length
;
634 if (Length
!= NULL
) {
635 *Length
= (UINTN
)LockBoxParameterRestore
->Length
;
638 Status
= (EFI_STATUS
)LockBoxParameterRestore
->Header
.ReturnStatus
;
639 if (Status
!= EFI_SUCCESS
) {
640 // Need or MAX_BIT, because there might be case that SMM is X64 while PEI is IA32.
644 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib RestoreLockBox - Exit (%r)\n", Status
));
653 This function will restore confidential information from all lockbox which have RestoreInPlace attribute.
655 @retval RETURN_SUCCESS the information is restored successfully.
656 @retval RETURN_NOT_STARTED it is too early to invoke this interface
657 @retval RETURN_UNSUPPORTED the service is not supported by implementaion.
661 RestoreAllLockBoxInPlace (
666 EFI_PEI_SMM_COMMUNICATION_PPI
*SmmCommunicationPpi
;
667 EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE
*LockBoxParameterRestoreAllInPlace
;
668 EFI_SMM_COMMUNICATE_HEADER
*CommHeader
;
669 UINT8 CommBuffer
[sizeof (EFI_GUID
) + sizeof (UINT64
) + sizeof (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE
)];
671 UINT64 MessageLength
;
674 // Please aware that there is UINTN in EFI_SMM_COMMUNICATE_HEADER. It might be UINT64 in DXE, while it is UINT32 in PEI.
676 // EFI_GUID HeaderGuid;
677 // UINTN MessageLength;
679 // } EFI_SMM_COMMUNICATE_HEADER;
682 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib RestoreAllLockBoxInPlace - Enter\n"));
685 // Get needed resource
687 Status
= PeiServicesLocatePpi (
688 &gEfiPeiSmmCommunicationPpiGuid
,
691 (VOID
**)&SmmCommunicationPpi
693 if (EFI_ERROR (Status
)) {
694 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib LocatePpi - (%r)\n", Status
));
695 Status
= InternalRestoreAllLockBoxInPlaceFromSmram ();
696 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib RestoreAllLockBoxInPlace - Exit (%r)\n", Status
));
703 CommHeader
= (EFI_SMM_COMMUNICATE_HEADER
*)&CommBuffer
[0];
704 CopyMem (&CommHeader
->HeaderGuid
, &gEfiSmmLockBoxCommunicationGuid
, sizeof (gEfiSmmLockBoxCommunicationGuid
));
705 if ((sizeof (UINTN
) == sizeof (UINT32
)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode
))) {
706 MessageLength
= sizeof (*LockBoxParameterRestoreAllInPlace
);
707 CopyMem (&CommBuffer
[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER
, MessageLength
)], &MessageLength
, sizeof (MessageLength
));
709 CommHeader
->MessageLength
= sizeof (*LockBoxParameterRestoreAllInPlace
);
712 if ((sizeof (UINTN
) == sizeof (UINT32
)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode
))) {
713 LockBoxParameterRestoreAllInPlace
= (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE
*)&CommBuffer
[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER
, MessageLength
) + sizeof (UINT64
)];
715 LockBoxParameterRestoreAllInPlace
= (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE
*)&CommBuffer
[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER
, MessageLength
) + sizeof (UINTN
)];
718 LockBoxParameterRestoreAllInPlace
->Header
.Command
= EFI_SMM_LOCK_BOX_COMMAND_RESTORE_ALL_IN_PLACE
;
719 LockBoxParameterRestoreAllInPlace
->Header
.DataLength
= sizeof (*LockBoxParameterRestoreAllInPlace
);
720 LockBoxParameterRestoreAllInPlace
->Header
.ReturnStatus
= (UINT64
)-1;
725 CommSize
= sizeof (CommBuffer
);
726 Status
= SmmCommunicationPpi
->Communicate (
731 if (Status
== EFI_NOT_STARTED
) {
733 // Pei SMM communication not ready yet, so we access SMRAM directly
735 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib Communicate - (%r)\n", Status
));
736 Status
= InternalRestoreAllLockBoxInPlaceFromSmram ();
737 LockBoxParameterRestoreAllInPlace
->Header
.ReturnStatus
= (UINT64
)Status
;
740 ASSERT_EFI_ERROR (Status
);
742 Status
= (EFI_STATUS
)LockBoxParameterRestoreAllInPlace
->Header
.ReturnStatus
;
743 if (Status
!= EFI_SUCCESS
) {
744 // Need or MAX_BIT, because there might be case that SMM is X64 while PEI is IA32.
748 DEBUG ((DEBUG_INFO
, "SmmLockBoxPeiLib RestoreAllLockBoxInPlace - Exit (%r)\n", Status
));