From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.92.22.95]) by mx.groups.io with SMTP id smtpd.web11.23845.1585346178610129437 for ; Fri, 27 Mar 2020 14:56:18 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@outlook.com header.s=selector1 header.b=oQEGsLk2; spf=pass (domain: outlook.com, ip: 40.92.22.95, mailfrom: michael.kubacki@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eezSxLgn18WwOxyMkG8N9tDJz8FZjkGl8yaIXYWEM+eUUU5NQQaG3m2pN6GLm+wG3ud16vad3UMoW1JwWyW8iSUIGGxkmYJzJkAhP1iBeZlZqIoHh6NPZNufLG1jJztw2XhwY8zR52qpJlksT+NvaC3P810ZwyXCgVf7ZzJ3ljsyCO66pG/KLinxZ7qxQ5bQoqFg18U2fOxfuljx1PuQ0uZt0d5FwC3B5A7MmdAsJjM2Qff0/BGu+1daLWc6A4GUP8TvjiZt/BK0Ej+cFDQiV1sRuR+DhiAJ1stJEQthTdpJZ6LQWTavMUXGtGvEh+WQY1D0X/Xhfn3fQzPbWi0gDg== 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=Pn7zIQ/xwSI58/tDO5zq3uE+kOwM6nXP7GG/KSevEtquDB1YbQNovCvoy2zATlKaZiboONGFPXHCnzkJzxhwX5dnW4KaBtN+Z46Yr5frjX2TivUkxcgh1938aZHbB2HML+OHhX9kk4ReDEtIMvDBrR8qHPSQ/AQ9yEhHlrQe7qQyocYFCLQPXycrkMUeznHe+LfF2Mpt4ZdVxaoPTnrHl+U3QYGIyqgrAy4AqVAShkLcBx9yhOHjFJT+LBx88bb+ob1mX15yjRPzLdF7BGR+xX16jlc5jpoF0gMuCl04Q89CxxV5PgIETuGoWAewcDD2wOesew6FqgDJsrVt7c9R5A== 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=oQEGsLk2doTiHnjVuw8od4xAYCn07+g8r3swV+j79NSkLxwMR3ZXF0qEGHfVGk9k7niv61OWao4XYq0hxQB79ULVJHPA+8GXi688wEVmqad7x+8IorRtM8gkLH/mTmMGHkYMUaO3DbLNtA9zM6XrdVCxwfmWyWhglfBltHyZN89fPF4Hi6mx/7pj3n/isDyTa9+Itlkdc/OAW/TFjo5xEpSxaHTA1GRVuREcgPFubawW3U79ZQQfyjb1Rm/LG8bKD7eNW12uyM73F8szotUy3RJW1U7tdi4sCEaftpaG7/rHwlBihQNnZbRkvLY3K0mAhVNV1KZODptYZnu5nQU48g== Received: from DM6NAM12FT037.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc64::50) by DM6NAM12HT045.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc64::228) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.9; Fri, 27 Mar 2020 21:56:17 +0000 Received: from MWHPR07MB3440.namprd07.prod.outlook.com (10.13.178.52) by DM6NAM12FT037.mail.protection.outlook.com (10.13.179.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.9 via Frontend Transport; Fri, 27 Mar 2020 21:56:17 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:42405882775CF8E589EC6C77088E89082A0ECBB47896905A4721D5A52C7084C6;UpperCasedChecksum:0CB2B862A3240BABBCDB343C65B524A144F84F3BDEEB5E88C2865084508AAF39;SizeAsReceived:7885;Count:49 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; Fri, 27 Mar 2020 21:56:17 +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 v3 1/3] MdeModulePkg Variable: Return GetVariable() attr if EFI_BUFFER_TOO_SMALL Date: Fri, 27 Mar 2020 14:55:34 -0700 Message-ID: X-Mailer: git-send-email 2.16.3.windows.1 In-Reply-To: <20200327215536.9556-1-michael.kubacki@outlook.com> References: <20200327215536.9556-1-michael.kubacki@outlook.com> X-ClientProxiedBy: MWHPR20CA0037.namprd20.prod.outlook.com (2603:10b6:300:ed::23) To MWHPR07MB3440.namprd07.prod.outlook.com (2603:10b6:301:69::28) Return-Path: michael.kubacki@outlook.com X-Microsoft-Original-Message-ID: <20200327215536.9556-2-michael.kubacki@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2001:4898:80e8:a:5a12:4b01:47a7:5411) by MWHPR20CA0037.namprd20.prod.outlook.com (2603:10b6:300:ed::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.19 via Frontend Transport; Fri, 27 Mar 2020 21:56:17 +0000 X-Mailer: git-send-email 2.16.3.windows.1 X-Microsoft-Original-Message-ID: <20200327215536.9556-2-michael.kubacki@outlook.com> X-TMN: [1mi2b1BUba7ePlzvFXV5Yrpx2wVf8hIiT+y0g/GOsjcdRKyEHgLVlWleCCAN6fWa] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 49 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 471b88a6-05a6-42f0-ff25-08d7d299ad27 X-MS-TrafficTypeDiagnostic: DM6NAM12HT045: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eqYS4nLSBrelvu4UrZZTLxwFCseYdRI8KHK4BcTRDtVGLfMXy5ew5rrfY/egoWM7m6WyWPOSX90OBXdydi+9CUB1rbXM/945wrxnMbjhHM1OsCi7jVPfjynJ8glhuWZr+On0Cub3od0CszBy6Bl+wwxn85KHPfJmPdVNUte7ylRKHVwsFyqLNK49KGkoyxc1Xd+5S5ffqLt2xLdWWK0K5tpxgCZ8tOcUOz6GNFEBsAk= X-MS-Exchange-AntiSpam-MessageData: LL8tiZcwkjAsrQR9a2f+zj4odUZv8oss34Hq99G202AKjUmCGoHinQNJUMecftU9Ej8U9G4ms6gB6iW6ZDPNB6ZYH80ZbiN5+/TrOKMcMx1FQf3r15LB/SgiXvrOz/xgy2BMEYDxlWvoxu8IVrBq/hZhZ370OQdexmOU3lO6XAfXkill7+onwwLi1jAir8dUx2RwnNHtMHnb5pon7S1xXg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 471b88a6-05a6-42f0-ff25-08d7d299ad27 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Mar 2020 21:56:17.4602 (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: DM6NAM12HT045 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