From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.126; helo=mga18.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 973822117D75A for ; Tue, 15 Jan 2019 00:05:24 -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 orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jan 2019 00:05:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,481,1539673200"; d="scan'208";a="135900996" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga004.fm.intel.com with ESMTP; 15 Jan 2019 00:05:24 -0800 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 15 Jan 2019 00:05:24 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 15 Jan 2019 00:05:23 -0800 Received: from shsmsx107.ccr.corp.intel.com ([169.254.9.239]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.196]) with mapi id 14.03.0415.000; Tue, 15 Jan 2019 16:05:21 +0800 From: "Wang, Jian J" To: "Zeng, Star" , "edk2-devel@lists.01.org" CC: "Wu, Hao A" Thread-Topic: [PATCH V2 04/15] MdeModulePkg Variable: Abstract VariableWriteServiceInitializeDxe/Smm Thread-Index: AQHUrByqj1oCwCX5/Eu9PrSdu+Ut6KWv+d0w Date: Tue, 15 Jan 2019 08:05:21 +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: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiM2E2N2QzMmItZTkzNC00YTkwLTg4Y2EtNGQ3NTUxYTNiNWRkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiOGZ6OHcxWTIxamlSMjBPNXdQUGtPNFRNMzQxbVZHd1wvcmxSWEpCeTA3MjE2WnFtXC9sYU8rbFhUZ09SVHZ2aWNDIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action 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 08:05:25 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jian J Wang > -----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