From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.9228.1573449387101474095 for ; Sun, 10 Nov 2019 21:16:27 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: michael.a.kubacki@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Nov 2019 21:16:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,291,1569308400"; d="scan'208";a="197558624" Received: from makuback-desk1.amr.corp.intel.com ([10.7.159.162]) by orsmga008.jf.intel.com with ESMTP; 10 Nov 2019 21:16:25 -0800 From: "Kubacki, Michael A" To: devel@edk2.groups.io Cc: Liming Gao , Michael D Kinney , Jian J Wang , Hao A Wu Subject: [PATCH V1 1/1] MdeModulePkg/Variable: Fix volatile variable RT cache update logic Date: Sun, 10 Nov 2019 21:16:20 -0800 Message-Id: <20191111051620.37748-1-michael.a.kubacki@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 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). 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(-) 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 ( Done: if (!EFI_ERROR (Status)) { - if (Variable->Volatile) { - VolatileCacheInstance = &(mVariableModuleGlobal->VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeVolatileCache); - } else { + VolatileCacheInstance = &(mVariableModuleGlobal->VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeVolatileCache); + if ((Variable->CurrPtr != NULL && !Variable->Volatile) || (Attributes & EFI_VARIABLE_NON_VOLATILE) != 0) { VolatileCacheInstance = &(mVariableModuleGlobal->VariableGlobal.VariableRuntimeCacheContext.VariableRuntimeNvCache); } -- 2.16.2.windows.1