3 Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions
7 of the BSD License which accompanies this distribution. The
8 full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #include <Library/PeiServicesTablePointerLib.h>
20 #include <Library/PeiServicesLib.h>
21 #include <Library/BaseLib.h>
22 #include <Library/BaseMemoryLib.h>
23 #include <Library/LockBoxLib.h>
24 #include <Library/HobLib.h>
25 #include <Library/DebugLib.h>
26 #include <Library/PcdLib.h>
27 #include <Protocol/SmmCommunication.h>
28 #include <Ppi/SmmCommunication.h>
29 #include <Ppi/SmmAccess.h>
30 #include <Guid/AcpiS3Context.h>
31 #include <Guid/SmmLockBox.h>
33 #include "SmmLockBoxLibPrivate.h"
35 #if defined (MDE_CPU_IA32)
36 typedef struct _LIST_ENTRY64 LIST_ENTRY64
;
37 struct _LIST_ENTRY64
{
38 LIST_ENTRY64
*ForwardLink
;
40 LIST_ENTRY64
*BackLink
;
46 UINT64 SmmFirmwareVendor
;
47 UINT64 SmmFirmwareRevision
;
48 UINT64 SmmInstallConfigurationTable
;
53 UINT64 SmmAllocatePool
;
55 UINT64 SmmAllocatePages
;
57 UINT64 SmmStartupThisAp
;
58 UINT64 CurrentlyExecutingCpu
;
60 UINT64 CpuSaveStateSize
;
62 UINT64 NumberOfTableEntries
;
63 UINT64 SmmConfigurationTable
;
64 } EFI_SMM_SYSTEM_TABLE2_64
;
69 } EFI_CONFIGURATION_TABLE64
;
72 #if defined (MDE_CPU_X64)
73 typedef LIST_ENTRY LIST_ENTRY64
;
74 typedef EFI_SMM_SYSTEM_TABLE2 EFI_SMM_SYSTEM_TABLE2_64
;
75 typedef EFI_CONFIGURATION_TABLE EFI_CONFIGURATION_TABLE64
;
79 This function return first node of LinkList queue.
81 @param LockBoxQueue LinkList queue
83 @return first node of LinkList queue
87 IN LIST_ENTRY
*LinkList
90 if ((sizeof(UINTN
) == sizeof(UINT32
)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode
)) ) {
94 return (LIST_ENTRY
*)(((LIST_ENTRY64
*)LinkList
)->ForwardLink
);
96 return LinkList
->ForwardLink
;
101 This function return next node of LinkList.
103 @param Link LinkList node
105 @return next node of LinkList
108 InternalNextLinkDxe (
112 if ((sizeof(UINTN
) == sizeof(UINT32
)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode
)) ) {
116 return (LIST_ENTRY
*)(((LIST_ENTRY64
*)Link
)->ForwardLink
);
118 return Link
->ForwardLink
;
123 This function find LockBox by GUID from SMRAM.
125 @param LockBoxQueue The LockBox queue in SMRAM
126 @param Guid The guid to indentify the LockBox
131 InternalFindLockBoxByGuidFromSmram (
132 IN LIST_ENTRY
*LockBoxQueue
,
137 SMM_LOCK_BOX_DATA
*LockBox
;
139 for (Link
= InternalInitLinkDxe (LockBoxQueue
);
140 Link
!= LockBoxQueue
;
141 Link
= InternalNextLinkDxe (Link
)) {
147 if (CompareGuid (&LockBox
->Guid
, Guid
)) {
155 Get VendorTable by VendorGuid in Smst.
157 @param Signature Signature of SMM_S3_RESUME_STATE
158 @param Smst SMM system table
159 @param VendorGuid vendor guid
161 @return vendor table.
164 InternalSmstGetVendorTableByGuid (
166 IN EFI_SMM_SYSTEM_TABLE2
*Smst
,
167 IN EFI_GUID
*VendorGuid
170 EFI_CONFIGURATION_TABLE
*SmmConfigurationTable
;
171 UINTN NumberOfTableEntries
;
173 EFI_SMM_SYSTEM_TABLE2_64
*Smst64
;
174 EFI_CONFIGURATION_TABLE64
*SmmConfigurationTable64
;
176 if ((sizeof(UINTN
) == sizeof(UINT32
)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode
))) {
180 Smst64
= (EFI_SMM_SYSTEM_TABLE2_64
*)Smst
;
181 SmmConfigurationTable64
= (EFI_CONFIGURATION_TABLE64
*)(UINTN
)Smst64
->SmmConfigurationTable
;
182 NumberOfTableEntries
= (UINTN
)Smst64
->NumberOfTableEntries
;
183 for (Index
= 0; Index
< NumberOfTableEntries
; Index
++) {
184 if (CompareGuid (&SmmConfigurationTable64
[Index
].VendorGuid
, VendorGuid
)) {
185 return (VOID
*)(UINTN
)SmmConfigurationTable64
[Index
].VendorTable
;
190 SmmConfigurationTable
= Smst
->SmmConfigurationTable
;
191 NumberOfTableEntries
= Smst
->NumberOfTableEntries
;
192 for (Index
= 0; Index
< NumberOfTableEntries
; Index
++) {
193 if (CompareGuid (&SmmConfigurationTable
[Index
].VendorGuid
, VendorGuid
)) {
194 return (VOID
*)SmmConfigurationTable
[Index
].VendorTable
;
202 Get SMM LockBox context.
204 @return SMM LockBox context.
206 SMM_LOCK_BOX_CONTEXT
*
207 InternalGetSmmLockBoxContext (
211 EFI_SMRAM_DESCRIPTOR
*SmramDescriptor
;
212 SMM_S3_RESUME_STATE
*SmmS3ResumeState
;
214 SMM_LOCK_BOX_CONTEXT
*SmmLockBoxContext
;
216 GuidHob
= GetFirstGuidHob (&gEfiAcpiVariableGuid
);
217 ASSERT (GuidHob
!= NULL
);
218 SmramDescriptor
= (EFI_SMRAM_DESCRIPTOR
*) GET_GUID_HOB_DATA (GuidHob
);
219 SmmS3ResumeState
= (SMM_S3_RESUME_STATE
*)(UINTN
)SmramDescriptor
->CpuStart
;
221 SmmLockBoxContext
= (SMM_LOCK_BOX_CONTEXT
*)InternalSmstGetVendorTableByGuid (
222 SmmS3ResumeState
->Signature
,
223 (EFI_SMM_SYSTEM_TABLE2
*)(UINTN
)SmmS3ResumeState
->Smst
,
224 &gEfiSmmLockBoxCommunicationGuid
226 ASSERT (SmmLockBoxContext
!= NULL
);
228 return SmmLockBoxContext
;
232 This function will restore confidential information from lockbox in SMRAM directly.
234 @param Guid the guid to identify the confidential information
235 @param Buffer the address of the restored confidential information
236 NULL means restored to original address, Length MUST be NULL at same time.
237 @param Length the length of the restored confidential information
239 @retval RETURN_SUCCESS the information is restored successfully.
240 @retval RETURN_WRITE_PROTECTED Buffer and Length are NULL, but the LockBox has no
241 LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE attribute.
242 @retval RETURN_BUFFER_TOO_SMALL the Length is too small to hold the confidential information.
243 @retval RETURN_NOT_FOUND the requested GUID not found.
246 InternalRestoreLockBoxFromSmram (
248 IN VOID
*Buffer
, OPTIONAL
249 IN OUT UINTN
*Length OPTIONAL
252 PEI_SMM_ACCESS_PPI
*SmmAccess
;
255 SMM_LOCK_BOX_CONTEXT
*SmmLockBoxContext
;
256 LIST_ENTRY
*LockBoxQueue
;
257 SMM_LOCK_BOX_DATA
*LockBox
;
261 // Get needed resource
263 Status
= PeiServicesLocatePpi (
264 &gPeiSmmAccessPpiGuid
,
269 if (!EFI_ERROR (Status
)) {
270 for (Index
= 0; !EFI_ERROR (Status
); Index
++) {
271 Status
= SmmAccess
->Open ((EFI_PEI_SERVICES
**)GetPeiServicesTablePointer (), SmmAccess
, Index
);
276 // Get LockBox context
278 SmmLockBoxContext
= InternalGetSmmLockBoxContext ();
279 LockBoxQueue
= (LIST_ENTRY
*)(UINTN
)SmmLockBoxContext
->LockBoxDataAddress
;
282 // We do NOT check Buffer address in SMRAM, because if SMRAM not locked, we trust the caller.
286 // Restore this, Buffer and Length MUST be both NULL or both non-NULL
292 LockBox
= InternalFindLockBoxByGuidFromSmram (LockBoxQueue
, Guid
);
293 if (LockBox
== NULL
) {
297 return EFI_NOT_FOUND
;
303 if (Buffer
!= NULL
) {
305 // restore to new buffer
307 RestoreBuffer
= Buffer
;
310 // restore to original buffer
312 if ((LockBox
->Attributes
& LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE
) == 0) {
313 return EFI_WRITE_PROTECTED
;
315 RestoreBuffer
= (VOID
*)(UINTN
)LockBox
->Buffer
;
321 if (Length
!= NULL
) {
322 if (*Length
< (UINTN
)LockBox
->Length
) {
324 // Input buffer is too small to hold all data.
326 *Length
= (UINTN
)LockBox
->Length
;
327 return EFI_BUFFER_TOO_SMALL
;
329 *Length
= (UINTN
)LockBox
->Length
;
335 CopyMem (RestoreBuffer
, (VOID
*)(UINTN
)LockBox
->SmramBuffer
, (UINTN
)LockBox
->Length
);
344 This function will restore confidential information from all lockbox which have RestoreInPlace attribute.
346 @retval RETURN_SUCCESS the information is restored successfully.
349 InternalRestoreAllLockBoxInPlaceFromSmram (
353 PEI_SMM_ACCESS_PPI
*SmmAccess
;
356 SMM_LOCK_BOX_CONTEXT
*SmmLockBoxContext
;
357 LIST_ENTRY
*LockBoxQueue
;
358 SMM_LOCK_BOX_DATA
*LockBox
;
362 // Get needed resource
364 Status
= PeiServicesLocatePpi (
365 &gPeiSmmAccessPpiGuid
,
370 if (!EFI_ERROR (Status
)) {
371 for (Index
= 0; !EFI_ERROR (Status
); Index
++) {
372 Status
= SmmAccess
->Open ((EFI_PEI_SERVICES
**)GetPeiServicesTablePointer (), SmmAccess
, Index
);
377 // Get LockBox context
379 SmmLockBoxContext
= InternalGetSmmLockBoxContext ();
380 LockBoxQueue
= (LIST_ENTRY
*)(UINTN
)SmmLockBoxContext
->LockBoxDataAddress
;
383 // We do NOT check Buffer address in SMRAM, because if SMRAM not locked, we trust the caller.
387 // Restore all, Buffer and Length MUST be NULL
389 for (Link
= InternalInitLinkDxe (LockBoxQueue
);
390 Link
!= LockBoxQueue
;
391 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
);
411 This function will save confidential information to lockbox.
413 @param Guid the guid to identify the confidential information
414 @param Buffer the address of the confidential information
415 @param Length the length of the confidential information
417 @retval RETURN_SUCCESS the information is saved successfully.
418 @retval RETURN_INVALID_PARAMETER the Guid is NULL, or Buffer is NULL, or Length is 0
419 @retval RETURN_ALREADY_STARTED the requested GUID already exist.
420 @retval RETURN_OUT_OF_RESOURCES no enough resource to save the information.
421 @retval RETURN_ACCESS_DENIED it is too late to invoke this interface
422 @retval RETURN_NOT_STARTED it is too early to invoke this interface
423 @retval RETURN_UNSUPPORTED the service is not supported by implementaion.
436 // No support to save at PEI phase
438 return RETURN_UNSUPPORTED
;
442 This function will set lockbox attributes.
444 @param Guid the guid to identify the confidential information
445 @param Attributes the attributes of the lockbox
447 @retval RETURN_SUCCESS the information is saved successfully.
448 @retval RETURN_INVALID_PARAMETER attributes is invalid.
449 @retval RETURN_NOT_FOUND the requested GUID not found.
450 @retval RETURN_ACCESS_DENIED it is too late to invoke this interface
451 @retval RETURN_NOT_STARTED it is too early to invoke this interface
452 @retval RETURN_UNSUPPORTED the service is not supported by implementaion.
456 SetLockBoxAttributes (
464 // No support to save at PEI phase
466 return RETURN_UNSUPPORTED
;
470 This function will update confidential information to lockbox.
472 @param Guid the guid to identify the original confidential information
473 @param Offset the offset of the original confidential information
474 @param Buffer the address of the updated confidential information
475 @param Length the length of the updated confidential information
477 @retval RETURN_SUCCESS the information is saved successfully.
478 @retval RETURN_INVALID_PARAMETER the Guid is NULL, or Buffer is NULL, or Length is 0.
479 @retval RETURN_NOT_FOUND the requested GUID not found.
480 @retval RETURN_BUFFER_TOO_SMALL the original buffer to too small to hold new information.
481 @retval RETURN_ACCESS_DENIED it is too late to invoke this interface
482 @retval RETURN_NOT_STARTED it is too early to invoke this interface
483 @retval RETURN_UNSUPPORTED the service is not supported by implementaion.
497 // No support to update at PEI phase
499 return RETURN_UNSUPPORTED
;
503 This function will restore confidential information from lockbox.
505 @param Guid the guid to identify the confidential information
506 @param Buffer the address of the restored confidential information
507 NULL means restored to original address, Length MUST be NULL at same time.
508 @param Length the length of the restored confidential information
510 @retval RETURN_SUCCESS the information is restored successfully.
511 @retval RETURN_INVALID_PARAMETER the Guid is NULL, or one of Buffer and Length is NULL.
512 @retval RETURN_WRITE_PROTECTED Buffer and Length are NULL, but the LockBox has no
513 LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE attribute.
514 @retval RETURN_BUFFER_TOO_SMALL the Length is too small to hold the confidential information.
515 @retval RETURN_NOT_FOUND the requested GUID not found.
516 @retval RETURN_NOT_STARTED it is too early to invoke this interface
517 @retval RETURN_ACCESS_DENIED not allow to restore to the address
518 @retval RETURN_UNSUPPORTED the service is not supported by implementaion.
524 IN VOID
*Buffer
, OPTIONAL
525 IN OUT UINTN
*Length OPTIONAL
529 EFI_PEI_SMM_COMMUNICATION_PPI
*SmmCommunicationPpi
;
530 EFI_SMM_LOCK_BOX_PARAMETER_RESTORE
*LockBoxParameterRestore
;
531 EFI_SMM_COMMUNICATE_HEADER
*CommHeader
;
532 UINT8 CommBuffer
[sizeof(EFI_GUID
) + sizeof(UINT64
) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_RESTORE
)];
534 UINT64 MessageLength
;
537 // Please aware that there is UINTN in EFI_SMM_COMMUNICATE_HEADER. It might be UINT64 in DXE, while it is UINT32 in PEI.
539 // EFI_GUID HeaderGuid;
540 // UINTN MessageLength;
542 // } EFI_SMM_COMMUNICATE_HEADER;
545 DEBUG ((EFI_D_INFO
, "SmmLockBoxPeiLib RestoreLockBox - Enter\n"));
550 if ((Guid
== NULL
) ||
551 ((Buffer
== NULL
) && (Length
!= NULL
)) ||
552 ((Buffer
!= NULL
) && (Length
== NULL
))) {
553 return EFI_INVALID_PARAMETER
;
557 // Get needed resource
559 Status
= PeiServicesLocatePpi (
560 &gEfiPeiSmmCommunicationPpiGuid
,
563 (VOID
**)&SmmCommunicationPpi
565 if (EFI_ERROR (Status
)) {
566 DEBUG ((EFI_D_INFO
, "SmmLockBoxPeiLib LocatePpi - (%r)\n", Status
));
567 Status
= InternalRestoreLockBoxFromSmram (Guid
, Buffer
, Length
);
568 DEBUG ((EFI_D_INFO
, "SmmLockBoxPeiLib RestoreLockBox - Exit (%r)\n", Status
));
575 CommHeader
= (EFI_SMM_COMMUNICATE_HEADER
*)&CommBuffer
[0];
576 CopyMem (&CommHeader
->HeaderGuid
, &gEfiSmmLockBoxCommunicationGuid
, sizeof(gEfiSmmLockBoxCommunicationGuid
));
577 if ((sizeof(UINTN
) == sizeof(UINT32
)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode
)) ) {
578 MessageLength
= sizeof(*LockBoxParameterRestore
);
579 CopyMem (&CommBuffer
[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER
, MessageLength
)], &MessageLength
, sizeof(MessageLength
));
581 CommHeader
->MessageLength
= sizeof(*LockBoxParameterRestore
);
584 DEBUG ((EFI_D_INFO
, "SmmLockBoxPeiLib CommBuffer - %x\n", &CommBuffer
[0]));
585 if ((sizeof(UINTN
) == sizeof(UINT32
)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode
)) ) {
586 LockBoxParameterRestore
= (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE
*)&CommBuffer
[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER
, MessageLength
) + sizeof(UINT64
)];
588 LockBoxParameterRestore
= (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE
*)&CommBuffer
[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER
, MessageLength
) + sizeof(UINTN
)];
590 DEBUG ((EFI_D_INFO
, "SmmLockBoxPeiLib LockBoxParameterRestore - %x\n", LockBoxParameterRestore
));
591 LockBoxParameterRestore
->Header
.Command
= EFI_SMM_LOCK_BOX_COMMAND_RESTORE
;
592 LockBoxParameterRestore
->Header
.DataLength
= sizeof(*LockBoxParameterRestore
);
593 LockBoxParameterRestore
->Header
.ReturnStatus
= (UINT64
)-1;
595 CopyMem (&LockBoxParameterRestore
->Guid
, Guid
, sizeof(*Guid
));
597 ZeroMem (&LockBoxParameterRestore
->Guid
, sizeof(*Guid
));
599 LockBoxParameterRestore
->Buffer
= (EFI_PHYSICAL_ADDRESS
)(UINTN
)Buffer
;
600 if (Length
!= NULL
) {
601 LockBoxParameterRestore
->Length
= (EFI_PHYSICAL_ADDRESS
)*Length
;
603 LockBoxParameterRestore
->Length
= 0;
609 CommSize
= sizeof(CommBuffer
);
610 Status
= SmmCommunicationPpi
->Communicate (
615 if (Status
== EFI_NOT_STARTED
) {
617 // Pei SMM communication not ready yet, so we access SMRAM directly
619 DEBUG ((EFI_D_INFO
, "SmmLockBoxPeiLib Communicate - (%r)\n", Status
));
620 Status
= InternalRestoreLockBoxFromSmram (Guid
, Buffer
, Length
);
621 LockBoxParameterRestore
->Header
.ReturnStatus
= (UINT64
)Status
;
622 if (Length
!= NULL
) {
623 LockBoxParameterRestore
->Length
= (UINT64
)*Length
;
626 ASSERT_EFI_ERROR (Status
);
628 if (Length
!= NULL
) {
629 *Length
= (UINTN
)LockBoxParameterRestore
->Length
;
632 Status
= (EFI_STATUS
)LockBoxParameterRestore
->Header
.ReturnStatus
;
633 if (Status
!= EFI_SUCCESS
) {
634 // Need or MAX_BIT, because there might be case that SMM is X64 while PEI is IA32.
638 DEBUG ((EFI_D_INFO
, "SmmLockBoxPeiLib RestoreLockBox - Exit (%r)\n", Status
));
647 This function will restore confidential information from all lockbox which have RestoreInPlace attribute.
649 @retval RETURN_SUCCESS the information is restored successfully.
650 @retval RETURN_NOT_STARTED it is too early to invoke this interface
651 @retval RETURN_UNSUPPORTED the service is not supported by implementaion.
655 RestoreAllLockBoxInPlace (
660 EFI_PEI_SMM_COMMUNICATION_PPI
*SmmCommunicationPpi
;
661 EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE
*LockBoxParameterRestoreAllInPlace
;
662 EFI_SMM_COMMUNICATE_HEADER
*CommHeader
;
663 UINT8 CommBuffer
[sizeof(EFI_GUID
) + sizeof(UINT64
) + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE
)];
665 UINT64 MessageLength
;
668 // Please aware that there is UINTN in EFI_SMM_COMMUNICATE_HEADER. It might be UINT64 in DXE, while it is UINT32 in PEI.
670 // EFI_GUID HeaderGuid;
671 // UINTN MessageLength;
673 // } EFI_SMM_COMMUNICATE_HEADER;
676 DEBUG ((EFI_D_INFO
, "SmmLockBoxPeiLib RestoreAllLockBoxInPlace - Enter\n"));
679 // Get needed resource
681 Status
= PeiServicesLocatePpi (
682 &gEfiPeiSmmCommunicationPpiGuid
,
685 (VOID
**)&SmmCommunicationPpi
687 if (EFI_ERROR (Status
)) {
688 DEBUG ((EFI_D_INFO
, "SmmLockBoxPeiLib LocatePpi - (%r)\n", Status
));
689 Status
= InternalRestoreAllLockBoxInPlaceFromSmram ();
690 DEBUG ((EFI_D_INFO
, "SmmLockBoxPeiLib RestoreAllLockBoxInPlace - Exit (%r)\n", Status
));
697 CommHeader
= (EFI_SMM_COMMUNICATE_HEADER
*)&CommBuffer
[0];
698 CopyMem (&CommHeader
->HeaderGuid
, &gEfiSmmLockBoxCommunicationGuid
, sizeof(gEfiSmmLockBoxCommunicationGuid
));
699 if ((sizeof(UINTN
) == sizeof(UINT32
)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode
)) ) {
700 MessageLength
= sizeof(*LockBoxParameterRestoreAllInPlace
);
701 CopyMem (&CommBuffer
[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER
, MessageLength
)], &MessageLength
, sizeof(MessageLength
));
703 CommHeader
->MessageLength
= sizeof(*LockBoxParameterRestoreAllInPlace
);
706 if ((sizeof(UINTN
) == sizeof(UINT32
)) && (FeaturePcdGet (PcdDxeIplSwitchToLongMode
)) ) {
707 LockBoxParameterRestoreAllInPlace
= (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE
*)&CommBuffer
[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER
, MessageLength
) + sizeof(UINT64
)];
709 LockBoxParameterRestoreAllInPlace
= (EFI_SMM_LOCK_BOX_PARAMETER_RESTORE_ALL_IN_PLACE
*)&CommBuffer
[OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER
, MessageLength
) + sizeof(UINTN
)];
711 LockBoxParameterRestoreAllInPlace
->Header
.Command
= EFI_SMM_LOCK_BOX_COMMAND_RESTORE_ALL_IN_PLACE
;
712 LockBoxParameterRestoreAllInPlace
->Header
.DataLength
= sizeof(*LockBoxParameterRestoreAllInPlace
);
713 LockBoxParameterRestoreAllInPlace
->Header
.ReturnStatus
= (UINT64
)-1;
718 CommSize
= sizeof(CommBuffer
);
719 Status
= SmmCommunicationPpi
->Communicate (
724 if (Status
== EFI_NOT_STARTED
) {
726 // Pei SMM communication not ready yet, so we access SMRAM directly
728 DEBUG ((EFI_D_INFO
, "SmmLockBoxPeiLib Communicate - (%r)\n", Status
));
729 Status
= InternalRestoreAllLockBoxInPlaceFromSmram ();
730 LockBoxParameterRestoreAllInPlace
->Header
.ReturnStatus
= (UINT64
)Status
;
732 ASSERT_EFI_ERROR (Status
);
734 Status
= (EFI_STATUS
)LockBoxParameterRestoreAllInPlace
->Header
.ReturnStatus
;
735 if (Status
!= EFI_SUCCESS
) {
736 // Need or MAX_BIT, because there might be case that SMM is X64 while PEI is IA32.
740 DEBUG ((EFI_D_INFO
, "SmmLockBoxPeiLib RestoreAllLockBoxInPlace - Exit (%r)\n", Status
));