From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=eric.dong@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C24C521EA15C4 for ; Wed, 11 Oct 2017 01:21:20 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2017 01:24:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,360,1503385200"; d="scan'208";a="1204574845" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga001.fm.intel.com with ESMTP; 11 Oct 2017 01:24:49 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 11 Oct 2017 01:24:49 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.175]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.159]) with mapi id 14.03.0319.002; Wed, 11 Oct 2017 16:24:46 +0800 From: "Dong, Eric" To: "Yao, Jiewen" , "edk2-devel@lists.01.org" CC: "Ni, Ruiyu" Thread-Topic: [Patch v2 3/3] MdeModulePkg/PiSmmCore: Install Protocol when S3 resume finished. Thread-Index: AQHTQmBjYB3gC5//k0m91uSXOhJPPaLeT2xw Date: Wed, 11 Oct 2017 08:24:46 +0000 Message-ID: References: <1507699907-7448-1-git-send-email-eric.dong@intel.com> <1507699907-7448-4-git-send-email-eric.dong@intel.com> <74D8A39837DF1E4DA445A8C0B3885C503A9D9CB0@shsmsx102.ccr.corp.intel.com> In-Reply-To: <74D8A39837DF1E4DA445A8C0B3885C503A9D9CB0@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch v2 3/3] MdeModulePkg/PiSmmCore: Install Protocol when S3 resume finished. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Oct 2017 08:21:21 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Jiewen, Yes, it will always install new protocol and may cause run out of memory. I= have updated code to uninstall this protocol right after install it. pleas= e check the V3 patch which fix your two comments. Thanks, Eric -----Original Message----- From: Yao, Jiewen=20 Sent: Wednesday, October 11, 2017 3:13 PM To: Dong, Eric ; edk2-devel@lists.01.org Cc: Ni, Ruiyu Subject: RE: [Patch v2 3/3] MdeModulePkg/PiSmmCore: Install Protocol when S= 3 resume finished. I have a question for below: > + SmmHandle =3D NULL; > + Status =3D SmmInstallProtocolInterface ( > + &SmmHandle, > + &gEdkiiSmmEndOfS3ResumeProtocolGuid, > + EFI_NATIVE_INTERFACE, > + NULL > + ); A platform may do S3 multiple times. What happen if the SmmInstallProtocolI= nterface() called twice? Will the system has 2 handle and 2 protocol? Thank you Yao Jiewen > -----Original Message----- > From: Dong, Eric > Sent: Wednesday, October 11, 2017 1:32 PM > To: edk2-devel@lists.01.org > Cc: Ni, Ruiyu ; Yao, Jiewen > Subject: [Patch v2 3/3] MdeModulePkg/PiSmmCore: Install Protocol when=20 > S3 resume finished. >=20 > Install EdkiiSmmEndOfS3ResumeProtocol when S3 resume finished. > S3ResumePei will send S3 resume finished event to SmmCore through=20 > communication buffer. >=20 > Cc: Ruiyu Ni > Cc: Jiewen Yao > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Eric Dong > --- > MdeModulePkg/Core/PiSmmCore/PiSmmCore.c | 55 > +++++++++++++++++++++++++++---- > MdeModulePkg/Core/PiSmmCore/PiSmmCore.h | 24 ++++++++++++++ > MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf | 1 + > 3 files changed, 73 insertions(+), 7 deletions(-) >=20 > diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c > b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c > index 9e4390e..aa44933 100644 > --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c > +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c > @@ -75,13 +75,14 @@ BOOLEAN mInLegacyBoot =3D FALSE; // Table of SMI=20 > Handlers that are registered by the SMM Core when it is initialized =20 > // SMM_CORE_SMI_HANDLERS mSmmCoreSmiHandlers[] =3D { > - { SmmDriverDispatchHandler, &gEfiEventDxeDispatchGuid, > NULL, TRUE }, > - { SmmReadyToLockHandler, &gEfiDxeSmmReadyToLockProtocolGuid, > NULL, TRUE }, > - { SmmLegacyBootHandler, &gEfiEventLegacyBootGuid, > NULL, FALSE }, > - { SmmExitBootServicesHandler, &gEfiEventExitBootServicesGuid, NULL= , > FALSE }, > - { SmmReadyToBootHandler, &gEfiEventReadyToBootGuid, > NULL, FALSE }, > - { SmmEndOfDxeHandler, &gEfiEndOfDxeEventGroupGuid, > NULL, TRUE }, > - { NULL, NULL, > NULL, FALSE } > + { SmmDriverDispatchHandler, &gEfiEventDxeDispatchGuid, > NULL, TRUE }, > + { SmmReadyToLockHandler, &gEfiDxeSmmReadyToLockProtocolGuid, > NULL, TRUE }, > + { SmmLegacyBootHandler, &gEfiEventLegacyBootGuid, > NULL, FALSE }, > + { SmmExitBootServicesHandler, &gEfiEventExitBootServicesGuid, NUL= L, > FALSE }, > + { SmmReadyToBootHandler, &gEfiEventReadyToBootGuid, > NULL, FALSE }, > + { SmmEndOfDxeHandler, &gEfiEndOfDxeEventGroupGuid, > NULL, TRUE }, > + { SmmEndOfS3ResumeHandler, > &gEdkiiSmmEndOfS3ResumeProtocolGuid, NULL, FALSE }, > + { NULL, NULL, > NULL, FALSE } > }; >=20 > UINTN mFullSmramRangeCount; > @@ -383,6 +384,46 @@ SmmEndOfDxeHandler ( } >=20 > /** > + Software SMI handler that is called when the EndOfS3Resume event is > trigged. > + This function installs the SMM EndOfS3Resume Protocol so SMM=20 > + Drivers are > informed that > + S3 resume has finished. > + > + @param DispatchHandle The unique handle assigned to this handler=20 > + by > SmiHandlerRegister(). > + @param Context Points to an optional handler context which wa= s > specified when the handler was registered. > + @param CommBuffer A pointer to a collection of data in memory > that will > + be conveyed from a non-SMM environment into > an SMM environment. > + @param CommBufferSize The size of the CommBuffer. > + > + @return Status Code > + > +**/ > +EFI_STATUS > +EFIAPI > +SmmEndOfS3ResumeHandler ( > + IN EFI_HANDLE DispatchHandle, > + IN CONST VOID *Context, OPTIONAL > + IN OUT VOID *CommBuffer, OPTIONAL > + IN OUT UINTN *CommBufferSize OPTIONAL > + ) > +{ > + EFI_STATUS Status; > + EFI_HANDLE SmmHandle; > + > + DEBUG ((EFI_D_INFO, "SmmEndOfS3ResumeHandler\n")); > + // > + // Install SMM EndOfDxe protocol > + // > + SmmHandle =3D NULL; > + Status =3D SmmInstallProtocolInterface ( > + &SmmHandle, > + &gEdkiiSmmEndOfS3ResumeProtocolGuid, > + EFI_NATIVE_INTERFACE, > + NULL > + ); > + return Status; > +} > + > +/** > Determine if two buffers overlap in memory. >=20 > @param[in] Buff1 Pointer to first buffer diff --git=20 > a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h > b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h > index b6f815c..6cc824b 100644 > --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h > +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.h > @@ -32,6 +32,7 @@ > #include #include=20 > #include > +#include >=20 > #include > #include > @@ -802,6 +803,29 @@ SmmReadyToBootHandler ( > ); >=20 > /** > + Software SMI handler that is called when the EndOfS3Resume event is > trigged. > + This function installs the SMM EndOfS3Resume Protocol so SMM=20 > + Drivers are > informed that > + S3 resume has finished. > + > + @param DispatchHandle The unique handle assigned to this handler=20 > + by > SmiHandlerRegister(). > + @param Context Points to an optional handler context which wa= s > specified when the handler was registered. > + @param CommBuffer A pointer to a collection of data in memory > that will > + be conveyed from a non-SMM environment into > an SMM environment. > + @param CommBufferSize The size of the CommBuffer. > + > + @return Status Code > + > +**/ > +EFI_STATUS > +EFIAPI > +SmmEndOfS3ResumeHandler ( > + IN EFI_HANDLE DispatchHandle, > + IN CONST VOID *Context, OPTIONAL > + IN OUT VOID *CommBuffer, OPTIONAL > + IN OUT UINTN *CommBufferSize OPTIONAL > + ); > + > +/** > Place holder function until all the SMM System Table Service are avail= able. >=20 > @param Arg1 Undefined > diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf > b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf > index 95e34bd..a724189 100644 > --- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf > +++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf > @@ -79,6 +79,7 @@ > gEdkiiSmmExitBootServicesProtocolGuid ## > SOMETIMES_PRODUCES > gEdkiiSmmLegacyBootProtocolGuid ## > SOMETIMES_PRODUCES > gEdkiiSmmReadyToBootProtocolGuid ## PRODUCES > + gEdkiiSmmEndOfS3ResumeProtocolGuid ## > SOMETIMES_PRODUCES >=20 > gEfiSmmSwDispatch2ProtocolGuid ## > SOMETIMES_CONSUMES > gEfiSmmSxDispatch2ProtocolGuid ## > SOMETIMES_CONSUMES > -- > 2.7.0.windows.1