From 91a33d41139b4ab8c446567cbe09e10501224277 Mon Sep 17 00:00:00 2001 From: Michael Kubacki Date: Sat, 28 Mar 2020 05:55:35 +0800 Subject: MdeModulePkg VariablePei: Return GetVariable() attr if EFI_BUFFER_TOO_SMALL REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2062 This commit makes the behavior for PeiGetVariable() match the following specification-defined behavior. It is now consistent with the DXE/SMM variable driver implementation. 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 Cc: Liming Gao Cc: Michael D Kinney Cc: Jian J Wang Cc: Hao A Wu Signed-off-by: Michael Kubacki Reviewed-by: Jian J Wang Reviewed-by: Guomin Jiang --- MdeModulePkg/Universal/Variable/Pei/Variable.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/MdeModulePkg/Universal/Variable/Pei/Variable.c b/MdeModulePkg/Universal/Variable/Pei/Variable.c index f61465f..f420b58 100644 --- a/MdeModulePkg/Universal/Variable/Pei/Variable.c +++ b/MdeModulePkg/Universal/Variable/Pei/Variable.c @@ -3,6 +3,7 @@ PEI ReadOnly Varaiable2 PPI. These services operates the non volatile storage space. Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -1047,17 +1048,17 @@ PeiGetVariable ( } GetVariableNameOrData (&StoreInfo, GetVariableDataPtr (Variable.CurrPtr, VariableHeader, StoreInfo.AuthFlag), VarDataSize, Data); - - if (Attributes != NULL) { - *Attributes = VariableHeader->Attributes; - } - - *DataSize = VarDataSize; - return EFI_SUCCESS; + Status = EFI_SUCCESS; } else { - *DataSize = VarDataSize; - return EFI_BUFFER_TOO_SMALL; + Status = EFI_BUFFER_TOO_SMALL; } + + if (Attributes != NULL) { + *Attributes = VariableHeader->Attributes; + } + *DataSize = VarDataSize; + + return Status; } /** -- cgit v1.1