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.151; helo=mga17.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (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 EDE50211B736F for ; Mon, 14 Jan 2019 22:37:52 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jan 2019 22:37:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,480,1539673200"; d="scan'208";a="135881880" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga004.fm.intel.com with ESMTP; 14 Jan 2019 22:37:52 -0800 Received: from fmsmsx116.amr.corp.intel.com (10.18.116.20) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 14 Jan 2019 22:37:52 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx116.amr.corp.intel.com (10.18.116.20) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 14 Jan 2019 22:37:51 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.196]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.159]) with mapi id 14.03.0415.000; Tue, 15 Jan 2019 14:37:48 +0800 From: "Wu, Hao A" To: "Zeng, Star" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH V2 04/15] MdeModulePkg Variable: Abstract VariableWriteServiceInitializeDxe/Smm Thread-Index: AQHUrByqxOW4UInvTkGPZAqGVhAd7KWv1imw Date: Tue, 15 Jan 2019 06:37:47 +0000 Message-ID: References: <1547479196-40248-1-git-send-email-star.zeng@intel.com> <1547479196-40248-5-git-send-email-star.zeng@intel.com> In-Reply-To: <1547479196-40248-5-git-send-email-star.zeng@intel.com> Accept-Language: zh-CN, 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 04/15] MdeModulePkg Variable: Abstract VariableWriteServiceInitializeDxe/Smm X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Jan 2019 06:37:53 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Hao Wu Best Regards, Hao Wu > -----Original Message----- > From: Zeng, Star > Sent: Monday, January 14, 2019 11:20 PM > To: edk2-devel@lists.01.org > Cc: Zeng, Star; Wang, Jian J; Wu, Hao A > Subject: [PATCH V2 04/15] MdeModulePkg Variable: Abstract > VariableWriteServiceInitializeDxe/Smm >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1323 > Merge EmuVariable and Real variable driver. >=20 > Abstract VariableWriteServiceInitializeDxe/Smm from > FtwNotificationEvent/SmmFtwNotificationEvent, then > VariableWriteServiceInitializeDxe/Smm could be not aware > the NV storage is real or emulated. >=20 > This patch prepares for adding emulated variable NV mode > support in VariableRuntimeDxe. >=20 > Cc: Jian J Wang > Cc: Hao Wu > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Star Zeng > --- > .../Universal/Variable/RuntimeDxe/VariableDxe.c | 55 ++++++++++++++-- > ------ > .../Universal/Variable/RuntimeDxe/VariableSmm.c | 43 ++++++++++++---- > - > 2 files changed, 66 insertions(+), 32 deletions(-) >=20 > diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c > index baba6729c1c2..5131e6f351e4 100644 > --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c > +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c > @@ -346,6 +346,40 @@ OnEndOfDxe ( > } >=20 > /** > + Initializes variable write service for DXE. > + > +**/ > +VOID > +VariableWriteServiceInitializeDxe ( > + VOID > + ) > +{ > + EFI_STATUS Status; > + > + Status =3D VariableWriteServiceInitialize (); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "Variable write service initialization failed. > Status =3D %r\n", Status)); > + } > + > + // > + // Some Secure Boot Policy Var (SecureBoot, etc) updates following oth= er > + // Secure Boot Policy Variable change. Record their initial value. > + // > + RecordSecureBootPolicyVarData(); > + > + // > + // Install the Variable Write Architectural protocol. > + // > + Status =3D gBS->InstallProtocolInterface ( > + &mHandle, > + &gEfiVariableWriteArchProtocolGuid, > + EFI_NATIVE_INTERFACE, > + NULL > + ); > + ASSERT_EFI_ERROR (Status); > +} > + > +/** > Fault Tolerant Write protocol notification event handler. >=20 > Non-Volatile variable write may needs FTW protocol to reclaim when > @@ -428,27 +462,10 @@ FtwNotificationEvent ( > } > } >=20 > - Status =3D VariableWriteServiceInitialize (); > - if (EFI_ERROR (Status)) { > - DEBUG ((DEBUG_ERROR, "Variable write service initialization failed. = Status > =3D %r\n", Status)); > - } > - > // > - // Some Secure Boot Policy Var (SecureBoot, etc) updates following oth= er > - // Secure Boot Policy Variable change. Record their initial value. > + // Initializes variable write service after FTW was ready. > // > - RecordSecureBootPolicyVarData(); > - > - // > - // Install the Variable Write Architectural protocol. > - // > - Status =3D gBS->InstallProtocolInterface ( > - &mHandle, > - &gEfiVariableWriteArchProtocolGuid, > - EFI_NATIVE_INTERFACE, > - NULL > - ); > - ASSERT_EFI_ERROR (Status); > + VariableWriteServiceInitializeDxe (); >=20 > // > // Close the notify event to avoid install gEfiVariableWriteArchProtoc= olGuid > again. > diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c > index 018587ed7373..e63af812534e 100644 > --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c > +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c > @@ -846,6 +846,34 @@ SmmEndOfDxeCallback ( > } >=20 > /** > + Initializes variable write service for SMM. > + > +**/ > +VOID > +VariableWriteServiceInitializeSmm ( > + VOID > + ) > +{ > + EFI_STATUS Status; > + > + Status =3D VariableWriteServiceInitialize (); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "Variable write service initialization failed. > Status =3D %r\n", Status)); > + } > + > + // > + // Notify the variable wrapper driver the variable write service is re= ady > + // > + Status =3D gBS->InstallProtocolInterface ( > + &mSmmVariableHandle, > + &gSmmVariableWriteGuid, > + EFI_NATIVE_INTERFACE, > + NULL > + ); > + ASSERT_EFI_ERROR (Status); > +} > + > +/** > SMM Fault Tolerant Write protocol notification event handler. >=20 > Non-Volatile variable write may needs FTW protocol to reclaim when > @@ -909,21 +937,10 @@ SmmFtwNotificationEvent ( >=20 > mVariableModuleGlobal->FvbInstance =3D FvbProtocol; >=20 > - Status =3D VariableWriteServiceInitialize (); > - if (EFI_ERROR (Status)) { > - DEBUG ((DEBUG_ERROR, "Variable write service initialization failed. = Status > =3D %r\n", Status)); > - } > - > // > - // Notify the variable wrapper driver the variable write service is re= ady > + // Initializes variable write service after FTW was ready. > // > - Status =3D gBS->InstallProtocolInterface ( > - &mSmmVariableHandle, > - &gSmmVariableWriteGuid, > - EFI_NATIVE_INTERFACE, > - NULL > - ); > - ASSERT_EFI_ERROR (Status); > + VariableWriteServiceInitializeSmm (); >=20 > return EFI_SUCCESS; > } > -- > 2.7.0.windows.1