public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Liming Gao" <liming.gao@intel.com>
To: "Kubacki, Michael A" <michael.a.kubacki@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Kinney, Michael D" <michael.d.kinney@intel.com>,
	"Wang, Jian J" <jian.j.wang@intel.com>,
	"Wu, Hao A" <hao.a.wu@intel.com>
Subject: Re: [PATCH V2 1/1] MdeModulePkg/Variable: Fix volatile variable RT cache update logic
Date: Wed, 13 Nov 2019 00:08:24 +0000	[thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E53E9D3@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <20191112234038.23092-1-michael.a.kubacki@intel.com>

Reviewed-by: Liming Gao <liming.gao@intel.com>

>-----Original Message-----
>From: Kubacki, Michael A
>Sent: Wednesday, November 13, 2019 7:41 AM
>To: devel@edk2.groups.io
>Cc: Gao, Liming <liming.gao@intel.com>; Kinney, Michael D
><michael.d.kinney@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu,
>Hao A <hao.a.wu@intel.com>
>Subject: [PATCH V2 1/1] MdeModulePkg/Variable: Fix volatile variable RT
>cache update logic
>
>REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2333
>
>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 <liming.gao@intel.com>
>Cc: Michael D Kinney <michael.d.kinney@intel.com>
>Cc: Jian J Wang <jian.j.wang@intel.com>
>Cc: Hao A Wu <hao.a.wu@intel.com>
>Signed-off-by: Michael Kubacki <michael.a.kubacki@intel.com>
>---
>
>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 = &(mVariableModuleGlobal-
>>VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeVolatileCach
>e);
>-    } else {
>+    if ((Variable->CurrPtr != NULL && !Variable->Volatile) || (Attributes &
>EFI_VARIABLE_NON_VOLATILE) != 0) {
>       VolatileCacheInstance = &(mVariableModuleGlobal-
>>VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeNvCache);
>+    } else {
>+      VolatileCacheInstance = &(mVariableModuleGlobal-
>>VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeVolatileCach
>e);
>     }
>
>     if (VolatileCacheInstance->Store != NULL) {
>--
>2.16.2.windows.1


  reply	other threads:[~2019-11-13  0:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-12 23:40 [PATCH V2 1/1] MdeModulePkg/Variable: Fix volatile variable RT cache update logic Kubacki, Michael A
2019-11-13  0:08 ` Liming Gao [this message]
2019-11-13  8:41 ` [edk2-devel] " Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A89E2EF3DFEDB4C8BFDE51014F606A14E53E9D3@SHSMSX104.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox