[edk2-devel] [PATCH 5/5] UefiCpuPkg: Uninstall EFI_SMM_CONFIGURATION_PROTOCOL at end of Dxe.

Laszlo Ersek lersek at redhat.com
Wed Jun 17 12:53:18 UTC 2020


On 06/17/20 07:30, Liu, Zhiguang wrote:
> Hi Laszlo,
> Thanks for the comments, I will take the first one.
> But I can't find service to unregister protocol notify in EFI_SMM_SYSTEM_TABLE2.
> Do you now how the unregister it in SMM driver?

It's a bit hidden, but it is explained by the PI spec, under
MmRegisterProtocolNotify():

    If Function == NULL and Registration is an existing registration,
    then the callback is unhooked. *Protocol must be validated it with
    *Registration. If Registration is not found then EFI_NOT_FOUND is
    returned.

So where you do

  gSmst->SmmRegisterProtocolNotify (
           &gEfiSmmEndOfDxeProtocolGuid,
           SmmEndOfDxeNotify,
           &Registration
           );

in PiCpuSmmEntry(), you'd have to save the registration value into a
global variable (which would live in SMRAM):

VOID *mEndOfDxeRegistration;

  gSmst->SmmRegisterProtocolNotify (
           &gEfiSmmEndOfDxeProtocolGuid,
           SmmEndOfDxeNotify,
           &mEndOfDxeRegistration // <----- here
           );

Then in SmmEndOfDxeNotify(), you could call

  Status = gSmst->SmmRegisterProtocolNotify (
                    &gEfiSmmEndOfDxeProtocolGuid,
                    NULL,
                    &mEndOfDxeRegistration
                    );
  ASSERT_EFI_ERROR (Status);

You can see examples in:
- MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
- MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.c
- MdePkg/Library/SmmIoLib/SmmIoLib.c
- MdePkg/Library/SmmMemLib/SmmMemLib.c

Thanks
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#61412): https://edk2.groups.io/g/devel/message/61412
Mute This Topic: https://groups.io/mt/74912556/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