From nobody Tue May 21 14:02:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+104388+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+104388+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1683646210; cv=none; d=zohomail.com; s=zohoarc; b=lP73EYle5pvmriEUmtbZVE7KTjhmQu7lZBsT6xZ6xBmjvf7AZIEij1Cih0/sAfVDWgQ4G1PXZqlBlhEBN+S6oaDb9sYVSJbjxWsEWne8aXlLn/l3Lio3w0Dzbnzj4hCHpCM+4MbR9zaC0HUcdSUeamu1KiNJtpL/eUdZYpIi/sk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683646210; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=Xiyoz22HYGhIH/fMzBp6fiIgtI9pLPco9Jz7j9Z8lzA=; b=l/PJwF168yZ7TvWs0IuApnPWuRmWw+hM+TCCBvTGRX+gl6NPKVRDYO6Is11LotShh6chKqLl2yzB91XyTaMletqY/mSo9Mpg/0skacEWBXWuW+ryfucfdIgwiwDb6VztRxOLwHyLOsTyAHWopOMGhkhMvlCjNjs0CmPkH0wWpl0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+104388+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1683646210188697.908329296685; Tue, 9 May 2023 08:30:10 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id TCO8YY1788612xixqloFrTmd; Tue, 09 May 2023 08:30:09 -0700 X-Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web11.24927.1683610750751751455 for ; Mon, 08 May 2023 22:39:10 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10704"; a="330173363" X-IronPort-AV: E=Sophos;i="5.99,261,1677571200"; d="scan'208";a="330173363" X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2023 22:39:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10704"; a="945135189" X-IronPort-AV: E=Sophos;i="5.99,261,1677571200"; d="scan'208";a="945135189" X-Received: from xzhang-desk.ccr.corp.intel.com ([10.240.102.162]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2023 22:39:00 -0700 From: Xiaoqiang Zhang To: devel@edk2.groups.io Cc: Xiaoqiang Zhang , Chasel Chiu , Nate DeSimone , Liming Gao , Eric Dong Subject: [edk2-devel] [PATCH v1] MinPlatformPkg: Fix SetLargeVariable fail issue Date: Tue, 9 May 2023 13:38:34 +0800 Message-Id: <20230509053834.379-1-xiaoqiang.zhang@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,xiaoqiang.zhang@intel.com X-Gm-Message-State: iRzAOS5uQt16eAxvcn46VA9ax1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1683646209; bh=ppFfJROuw1xup6dSbV2+rDt5fxspyuh3OdNQ+b1oCHI=; h=Cc:Date:From:Reply-To:Subject:To; b=MOAOjZgY/3EOxX0WLOr9mKc5wJU/gGWDhNTpY18a+WyT/65AgU39G2QGui1W6qzdw4c 7qGtnM0QHfseGra+sB5yv5qzNKpzRErAYmk3IVGBhl8p3Z23yZaKYgLaGX2o68Q7cER0K KI8SGYbyr8/6pHoPRptEeeFbNTKZrUKpFFs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1683646211282100007 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4454 On Server platform, when the large variable "FspNvsBuffer" is already in the UEFI variable store and the remaining variable storage space is less than the large variable size. And also not in OS runtime then we need to add the size of the current data that will end up being replaced by the new data to the remaining space before we decide that there is not enough space to store the large variable. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Liming Gao Cc: Eric Dong Signed-off-by: Xiaoqiang Zhang --- Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVariableWr= iteLib.c | 10 +++++++++- Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeVariab= leWriteLib.inf | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/Lar= geVariableWriteLib.c b/Platform/Intel/MinPlatformPkg/Library/BaseLargeVaria= bleLib/LargeVariableWriteLib.c index de23ae6160..da820f65b9 100644 --- a/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVaria= bleWriteLib.c +++ b/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVaria= bleWriteLib.c @@ -22,7 +22,7 @@ #include #include #include - +#include #include "LargeVariableCommon.h" =20 /** @@ -270,6 +270,7 @@ SetLargeVariable ( UINT8 *OffsetPtr; UINTN BytesRemaining; UINTN SizeToSave; + UINTN BufferSize =3D 0; =20 // // Check input parameters. @@ -365,6 +366,13 @@ SetLargeVariable ( // Non-Volatile storage to store the data. // RemainingVariableStorage =3D GetRemainingVariableStorageSpace (); + // + // Check if current variable already existed in NV storage variable sp= ace + // + Status =3D GetLargeVariable (VariableName, VendorGuid, &BufferSize, NU= LL); + if ((Status =3D=3D EFI_BUFFER_TOO_SMALL) && (BufferSize !=3D 0)) { + RemainingVariableStorage =3D RemainingVariableStorage + BufferSize; + } if (DataSize > RemainingVariableStorage) { DEBUG ((DEBUG_ERROR, "SetLargeVariable: Not enough NV storage space = to store the data\n")); Status =3D EFI_OUT_OF_RESOURCES; diff --git a/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/Bas= eLargeVariableWriteLib.inf b/Platform/Intel/MinPlatformPkg/Library/BaseLarg= eVariableLib/BaseLargeVariableWriteLib.inf index 2493a94596..cbc2a5d93a 100644 --- a/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeV= ariableWriteLib.inf +++ b/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeV= ariableWriteLib.inf @@ -49,3 +49,4 @@ PrintLib VariableReadLib VariableWriteLib + LargeVariableReadLib --=20 2.39.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#104388): https://edk2.groups.io/g/devel/message/104388 Mute This Topic: https://groups.io/mt/98786447/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-