From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (NAM02-CY1-obe.outbound.protection.outlook.com [40.92.4.80]) by mx.groups.io with SMTP id smtpd.web12.4607.1585105195547183177 for ; Tue, 24 Mar 2020 19:59:55 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@outlook.com header.s=selector1 header.b=CbWOS7So; spf=pass (domain: outlook.com, ip: 40.92.4.80, mailfrom: michael.kubacki@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iQMdtg3/al2T/vsY1YzAk4uhJcm0wkdXZoPeCFxmLbsLVLa6GUfRbh2eBHVY0qqZ47Yf0ggJKtY0Eir1Xj8NpynN+z7wxs6J+qH6H63tPpty8NA6pPmp6X/o1fNFMrdkLVOle5JY72JWb6Y2gOOPhQkyeo5mprGAZLmmbQ6k76CKoKkLzhR0Mdn9msvoUuOBIM6GgMqQ9OXXsB9y9wbYb5M8bdlIwrGJiOW435ALJgqxo54zr+PuvzXmJEA9VFr763aLcDdQRCIe+iM2kLWWq/dQBmTZjlE6yLv/Q8AJKbFgf4Td716Ce/zJNrCi4XjSO731Yw6An2/wlc3Eq8eH0A== 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=kRhZD/Au0ZLEtLkLTWB0bPouztQNkrodqoTdBeM7xTlzJLfWo2W/HtQJUp5Qy/GFtIRnPPnY44cuS/gjaTqMSXnZgmW/AxF4jtnhI6h2K/nM4vDclL3n97K6om4Om7XhpQEuF68ax76aqvbC1HyAOhurI94bwb39SpW8CJLer6kBo4TNu0wkeTJwtmBgmky8Tf1bbPHMrymIVETudx/AiZeCeXEls8nOm4shlfU9jvpycb793CjHx0HmGWvyEjQ88yH0hu3EfKlYiBUASH2VNWNftDgauILOMam5NyyfnGvgWDB+3sFUo3wkG2GOZwhuXSB4y8qnjrV3zTI3TH0sPA== 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=CbWOS7SoN2npK9zOhMLjvN7MQE7UdYQpoKOhdeOJRrzUbfXduMlwi/ieLeFkb1Yr62pqwtXURXCg8p+WBCiqGDAZCWE6dcFGesCeYBvK4BghIT6c5gKl/+ymYM8nrj68pGeA5rtyhACv7zr1g1HlgUZqXrZjj24IFZxWkl7OpPecqKULtPlxzzcI/jSpNKjAseRoUZWho3NGKqf03M6lbbWlbBjjZKYZB1Be7IUjTmNKoSmJn5gegF9CNUN6w+O1h03X/RryXbULOX8uI+WiGoCOfTFEx96to5RR40A+/EdicQtgAhwkvi/aFib/FolFyr2/Pa4ObkiuH6arPBDtnw== Received: from SN1NAM02FT035.eop-nam02.prod.protection.outlook.com (10.152.72.60) by SN1NAM02HT121.eop-nam02.prod.protection.outlook.com (10.152.73.230) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.13; Wed, 25 Mar 2020 02:59:54 +0000 Received: from MWHPR07MB3440.namprd07.prod.outlook.com (2a01:111:e400:7e44::33) by SN1NAM02FT035.mail.protection.outlook.com (2a01:111:e400:7e44::145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.17 via Frontend Transport; Wed, 25 Mar 2020 02:59:54 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:015B333BB6E7B6D0294336CA692208734F12FC2105748FD3F938AF4F045537B9;UpperCasedChecksum:40FA896F94F1BB105F94B901E74D278C325C0501F471ABD7C86EEDA5A1EB7341;SizeAsReceived:7671;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; Wed, 25 Mar 2020 02:59:54 +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 v2 1/2] MdeModulePkg/Variable: Return GetVariable() attr if EFI_BUFFER_TOO_SMALL Date: Tue, 24 Mar 2020 19:59:31 -0700 Message-ID: X-Mailer: git-send-email 2.16.3.windows.1 X-ClientProxiedBy: CO2PR18CA0045.namprd18.prod.outlook.com (2603:10b6:104:2::13) To MWHPR07MB3440.namprd07.prod.outlook.com (2603:10b6:301:69::28) Return-Path: michael.kubacki@outlook.com X-Microsoft-Original-Message-ID: <20200325025932.13828-1-michael.kubacki@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (131.107.159.121) by CO2PR18CA0045.namprd18.prod.outlook.com (2603:10b6:104:2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20 via Frontend Transport; Wed, 25 Mar 2020 02:59:54 +0000 X-Mailer: git-send-email 2.16.3.windows.1 X-Microsoft-Original-Message-ID: <20200325025932.13828-1-michael.kubacki@outlook.com> X-TMN: [gmwaKtaUFYZZkbwFo99eQMeYqTYv7PbM1eXEk7WxTl8=] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 3cf9b723-ce04-4fa3-4408-08d7d06897f6 X-MS-TrafficTypeDiagnostic: SN1NAM02HT121: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JSZmyHV/vcuajeT+vujMuGP5PughKLM9ZD9Mz1s2rlv7hA7CGN0W6mN6jPlT4gbQfiBSzc6A0Ytx4iyJOYaUsQn1iFL1nzivR2u0RfbZZcpN2nqIJMyNl0SpJBvsEfJt1kn5b07lom0zqyR7Ey7nahQBvKY2z5/bptCQBAdm4Wb/V95Z1YwoPxPVeWxGy9vyODXgryaHd6qGN4FT2akDE3FepEIbJKq8Kbo7d9KZltA= X-MS-Exchange-AntiSpam-MessageData: yZQuvZYkD/2HJLpZlv267PZvuyrxw9V0QX0RlDwWPppzAWtzwWSyH/11lTxlZIfyTqOloV4Irs2Ydk9PFuBAIURBHXTruvAcrv+cE2T91GZNO52x5ZI02F02kGQlYbHuGuZ3hapV6Dm1Y84HD2E+ww== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3cf9b723-ce04-4fa3-4408-08d7d06897f6 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2020 02:59:54.2738 (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: SN1NAM02HT121 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