From nobody Mon Nov 25 12:15:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+69530+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+69530+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1609729887; cv=none; d=zohomail.com; s=zohoarc; b=Cb2ilxWaSOQqUkp/kwTV1LOzH+hT/PikPwStladA2m0D5B1d1vbNI8vAyaQiOa6XUcE7qWqa7sf3QjxYsrdjagoehwBz5dZaYEYSxJOTkaftfo5MO+3Ag9DKH1AlKnVuiwRt6koOPSqyee5Jo1gpw9lSIIwG31p//G3JKc2k6vE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609729887; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To; bh=w2rNtt2z5bdlqhFhKAEOyu2LC3LeBBGwMroCpbsVX1M=; b=OUIMnfLmdcSGPzRAUTevBQ4kFl7W6CalUVOb4s1S4LTnRcHRDHKFt2Ot+EsscglfgTKKksHf87SYkTyJcsXPYdK08JSe4RvgWb8IDMWVYnne6blSRfTME8eKcbZrN6Y61LNz7nXHhssQfjbVhvvFJrdGKJto+RPkYWRGE8Lw7GU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+69530+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16097298872231018.9550535098077; Sun, 3 Jan 2021 19:11:27 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id Yi9AYY1788612xUj0e4rdlyv; Sun, 03 Jan 2021 19:11:26 -0800 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web09.8730.1609729880688899991 for ; Sun, 03 Jan 2021 19:11:21 -0800 IronPort-SDR: TyuAvy5FYCv81zMSs8q6+aTAfe+9zpjKyYpysG3RqGVhp8j1CDoT3F6m7TwCg0/Ea/Kl2dknFX NJboRDItaoVg== X-IronPort-AV: E=McAfee;i="6000,8403,9853"; a="156099023" X-IronPort-AV: E=Sophos;i="5.78,472,1599548400"; d="scan'208";a="156099023" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2021 19:11:19 -0800 IronPort-SDR: h4Mg7MVvFNx4OmsmTfa8LRdF3IlU3ymg7AmMgRY1HS3vhfn82jtzWK3PPh7SmI9Gjunje0UrWt +IVcZhgr5lnw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,472,1599548400"; d="scan'208";a="349738648" X-Received: from chinghux-desk1.gar.corp.intel.com ([10.5.215.141]) by fmsmga008.fm.intel.com with ESMTP; 03 Jan 2021 19:11:18 -0800 From: "GregX Yeh" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao Subject: [edk2-devel] [PATCH] [edk2-staging] BaseTools/FMMT: Replace file failure when FV level over 2 Date: Mon, 4 Jan 2021 11:11:13 +0800 Message-Id: <20210104031113.16100-1-gregx.yeh@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,gregx.yeh@intel.com X-Gm-Message-State: 5s4FY9JV9JGFwPyqiBmf8ntBx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1609729886; bh=LOD7daDaIQhS7f6Yw7R4fVsY+tVFAZyku4myPb0qxm0=; h=Cc:Date:From:Reply-To:Subject:To; b=ueMoJ9BtVMuJBz56Sq8CSk2koS+fx6yPBScFb+jRV2b5qQ+dqqY7m3PiNJv/fusugUP B1RqhU5ya/V7uSSkNEVsQIF17kX2B4U/yT52qvjGtWHZJMAz36KhWwW2AHaSbfMiYnbSf klafF4IC97YKdAuA9/+FNPnCzWRRg6RKRVQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/BaseTools/Source/C/FMMT/FmmtLib.c b/BaseTools/Source/C/FMMT/Fm= mtLib.c index b945e9b63d..60bd47e5bb 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 @@ LibParseSection ( 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, LocalEncapDataTemp,Local= EncapDataTemp->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 =3D= =3D FMMT_ENCAP_TREE_FFS)) { LocalEncapDataTemp =3D LocalEncapData->RightNode; while (LocalEncapDataTemp !=3D NULL) { LocalEncapDataNext =3D LocalEncapDataTemp->NextNode; @@ -4473,7 +4472,7 @@ LibEncapNewFvFile( while (LocalEncapData->Level !=3D ParentLevel) { LocalEncapData =3D LocalEncapData->NextNode; } - for (Index =3D 0; Index <=3D FvInFd->FfsNumbers; Index++) { + for (Index =3D 0; Index < FvInFd->FfsNumbers; Index++) { if ((memcmp(&FvInFd->FfsAttuibutes[Index].GuidName, &(Loca= lEncapData->FvExtHeader->FvName), sizeof(EFI_GUID)) =3D=3D 0)) { SubFvId =3D Index; break; @@ -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; --=20 2.16.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#69530): https://edk2.groups.io/g/devel/message/69530 Mute This Topic: https://groups.io/mt/78798812/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-