public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] BaseTools: Fix wrong variable header size
@ 2022-01-11 13:01 Chen Lin Z
  2022-01-11  5:25 ` Bob Feng
  0 siblings, 1 reply; 2+ messages in thread
From: Chen Lin Z @ 2022-01-11 13:01 UTC (permalink / raw)
  To: bob.c.feng, gaoliming, yuwei.chen, devel
  Cc: zhuangzhi.li, di.zhang, Chen, Lin Z, Chen

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-11  5:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-11 13:01 [PATCH] BaseTools: Fix wrong variable header size Chen Lin Z
2022-01-11  5:25 ` Bob Feng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox