From: Xiaoqiang Zhang <xiaoqiang.zhang@intel.com>
To: devel@edk2.groups.io
Cc: Xiaoqiang Zhang <xiaoqiang.zhang@intel.com>,
Chasel Chiu <chasel.chiu@intel.com>,
Nate DeSimone <nathaniel.l.desimone@intel.com>,
Liming Gao <gaoliming@byosoft.com.cn>,
Eric Dong <eric.dong@intel.com>
Subject: [PATCH v1] MinPlatformPkg: Fix SetLargeVariable fail issue
Date: Tue, 9 May 2023 13:38:34 +0800 [thread overview]
Message-ID: <20230509053834.379-1-xiaoqiang.zhang@intel.com> (raw)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4454
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 <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: Xiaoqiang Zhang <xiaoqiang.zhang@intel.com>
---
Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVariableWriteLib.c | 10 +++++++++-
Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeVariableWriteLib.inf | 1 +
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVariableWriteLib.c b/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVariableWriteLib.c
index de23ae6160..da820f65b9 100644
--- a/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVariableWriteLib.c
+++ b/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/LargeVariableWriteLib.c
@@ -22,7 +22,7 @@
#include <Library/PrintLib.h>
#include <Library/VariableReadLib.h>
#include <Library/VariableWriteLib.h>
-
+#include <Library/LargeVariableReadLib.h>
#include "LargeVariableCommon.h"
/**
@@ -270,6 +270,7 @@ SetLargeVariable (
UINT8 *OffsetPtr;
UINTN BytesRemaining;
UINTN SizeToSave;
+ UINTN BufferSize = 0;
//
// Check input parameters.
@@ -365,6 +366,13 @@ SetLargeVariable (
// Non-Volatile storage to store the data.
//
RemainingVariableStorage = GetRemainingVariableStorageSpace ();
+ //
+ // Check if current variable already existed in NV storage variable space
+ //
+ Status = GetLargeVariable (VariableName, VendorGuid, &BufferSize, NULL);
+ if ((Status == EFI_BUFFER_TOO_SMALL) && (BufferSize != 0)) {
+ RemainingVariableStorage = RemainingVariableStorage + BufferSize;
+ }
if (DataSize > RemainingVariableStorage) {
DEBUG ((DEBUG_ERROR, "SetLargeVariable: Not enough NV storage space to store the data\n"));
Status = EFI_OUT_OF_RESOURCES;
diff --git a/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeVariableWriteLib.inf b/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeVariableWriteLib.inf
index 2493a94596..cbc2a5d93a 100644
--- a/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeVariableWriteLib.inf
+++ b/Platform/Intel/MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeVariableWriteLib.inf
@@ -49,3 +49,4 @@
PrintLib
VariableReadLib
VariableWriteLib
+ LargeVariableReadLib
--
2.39.1.windows.1
next reply other threads:[~2023-05-09 5:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-09 5:38 Xiaoqiang Zhang [this message]
2023-05-10 4:34 ` [PATCH v1] MinPlatformPkg: Fix SetLargeVariable fail issue Nate DeSimone
2023-05-10 5:12 ` Zhang, Xiaoqiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230509053834.379-1-xiaoqiang.zhang@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox