From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web11.7605.1573537328561957838 for ; Mon, 11 Nov 2019 21:42:08 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: jian.j.wang@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Nov 2019 21:42:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,295,1569308400"; d="scan'208";a="207003537" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga003.jf.intel.com with ESMTP; 11 Nov 2019 21:42:07 -0800 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 11 Nov 2019 21:42:06 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 11 Nov 2019 21:42:06 -0800 Received: from shsmsx107.ccr.corp.intel.com ([169.254.9.63]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.127]) with mapi id 14.03.0439.000; Tue, 12 Nov 2019 13:42:04 +0800 From: "Wang, Jian J" To: "devel@edk2.groups.io" , "Kubacki, Michael A" CC: "Gao, Liming" , "Kinney, Michael D" , "Wu, Hao A" Subject: Re: [edk2-devel] [PATCH V1 1/1] MdeModulePkg/Variable: Fix volatile variable RT cache update logic Thread-Topic: [edk2-devel] [PATCH V1 1/1] MdeModulePkg/Variable: Fix volatile variable RT cache update logic Thread-Index: AQHVmE8xgq/xcwlcOU6MFIR7jpeD+qeHAfYw Date: Tue, 12 Nov 2019 05:42:03 +0000 Message-ID: References: <20191111051620.37748-1-michael.a.kubacki@intel.com> In-Reply-To: <20191111051620.37748-1-michael.a.kubacki@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMDQ2ZmE0OWEtMmYyNi00YTBmLWI5ZDctZTM4MTI0YTM5YzQyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiMmt4YTRGc2NEZHE4Z2tkanp1MnhEd0VCRTNTVElINWFGOFwvNXFMb1NTdkVGK2FNTUFMZXN1R3pCSzZcL3VEUWxYIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: jian.j.wang@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I reproduced this issue in secure boot. The patch fixed the problem. One minor issue in the patch: you changed the code from if...else... to ..= .if..., which confused me a little bit. I thought you wanted to use=20 'VolatileCacheInstance' in the 'if' expression but you didn't. So I sugges= t to keep original style, i.e. put the first fetch of 'VolatileCacheInstance' i= n the 'else' statement (it'd be better to go to the if statement to keep the same order= as original code, if it won't cause too complex if expression). From the revi= ewer perspective, this way make it clearer to know you just want to update the condition to determine the non-volatile variable update. With this addressed (no v2 needed), Reviewed-by: Jian J Wang Regards, Jian > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Kubacki, > Michael A > Sent: Monday, November 11, 2019 1:16 PM > To: devel@edk2.groups.io > Cc: Gao, Liming ; Kinney, Michael D > ; Wang, Jian J ; Wu, = Hao > A > Subject: [edk2-devel] [PATCH V1 1/1] MdeModulePkg/Variable: Fix volatile > variable RT cache update logic >=20 > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2333 >=20 > During a SetVariable () invocation, UpdateVariable () is called. > UpdateVariable () contains logic to determine whether a volatile or > non-volatile UEFI variable was set so the corresponding runtime > cache can be updated to reflect the change. The current logic simply > evaluates Variable->Volatile to determine which runtime cache should > be updated. >=20 > The problem is Variable->Volatile does not always reflect whether a > volatile variable is being set. Variable->Volatile is set to TRUE > only in the case a pre-existing variable is found in the volatile > variable store. Therefore, the value is FALSE when a new volatile > variable is written. >=20 > This change updates the logic to take this into account. If a new > variable is written successfully, the Attributes will accurately > reflect whether the variable is non-volatile. If a pre-existing > variable is modified, the Volatile field will reflect the type of > variable (Attributes are not reliable; e.g. 0x0 indicates deletion). >=20 > Cc: Liming Gao > Cc: Michael D Kinney > Cc: Jian J Wang > Cc: Hao A Wu > Signed-off-by: Michael Kubacki > --- > MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) >=20 > diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c > b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c > index 29d6aca993..75d33ff724 100644 > --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c > +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c > @@ -2296,9 +2296,8 @@ UpdateVariable ( >=20 > Done: > if (!EFI_ERROR (Status)) { > - if (Variable->Volatile) { > - VolatileCacheInstance =3D &(mVariableModuleGlobal- > >VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeVolatileCache= ); > - } else { > + VolatileCacheInstance =3D &(mVariableModuleGlobal- > >VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeVolatileCache= ); > + if ((Variable->CurrPtr !=3D NULL && !Variable->Volatile) || (Attrib= utes & > EFI_VARIABLE_NON_VOLATILE) !=3D 0) { > VolatileCacheInstance =3D &(mVariableModuleGlobal- > >VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeNvCache); > } >=20 > -- > 2.16.2.windows.1 >=20 >=20 >=20