From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web10.4676.1681811570910012196 for ; Tue, 18 Apr 2023 02:52:51 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=frT8K8Sr; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: yuwei.chen@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681811570; x=1713347570; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=PAmmVg2vgeV2ucMhbfFBigc+1JUnB3ldV/Xf2TVKjJk=; b=frT8K8SrGDuQ0dx4PSVn362pD/hrrfUmXT5SDQg+Y3mRp13vAbclwA4r ANjvcHKkxrE0B7F868Rtwn18yh2xy/eSQsRiX9WZqzSQxe1xjxSEJfK3n +OEEeljkt6p94KgkekZXSHyzd77ln59jkum6M192fbRdn0TBjK+VxFBcu 6ah4JQ0mNPj4GnIKcXc6sg3pVeJZcV4DXPfoIdYKLuPd2CK9NtKWKtuHy Vj/6m9y2Xs2XwH/+okuPcJmsAPWbpg+EM6WQvKVBH7dkI0wHl636Em2yN dXG1rbRx+OQFEmUekgyp5TMlk6h/zV0Rh+IlZ8qIFFvU+sPzQhztMzMtG A==; X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="408025193" X-IronPort-AV: E=Sophos;i="5.99,206,1677571200"; d="scan'208";a="408025193" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2023 02:52:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10683"; a="865315919" X-IronPort-AV: E=Sophos;i="5.99,206,1677571200"; d="scan'208";a="865315919" Received: from yuweipc.ccr.corp.intel.com ([10.239.158.38]) by orsmga005.jf.intel.com with ESMTP; 18 Apr 2023 02:52:46 -0700 From: "Yuwei Chen" To: devel@edk2.groups.io Cc: Rebecca Cran , Liming Gao , Bob Feng Subject: [Patch V1 1/3] BaseTools: fixing FMMT ShrinkFv issue Date: Tue, 18 Apr 2023 17:52:44 +0800 Message-Id: <20230418095244.676-1-yuwei.chen@intel.com> X-Mailer: git-send-email 2.27.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 1. FvLength not change issue; 2. FileSystemGuid align with File Size; Cc: Rebecca Cran Cc: Liming Gao Cc: Bob Feng Signed-off-by: Yuwei Chen --- BaseTools/Source/Python/FMMT/core/FMMTOperation.py | 2 +- BaseTools/Source/Python/FMMT/core/FvHandler.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/Python/FMMT/core/FMMTOperation.py b/BaseTools/Source/Python/FMMT/core/FMMTOperation.py index a86f8dda9a..d4aa339703 100644 --- a/BaseTools/Source/Python/FMMT/core/FMMTOperation.py +++ b/BaseTools/Source/Python/FMMT/core/FMMTOperation.py @@ -188,7 +188,7 @@ def ExtractFfs(inputfile: str, Ffs_name: str, outputfile: str, Fv_name: str=None FmmtParser.WholeFvTree.Findlist.remove(FmmtParser.WholeFvTree.Findlist[index]) if FmmtParser.WholeFvTree.Findlist != []: TargetNode = FmmtParser.WholeFvTree.Findlist[0] - if TargetNode.type == FV_TREE or SEC_FV_TREE or DATA_FV_TREE: + if TargetNode.type == FV_TREE or TargetNode.type == SEC_FV_TREE or TargetNode.type == DATA_FV_TREE: FinalData = struct2stream(TargetNode.Data.Header) + TargetNode.Data.Data with open(outputfile, "wb") as f: f.write(FinalData) diff --git a/BaseTools/Source/Python/FMMT/core/FvHandler.py b/BaseTools/Source/Python/FMMT/core/FvHandler.py index ff3d637623..b0cc1951a1 100644 --- a/BaseTools/Source/Python/FMMT/core/FvHandler.py +++ b/BaseTools/Source/Python/FMMT/core/FvHandler.py @@ -279,7 +279,7 @@ class FvHandler: ParTree.Child.remove(ParTree.Child[-1]) ParTree.Data.Free_Space = 0 ParTree.Data.Size += Needed_Space - ParTree.Data.Header.Fvlength = ParTree.Data.Size + ParTree.Data.Header.FvLength = ParTree.Data.Size ModifyFvSystemGuid(ParTree) for item in ParTree.Child: if item.type == FFS_FREE_SPACE: @@ -650,8 +650,12 @@ class FvHandler: Removed_Space = TargetFv.Data.Free_Space - New_Free_Space TargetFv.Child[-1].Data.Data = b'\xff' * New_Free_Space TargetFv.Data.Size -= Removed_Space - TargetFv.Data.Header.Fvlength = TargetFv.Data.Size - ModifyFvSystemGuid(TargetFv) + TargetFv.Data.Header.FvLength = TargetFv.Data.Size + if struct2stream(TargetFv.Data.Header.FileSystemGuid) == EFI_FIRMWARE_FILE_SYSTEM3_GUID_BYTE: + if TargetFv.Data.Size <= 0xFFFFFF: + TargetFv.Data.Header.FileSystemGuid = ModifyGuidFormat( + "8c8ce578-8a3d-4f1c-9935-896185c32dd3") + for item in TargetFv.Child: if item.type == FFS_FREE_SPACE: TargetFv.Data.Data += item.Data.Data + item.Data.PadData -- 2.39.1.windows.1