From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web11.7423.1608284007786904128 for ; Fri, 18 Dec 2020 01:33:28 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=GmR+RqCX; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: bob.c.feng@intel.com) IronPort-SDR: gnZ7lGlcDwN0e5FwpVSVX7v9EcSS8DK25eNA6MRursuzuV0ZhDordg3D39k4As4iugL3A+5RF1 o39qeT32OkoA== X-IronPort-AV: E=McAfee;i="6000,8403,9838"; a="172842083" X-IronPort-AV: E=Sophos;i="5.78,430,1599548400"; d="scan'208";a="172842083" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2020 01:33:25 -0800 IronPort-SDR: WdZ2Z6pa/tVjNevxsCzMBK9+ZrbLRzfMq3WG1xff4+bIS5K9igjFaXodSbwNSeuZOTM6Eju2Sy OcGB/MaGO+IA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,430,1599548400"; d="scan'208";a="561126026" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by fmsmga005.fm.intel.com with ESMTP; 18 Dec 2020 01:33:24 -0800 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 18 Dec 2020 01:33:24 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Fri, 18 Dec 2020 01:33:24 -0800 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.176) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Fri, 18 Dec 2020 01:33:23 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dw5UUvrALsN1RP+8pa0fcpbfMdnBApdA3n78JPzlXjztiQx3hr0ynSQMIWzTDqeBFDZm3E6rTFyxV6/B1hqe1lwY5f6GAnD3IXP9Z9WFc3UjSztNzI+YmXi/dPVEJsV2NYtPMUcaGdbvaDt4T235nxDn5K9+dRgzSxoEekyUHQuBM2koDD3HT7A67MaRucQiMEGPpyvCvwuAh5kJDmfP5Uska3HUzLY/9fb2Ii3l5VMM/TkxzRGsCkNV7xaSH0P3Azm8eAmFMVtdAjt+brWeAOgnHhKZbDKfu9IMkrnvuVuDj2RSDJ8NLu6aeVFxaQ7RERbHQuPQb3d8Jzvsf+OsKA== 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-SenderADCheck; bh=7CmV9ZzNjnNJoe8EP7AcSrQj9gLco+HLJ7G3kxqimsc=; b=diC0XcPVJEaEzdqG4WkHfhnkqFZ4iz2g7q/pE47Nqf+6sfXxsQb5ms6TbS/vqIBfjT+xjtmy+U7uS70im6a06NvQo8BrBGoakJPwSXVtcnuKtGvGxPMqeoBtnHC4cyjNXwtuyde2PUxgbZwRvWwrSy8JGNOC5k2C/eQM7eJ1aBf5sgwlcZFe/UOiUacbJrfMOmm3WP4VkWKUksL6+FDCMtER0mhq8ZGIP8EwyPy96MSxyagXi+cP28S0kvnSDPLBJ3+8rRSPnoMf9Z548ZhG81zrSXCXVdP3VkPUuniybTOJ7V9v+rlR8hjs0kRvNZoOIW/G+JidGrMTeQXtDVng0A== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7CmV9ZzNjnNJoe8EP7AcSrQj9gLco+HLJ7G3kxqimsc=; b=GmR+RqCXH2nV/+qhT2mPDAU5L167Rcm5TzXyN6R6tsfRYQeJH8KGDqxTYm2NVgsgrzdL3cNxWv+Z2k9tby5Myh63vzYdSlIP8GqZnPrMB9jJzjTVmopZjp5NDyjBybUOekbYHK+Era+DauInt4W/4y0hEKEu1Ibcd8Q8ZybAMBA= Received: from DM6PR11MB4073.namprd11.prod.outlook.com (2603:10b6:5:19f::22) by DM6PR11MB4329.namprd11.prod.outlook.com (2603:10b6:5:201::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.15; Fri, 18 Dec 2020 09:33:22 +0000 Received: from DM6PR11MB4073.namprd11.prod.outlook.com ([fe80::c9f:47ea:6321:5ccb]) by DM6PR11MB4073.namprd11.prod.outlook.com ([fe80::c9f:47ea:6321:5ccb%3]) with mapi id 15.20.3654.025; Fri, 18 Dec 2020 09:33:22 +0000 From: "Bob Feng" To: "Yeh, GregX" , "devel@edk2.groups.io" CC: Liming Gao , 'Yunhua Feng' Subject: Re: [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2 Thread-Topic: [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2 Thread-Index: AQHWzTRNhDK8qHoARk2EOwuMJJvSt6n8ojCA Date: Fri, 18 Dec 2020 09:33:21 +0000 Message-ID: References: <20201208073222.19400-1-gregx.yeh@intel.com> In-Reply-To: <20201208073222.19400-1-gregx.yeh@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.102.204.36] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4d223f4a-6831-4f1d-624d-08d8a337f623 x-ms-traffictypediagnostic: DM6PR11MB4329: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: vkoJ0YviMfpnJHtIbdzDFcMHVcxmCp9ixGpICGof/5/Jpp66dTJWqR0kb/wVKlFzC+nStdNYwDbmb+/Xo9ELLpjxuKkEUtkRQ49H+3wt9M9FowqlB4xaDWYIc3JkuCR/XQPeuAQNIK7AyKlEDv1JNDj6QhvE6SD3X1a2olaXUJh/614iHojIPJAeN5ZaE2EYYm85TqD++0hQWtjFYICKX04BNxnm563JTB9sKQ1W2K97PzQYM0jE/EOFT4JIlNMRocVmcG8qN7xOudQnH5isbqUdsWk8OEY8vg6d2TiDNaCtxs7LKWFOcjZ3zJZpk9Adbulq3htj4vWfDK8bZC/SDA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR11MB4073.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(39860400002)(366004)(376002)(346002)(136003)(66946007)(66476007)(64756008)(66556008)(66446008)(33656002)(4326008)(54906003)(5660300002)(52536014)(478600001)(55016002)(110136005)(71200400001)(9686003)(8936002)(83380400001)(26005)(6506007)(53546011)(186003)(316002)(7696005)(2906002)(86362001)(8676002)(76116006);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?t96Mwn7NakcFYhcsNp8rW2GGO5oG93q+1P5/5gLsgyU+E2w5vSrQcAneaK3L?= =?us-ascii?Q?bTrFT0xonlW/qkOor6P4HyklvT9w5JExxJCxbWAWni/yvNV9IYVHShgoNdNn?= =?us-ascii?Q?0oMMnB+C3BcvNcNOu5buk/3OcARTMFAbdJYhJQ51wtmriQnxDPMmIatHcZri?= =?us-ascii?Q?e6i3OJqHjABOxrdLCsQspKAosQixPzLimuazsVRuThASIN83kj/MHnX5+hse?= =?us-ascii?Q?aAslnUZjkRMonxFxEHczRrKr8cktBiMfFEkHFXHpIwl7VT/N96C2dZJkD800?= =?us-ascii?Q?IsPr4JPshHLP5ZgM8mAtuiUWCmVsbf6C1tAoYJcdNbYJ1x8Zqw6o5mnLy3pL?= =?us-ascii?Q?/ZT1sVb/zfwqDFoaPIBPAG2iwdzJ9dBvirhbdTUmm4N2tn027JNlYji4LtJ9?= =?us-ascii?Q?Y1VtlInh8haiKraQC/MxM4gs/4sp6es0SJtg3Jp74YYtL3PCUlP2Ry3fuwMs?= =?us-ascii?Q?5tZFmwR/EWgr2Ileck9gN/l73L5t54EjMegjtQODEriAo/twGas/BIEPZYVz?= =?us-ascii?Q?VypB3xX3WWOCPH/mk5D1ciIhxn09f6vKcbhpgT/uGwyndn/QoSoJt9Iu8oki?= =?us-ascii?Q?LoPW4GmgwvPjnSMhxcHckyi5SIX3s2M70ljx34TL/WvewCpqFc9NeKrAVYmZ?= =?us-ascii?Q?ed26fT4OruA69v0VQ9VLah0pXtZV8D2XZDAekjkCWdVIOhOyFe+CmWB6gNe/?= =?us-ascii?Q?FwGJ+VleY46jevXpzZOpvPQidZcTmSPOMTUAcKoGk+OT2XTtMu4iqNiNmHD8?= =?us-ascii?Q?5Ra7oP0bKH9TAdlD844rlBUfk03OTp4/kNIqPTfKar6p9X/0gJQV7+TCQrif?= =?us-ascii?Q?jCkPgBfwpg3nkrZGsA6UeozqVu4yHpkVgtUU+X1evvBO3+ap40AWSNCjbnHY?= =?us-ascii?Q?F/mfHNk2I+5kyeoYsDbmhz019TR/7omFglFNEm10MDjaRl/ez1qAO87SgGsJ?= =?us-ascii?Q?2Xy3FV+wUc8doMM2uwK4aJna65WAHBTXnHqDmUkbraM=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB4073.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4d223f4a-6831-4f1d-624d-08d8a337f623 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Dec 2020 09:33:21.9438 (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: B3EoZ3tWHddFC4HhLfa/KEc/H/20lEjdoPgETmXzM8Idmx3uuu7Rbtlgf39LJSI0WyoJIXS/3SNHbdR2ftVmkQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB4329 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 Hi Greg For the change of the following block, 1.=20 - CurrentFv->FfsNumbers =3D *FfsCount; - *FfsCount +=3D 1; =20 + CurrentFv->FfsNumbers =3D *FfsCount; + 2. - for (Index=3D0; Index <=3D FvInFd->FfsNumbers; Index++) { + for (Index=3D0; Index < FvInFd->FfsNumbers; Index++) { I think it's correct but I see there are many places still have such statem= ent:=20 "for (Index =3D 0; Index <=3D FvInFd->FfsNumbers; Index++) { " I think all others may also need to be changed from "for (Index =3D 0; Inde= x <=3D FvInFd->FfsNumbers; Index++) {" need to change to "for (Index =3D 0;= Index < FvInFd->FfsNumbers; Index++) {" Thanks, Bob -----Original Message----- From: Yeh, GregX =20 Sent: Tuesday, December 8, 2020 3:32 PM To: devel@edk2.groups.io Cc: Feng, Bob C ; Liming Gao Subject: [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when F= V level over 2 Fixed replace file failure when FFS in multiple level FV and FV level over = 2. Signed-off-by: GregX Yeh Cc: Bob Feng Cc: Liming Gao --- BaseTools/Source/C/FMMT/FmmtLib.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/BaseTools/Source/C/FMMT/FmmtLib.c b/BaseTools/Source/C/FMMT/Fm= mtLib.c index b945e9b63d..bfb3b57d4a 100644 --- a/BaseTools/Source/C/FMMT/FmmtLib.c +++ b/BaseTools/Source/C/FMMT/FmmtLib.c @@ -709,10 +709,10 @@ LibGenFfsFile ( free(FfsFileName); FfsFileName =3D NULL; =20 - CurrentFv->FfsNumbers =3D *FfsCount; - *FfsCount +=3D 1; =20 + CurrentFv->FfsNumbers =3D *FfsCount; + if (ErasePolarity) { CurrentFile->State =3D (UINT8)~(CurrentFile->State); } @@ -833,7 +833,6 @@ LibParseSection ( CHAR8 *ToolInputFileName; CHAR8 *ToolOutputFileName; BOOLEAN HasUiSection; - BOOLEAN FirstInFlag; =20 DataOffset =3D 0; GuidAttr =3D 0; @@ -869,7 +868,6 @@ LibParseSection ( EncapDataNeedUpdata =3D TRUE; LargeHeaderOffset =3D 0; HasUiSection =3D FALSE; - FirstInFlag =3D TRUE; =20 =20 while (ParsedLength < BufferLength) { @@ -997,9 +995,7 @@ LibParseSectio= n ( break; =20 case EFI_SECTION_COMPRESSION: - if (FirstInFlag) { - Level ++; - } + Level ++; NumberOfSections ++; =20 EncapDataNeedUpdata =3D TRUE; @@ -1181,9 +1177,7 @@ LibParseSection ( // looks up the appropriate tool to use for extracting // a GUID defined FV section. // - if (FirstInFlag) { - Level ++; - } + Level ++; NumberOfSections++; EncapDataNeedUpdata =3D TRUE; HasUiSection =3D TRUE; @@ -1682,7 +1676,6 @@ LibParseSection ( } =20 ParsedLength +=3D SectionLength; - FirstInFlag =3D FALSE; // // We make then next section begin on a 4-byte boundary // @@ -4198,10 +4191,13 @@ LibEncapNewFvFile( UINT32 header; UINT8 AlignN; UINT8 AlignV[1] =3D {0xFF}; + UINT32 EntryFvId; + AlignN =3D 0; Id =3D 0; InputFileSize =3D 0; TmpFileSize =3D 0; + AlignmentFileSize =3D 0; EncapFvIndex =3D 0; Index =3D 0; OuterIndex =3D 0; @@ -4224,7 +4220,7 @@ LibEncapNewFvFile( IsLargeFile =3D FALSE; OutputFileSize =3D 0; LargeFileSize =3D 0x1000000; - + EntryFvId =3D 0; =20 OutputFileNameList =3D (FFS_INFORMATION *)malloc(sizeof(FFS_INFORMATION)= ); if (OutputFileNameList =3D=3D NULL) { @@ -4261,6 +4257,9 @@ LibEncapNewFvFile( LocalEncapData =3D CurrentEncapData; if (LocalEncapData =3D=3D NULL) { LocalEncapData =3D FvInFd->EncapData; + EntryFvId =3D 0xFFFFFFFF; + } else { + EntryFvId =3D LocalEncapData->FvId; } Level =3D LocalEncapData->Level; Type =3D LocalEncapData->Type; @@ -4274,7 +4273,7 @@ LibEncapNewFvFile( LocalEncapDataNext =3D LocalEncapDataTemp->NextNode; if (LocalEncapDataNext !=3D NULL && LocalEncapDataNext->NextNo= de !=3D NULL) { =20 - LibEncapNewFvFile(FvInFd, TemDir, LocalEncapDataTemp, 1, &= ChildFileNameList); + LibEncapNewFvFile(FvInFd, TemDir,=20 + LocalEncapDataTemp,LocalEncapDataTemp->Level - 1, &ChildFileNameList); ChildFileNameList->ParentLevel =3D LocalEncapDataTemp->Lev= el -1; if (FvInFd->ChildFvFFS =3D=3D NULL) { FvInFd->ChildFvFFS =3D ChildFileNameList; @@ -4329,7 += 4328,7 @@ LibEncapNewFvFile( } else { LocalEncapData =3D CurrentEncapData; while (LocalEncapData !=3D NULL) { - if (Level_Break > 1 && LocalEncapData->Type =3D=3D FMMT_ENCAP_TREE_F= FS) { + if ((LocalEncapData->FvId > EntryFvId) && (LocalEncapData->Type=20 + =3D=3D FMMT_ENCAP_TREE_FFS)) { LocalEncapDataTemp =3D LocalEncapData->RightNode; while (LocalEncapDataTemp !=3D NULL) { LocalEncapDataNext =3D LocalEncapDataTemp->NextNode; @@ -4485,= 7 +4484,7 @@ LibEncapNewFvFile( // FfsFoundFlag =3D FALSE; IsRootFv =3D FALSE; - for (Index=3D0; Index <=3D FvInFd->FfsNumbers; Index++) { + for (Index=3D0; Index < FvInFd->FfsNumbers; Index++) { if (OutputFileNameList !=3D NULL && OutputFileNameList->FFSNam= e !=3D NULL && OutputFileNameList->IsFFS =3D=3D FALSE){ break; } @@ -4818,6 +4817,7 @@ LibEncapNewFvFile( memcpy((char *)OutputFileNameList->FFSName, (char *)OutputFileName, = strlen(OutputFileName)+1); OutputFileNameList->IsFFS =3D TRUE; OutputFileNameList->ParentLevel =3D ParentLevel - 1; + OutputFileNameList->InFvId =3D Id; if (OutputFileNameList->Next =3D=3D NULL){ break; } @@ -5077,10 +5077,6 @@ LibEncapNewFvFile( if (CurrentEncapData =3D=3D NULL) { LocalEncapData =3D FvInFd->EncapData; } else { - if (OutputFileNameList !=3D NULL && OutputFileNameList->FFSName != =3D NULL && OutputFileNameList->IsFFS =3D=3D TRUE) { - *OutputFile =3D OutputFileNameList; - return EFI_SUCCESS; - } LocalEncapData =3D CurrentEncapData; } ParentLevel -=3D 1; -- 2.16.2.windows.1