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.web09.32.1573603709510409767 for ; Tue, 12 Nov 2019 16:08:29 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: liming.gao@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Nov 2019 16:08:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,298,1569308400"; d="scan'208";a="202583340" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga008.fm.intel.com with ESMTP; 12 Nov 2019 16:08:27 -0800 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 12 Nov 2019 16:08:27 -0800 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 12 Nov 2019 16:08:27 -0800 Received: from shsmsx154.ccr.corp.intel.com (10.239.6.54) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 12 Nov 2019 16:08:27 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.127]) by SHSMSX154.ccr.corp.intel.com ([169.254.7.200]) with mapi id 14.03.0439.000; Wed, 13 Nov 2019 08:08:24 +0800 From: "Liming Gao" To: "Kubacki, Michael A" , "devel@edk2.groups.io" CC: "Kinney, Michael D" , "Wang, Jian J" , "Wu, Hao A" Subject: Re: [PATCH V2 1/1] MdeModulePkg/Variable: Fix volatile variable RT cache update logic Thread-Topic: [PATCH V2 1/1] MdeModulePkg/Variable: Fix volatile variable RT cache update logic Thread-Index: AQHVmbKdL+ytUUcCa0O5VxukMMSaeqeIOYag Date: Wed, 13 Nov 2019 00:08:24 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E53E9D3@SHSMSX104.ccr.corp.intel.com> References: <20191112234038.23092-1-michael.a.kubacki@intel.com> In-Reply-To: <20191112234038.23092-1-michael.a.kubacki@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 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao >-----Original Message----- >From: Kubacki, Michael A >Sent: Wednesday, November 13, 2019 7:41 AM >To: devel@edk2.groups.io >Cc: Gao, Liming ; Kinney, Michael D >; Wang, Jian J ; Wu, >Hao A >Subject: [PATCH V2 1/1] MdeModulePkg/Variable: Fix volatile variable RT >cache update logic > >REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2333 > >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. > >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. > >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). > >* Observable symptom: A volatile variable that was set successfully > might return EFI_NOT_FOUND when the variable should be found. > >* The issue is a regression introduced to the variable services only > when the variable runtime cache is enabled by the following PCD > being set to TRUE: > gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache > >* The issue was implemented in commit aab3b9b9a1 but the PCD was not > set to TRUE by default enabling the issue until commit e07b7d024a. > >Fixes: aab3b9b9a1e5e1f3fa966fb1667fc3e6c47e7706 > >Cc: Liming Gao >Cc: Michael D Kinney >Cc: Jian J Wang >Cc: Hao A Wu >Signed-off-by: Michael Kubacki >--- > >Notes: > V2 changes: > * Sets the runtime cache instance pointer that was updated in V1 > using an if/else statement instead of just an if statement so > it better aligns to the original code style. > * Updates the commit message to include the simple symptom most > commonly observed that this change fixes, an explicit description > that this change is a regression to the variable services, that > it only is present when the runtime variable cache is enabled, and > relevant commit details. > > MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > >diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c >b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c >index 29d6aca993..b0ee5e50d0 100644 >--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c >+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c >@@ -2296,10 +2296,10 @@ UpdateVariable ( > > Done: > if (!EFI_ERROR (Status)) { >- if (Variable->Volatile) { >- VolatileCacheInstance =3D &(mVariableModuleGlobal- >>VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeVolatileCach >e); >- } else { >+ if ((Variable->CurrPtr !=3D NULL && !Variable->Volatile) || (Attribut= es & >EFI_VARIABLE_NON_VOLATILE) !=3D 0) { > VolatileCacheInstance =3D &(mVariableModuleGlobal- >>VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeNvCache); >+ } else { >+ VolatileCacheInstance =3D &(mVariableModuleGlobal- >>VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeVolatileCach >e); > } > > if (VolatileCacheInstance->Store !=3D NULL) { >-- >2.16.2.windows.1