2 Implement all four UEFI Runtime Variable services for the nonvolatile
3 and volatile storage space and install variable architecture protocol
4 based on SMM variable module.
6 Caution: This module requires additional review when modified.
7 This driver will have external input - variable data.
8 This external input must be validated carefully to avoid security issue like
9 buffer overflow, integer overflow.
11 RuntimeServiceGetVariable() and RuntimeServiceSetVariable() are external API
12 to receive data buffer. The size should be checked carefully.
14 InitCommunicateBuffer() is really function to check the variable data size.
16 Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
17 This program and the accompanying materials
18 are licensed and made available under the terms and conditions of the BSD License
19 which accompanies this distribution. The full text of the license may be found at
20 http://opensource.org/licenses/bsd-license.php
22 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
23 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
28 #include <Protocol/VariableWrite.h>
29 #include <Protocol/Variable.h>
30 #include <Protocol/SmmCommunication.h>
31 #include <Protocol/SmmVariable.h>
33 #include <Library/UefiBootServicesTableLib.h>
34 #include <Library/UefiRuntimeServicesTableLib.h>
35 #include <Library/MemoryAllocationLib.h>
36 #include <Library/UefiDriverEntryPoint.h>
37 #include <Library/UefiRuntimeLib.h>
38 #include <Library/BaseMemoryLib.h>
39 #include <Library/DebugLib.h>
40 #include <Library/PcdLib.h>
41 #include <Library/UefiLib.h>
42 #include <Library/BaseLib.h>
44 #include <Guid/EventGroup.h>
45 #include <Guid/AuthenticatedVariableFormat.h>
46 #include <Guid/SmmVariableCommon.h>
48 EFI_HANDLE mHandle
= NULL
;
49 EFI_SMM_VARIABLE_PROTOCOL
*mSmmVariable
= NULL
;
50 EFI_EVENT mVirtualAddressChangeEvent
= NULL
;
51 EFI_SMM_COMMUNICATION_PROTOCOL
*mSmmCommunication
= NULL
;
52 UINT8
*mVariableBuffer
= NULL
;
53 UINT8
*mVariableBufferPhysical
= NULL
;
54 UINTN mVariableBufferSize
;
55 EFI_LOCK mVariableServicesLock
;
58 Acquires lock only at boot time. Simply returns at runtime.
60 This is a temperary function that will be removed when
61 EfiAcquireLock() in UefiLib can handle the call in UEFI
62 Runtimer driver in RT phase.
63 It calls EfiAcquireLock() at boot time, and simply returns
66 @param Lock A pointer to the lock to acquire.
70 AcquireLockOnlyAtBootTime (
74 if (!EfiAtRuntime ()) {
75 EfiAcquireLock (Lock
);
80 Releases lock only at boot time. Simply returns at runtime.
82 This is a temperary function which will be removed when
83 EfiReleaseLock() in UefiLib can handle the call in UEFI
84 Runtimer driver in RT phase.
85 It calls EfiReleaseLock() at boot time and simply returns
88 @param Lock A pointer to the lock to release.
92 ReleaseLockOnlyAtBootTime (
96 if (!EfiAtRuntime ()) {
97 EfiReleaseLock (Lock
);
102 Initialize the communicate buffer using DataSize and Function.
104 The communicate size is: SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE +
107 Caution: This function may receive untrusted input.
108 The data size external input, so this function will validate it carefully to avoid buffer overflow.
110 @param[out] DataPtr Points to the data in the communicate buffer.
111 @param[in] DataSize The data size to send to SMM.
112 @param[in] Function The function number to initialize the communicate header.
114 @retval EFI_INVALID_PARAMETER The data size is too big.
115 @retval EFI_SUCCESS Find the specified variable.
119 InitCommunicateBuffer (
120 OUT VOID
**DataPtr OPTIONAL
,
125 EFI_SMM_COMMUNICATE_HEADER
*SmmCommunicateHeader
;
126 SMM_VARIABLE_COMMUNICATE_HEADER
*SmmVariableFunctionHeader
;
129 if (DataSize
+ SMM_COMMUNICATE_HEADER_SIZE
+ SMM_VARIABLE_COMMUNICATE_HEADER_SIZE
> mVariableBufferSize
) {
130 return EFI_INVALID_PARAMETER
;
133 SmmCommunicateHeader
= (EFI_SMM_COMMUNICATE_HEADER
*) mVariableBuffer
;
134 CopyGuid (&SmmCommunicateHeader
->HeaderGuid
, &gEfiSmmVariableProtocolGuid
);
135 SmmCommunicateHeader
->MessageLength
= DataSize
+ SMM_VARIABLE_COMMUNICATE_HEADER_SIZE
;
137 SmmVariableFunctionHeader
= (SMM_VARIABLE_COMMUNICATE_HEADER
*) SmmCommunicateHeader
->Data
;
138 SmmVariableFunctionHeader
->Function
= Function
;
139 if (DataPtr
!= NULL
) {
140 *DataPtr
= SmmVariableFunctionHeader
->Data
;
148 Send the data in communicate buffer to SMM.
150 @param[in] DataSize This size of the function header and the data.
152 @retval EFI_SUCCESS Success is returned from the functin in SMM.
153 @retval Others Failure is returned from the function in SMM.
157 SendCommunicateBuffer (
163 EFI_SMM_COMMUNICATE_HEADER
*SmmCommunicateHeader
;
164 SMM_VARIABLE_COMMUNICATE_HEADER
*SmmVariableFunctionHeader
;
166 CommSize
= DataSize
+ SMM_COMMUNICATE_HEADER_SIZE
+ SMM_VARIABLE_COMMUNICATE_HEADER_SIZE
;
167 Status
= mSmmCommunication
->Communicate (mSmmCommunication
, mVariableBufferPhysical
, &CommSize
);
168 ASSERT_EFI_ERROR (Status
);
170 SmmCommunicateHeader
= (EFI_SMM_COMMUNICATE_HEADER
*) mVariableBuffer
;
171 SmmVariableFunctionHeader
= (SMM_VARIABLE_COMMUNICATE_HEADER
*)SmmCommunicateHeader
->Data
;
172 return SmmVariableFunctionHeader
->ReturnStatus
;
177 This code finds variable in storage blocks (Volatile or Non-Volatile).
179 Caution: This function may receive untrusted input.
180 The data size is external input, so this function will validate it carefully to avoid buffer overflow.
182 @param[in] VariableName Name of Variable to be found.
183 @param[in] VendorGuid Variable vendor GUID.
184 @param[out] Attributes Attribute value of the variable found.
185 @param[in, out] DataSize Size of Data found. If size is less than the
186 data, this value contains the required size.
187 @param[out] Data Data pointer.
189 @retval EFI_INVALID_PARAMETER Invalid parameter.
190 @retval EFI_SUCCESS Find the specified variable.
191 @retval EFI_NOT_FOUND Not found.
192 @retval EFI_BUFFER_TO_SMALL DataSize is too small for the result.
197 RuntimeServiceGetVariable (
198 IN CHAR16
*VariableName
,
199 IN EFI_GUID
*VendorGuid
,
200 OUT UINT32
*Attributes OPTIONAL
,
201 IN OUT UINTN
*DataSize
,
207 SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE
*SmmVariableHeader
;
209 if (VariableName
== NULL
|| VendorGuid
== NULL
|| DataSize
== NULL
) {
210 return EFI_INVALID_PARAMETER
;
213 if ((*DataSize
!= 0) && (Data
== NULL
)) {
214 return EFI_INVALID_PARAMETER
;
217 if (*DataSize
>= mVariableBufferSize
) {
219 // DataSize may be near MAX_ADDRESS incorrectly, this can cause the computed PayLoadSize to
220 // overflow to a small value and pass the check in InitCommunicateBuffer().
221 // To protect against this vulnerability, return EFI_INVALID_PARAMETER if DataSize is >= mVariableBufferSize.
222 // And there will be further check to ensure the total size is also not > mVariableBufferSize.
224 return EFI_INVALID_PARAMETER
;
227 AcquireLockOnlyAtBootTime(&mVariableServicesLock
);
230 // Init the communicate buffer. The buffer data size is:
231 // SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + PayloadSize.
233 PayloadSize
= OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE
, Name
) + StrSize (VariableName
) + *DataSize
;
234 Status
= InitCommunicateBuffer ((VOID
**)&SmmVariableHeader
, PayloadSize
, SMM_VARIABLE_FUNCTION_GET_VARIABLE
);
235 if (EFI_ERROR (Status
)) {
238 ASSERT (SmmVariableHeader
!= NULL
);
240 CopyGuid (&SmmVariableHeader
->Guid
, VendorGuid
);
241 SmmVariableHeader
->DataSize
= *DataSize
;
242 SmmVariableHeader
->NameSize
= StrSize (VariableName
);
243 if (Attributes
== NULL
) {
244 SmmVariableHeader
->Attributes
= 0;
246 SmmVariableHeader
->Attributes
= *Attributes
;
248 CopyMem (SmmVariableHeader
->Name
, VariableName
, SmmVariableHeader
->NameSize
);
253 Status
= SendCommunicateBuffer (PayloadSize
);
256 // Get data from SMM.
258 *DataSize
= SmmVariableHeader
->DataSize
;
259 if (Attributes
!= NULL
) {
260 *Attributes
= SmmVariableHeader
->Attributes
;
263 if (EFI_ERROR (Status
)) {
267 CopyMem (Data
, (UINT8
*)SmmVariableHeader
->Name
+ SmmVariableHeader
->NameSize
, SmmVariableHeader
->DataSize
);
270 ReleaseLockOnlyAtBootTime (&mVariableServicesLock
);
276 This code Finds the Next available variable.
278 @param[in, out] VariableNameSize Size of the variable name.
279 @param[in, out] VariableName Pointer to variable name.
280 @param[in, out] VendorGuid Variable Vendor Guid.
282 @retval EFI_INVALID_PARAMETER Invalid parameter.
283 @retval EFI_SUCCESS Find the specified variable.
284 @retval EFI_NOT_FOUND Not found.
285 @retval EFI_BUFFER_TO_SMALL DataSize is too small for the result.
290 RuntimeServiceGetNextVariableName (
291 IN OUT UINTN
*VariableNameSize
,
292 IN OUT CHAR16
*VariableName
,
293 IN OUT EFI_GUID
*VendorGuid
298 SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME
*SmmGetNextVariableName
;
300 if (VariableNameSize
== NULL
|| VariableName
== NULL
|| VendorGuid
== NULL
) {
301 return EFI_INVALID_PARAMETER
;
304 if (*VariableNameSize
>= mVariableBufferSize
) {
306 // VariableNameSize may be near MAX_ADDRESS incorrectly, this can cause the computed PayLoadSize to
307 // overflow to a small value and pass the check in InitCommunicateBuffer().
308 // To protect against this vulnerability, return EFI_INVALID_PARAMETER if VariableNameSize is >= mVariableBufferSize.
309 // And there will be further check to ensure the total size is also not > mVariableBufferSize.
311 return EFI_INVALID_PARAMETER
;
314 AcquireLockOnlyAtBootTime(&mVariableServicesLock
);
317 // Init the communicate buffer. The buffer data size is:
318 // SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + PayloadSize.
320 PayloadSize
= OFFSET_OF (SMM_VARIABLE_COMMUNICATE_GET_NEXT_VARIABLE_NAME
, Name
) + *VariableNameSize
;
321 Status
= InitCommunicateBuffer ((VOID
**)&SmmGetNextVariableName
, PayloadSize
, SMM_VARIABLE_FUNCTION_GET_NEXT_VARIABLE_NAME
);
322 if (EFI_ERROR (Status
)) {
325 ASSERT (SmmGetNextVariableName
!= NULL
);
327 SmmGetNextVariableName
->NameSize
= *VariableNameSize
;
328 CopyGuid (&SmmGetNextVariableName
->Guid
, VendorGuid
);
329 CopyMem (SmmGetNextVariableName
->Name
, VariableName
, *VariableNameSize
);
334 Status
= SendCommunicateBuffer (PayloadSize
);
337 // Get data from SMM.
339 *VariableNameSize
= SmmGetNextVariableName
->NameSize
;
340 if (EFI_ERROR (Status
)) {
344 CopyGuid (VendorGuid
, &SmmGetNextVariableName
->Guid
);
345 CopyMem (VariableName
, SmmGetNextVariableName
->Name
, SmmGetNextVariableName
->NameSize
);
348 ReleaseLockOnlyAtBootTime (&mVariableServicesLock
);
353 This code sets variable in storage blocks (Volatile or Non-Volatile).
355 Caution: This function may receive untrusted input.
356 The data size and data are external input, so this function will validate it carefully to avoid buffer overflow.
358 @param[in] VariableName Name of Variable to be found.
359 @param[in] VendorGuid Variable vendor GUID.
360 @param[in] Attributes Attribute value of the variable found
361 @param[in] DataSize Size of Data found. If size is less than the
362 data, this value contains the required size.
363 @param[in] Data Data pointer.
365 @retval EFI_INVALID_PARAMETER Invalid parameter.
366 @retval EFI_SUCCESS Set successfully.
367 @retval EFI_OUT_OF_RESOURCES Resource not enough to set variable.
368 @retval EFI_NOT_FOUND Not found.
369 @retval EFI_WRITE_PROTECTED Variable is read-only.
374 RuntimeServiceSetVariable (
375 IN CHAR16
*VariableName
,
376 IN EFI_GUID
*VendorGuid
,
377 IN UINT32 Attributes
,
384 SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE
*SmmVariableHeader
;
387 // Check input parameters.
389 if (VariableName
== NULL
|| VariableName
[0] == 0 || VendorGuid
== NULL
) {
390 return EFI_INVALID_PARAMETER
;
393 if (DataSize
!= 0 && Data
== NULL
) {
394 return EFI_INVALID_PARAMETER
;
397 if (DataSize
>= mVariableBufferSize
) {
399 // DataSize may be near MAX_ADDRESS incorrectly, this can cause the computed PayLoadSize to
400 // overflow to a small value and pass the check in InitCommunicateBuffer().
401 // To protect against this vulnerability, return EFI_INVALID_PARAMETER if DataSize is >= mVariableBufferSize.
402 // And there will be further check to ensure the total size is also not > mVariableBufferSize.
404 return EFI_INVALID_PARAMETER
;
407 AcquireLockOnlyAtBootTime(&mVariableServicesLock
);
410 // Init the communicate buffer. The buffer data size is:
411 // SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + PayloadSize.
413 PayloadSize
= OFFSET_OF (SMM_VARIABLE_COMMUNICATE_ACCESS_VARIABLE
, Name
) + StrSize (VariableName
) + DataSize
;
414 Status
= InitCommunicateBuffer ((VOID
**)&SmmVariableHeader
, PayloadSize
, SMM_VARIABLE_FUNCTION_SET_VARIABLE
);
415 if (EFI_ERROR (Status
)) {
418 ASSERT (SmmVariableHeader
!= NULL
);
420 CopyGuid ((EFI_GUID
*) &SmmVariableHeader
->Guid
, VendorGuid
);
421 SmmVariableHeader
->DataSize
= DataSize
;
422 SmmVariableHeader
->NameSize
= StrSize (VariableName
);
423 SmmVariableHeader
->Attributes
= Attributes
;
424 CopyMem (SmmVariableHeader
->Name
, VariableName
, SmmVariableHeader
->NameSize
);
425 CopyMem ((UINT8
*) SmmVariableHeader
->Name
+ SmmVariableHeader
->NameSize
, Data
, DataSize
);
430 Status
= SendCommunicateBuffer (PayloadSize
);
433 ReleaseLockOnlyAtBootTime (&mVariableServicesLock
);
439 This code returns information about the EFI variables.
441 @param[in] Attributes Attributes bitmask to specify the type of variables
442 on which to return information.
443 @param[out] MaximumVariableStorageSize Pointer to the maximum size of the storage space available
444 for the EFI variables associated with the attributes specified.
445 @param[out] RemainingVariableStorageSize Pointer to the remaining size of the storage space available
446 for EFI variables associated with the attributes specified.
447 @param[out] MaximumVariableSize Pointer to the maximum size of an individual EFI variables
448 associated with the attributes specified.
450 @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied.
451 @retval EFI_SUCCESS Query successfully.
452 @retval EFI_UNSUPPORTED The attribute is not supported on this platform.
457 RuntimeServiceQueryVariableInfo (
458 IN UINT32 Attributes
,
459 OUT UINT64
*MaximumVariableStorageSize
,
460 OUT UINT64
*RemainingVariableStorageSize
,
461 OUT UINT64
*MaximumVariableSize
466 SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO
*SmmQueryVariableInfo
;
468 if(MaximumVariableStorageSize
== NULL
|| RemainingVariableStorageSize
== NULL
|| MaximumVariableSize
== NULL
|| Attributes
== 0) {
469 return EFI_INVALID_PARAMETER
;
472 AcquireLockOnlyAtBootTime(&mVariableServicesLock
);
475 // Init the communicate buffer. The buffer data size is:
476 // SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + PayloadSize;
478 PayloadSize
= sizeof (SMM_VARIABLE_COMMUNICATE_QUERY_VARIABLE_INFO
);
479 Status
= InitCommunicateBuffer ((VOID
**)&SmmQueryVariableInfo
, PayloadSize
, SMM_VARIABLE_FUNCTION_QUERY_VARIABLE_INFO
);
480 if (EFI_ERROR (Status
)) {
483 ASSERT (SmmQueryVariableInfo
!= NULL
);
485 SmmQueryVariableInfo
->Attributes
= Attributes
;
490 Status
= SendCommunicateBuffer (PayloadSize
);
491 if (EFI_ERROR (Status
)) {
496 // Get data from SMM.
498 *MaximumVariableSize
= SmmQueryVariableInfo
->MaximumVariableSize
;
499 *MaximumVariableStorageSize
= SmmQueryVariableInfo
->MaximumVariableStorageSize
;
500 *RemainingVariableStorageSize
= SmmQueryVariableInfo
->RemainingVariableStorageSize
;
503 ReleaseLockOnlyAtBootTime (&mVariableServicesLock
);
509 Exit Boot Services Event notification handler.
511 Notify SMM variable driver about the event.
513 @param[in] Event Event whose notification function is being invoked.
514 @param[in] Context Pointer to the notification function's context.
525 // Init the communicate buffer. The buffer data size is:
526 // SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE.
528 InitCommunicateBuffer (NULL
, 0, SMM_VARIABLE_FUNCTION_EXIT_BOOT_SERVICE
);
533 SendCommunicateBuffer (0);
538 On Ready To Boot Services Event notification handler.
540 Notify SMM variable driver about the event.
542 @param[in] Event Event whose notification function is being invoked
543 @param[in] Context Pointer to the notification function's context
554 // Init the communicate buffer. The buffer data size is:
555 // SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE.
557 InitCommunicateBuffer (NULL
, 0, SMM_VARIABLE_FUNCTION_READY_TO_BOOT
);
562 SendCommunicateBuffer (0);
567 Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.
569 This is a notification function registered on EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.
570 It convers pointer to new virtual address.
572 @param[in] Event Event whose notification function is being invoked.
573 @param[in] Context Pointer to the notification function's context.
578 VariableAddressChangeEvent (
583 EfiConvertPointer (0x0, (VOID
**) &mVariableBuffer
);
584 EfiConvertPointer (0x0, (VOID
**) &mSmmCommunication
);
589 Initialize variable service and install Variable Architectural protocol.
591 @param[in] Event Event whose notification function is being invoked.
592 @param[in] Context Pointer to the notification function's context.
604 Status
= gBS
->LocateProtocol (&gEfiSmmVariableProtocolGuid
, NULL
, (VOID
**)&mSmmVariable
);
605 if (EFI_ERROR (Status
)) {
609 Status
= gBS
->LocateProtocol (&gEfiSmmCommunicationProtocolGuid
, NULL
, (VOID
**) &mSmmCommunication
);
610 ASSERT_EFI_ERROR (Status
);
613 // Allocate memory for variable store.
615 mVariableBufferSize
= SMM_COMMUNICATE_HEADER_SIZE
+ SMM_VARIABLE_COMMUNICATE_HEADER_SIZE
;
616 mVariableBufferSize
+= MAX (PcdGet32 (PcdMaxVariableSize
), PcdGet32 (PcdMaxHardwareErrorVariableSize
));
617 mVariableBuffer
= AllocateRuntimePool (mVariableBufferSize
);
618 ASSERT (mVariableBuffer
!= NULL
);
621 // Save the buffer physical address used for SMM conmunication.
623 mVariableBufferPhysical
= mVariableBuffer
;
625 gRT
->GetVariable
= RuntimeServiceGetVariable
;
626 gRT
->GetNextVariableName
= RuntimeServiceGetNextVariableName
;
627 gRT
->SetVariable
= RuntimeServiceSetVariable
;
628 gRT
->QueryVariableInfo
= RuntimeServiceQueryVariableInfo
;
631 // Install the Variable Architectural Protocol on a new handle.
633 Status
= gBS
->InstallProtocolInterface (
635 &gEfiVariableArchProtocolGuid
,
636 EFI_NATIVE_INTERFACE
,
639 ASSERT_EFI_ERROR (Status
);
644 SMM Non-Volatile variable write service is ready notify event handler.
646 @param[in] Event Event whose notification function is being invoked.
647 @param[in] Context Pointer to the notification function's context.
652 SmmVariableWriteReady (
661 // Check whether the protocol is installed or not.
663 Status
= gBS
->LocateProtocol (&gSmmVariableWriteGuid
, NULL
, (VOID
**) &ProtocolOps
);
664 if (EFI_ERROR (Status
)) {
668 Status
= gBS
->InstallProtocolInterface (
670 &gEfiVariableWriteArchProtocolGuid
,
671 EFI_NATIVE_INTERFACE
,
674 ASSERT_EFI_ERROR (Status
);
679 Variable Driver main entry point. The Variable driver places the 4 EFI
680 runtime services in the EFI System Table and installs arch protocols
681 for variable read and write services being available. It also registers
682 a notification function for an EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.
684 @param[in] ImageHandle The firmware allocated handle for the EFI image.
685 @param[in] SystemTable A pointer to the EFI System Table.
687 @retval EFI_SUCCESS Variable service successfully initialized.
692 VariableSmmRuntimeInitialize (
693 IN EFI_HANDLE ImageHandle
,
694 IN EFI_SYSTEM_TABLE
*SystemTable
697 VOID
*SmmVariableRegistration
;
698 VOID
*SmmVariableWriteRegistration
;
699 EFI_EVENT OnReadyToBootEvent
;
700 EFI_EVENT ExitBootServiceEvent
;
702 EfiInitializeLock (&mVariableServicesLock
, TPL_NOTIFY
);
705 // Smm variable service is ready
707 EfiCreateProtocolNotifyEvent (
708 &gEfiSmmVariableProtocolGuid
,
712 &SmmVariableRegistration
716 // Smm Non-Volatile variable write service is ready
718 EfiCreateProtocolNotifyEvent (
719 &gSmmVariableWriteGuid
,
721 SmmVariableWriteReady
,
723 &SmmVariableWriteRegistration
727 // Register the event to reclaim variable for OS usage.
729 EfiCreateEventReadyToBootEx (
737 // Register the event to inform SMM variable that it is at runtime.
744 &gEfiEventExitBootServicesGuid
,
745 &ExitBootServiceEvent
749 // Register the event to convert the pointer for runtime.
754 VariableAddressChangeEvent
,
756 &gEfiEventVirtualAddressChangeGuid
,
757 &mVirtualAddressChangeEvent