From: "Chen, Lin Z" <lin.z.chen@intel.com>
There are two type variable header and their size are different,
need to use matched size when calculating offset info, otherwise
it'll destroy other variables content when patching.
Signed-off-by: Chen, Lin Z <lin.z.chen@intel.com>
---
BaseTools/Source/Python/AutoGen/GenVar.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/Python/AutoGen/GenVar.py
index 3f3dc69e90..f2ad54ba63 100644
--- a/BaseTools/Source/Python/AutoGen/GenVar.py
+++ b/BaseTools/Source/Python/AutoGen/GenVar.py
@@ -20,6 +20,7 @@ import Common.GlobalData as GlobalData
var_info = collections.namedtuple("uefi_var", "pcdindex,pcdname,defaultstoragename,skuname,var_name, var_guid, var_offset,var_attribute,pcd_default_value, default_value, data_type,PcdDscLine,StructurePcd")
NvStorageHeaderSize = 28
VariableHeaderSize = 32
+AuthenticatedVariableHeaderSize = 60
class VariableMgr(object):
def __init__(self, DefaultStoreMap, SkuIdMap):
@@ -171,7 +172,10 @@ class VariableMgr(object):
DataBuffer = VariableMgr.AlignData(var_name_buffer + default_data)
data_size = len(DataBuffer)
- offset += VariableHeaderSize + len(default_info.var_name.split(","))
+ if GlobalData.gCommandLineDefines.get(TAB_DSC_DEFINES_VPD_AUTHENTICATED_VARIABLE_STORE,"FALSE").upper() == "TRUE":
+ offset += AuthenticatedVariableHeaderSize + len(default_info.var_name.split(","))
+ else:
+ offset += VariableHeaderSize + len(default_info.var_name.split(","))
var_data_offset[default_info.pcdindex] = offset
offset += data_size - len(default_info.var_name.split(","))
if GlobalData.gCommandLineDefines.get(TAB_DSC_DEFINES_VPD_AUTHENTICATED_VARIABLE_STORE,"FALSE").upper() == "TRUE":
--
2.26.2.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#85519): https://edk2.groups.io/g/devel/message/85519
Mute This Topic: https://groups.io/mt/88342888/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
This patch is good to me. Reviewed-by: Bob Feng <bob.c.feng@intel.com> -----Original Message----- From: Chen, Lin Z <lin.z.chen@intel.com> Sent: Tuesday, January 11, 2022 12:58 PM To: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; Chen, Christine <yuwei.chen@intel.com>; devel@edk2.groups.io Cc: Li, Zhuangzhi <zhuangzhi.li@intel.com>; Zhang, Di <di.zhang@intel.com>; Chen, Lin Z <lin.z.chen@intel.com>; Chen Subject: [PATCH] BaseTools: Fix wrong variable header size There are two type variable header and their size are different, need to use matched size when calculating offset info, otherwise it'll destroy other variables content when patching. Signed-off-by: Chen, Lin Z <lin.z.chen@intel.com> --- BaseTools/Source/Python/AutoGen/GenVar.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/Python/AutoGen/GenVar.py index 3f3dc69e90..f2ad54ba63 100644 --- a/BaseTools/Source/Python/AutoGen/GenVar.py +++ b/BaseTools/Source/Python/AutoGen/GenVar.py @@ -20,6 +20,7 @@ import Common.GlobalData as GlobalData var_info = collections.namedtuple("uefi_var", "pcdindex,pcdname,defaultstoragename,skuname,var_name, var_guid, var_offset,var_attribute,pcd_default_value, default_value, data_type,PcdDscLine,StructurePcd") NvStorageHeaderSize = 28 VariableHeaderSize = 32+AuthenticatedVariableHeaderSize = 60 class VariableMgr(object): def __init__(self, DefaultStoreMap, SkuIdMap):@@ -171,7 +172,10 @@ class VariableMgr(object): DataBuffer = VariableMgr.AlignData(var_name_buffer + default_data) data_size = len(DataBuffer)- offset += VariableHeaderSize + len(default_info.var_name.split(","))+ if GlobalData.gCommandLineDefines.get(TAB_DSC_DEFINES_VPD_AUTHENTICATED_VARIABLE_STORE,"FALSE").upper() == "TRUE":+ offset += AuthenticatedVariableHeaderSize + len(default_info.var_name.split(","))+ else:+ offset += VariableHeaderSize + len(default_info.var_name.split(",")) var_data_offset[default_info.pcdindex] = offset offset += data_size - len(default_info.var_name.split(",")) if GlobalData.gCommandLineDefines.get(TAB_DSC_DEFINES_VPD_AUTHENTICATED_VARIABLE_STORE,"FALSE").upper() == "TRUE":-- 2.26.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#85520): https://edk2.groups.io/g/devel/message/85520 Mute This Topic: https://groups.io/mt/88342888/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
© 2016 - 2024 Red Hat, Inc.