From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web11.2999.1688021654384280016 for ; Wed, 28 Jun 2023 23:54:14 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=QAntHsBR; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: bob.c.feng@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688021654; x=1719557654; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=37bU8d0GokHXWucxYZwWurB6ofa+in6xZLo93x7Va8A=; b=QAntHsBRSIeqWLZqUthS8pp+C6nr8xkowJwZgBQMMjzMjIZ3WdIlIrn9 JobhOan5eqGZvMKef5NrY4mP3PIF1bhxCdBWt7MHBuAQCAH2dxiL3jvvM Qz+xye8UuiMr/joofo7q5X1ok6vkClobKD8eVE1jCMPjGEYFntTXqmX9k /6ZCaA8hFIxpttCU5FyNzmzBCOcMVHj76BXaMBBiuCR6pkeAy4FSTRPL0 Y9VlfutogoKFYFoydQhuYCT9aHION/CSqu7/GGSdYzgVMItDnl/F/EdVk mm1Cluo50GbtkgUXVDu1SDp19iwpyEEyCqFLlDxjJiMcWWoTTSf280rP3 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="351837929" X-IronPort-AV: E=Sophos;i="6.01,167,1684825200"; d="scan'208";a="351837929" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2023 23:54:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10755"; a="667400628" X-IronPort-AV: E=Sophos;i="6.01,167,1684825200"; d="scan'208";a="667400628" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga003.jf.intel.com with ESMTP; 28 Jun 2023 23:54:13 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 28 Jun 2023 23:54:13 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 28 Jun 2023 23:54:12 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27 via Frontend Transport; Wed, 28 Jun 2023 23:54:12 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.42) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.27; Wed, 28 Jun 2023 23:54:12 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ji/gGsKjbwv+WOCVjhEKbgzWZ4zihb8/Sqy6QyvpNhcMWZVzuxzjdCo7nTtDEiHRE2J8scNX2y/Z1eFFvq4dKjdt1VzYJiADF5sEYi6munb8bPL3Ixa3/1hWFBC7lhlpKT2EFa1BfbX81RIMnms9kRcnE9GYgkfxJT8O6DdcpnFYSE2fVra05z2SJu1HUxU18UL6Aa45VqqcGdfhIA4tK30W9sFsua9G5cTYId5maRMRVsyaEZIkWz5u0/B95PyrIt4K8oQE185A3EzBGXKc3BPuf8jG+MBlDzY4oSIeqdS/aEjr6sEXsyqQ8W3/r8OUyBhGXsWljN1uUflZbbERjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=56fkPvVOR0PyOeX5918/7HQ7rC3mbowaa2jYWQM/W8I=; b=h+nPYh56QHx/6roCZITkUuGl6/LhdKPM/n2eVVWNRiyU6g3YNzuwWo64RWu4LKqFyPJmAhvNWdr+qBGJaBB3W5dV/YBkc66XmPNyxRMBT5lEjSxJKfdoOl58SlH8+iXUtovfFVXPh6uECbKkvGM2Suezfp8v2BmW6Iw3yV+3eoOZoKwmiVR7/PVH+wuorVDFLXlslCF5klpfsxMlF2n5tJBC8uZw73yh04wwL5QeJyrYFw2jAhxZz7pxY0ps7XoSuxhFHDZHbGBZCv0q49JlBpWogR/+cMdCjJkmcKY/JDZr15u6i07z5bYy4HB2H4p1p9J7UHYP3nqeawu2cwak4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from PH7PR11MB5863.namprd11.prod.outlook.com (2603:10b6:510:135::11) by CY5PR11MB6115.namprd11.prod.outlook.com (2603:10b6:930:2c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24; Thu, 29 Jun 2023 06:54:05 +0000 Received: from PH7PR11MB5863.namprd11.prod.outlook.com ([fe80::c14c:19b2:4d95:30f9]) by PH7PR11MB5863.namprd11.prod.outlook.com ([fe80::c14c:19b2:4d95:30f9%4]) with mapi id 15.20.6521.023; Thu, 29 Jun 2023 06:54:05 +0000 From: "Bob Feng" To: "Chen, Christine" , "devel@edk2.groups.io" CC: Rebecca Cran , "Gao, Liming" Subject: Re: [Patch V2 1/4] BaseTools: fixing FMMT ShrinkFv issue Thread-Topic: [Patch V2 1/4] BaseTools: fixing FMMT ShrinkFv issue Thread-Index: AQHZqjqnOrgRz1+Kpk2l/i/F4mklM6+hWFbA Date: Thu, 29 Jun 2023 06:54:05 +0000 Message-ID: References: <20230629033420.872-1-yuwei.chen@intel.com> In-Reply-To: <20230629033420.872-1-yuwei.chen@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH7PR11MB5863:EE_|CY5PR11MB6115:EE_ x-ms-office365-filtering-correlation-id: dd3434df-c3f7-45fb-bbe7-08db786da11a x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Tvp9f93YZqDngn512tZnaer9Ognu5k2ZICKyoesBbOnBMukt3uZ5Wokvav4IWbF2ESDM1NjcQZYXg92iY1q2qQoQQVzw97psdx3gan8ySfBVwT1m2qilczjSohWbpnLKz5+uradlsI7fpV5YFhVJhShD+0rallqQ61IPJccUPwwGJYJhJS74AXt9zA7hbvODcYS5UbFVu0pT0L5jzzoExmgAdArkcmhQZBMARlaUe/b7ZgmzJEMt4v9RLevrgbpFHrlVXPaNa9EKzEfix0mvPn5uVY2gS3ieaepDl3gYb7E+ywVuBc2DNWd8caV6GePMwj3S+lLJJoB7w0n6/I7wpjI7YoMb9mqWQ7+jSoGfstpgwBJZg+452NveDFr624v0gBylmYT9C4uhSW29hBUYzvlN9SiUuZV4TmUj7DvVlr5noPNXOIJBDh7r6CEOJ+89sSWGZfm6u78LQVG/w9PYOwGow1KtneFIBZwg52peKTRTaVlZ9LkRl3FpPP0F/xXMpUVtcNUahUq6rRHOD1CrKVhN4DvrzIYP0EBFb78ug+qNF+a+sNcHMh+0UCuvhi8Mqx1dwhJjk3XdVNrjjy5TfGsM/mtxtXMWMN+nAPyDqY2zgV/zS+M09GE/i96AqfAd x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR11MB5863.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(136003)(39860400002)(376002)(366004)(396003)(451199021)(66446008)(38070700005)(9686003)(26005)(66556008)(66476007)(4326008)(66946007)(122000001)(86362001)(33656002)(8936002)(41300700001)(316002)(8676002)(55016003)(82960400001)(5660300002)(52536014)(64756008)(38100700002)(76116006)(110136005)(6506007)(53546011)(186003)(2906002)(83380400001)(71200400001)(54906003)(7696005)(478600001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Rc1/2b5xStpbcZdtHTv6wyFMbOplxykzXfrbuTOkplt30fCyCD+f9RlkeQjU?= =?us-ascii?Q?zdVr8a7v2X3UyUKLjhydBTwyvYfrpB0AWN3TJnNN79dbS1THirbtld+wlLfQ?= =?us-ascii?Q?CIQyI2La1wNBSjMDfk/Fsclq5PpJkxDbH/rbyor52kFp6xnHUZkftCALlmvg?= =?us-ascii?Q?M622tII2QOIQa2UyMoT5BKj5z/OJdzDoSuxsWcIwmKIbz2ukmUOwEMgQ7PSm?= =?us-ascii?Q?XEM4u0KYp+Wm/vBOslYedGyg15FKTLwXrEG/jQCx16R9NY59yD5lnGbA7paS?= =?us-ascii?Q?S3lNkYdu5e+v/iTQfW6nepCLsCEf5Rf5I6sX4p4ZrvfvtZEykZwJTE9Vmox8?= =?us-ascii?Q?xZvfncQnbi0vujVeCWf6LO402Fq1pBtRHZr/lqXVkKuQkEDtRfrelynPiv5b?= =?us-ascii?Q?0fHehEzxKFDUZ0hVRGuhe/28JH5/JcRw+nIkE0m5o7PHF7fFDfSSnYZU0F9/?= =?us-ascii?Q?49lsCav5qUYiVNEkU1TULrR4JWkFL0aVZtvClHMg8AQc+DrFC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bL13OuPpn9uLsyFOY8SWWVE57nzMjGZGquk1?= =?us-ascii?Q?PCZbkawJTsvasp1As/1tVpuNTfYPnYZTdAa7qip2ksIdej/g+DvPh0GEvndP?= =?us-ascii?Q?vzL5rYsJ1R/socWACJPBBLtGc56l4ZrnWRCtsCDNC8Of3WdYV1wm8uo79les?= =?us-ascii?Q?NvtXCV8LtkI5NBuYx5hL18YjGmCjOHB2SFJjNs8z?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH7PR11MB5863.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd3434df-c3f7-45fb-bbe7-08db786da11a X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jun 2023 06:54:05.2348 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: yBEjuVcn82yDkGFR3mz8Nz84wXzQDwogS93aSVzR2Pr8aiGx1QMNGZo9LYPXqmXmBogAU+WHfgyw7XYqbW7fyw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR11MB6115 Return-Path: bob.c.feng@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Bob Feng -----Original Message----- From: Chen, Christine =20 Sent: Thursday, June 29, 2023 11:34 AM To: devel@edk2.groups.io Cc: Rebecca Cran ; Gao, Liming ; Feng, Bob C Subject: [Patch V2 1/4] BaseTools: fixing FMMT ShrinkFv issue 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 a86f8dda9a1a..d4aa3397036d 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, outputfil= e: str, Fv_name: str=3DNone FmmtParser.WholeFvTree.Findlist.remove(FmmtParser.WholeFvT= ree.Findlist[index]) if FmmtParser.WholeFvTree.Findlist !=3D []: TargetNode =3D FmmtParser.WholeFvTree.Findlist[0] - if TargetNode.type =3D=3D FV_TREE or SEC_FV_TREE or DATA_FV_TREE: + if TargetNode.type =3D=3D FV_TREE or TargetNode.type =3D=3D SEC_FV= _TREE or TargetNode.type =3D=3D DATA_FV_TREE: FinalData =3D struct2stream(TargetNode.Data.Header) + TargetNo= de.Data.Data with open(outputfile, "wb") as f: f.write(FinalData) diff --git a/BaseTools/Source/Python/FMMT/core/FvHandler.py b/BaseTools/Sou= rce/Python/FMMT/core/FvHandler.py index ff3d637623f8..b0cc1951a1c6 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 =3D 0 ParTree.Data.Size +=3D Needed_Space - ParTree.Data.Header.Fvlength =3D ParTree.Data.Size + ParTree.Data.Header.FvLength =3D ParTree.Data.Size ModifyFvSystemGuid(ParTree) for item in ParTree.Child: if item.type =3D=3D FFS_FREE_SPACE: @@ -650,8 +650,12 @@ class FvHandler: Removed_Space =3D TargetFv.Data.Free_Space - New_Free_Space TargetFv.Child[-1].Data.Data =3D b'\xff' * New_Free_Space TargetFv.Data.Size -=3D Removed_Space - TargetFv.Data.Header.Fvlength =3D TargetFv.Data.Size - ModifyFvSystemGuid(TargetFv) + TargetFv.Data.Header.FvLength =3D TargetFv.Data.Size + if struct2stream(TargetFv.Data.Header.FileSystemGuid) =3D=3D E= FI_FIRMWARE_FILE_SYSTEM3_GUID_BYTE: + if TargetFv.Data.Size <=3D 0xFFFFFF: + TargetFv.Data.Header.FileSystemGuid =3D ModifyGuidForm= at( + "8c8ce578-8a3d-4f1c-9935-896185c32dd3") + for item in TargetFv.Child: if item.type =3D=3D FFS_FREE_SPACE: TargetFv.Data.Data +=3D item.Data.Data + item.Data.Pad= Data --=20 2.27.0.windows.1