TianoCore EDK2 master
Loading...
Searching...
No Matches
VariableSmmRuntimeDxe.c File Reference

Go to the source code of this file.

Functions

EFI_STATUS EFIAPI VariablePolicySmmDxeMain (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
VOID EFIAPI RecordSecureBootPolicyVarData (VOID)
 
VOID AcquireLockOnlyAtBootTime (IN EFI_LOCK *Lock)
 
VOID ReleaseLockOnlyAtBootTime (IN EFI_LOCK *Lock)
 
BOOLEAN AtRuntime (VOID)
 
EFI_STATUS InitCommunicateBuffer (OUT VOID **DataPtr OPTIONAL, IN UINTN DataSize, IN UINTN Function)
 
EFI_STATUS SendCommunicateBuffer (IN UINTN DataSize)
 
EFI_STATUS EFIAPI VariableLockRequestToLock (IN CONST EDKII_VARIABLE_LOCK_PROTOCOL *This, IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid)
 === CODE UNDER TEST ===========================================================================
 
EFI_STATUS EFIAPI VarCheckRegisterSetVariableCheckHandler (IN VAR_CHECK_SET_VARIABLE_CHECK_HANDLER Handler)
 
EFI_STATUS EFIAPI VarCheckVariablePropertySet (IN CHAR16 *Name, IN EFI_GUID *Guid, IN VAR_CHECK_VARIABLE_PROPERTY *VariableProperty)
 
EFI_STATUS EFIAPI VarCheckVariablePropertyGet (IN CHAR16 *Name, IN EFI_GUID *Guid, OUT VAR_CHECK_VARIABLE_PROPERTY *VariableProperty)
 
VOID SyncRuntimeCache (VOID)
 
VOID CheckForRuntimeCacheSync (VOID)
 
EFI_STATUS FindVariableInRuntimeCache (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT UINT32 *Attributes OPTIONAL, IN OUT UINTN *DataSize, OUT VOID *Data OPTIONAL)
 
EFI_STATUS FindVariableInSmm (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT UINT32 *Attributes OPTIONAL, IN OUT UINTN *DataSize, OUT VOID *Data OPTIONAL)
 
EFI_STATUS EFIAPI RuntimeServiceGetVariable (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT UINT32 *Attributes OPTIONAL, IN OUT UINTN *DataSize, OUT VOID *Data)
 
EFI_STATUS GetNextVariableNameInRuntimeCache (IN OUT UINTN *VariableNameSize, IN OUT CHAR16 *VariableName, IN OUT EFI_GUID *VendorGuid)
 
EFI_STATUS GetNextVariableNameInSmm (IN OUT UINTN *VariableNameSize, IN OUT CHAR16 *VariableName, IN OUT EFI_GUID *VendorGuid)
 
EFI_STATUS EFIAPI RuntimeServiceGetNextVariableName (IN OUT UINTN *VariableNameSize, IN OUT CHAR16 *VariableName, IN OUT EFI_GUID *VendorGuid)
 
EFI_STATUS EFIAPI RuntimeServiceSetVariable (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, IN VOID *Data)
 
EFI_STATUS EFIAPI RuntimeServiceQueryVariableInfo (IN UINT32 Attributes, OUT UINT64 *MaximumVariableStorageSize, OUT UINT64 *RemainingVariableStorageSize, OUT UINT64 *MaximumVariableSize)
 
VOID EFIAPI OnExitBootServices (IN EFI_EVENT Event, IN VOID *Context)
 
VOID EFIAPI OnReadyToBoot (IN EFI_EVENT Event, IN VOID *Context)
 
VOID EFIAPI VariableAddressChangeEvent (IN EFI_EVENT Event, IN VOID *Context)
 
EFI_STATUS EFIAPI GetVariablePayloadSize (OUT UINTN *VariablePayloadSize)
 
EFI_STATUS GetRuntimeCacheInfo (OUT UINTN *TotalHobStorageSize, OUT UINTN *TotalNvStorageSize, OUT UINTN *TotalVolatileStorageSize, OUT BOOLEAN *AuthenticatedVariableUsage)
 
VOID InitVariableStoreHeader (IN VARIABLE_STORE_HEADER *VariableCacheBuffer, IN UINTN TotalVariableCacheSize)
 
EFI_STATUS InitVariableCache (IN EFI_HOB_GUID_TYPE *RuntimeCacheInfoGuidHob)
 
EFI_STATUS SendRuntimeVariableCacheContextToSmm (VOID)
 
VOID EFIAPI SmmVariableReady (IN EFI_EVENT Event, IN VOID *Context)
 
VOID EFIAPI SmmVariableWriteReady (IN EFI_EVENT Event, IN VOID *Context)
 
EFI_STATUS EFIAPI VariableSmmRuntimeInitialize (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

EFI_HANDLE mHandle = NULL
 
EFI_SMM_VARIABLE_PROTOCOLmSmmVariable = NULL
 
EFI_EVENT mVirtualAddressChangeEvent = NULL
 
EFI_MM_COMMUNICATION2_PROTOCOLmMmCommunication2 = NULL
 
UINT8 * mVariableBuffer = NULL
 
UINT8 * mVariableBufferPhysical = NULL
 
VARIABLE_INFO_ENTRYmVariableInfo = NULL
 
UINTN mVariableBufferSize
 
UINTN mVariableBufferPayloadSize
 
BOOLEAN mVariableAuthFormat
 
EFI_LOCK mVariableServicesLock
 
EDKII_VARIABLE_LOCK_PROTOCOL mVariableLock
 
EDKII_VAR_CHECK_PROTOCOL mVarCheck
 
VARIABLE_RUNTIME_CACHE_INFO mVariableRtCacheInfo
 
BOOLEAN mIsRuntimeCacheEnabled = FALSE
 

Detailed Description

Implement all four UEFI Runtime Variable services for the nonvolatile and volatile storage space and install variable architecture protocol based on SMM variable module.

Caution: This module requires additional review when modified. This driver will have external input - variable data. This external input must be validated carefully to avoid security issue like buffer overflow, integer overflow.

RuntimeServiceGetVariable() and RuntimeServiceSetVariable() are external API to receive data buffer. The size should be checked carefully.

InitCommunicateBuffer() is really function to check the variable data size.

Copyright (c) 2010 - 2024, Intel Corporation. All rights reserved.
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file VariableSmmRuntimeDxe.c.

Function Documentation

◆ AcquireLockOnlyAtBootTime()

VOID AcquireLockOnlyAtBootTime ( IN EFI_LOCK Lock)

Acquires lock only at boot time. Simply returns at runtime.

This is a temperary function that will be removed when EfiAcquireLock() in UefiLib can handle the call in UEFI Runtimer driver in RT phase. It calls EfiAcquireLock() at boot time, and simply returns at runtime.

Parameters
LockA pointer to the lock to acquire.

Definition at line 98 of file VariableSmmRuntimeDxe.c.

◆ AtRuntime()

BOOLEAN AtRuntime ( VOID  )

Return TRUE if ExitBootServices () has been called.

Return values
TRUEIf ExitBootServices () has been called. FALSE if ExitBootServices () has not been called.

Definition at line 135 of file VariableSmmRuntimeDxe.c.

◆ CheckForRuntimeCacheSync()

VOID CheckForRuntimeCacheSync ( VOID  )

Check whether a SMI must be triggered to retrieve pending cache updates.

If the variable HOB was finished being flushed since the last check for a runtime cache update, this function will prevent the HOB cache from being used for future runtime cache hits.

Definition at line 494 of file VariableSmmRuntimeDxe.c.

◆ FindVariableInRuntimeCache()

EFI_STATUS FindVariableInRuntimeCache ( IN CHAR16 *  VariableName,
IN EFI_GUID VendorGuid,
OUT UINT32 *Attributes  OPTIONAL,
IN OUT UINTN DataSize,
OUT VOID *Data  OPTIONAL 
)

Finds the given variable in a runtime cache variable store.

Caution: This function may receive untrusted input. The data size is external input, so this function will validate it carefully to avoid buffer overflow.

Parameters
[in]VariableNameName of Variable to be found.
[in]VendorGuidVariable vendor GUID.
[out]AttributesAttribute value of the variable found.
[in,out]DataSizeSize of Data found. If size is less than the data, this value contains the required size.
[out]DataData pointer.
Return values
EFI_SUCCESSFound the specified variable.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_NOT_FOUNDThe specified variable could not be found.

Definition at line 535 of file VariableSmmRuntimeDxe.c.

◆ FindVariableInSmm()

EFI_STATUS FindVariableInSmm ( IN CHAR16 *  VariableName,
IN EFI_GUID VendorGuid,
OUT UINT32 *Attributes  OPTIONAL,
IN OUT UINTN DataSize,
OUT VOID *Data  OPTIONAL 
)

Finds the given variable in a variable store in SMM.

Caution: This function may receive untrusted input. The data size is external input, so this function will validate it carefully to avoid buffer overflow.

Parameters
[in]VariableNameName of Variable to be found.
[in]VendorGuidVariable vendor GUID.
[out]AttributesAttribute value of the variable found.
[in,out]DataSizeSize of Data found. If size is less than the data, this value contains the required size.
[out]DataData pointer.
Return values
EFI_SUCCESSFound the specified variable.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_NOT_FOUNDThe specified variable could not be found.

Definition at line 654 of file VariableSmmRuntimeDxe.c.

◆ GetNextVariableNameInRuntimeCache()

EFI_STATUS GetNextVariableNameInRuntimeCache ( IN OUT UINTN VariableNameSize,
IN OUT CHAR16 *  VariableName,
IN OUT EFI_GUID VendorGuid 
)

Finds the next available variable in a runtime cache variable store.

Parameters
[in,out]VariableNameSizeSize of the variable name.
[in,out]VariableNamePointer to variable name.
[in,out]VendorGuidVariable Vendor Guid.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_NOT_FOUNDThe next variable was not found.
EFI_BUFFER_TOO_SMALLThe VariableNameSize is too small for the result. VariableNameSize has been updated with the size needed to complete the request.
EFI_INVALID_PARAMETERVariableNameSize is NULL.
EFI_INVALID_PARAMETERVariableName is NULL.
EFI_INVALID_PARAMETERVendorGuid is NULL.
EFI_INVALID_PARAMETERThe input values of VariableName and VendorGuid are not a name and GUID of an existing variable.
EFI_INVALID_PARAMETERNull-terminator is not found in the first VariableNameSize bytes of the input VariableName buffer.
EFI_DEVICE_ERRORThe variable could not be retrieved due to a hardware error.
EFI_UNSUPPORTEDAfter ExitBootServices() has been called, this return code may be returned if no variable storage is supported. The platform should describe this runtime service as unsupported at runtime via an EFI_RT_PROPERTIES_TABLE configuration table.

Definition at line 834 of file VariableSmmRuntimeDxe.c.

◆ GetNextVariableNameInSmm()

EFI_STATUS GetNextVariableNameInSmm ( IN OUT UINTN VariableNameSize,
IN OUT CHAR16 *  VariableName,
IN OUT EFI_GUID VendorGuid 
)

Finds the next available variable in a SMM variable store.

Parameters
[in,out]VariableNameSizeSize of the variable name.
[in,out]VariableNamePointer to variable name.
[in,out]VendorGuidVariable Vendor Guid.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_NOT_FOUNDThe next variable was not found.
EFI_BUFFER_TOO_SMALLThe VariableNameSize is too small for the result. VariableNameSize has been updated with the size needed to complete the request.
EFI_INVALID_PARAMETERVariableNameSize is NULL.
EFI_INVALID_PARAMETERVariableName is NULL.
EFI_INVALID_PARAMETERVendorGuid is NULL.
EFI_INVALID_PARAMETERThe input values of VariableName and VendorGuid are not a name and GUID of an existing variable.
EFI_INVALID_PARAMETERNull-terminator is not found in the first VariableNameSize bytes of the input VariableName buffer.
EFI_DEVICE_ERRORThe variable could not be retrieved due to a hardware error.
EFI_UNSUPPORTEDAfter ExitBootServices() has been called, this return code may be returned if no variable storage is supported. The platform should describe this runtime service as unsupported at runtime via an EFI_RT_PROPERTIES_TABLE configuration table.

Definition at line 923 of file VariableSmmRuntimeDxe.c.

◆ GetRuntimeCacheInfo()

EFI_STATUS GetRuntimeCacheInfo ( OUT UINTN TotalHobStorageSize,
OUT UINTN TotalNvStorageSize,
OUT UINTN TotalVolatileStorageSize,
OUT BOOLEAN *  AuthenticatedVariableUsage 
)

This code gets information needed from SMM for runtime cache initialization.

Parameters
[out]TotalHobStorageSizeOutput pointer for the total HOB storage size in bytes.
[out]TotalNvStorageSizeOutput pointer for the total non-volatile storage size in bytes.
[out]TotalVolatileStorageSizeOutput pointer for the total volatile storage size in bytes.
[out]AuthenticatedVariableUsageOutput pointer that indicates if authenticated variables are to be used.
Return values
EFI_SUCCESSRetrieved the size successfully.
EFI_INVALID_PARAMETERTotalNvStorageSize parameter is NULL.
EFI_OUT_OF_RESOURCESThe memory resources needed for a CommBuffer are not available.
OthersCould not retrieve the size successfully.

Definition at line 1443 of file VariableSmmRuntimeDxe.c.

◆ GetVariablePayloadSize()

EFI_STATUS EFIAPI GetVariablePayloadSize ( OUT UINTN VariablePayloadSize)

This code gets variable payload size.

Parameters
[out]VariablePayloadSizeOutput pointer to variable payload size.
Return values
EFI_SUCCESSGet successfully.
OthersGet unsuccessfully.

Definition at line 1364 of file VariableSmmRuntimeDxe.c.

◆ InitCommunicateBuffer()

EFI_STATUS InitCommunicateBuffer ( OUT VOID **DataPtr  OPTIONAL,
IN UINTN  DataSize,
IN UINTN  Function 
)

Initialize the communicate buffer using DataSize and Function.

The communicate size is: SMM_COMMUNICATE_HEADER_SIZE + SMM_VARIABLE_COMMUNICATE_HEADER_SIZE + DataSize.

Caution: This function may receive untrusted input. The data size external input, so this function will validate it carefully to avoid buffer overflow.

Parameters
[out]DataPtrPoints to the data in the communicate buffer.
[in]DataSizeThe data size to send to SMM.
[in]FunctionThe function number to initialize the communicate header.
Return values
EFI_INVALID_PARAMETERThe data size is too big.
EFI_SUCCESSFind the specified variable.

Definition at line 160 of file VariableSmmRuntimeDxe.c.

◆ InitVariableCache()

EFI_STATUS InitVariableCache ( IN EFI_HOB_GUID_TYPE RuntimeCacheInfoGuidHob)

Initialize the runtime variable cache related content.

Parameters
[in]RuntimeCacheInfoGuidHobPointer to the gEdkiiVariableRuntimeCacheInfoHobGuid HOB.
Return values
EFI_SUCCESSInitialize the runtime variable cache related content successfully.
OthersCould not initialize the runtime variable cache related content successfully.

Definition at line 1543 of file VariableSmmRuntimeDxe.c.

◆ InitVariableStoreHeader()

VOID InitVariableStoreHeader ( IN VARIABLE_STORE_HEADER VariableCacheBuffer,
IN UINTN  TotalVariableCacheSize 
)

Initialize the variable cache buffer as an empty variable store.

Parameters
[in]VariableCacheBufferA pointer to pointer of a cache variable store.
[in]TotalVariableCacheSizeThe size needed for the UEFI variable store cache buffer that is allocated.

Definition at line 1517 of file VariableSmmRuntimeDxe.c.

◆ OnExitBootServices()

VOID EFIAPI OnExitBootServices ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Exit Boot Services Event notification handler.

Notify SMM variable driver about the event.

Parameters
[in]EventEvent whose notification function is being invoked.
[in]ContextPointer to the notification function's context.

Definition at line 1270 of file VariableSmmRuntimeDxe.c.

◆ OnReadyToBoot()

VOID EFIAPI OnReadyToBoot ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

On Ready To Boot Services Event notification handler.

Notify SMM variable driver about the event.

Parameters
[in]EventEvent whose notification function is being invoked
[in]ContextPointer to the notification function's context

Definition at line 1298 of file VariableSmmRuntimeDxe.c.

◆ RecordSecureBootPolicyVarData()

VOID EFIAPI RecordSecureBootPolicyVarData ( VOID  )

Some Secure Boot Policy Variable may update following other variable changes(SecureBoot follows PK change, etc). Record their initial State when variable write service is ready.

Definition at line 347 of file Measurement.c.

◆ ReleaseLockOnlyAtBootTime()

VOID ReleaseLockOnlyAtBootTime ( IN EFI_LOCK Lock)

Releases lock only at boot time. Simply returns at runtime.

This is a temperary function which will be removed when EfiReleaseLock() in UefiLib can handle the call in UEFI Runtimer driver in RT phase. It calls EfiReleaseLock() at boot time and simply returns at runtime.

Parameters
LockA pointer to the lock to release.

Definition at line 120 of file VariableSmmRuntimeDxe.c.

◆ RuntimeServiceGetNextVariableName()

EFI_STATUS EFIAPI RuntimeServiceGetNextVariableName ( IN OUT UINTN VariableNameSize,
IN OUT CHAR16 *  VariableName,
IN OUT EFI_GUID VendorGuid 
)

This code Finds the Next available variable.

Parameters
[in,out]VariableNameSizeSize of the variable name.
[in,out]VariableNamePointer to variable name.
[in,out]VendorGuidVariable Vendor Guid.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_NOT_FOUNDThe next variable was not found.
EFI_BUFFER_TOO_SMALLThe VariableNameSize is too small for the result. VariableNameSize has been updated with the size needed to complete the request.
EFI_INVALID_PARAMETERVariableNameSize is NULL.
EFI_INVALID_PARAMETERVariableName is NULL.
EFI_INVALID_PARAMETERVendorGuid is NULL.
EFI_INVALID_PARAMETERThe input values of VariableName and VendorGuid are not a name and GUID of an existing variable.
EFI_INVALID_PARAMETERNull-terminator is not found in the first VariableNameSize bytes of the input VariableName buffer.
EFI_DEVICE_ERRORThe variable could not be retrieved due to a hardware error.
EFI_UNSUPPORTEDAfter ExitBootServices() has been called, this return code may be returned if no variable storage is supported. The platform should describe this runtime service as unsupported at runtime via an EFI_RT_PROPERTIES_TABLE configuration table.

Definition at line 1037 of file VariableSmmRuntimeDxe.c.

◆ RuntimeServiceGetVariable()

EFI_STATUS EFIAPI RuntimeServiceGetVariable ( IN CHAR16 *  VariableName,
IN EFI_GUID VendorGuid,
OUT UINT32 *Attributes  OPTIONAL,
IN OUT UINTN DataSize,
OUT VOID *  Data 
)

This code finds variable in storage blocks (Volatile or Non-Volatile).

Caution: This function may receive untrusted input. The data size is external input, so this function will validate it carefully to avoid buffer overflow.

Parameters
[in]VariableNameName of Variable to be found.
[in]VendorGuidVariable vendor GUID.
[out]AttributesAttribute value of the variable found.
[in,out]DataSizeSize of Data found. If size is less than the data, this value contains the required size.
[out]DataData pointer.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_NOT_FOUNDThe variable was not found.
EFI_BUFFER_TOO_SMALLThe DataSize is too small for the result.
EFI_INVALID_PARAMETERVariableName is NULL.
EFI_INVALID_PARAMETERVendorGuid is NULL.
EFI_INVALID_PARAMETERDataSize is NULL.
EFI_INVALID_PARAMETERThe DataSize is not too small and Data is NULL.
EFI_DEVICE_ERRORThe variable could not be retrieved due to a hardware error.
EFI_SECURITY_VIOLATIONThe variable could not be retrieved due to an authentication failure.
EFI_UNSUPPORTEDAfter ExitBootServices() has been called, this return code may be returned if no variable storage is supported. The platform should describe this runtime service as unsupported at runtime via an EFI_RT_PROPERTIES_TABLE configuration table.

Definition at line 778 of file VariableSmmRuntimeDxe.c.

◆ RuntimeServiceQueryVariableInfo()

EFI_STATUS EFIAPI RuntimeServiceQueryVariableInfo ( IN UINT32  Attributes,
OUT UINT64 *  MaximumVariableStorageSize,
OUT UINT64 *  RemainingVariableStorageSize,
OUT UINT64 *  MaximumVariableSize 
)

This code returns information about the EFI variables.

Parameters
[in]AttributesAttributes bitmask to specify the type of variables on which to return information.
[out]MaximumVariableStorageSizePointer to the maximum size of the storage space available for the EFI variables associated with the attributes specified.
[out]RemainingVariableStorageSizePointer to the remaining size of the storage space available for EFI variables associated with the attributes specified.
[out]MaximumVariableSizePointer to the maximum size of an individual EFI variables associated with the attributes specified.
Return values
EFI_INVALID_PARAMETERAn invalid combination of attribute bits was supplied.
EFI_SUCCESSQuery successfully.
EFI_UNSUPPORTEDThe attribute is not supported on this platform.

Definition at line 1206 of file VariableSmmRuntimeDxe.c.

◆ RuntimeServiceSetVariable()

EFI_STATUS EFIAPI RuntimeServiceSetVariable ( IN CHAR16 *  VariableName,
IN EFI_GUID VendorGuid,
IN UINT32  Attributes,
IN UINTN  DataSize,
IN VOID *  Data 
)

This code sets variable in storage blocks (Volatile or Non-Volatile).

Caution: This function may receive untrusted input. The data size and data are external input, so this function will validate it carefully to avoid buffer overflow.

Parameters
[in]VariableNameName of Variable to be found.
[in]VendorGuidVariable vendor GUID.
[in]AttributesAttribute value of the variable found
[in]DataSizeSize of Data found. If size is less than the data, this value contains the required size.
[in]DataData pointer.
Return values
EFI_SUCCESSThe firmware has successfully stored the variable and its data as defined by the Attributes.
EFI_INVALID_PARAMETERAn invalid combination of attribute bits, name, and GUID was supplied, or the DataSize exceeds the maximum allowed.
EFI_INVALID_PARAMETERVariableName is an empty string.
EFI_OUT_OF_RESOURCESNot enough storage is available to hold the variable and its data.
EFI_DEVICE_ERRORThe variable could not be retrieved due to a hardware error.
EFI_WRITE_PROTECTEDThe variable in question is read-only.
EFI_WRITE_PROTECTEDThe variable in question cannot be deleted.
EFI_SECURITY_VIOLATIONThe variable could not be written due to EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACESS being set, but the AuthInfo does NOT pass the validation check carried out by the firmware.
EFI_NOT_FOUNDThe variable trying to be updated or deleted was not found.
EFI_UNSUPPORTEDThis call is not supported by this platform at the time the call is made. The platform should describe this runtime service as unsupported at runtime via an EFI_RT_PROPERTIES_TABLE configuration table.

Definition at line 1110 of file VariableSmmRuntimeDxe.c.

◆ SendCommunicateBuffer()

EFI_STATUS SendCommunicateBuffer ( IN UINTN  DataSize)

Send the data in communicate buffer to SMM.

Parameters
[in]DataSizeThis size of the function header and the data.
Return values
EFI_SUCCESSSuccess is returned from the functin in SMM.
OthersFailure is returned from the function in SMM.

Definition at line 196 of file VariableSmmRuntimeDxe.c.

◆ SendRuntimeVariableCacheContextToSmm()

EFI_STATUS SendRuntimeVariableCacheContextToSmm ( VOID  )

Sends the runtime variable cache context information to SMM.

Return values
EFI_SUCCESSRetrieved the size successfully.
EFI_INVALID_PARAMETERTotalNvStorageSize parameter is NULL.
EFI_OUT_OF_RESOURCESThe memory resources needed for a CommBuffer are not available.
OthersCould not retrieve the size successfully.;

Definition at line 1596 of file VariableSmmRuntimeDxe.c.

◆ SmmVariableReady()

VOID EFIAPI SmmVariableReady ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Initialize variable service and install Variable Architectural protocol.

Parameters
[in]EventEvent whose notification function is being invoked.
[in]ContextPointer to the notification function's context.

Definition at line 1667 of file VariableSmmRuntimeDxe.c.

◆ SmmVariableWriteReady()

VOID EFIAPI SmmVariableWriteReady ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

SMM Non-Volatile variable write service is ready notify event handler.

Parameters
[in]EventEvent whose notification function is being invoked.
[in]ContextPointer to the notification function's context.

Definition at line 1767 of file VariableSmmRuntimeDxe.c.

◆ SyncRuntimeCache()

VOID SyncRuntimeCache ( VOID  )

Signals SMM to synchronize any pending variable updates with the runtime cache(s).

Definition at line 470 of file VariableSmmRuntimeDxe.c.

◆ VarCheckRegisterSetVariableCheckHandler()

EFI_STATUS EFIAPI VarCheckRegisterSetVariableCheckHandler ( IN VAR_CHECK_SET_VARIABLE_CHECK_HANDLER  Handler)

Register SetVariable check handler.

Parameters
[in]HandlerPointer to check handler.
Return values
EFI_SUCCESSThe SetVariable check handler was registered successfully.
EFI_INVALID_PARAMETERHandler is NULL.
EFI_ACCESS_DENIEDEFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has already been signaled.
EFI_OUT_OF_RESOURCESThere is not enough resource for the SetVariable check handler register request.
EFI_UNSUPPORTEDThis interface is not implemented. For example, it is unsupported in VarCheck protocol if both VarCheck and SmmVarCheck protocols are present.

Definition at line 305 of file VariableSmmRuntimeDxe.c.

◆ VarCheckVariablePropertyGet()

EFI_STATUS EFIAPI VarCheckVariablePropertyGet ( IN CHAR16 *  Name,
IN EFI_GUID Guid,
OUT VAR_CHECK_VARIABLE_PROPERTY VariableProperty 
)

Variable property get.

Parameters
[in]NamePointer to the variable name.
[in]GuidPointer to the vendor GUID.
[out]VariablePropertyPointer to the output variable property.
Return values
EFI_SUCCESSThe property of variable specified by the Name and Guid was got successfully.
EFI_INVALID_PARAMETERName, Guid or VariableProperty is NULL, or Name is an empty string.
EFI_NOT_FOUNDThe property of variable specified by the Name and Guid was not found.

Definition at line 405 of file VariableSmmRuntimeDxe.c.

◆ VarCheckVariablePropertySet()

EFI_STATUS EFIAPI VarCheckVariablePropertySet ( IN CHAR16 *  Name,
IN EFI_GUID Guid,
IN VAR_CHECK_VARIABLE_PROPERTY VariableProperty 
)

Variable property set.

Parameters
[in]NamePointer to the variable name.
[in]GuidPointer to the vendor GUID.
[in]VariablePropertyPointer to the input variable property.
Return values
EFI_SUCCESSThe property of variable specified by the Name and Guid was set successfully.
EFI_INVALID_PARAMETERName, Guid or VariableProperty is NULL, or Name is an empty string, or the fields of VariableProperty are not valid.
EFI_ACCESS_DENIEDEFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has already been signaled.
EFI_OUT_OF_RESOURCESThere is not enough resource for the variable property set request.

Definition at line 329 of file VariableSmmRuntimeDxe.c.

◆ VariableAddressChangeEvent()

VOID EFIAPI VariableAddressChangeEvent ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.

This is a notification function registered on EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event. It convers pointer to new virtual address.

Parameters
[in]EventEvent whose notification function is being invoked.
[in]ContextPointer to the notification function's context.

Definition at line 1340 of file VariableSmmRuntimeDxe.c.

◆ VariableLockRequestToLock()

EFI_STATUS EFIAPI VariableLockRequestToLock ( IN CONST EDKII_VARIABLE_LOCK_PROTOCOL This,
IN CHAR16 *  VariableName,
IN EFI_GUID VendorGuid 
)

=== CODE UNDER TEST ===========================================================================

Mark a variable that will become read-only after leaving the DXE phase of execution.

Parameters
[in]ThisThe VARIABLE_LOCK_PROTOCOL instance.
[in]VariableNameA pointer to the variable name that will be made read-only subsequently.
[in]VendorGuidA pointer to the vendor GUID that will be made read-only subsequently.
Return values
EFI_SUCCESSThe variable specified by the VariableName and the VendorGuid was marked as pending to be read-only.
EFI_INVALID_PARAMETERVariableName or VendorGuid is NULL. Or VariableName is an empty string.
EFI_ACCESS_DENIEDEFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has already been signaled.
EFI_OUT_OF_RESOURCESThere is not enough resource to hold the lock request.

Definition at line 236 of file VariableSmmRuntimeDxe.c.

◆ VariablePolicySmmDxeMain()

EFI_STATUS EFIAPI VariablePolicySmmDxeMain ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

The logic to initialize the VariablePolicy engine is in its own file.

The driver's entry point.

Parameters
[in]ImageHandleThe firmware allocated handle for the EFI image.
[in]SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSThe entry point executed successfully.
otherSome error occured when executing this entry point.

Definition at line 816 of file VariablePolicySmmDxe.c.

◆ VariableSmmRuntimeInitialize()

EFI_STATUS EFIAPI VariableSmmRuntimeInitialize ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Variable Driver main entry point. The Variable driver places the 4 EFI runtime services in the EFI System Table and installs arch protocols for variable read and write services being available. It also registers a notification function for an EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.

Parameters
[in]ImageHandleThe firmware allocated handle for the EFI image.
[in]SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSVariable service successfully initialized.

Definition at line 1814 of file VariableSmmRuntimeDxe.c.

Variable Documentation

◆ mHandle

EFI_HANDLE mHandle = NULL

Handle for the Capsule Update Policy Protocol

Definition at line 47 of file VariableSmmRuntimeDxe.c.

◆ mIsRuntimeCacheEnabled

BOOLEAN mIsRuntimeCacheEnabled = FALSE

Definition at line 61 of file VariableSmmRuntimeDxe.c.

◆ mMmCommunication2

EFI_MM_COMMUNICATION2_PROTOCOL* mMmCommunication2 = NULL

Definition at line 50 of file VariableSmmRuntimeDxe.c.

◆ mSmmVariable

Definition at line 48 of file VariableSmmRuntimeDxe.c.

◆ mVarCheck

Definition at line 59 of file VariableSmmRuntimeDxe.c.

◆ mVariableAuthFormat

BOOLEAN mVariableAuthFormat

Definition at line 56 of file VariableSmmRuntimeDxe.c.

◆ mVariableBuffer

UINT8* mVariableBuffer = NULL

Definition at line 51 of file VariableSmmRuntimeDxe.c.

◆ mVariableBufferPayloadSize

UINTN mVariableBufferPayloadSize

Definition at line 55 of file VariableSmmRuntimeDxe.c.

◆ mVariableBufferPhysical

UINT8* mVariableBufferPhysical = NULL

Definition at line 52 of file VariableSmmRuntimeDxe.c.

◆ mVariableBufferSize

UINTN mVariableBufferSize

Definition at line 54 of file VariableSmmRuntimeDxe.c.

◆ mVariableInfo

VARIABLE_INFO_ENTRY* mVariableInfo = NULL

Definition at line 53 of file VariableSmmRuntimeDxe.c.

◆ mVariableLock

Definition at line 58 of file VariableSmmRuntimeDxe.c.

◆ mVariableRtCacheInfo

VARIABLE_RUNTIME_CACHE_INFO mVariableRtCacheInfo

Definition at line 60 of file VariableSmmRuntimeDxe.c.

◆ mVariableServicesLock

EFI_LOCK mVariableServicesLock

Definition at line 57 of file VariableSmmRuntimeDxe.c.

◆ mVirtualAddressChangeEvent

EFI_EVENT mVirtualAddressChangeEvent = NULL

Definition at line 49 of file VariableSmmRuntimeDxe.c.