From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.92.18.104]) by mx.groups.io with SMTP id smtpd.web12.2071.1585087480745692639 for ; Tue, 24 Mar 2020 15:04:41 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@outlook.com header.s=selector1 header.b=hUUB6TWp; spf=pass (domain: outlook.com, ip: 40.92.18.104, mailfrom: michael.kubacki@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mbN+BKfCnAJ6+KuJFV6ku0ytoIuKOhp7yyNqEITmKwnREKyN+TFvri34xJ4jNA9BmUnQchU00nhq/B6hu54M4nrwteAb9lHJVUueK9l6Y9BRNawhqFLo7wltwC719/BYyG2RcCqQffU0qKCky2ZZSfMk8nEgZ98/p8mO+F/mbsBjIs0tJ9M+itNDo5vI/7XtazFbS2CfG1eW73oNQl+dPTDCtvNFRA9p+wjvEBKxc2oa/Etzcy5+gKokgoJo4Zg9VIjSDHmeLBBn1u/P6BLq/TJiYM55YtURP4mumVxQ4prxeM2Z4fosjjemlOTmEfCRiwxZNwpAGXljnqgHm1emEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ej9P8cT2bOCXS6oeihRQAT26AJYvmGJ/PfQWiS7+fjg=; b=enY/4KPcU5ePFZnCj7ukIgHYe2p//W+5GGwSwu+1Yu8Sz9r1G3xAmHlpGPcVQ4oR/HH8FI44CBnU6NEh2jusc9VU9nC99vdSmSpJ410lY8rv4gqbsFEFKLkSNGvxlnZuOFjnMMlSUdHXOgBvHLFWovVmN1V3+jf5arOa0s6JPx8cbr0ZW4OGIG8FrL92TdcHn5d5iCigsC5w9l/a9qx5Qld2BVhAaneJ8CUjezrCeuoBhjY3izACKf1gXLvawYci//jy8EXy08Oa1LVsb5K4FxZwNXrpfMwtDHnUA6FL2KwqXlDNkS2lZPF+e/EjyQAWLlXDs1iZ5wKkIgAQu0+kug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=outlook.com; dmarc=pass action=none header.from=outlook.com; dkim=pass header.d=outlook.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ej9P8cT2bOCXS6oeihRQAT26AJYvmGJ/PfQWiS7+fjg=; b=hUUB6TWpE34wFXIwqejTYVeXMpvFP0Ye61tEpkwXVdvYVcwRBoAyFxYiJ30v3x95aAl9wws9EVK8bpqEfubg0svTOgBxIbR7BTUJRCSe84UO2rItAz+60/+mdIy/C14ZdNwETOaRa+JZqEi5cE1lXryrOdjQ1zTTV3aJrE3bJ+LLzSGnhajUZWoMIlAeEo7QbAa5OA72QKl03NcKMCKrQpAJYBNDZyBEUAXag98S6S930qqPByu9ogwDWeZj580C8kkEN3jtse+KsrcCMOJJ7KDJUApmEcnlPbp1hYcunvhc05SHmvLFZLS9gNaqf10C1N9QQ0i8hGPXbt+nuHeeuw== Received: from BN8NAM11FT054.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4b::3b) by BN8NAM11HT114.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4b::273) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13; Tue, 24 Mar 2020 22:04:39 +0000 Received: from MWHPR07MB3440.namprd07.prod.outlook.com (2a01:111:e400:fc4b::38) by BN8NAM11FT054.mail.protection.outlook.com (2a01:111:e400:fc4b::358) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13 via Frontend Transport; Tue, 24 Mar 2020 22:04:39 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:AF26FB0F7B1F5998F18F9EE02B0F688BA0438BC81C77DBF4F474111F46D0C664;UpperCasedChecksum:A275519EF142AF939394C65099EEF1E05CAEB5449565C534B98C7E0FC9A25AC3;SizeAsReceived:7780;Count:47 Received: from MWHPR07MB3440.namprd07.prod.outlook.com ([fe80::f5a7:e51b:e22a:959f]) by MWHPR07MB3440.namprd07.prod.outlook.com ([fe80::f5a7:e51b:e22a:959f%7]) with mapi id 15.20.2835.023; Tue, 24 Mar 2020 22:04:38 +0000 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Bret Barkelew , Liming Gao , Michael D Kinney , Jian J Wang , Hao A Wu Subject: [PATCH v1 1/1] MdeModulePkg/Variable: Return GetVariable() attr if EFI_BUFFER_TOO_SMALL Date: Tue, 24 Mar 2020 15:04:04 -0700 Message-ID: X-Mailer: git-send-email 2.16.3.windows.1 X-ClientProxiedBy: CO1PR15CA0049.namprd15.prod.outlook.com (2603:10b6:101:1f::17) To MWHPR07MB3440.namprd07.prod.outlook.com (2603:10b6:301:69::28) Return-Path: michael.kubacki@outlook.com X-Microsoft-Original-Message-ID: <20200324220404.17300-1-michael.kubacki@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2001:4898:80e8:2:1469:1107:fe2d:619b) by CO1PR15CA0049.namprd15.prod.outlook.com (2603:10b6:101:1f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.19 via Frontend Transport; Tue, 24 Mar 2020 22:04:38 +0000 X-Mailer: git-send-email 2.16.3.windows.1 X-Microsoft-Original-Message-ID: <20200324220404.17300-1-michael.kubacki@outlook.com> X-TMN: [lmXy9yuL6xMFwiDqf5ls+fD1ckyPENhIH5C9tU1rCoMkI/9qE+dCNIBx8I2mgllw] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 85a1a2d2-27de-4bc7-39a7-08d7d03f58c3 X-MS-TrafficTypeDiagnostic: BN8NAM11HT114: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5MgXIqrtFxg6aaKmR1TyYfY8sz92AVDZ+untd7WEUVLasJboFTr4OlVpn7PTCxLmeaMvgCrrHGOO87LHLZ2GZWRE5bjs/xfjyDTIuruZEm2kPqHqBPl7afJKHiUKr5tXAsAbFObsoJVKdF6YMkA5hx4t8QpcKZ9veNkKaS6ue43N2JEg2U6INZvLImxzxMyzkXrYtuw+ebf48mQlv0tEuSgSBzHvhb31OyQUU5N4GKg= X-MS-Exchange-AntiSpam-MessageData: No9GaX8ROSRMeSEn6Wy3ptV84ZiQSZ7trbuVA9zCAt4BFTH3J8W5IWCbWVwcVqNWWUBBq8roSuAMWWO6EHHgIXaXO/9oloLIDO12KG88hFUQUWqKISt+ZiX4iPJ/odoBI3B1v2zsETP/Gbon9RgDSNCJXGPL4Fxy0pyQJrWdtwMGbVdB6uvWMR0vUOXlkW3VqAOUZbsWXmqDYiiQh4FHCw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85a1a2d2-27de-4bc7-39a7-08d7d03f58c3 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Mar 2020 22:04:38.8869 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8NAM11HT114 Content-Type: text/plain From: Michael Kubacki 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 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 | 10 +++++++--- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c | 10 ++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c index d23aea4bc712..1e71fc642c76 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c @@ -18,6 +18,8 @@ Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
(C) Copyright 2015-2018 Hewlett Packard Enterprise Development LP
+Copyright (c) Microsoft Corporation.
+ SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -2379,9 +2381,6 @@ VariableServiceGetVariable ( } CopyMem (Data, GetVariableDataPtr (Variable.CurrPtr, mVariableModuleGlobal->VariableGlobal.AuthFormat), VarDataSize); - if (Attributes != NULL) { - *Attributes = Variable.CurrPtr->Attributes; - } *DataSize = VarDataSize; UpdateVariableInfo (VariableName, VendorGuid, Variable.Volatile, TRUE, FALSE, FALSE, FALSE, &gVariableInfo); @@ -2395,6 +2394,11 @@ VariableServiceGetVariable ( } Done: + if (Status == EFI_SUCCESS || Status == EFI_BUFFER_TOO_SMALL) { + if (Attributes != NULL && Variable.CurrPtr != NULL) { + *Attributes = Variable.CurrPtr->Attributes; + } + } ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock); return Status; } diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c index 2cf0ed32ae55..ca833fb0244d 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c @@ -14,6 +14,7 @@ InitCommunicateBuffer() is really function to check the variable data size. Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -642,10 +643,6 @@ FindVariableInRuntimeCache ( } CopyMem (Data, GetVariableDataPtr (RtPtrTrack.CurrPtr, mVariableAuthFormat), TempDataSize); - if (Attributes != NULL) { - *Attributes = RtPtrTrack.CurrPtr->Attributes; - } - *DataSize = TempDataSize; UpdateVariableInfo (VariableName, VendorGuid, RtPtrTrack.Volatile, TRUE, FALSE, FALSE, TRUE, &mVariableInfo); @@ -661,6 +658,11 @@ FindVariableInRuntimeCache ( } Done: + if (Status == EFI_SUCCESS || Status == EFI_BUFFER_TOO_SMALL) { + if (Attributes != NULL && RtPtrTrack.CurrPtr != NULL) { + *Attributes = RtPtrTrack.CurrPtr->Attributes; + } + } mVariableRuntimeCacheReadLock = FALSE; return Status; -- 2.16.3.windows.1