[edk2-devel] RFC: SetVariable callbacks

Girish Mahadevan via groups.io gmahadevan=nvidia.com at groups.io
Thu Sep 21 15:58:17 UTC 2023


Hello Nhi,

On 9/21/2023 1:41 AM, Nhi Pham via groups.io wrote:
> External email: Use caution opening links or attachments
> 
> 
> Can we write a DXE_RUNTIME driver to override the pointers of UEFI
> Runtime Get/SetVariable() services? Then, we can add platform specific
> or custom implementation before/after calling the original
> Get/SetVariable()?
> 

Thanks for the suggestion. This doesn't work for us, we need the 
notifications in StMM, also we'd prefer to get these callbacks from
VariableServiceSetVariable() itself after the basic checks for the set 
var are done (similar to how VarCheckLib is called)

Best Regards
Girish

> Regards,
> Nhi
> 
> On 9/21/2023 3:27 AM, Girish Mahadevan via groups.io wrote:
>> Hello
>>
>> We have a requirement to monitor setVariable calls, we'd like to get a
>> callback before and after the variable update.
>>
>> Similar to VarCheckLib, except that VarCheckLib's set callbacks are
>> called after endOfDxe.
>>
>> We were thinking of doing something like:
>>
>> ===============
>>
>> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
>> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
>> @@ -2853,6 +2853,11 @@ VariableServiceSetVariable (
>>       return Status;
>>     }
>>
>> +  Status = VarPreSetVariableCallback (VariableName, VendorGuid,
>> Attributes, PayloadSize, (VOID *)((UINTN)Data + DataSize - PayloadSize),
>> mRequestSource);^M
>> +  if (EFI_ERROR (Status)) {^M
>> +    return Status;^M
>> +  }^M
>> +^M
>>     AcquireLockOnlyAtBootTime
>> (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
>>
>>     //
>> @@ -2917,6 +2922,8 @@ Done:
>>     InterlockedDecrement
>> (&mVariableModuleGlobal->VariableGlobal.ReentrantState);
>>     ReleaseLockOnlyAtBootTime
>> (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
>>
>> +  Status = VarPostSetVariableCallback (VariableName, VendorGuid,
>> Attributes, PayloadSize, (VOID *)((UINTN)Data + DataSize - PayloadSize),
>> mRequestSource);^M
>> +^M
>>
>> ==========================
>>
>>
>> We were thinking of 4 options:
>> 1. A new Library, platforms can include the Null implementation if they
>> don't need this.
>> 2. A new protocol that is called from the Variable driver (similar to
>> the Fvb protocol, we let the Smm/Dxe Variable drivers get this protocol)
>> 3. Expand the existing VarCheckLib to include these new callbacks.
>> (which can be called before end of dxe)
>> 4. Something we don't know about (please let us know)
>>
>> We are leaning toward option 1. Let us know your thoughts.
>>
>> Best Regards
>> Girish
>>
>>
>>
>>
>>
> 
> 
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108947): https://edk2.groups.io/g/devel/message/108947
Mute This Topic: https://groups.io/mt/101487036/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list