]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg Variable: Return GetVariable() attr if EFI_BUFFER_TOO_SMALL
authorMichael Kubacki <michael.kubacki@microsoft.com>
Fri, 27 Mar 2020 21:55:34 +0000 (05:55 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 7 Apr 2020 13:51:24 +0000 (13:51 +0000)
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2062

The UEFI specification v2.8 Errata A Section 8.2 "GetVariable()"
"Attributes" parameter description states:

"If not NULL, a pointer to the memory location to return the
 attributes bitmask for the variable. See 'Related Definitions.'
 If not NULL, then Attributes is set on output both when
 EFI_SUCCESS and when EFI_BUFFER_TOO_SMALL is returned."

The attributes were previously only returned from the implementation
in Variable.c on EFI_SUCCESS. They are now returned on EFI_SUCCESS or
EFI_BUFFER_TOO_SMALL according to spec.

Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
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.kubacki@microsoft.com>
Reviewed-by: Guomin Jiang <guomin.jiang@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c

index d23aea4bc712d4afb7f90f8a52d17394353ae82c..1e71fc642c763571a493ca0cd28e73f6ed5c6186 100644 (file)
@@ -18,6 +18,8 @@
 \r
 Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP<BR>\r
+Copyright (c) Microsoft Corporation.<BR>\r
+\r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -2379,9 +2381,6 @@ VariableServiceGetVariable (
     }\r
 \r
     CopyMem (Data, GetVariableDataPtr (Variable.CurrPtr, mVariableModuleGlobal->VariableGlobal.AuthFormat), VarDataSize);\r
-    if (Attributes != NULL) {\r
-      *Attributes = Variable.CurrPtr->Attributes;\r
-    }\r
 \r
     *DataSize = VarDataSize;\r
     UpdateVariableInfo (VariableName, VendorGuid, Variable.Volatile, TRUE, FALSE, FALSE, FALSE, &gVariableInfo);\r
@@ -2395,6 +2394,11 @@ VariableServiceGetVariable (
   }\r
 \r
 Done:\r
+  if (Status == EFI_SUCCESS || Status == EFI_BUFFER_TOO_SMALL) {\r
+    if (Attributes != NULL && Variable.CurrPtr != NULL) {\r
+      *Attributes = Variable.CurrPtr->Attributes;\r
+    }\r
+  }\r
   ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);\r
   return Status;\r
 }\r
index 2cf0ed32ae55bea2094e7bb578a60810c242dbc1..ca833fb0244d1b62f10caaf939f932af5766b678 100644 (file)
@@ -14,6 +14,7 @@
   InitCommunicateBuffer() is really function to check the variable data size.\r
 \r
 Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) Microsoft Corporation.<BR>\r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -642,10 +643,6 @@ FindVariableInRuntimeCache (
         }\r
 \r
         CopyMem (Data, GetVariableDataPtr (RtPtrTrack.CurrPtr, mVariableAuthFormat), TempDataSize);\r
-        if (Attributes != NULL) {\r
-          *Attributes = RtPtrTrack.CurrPtr->Attributes;\r
-        }\r
-\r
         *DataSize = TempDataSize;\r
 \r
         UpdateVariableInfo (VariableName, VendorGuid, RtPtrTrack.Volatile, TRUE, FALSE, FALSE, TRUE, &mVariableInfo);\r
@@ -661,6 +658,11 @@ FindVariableInRuntimeCache (
   }\r
 \r
 Done:\r
+  if (Status == EFI_SUCCESS || Status == EFI_BUFFER_TOO_SMALL) {\r
+    if (Attributes != NULL && RtPtrTrack.CurrPtr != NULL) {\r
+      *Attributes = RtPtrTrack.CurrPtr->Attributes;\r
+    }\r
+  }\r
   mVariableRuntimeCacheReadLock = FALSE;\r
 \r
   return Status;\r