From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.953.1688009735539563499 for ; Wed, 28 Jun 2023 20:35:35 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=BKl83Yql; spf=pass (domain: intel.com, ip: 192.55.52.136, 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=1688009735; x=1719545735; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=jJxgNHUOYfYIgA/8VtY3CYKx6KkNg1fqRX8bKlO7D6M=; b=BKl83Yqlv+sCYXPeLJhxoMpCywYxToo/0UpCY9P8CPaHpn6H3tIsFtkw zvrn2wi0bnK1zt3eDRNS6vuJw8hf+VTjoKbymKkahtcaZ7743SgPgAczZ cT10CcBykxCTwCgFTKXM2v8SKbXSAk6jBzynokyEg2yrl3/K5SpVy9ZRV 2K/bhkfhN/RNI1W36nlOoRJiXJdVFYj2s2zwGt8+rtwTgfWLn04NvqPAI gjOIY3u2Nll1QSvjKan0HdYUpuyjlLir/oo5EPiuwInKI1+x+zrrpdgs7 6/19PsY+fLMs0hzX24Ndvion1iHUxjhABARnnXi3u3LlsfweLHB3OUcSs w==; X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="341596895" X-IronPort-AV: E=Sophos;i="6.01,167,1684825200"; d="scan'208";a="341596895" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2023 20:35:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="807165141" X-IronPort-AV: E=Sophos;i="6.01,167,1684825200"; d="scan'208";a="807165141" Received: from yuweipc.ccr.corp.intel.com ([10.239.158.24]) by FMSMGA003.fm.intel.com with ESMTP; 28 Jun 2023 20:35:33 -0700 From: "Yuwei Chen" To: devel@edk2.groups.io Cc: Rebecca Cran , Liming Gao , Bob Feng Subject: [Patch V2 4/4] BaseTools: FMMT replace new free space fixing in replace Date: Thu, 29 Jun 2023 11:35:19 +0800 Message-Id: <20230629033519.772-1-yuwei.chen@intel.com> X-Mailer: git-send-email 2.27.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In FMMT replace function, when newffs size <= targetffs size, the new free space is calculated wrong as loss the pad data delta size. That will cause invalid binary generated. This patch fixes this issue. Cc: Rebecca Cran Cc: Liming Gao Cc: Bob Feng Signed-off-by: Yuwei Chen --- BaseTools/Source/Python/FMMT/core/FvHandler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseTools/Source/Python/FMMT/core/FvHandler.py b/BaseTools/Source/Python/FMMT/core/FvHandler.py index 49bbc35baa4d..7a6076033681 100644 --- a/BaseTools/Source/Python/FMMT/core/FvHandler.py +++ b/BaseTools/Source/Python/FMMT/core/FvHandler.py @@ -456,7 +456,7 @@ class FvHandler: # Start free space calculating and moving process. self.ModifyTest(TargetFv.Parent, Needed_Space) else: - New_Free_Space = self.TargetFfs.Data.Size - self.NewFfs.Data.Size + New_Free_Space = self.TargetFfs.Data.Size + len(self.TargetFfs.Data.PadData) - self.NewFfs.Data.Size - len(self.NewFfs.Data.PadData) # If TargetFv already have free space, move the new free space into it. if TargetFv.Data.Free_Space: TargetFv.Child[-1].Data.Data += b'\xff' * New_Free_Space -- 2.27.0.windows.1