public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] RFC: SetVariable callbacks
@ 2023-09-20 20:27 Girish Mahadevan via groups.io
  2023-09-21  7:41 ` Nhi Pham via groups.io
  0 siblings, 1 reply; 4+ messages in thread
From: Girish Mahadevan via groups.io @ 2023-09-20 20:27 UTC (permalink / raw)
  To: Hao A Wu, Liming Gao, devel@edk2.groups.io; +Cc: Jeff Brasen, Ashish Singhal

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 (#108929): https://edk2.groups.io/g/devel/message/108929
Mute This Topic: https://groups.io/mt/101487036/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-10-20  3:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-20 20:27 [edk2-devel] RFC: SetVariable callbacks Girish Mahadevan via groups.io
2023-09-21  7:41 ` Nhi Pham via groups.io
2023-09-21 15:58   ` Girish Mahadevan via groups.io
2023-10-20  3:56     ` Nhi Pham via groups.io

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox