From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web11.4581.1615782891014456982 for ; Sun, 14 Mar 2021 21:34:51 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=zOSgGDJq; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: bob.c.feng@intel.com) IronPort-SDR: 2vsPSeCMnn1/qpEkH3tY/gmsW/cNjRVrZGG1SVknMClSgf/qKuMreaxUIonWTRWXzwT20pzSUM 7tGGfrstGUiA== X-IronPort-AV: E=McAfee;i="6000,8403,9923"; a="208929910" X-IronPort-AV: E=Sophos;i="5.81,249,1610438400"; d="scan'208";a="208929910" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2021 21:34:43 -0700 IronPort-SDR: QDzCKN5I6kDWFlYtADa+8VVDev3kl6FKV4PCrX2lkp5l5g0g01OsrH9IIq+zQNQMvoAhHffqt9 IKlNrUZB9BgQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,249,1610438400"; d="scan'208";a="590201656" Received: from fmsmsx606.amr.corp.intel.com ([10.18.126.86]) by orsmga005.jf.intel.com with ESMTP; 14 Mar 2021 21:34:43 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Sun, 14 Mar 2021 21:34:42 -0700 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) 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.2106.2; Sun, 14 Mar 2021 21:34:42 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) 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.2106.2 via Frontend Transport; Sun, 14 Mar 2021 21:34:42 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.108) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2106.2; Sun, 14 Mar 2021 21:34:40 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YAGw6npxM5++Xfj7No2LDcODvrd6AhKsfvElNZ6FNiV2ERbLPWTagseZMpoY1nnrTOcWIt25dvPQbH2OXRVpqSJ0x7ky99B3DmHKP4RrY37DctHFkbpg2En888UdullEQ69ZIaRBnxNpnxngEvvJSA/2Jks+vg1Mw9JOFMZLMH3Va6x209NGbfxoi7BRPJTXSTnPsMrP/PzBcvVphiteSmymNJmmMnvnGXbbpeiONCNp/wtozoLcq871ygPC2gLAJFOQ1vSOvOTwG1987cxppI0xBTZIppAOuXk8RAgxb5T7NQNrUrMct+tYhXy4aZMdmy0/3F3t5hk/zdkAKrJVmQ== 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=9P2eNmUoVvWr6M6ToY7qEaipJmb2n1o1ngdEVRrGKDU=; b=Vws/o6uY+OwLQoFE0u/0ReATwrc2kES6lUELsxY0CXGZwCNhAmkDg7eN1bBwLiKUIx3lHWK1OwBS2g5n6o7761f8Fnbb9+sqXqeYpOlj/saZAz8ewfEwUqzwJClXd9QwNYvQFNILumM4CVMfg5cEwyNNAbD4c1DxEmj6C4TerjApBRd/Q2zZVBh81kbVeVbjR/eINoK1tVctf8M4Wu2uHeytBS0D68mpZC+5VMhn/0LEbbT4GsZ6gpIyuR+MCnsqs+CGa8ZHpqmaGA2svqy81eRKhYB79xReXhT0mSaUIGdejVVsFBgZQs0YLMp3yXSrn3Z+NqZnonPDoG+m7/lgRw== 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=9P2eNmUoVvWr6M6ToY7qEaipJmb2n1o1ngdEVRrGKDU=; b=zOSgGDJqCbvwofYtI2ed/V8LyfBHSSbvipMLuIYbggXKy2rHoekVslN7EhQpXgMhZnxmfYKRJxDQSv6OO+YchT5LOQa6m88B17KR4cJSjK5Kt2DWNj+y4LKUzd8IQ/LHKWsP52XCwKeB70CZn8Sl/suQ8HG1HLfyI+hzq+63ckY= Received: from DM6PR11MB4073.namprd11.prod.outlook.com (2603:10b6:5:19f::22) by DM5PR1101MB2108.namprd11.prod.outlook.com (2603:10b6:4:53::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.32; Mon, 15 Mar 2021 04:34:39 +0000 Received: from DM6PR11MB4073.namprd11.prod.outlook.com ([fe80::10db:5760:d7f5:d0e0]) by DM6PR11MB4073.namprd11.prod.outlook.com ([fe80::10db:5760:d7f5:d0e0%3]) with mapi id 15.20.3933.032; Mon, 15 Mar 2021 04:34:38 +0000 From: "Bob Feng" To: "Yeh, GregX" , "devel@edk2.groups.io" , Yunhua Feng CC: Liming Gao 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: AQHXFVHee5nf56AOnE2kZ7LYe1W1YKqEfJRA Date: Mon, 15 Mar 2021 04:34:38 +0000 Message-ID: References: <20210310020528.1924-1-gregx.yeh@intel.com> In-Reply-To: <20210310020528.1924-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.55.46.54] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 49072d2d-15db-447f-cbd5-08d8e76ba50d x-ms-traffictypediagnostic: DM5PR1101MB2108: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:962; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 3RK7akHvssUC0cAFaYuqSuJ7Lpow0uTk68O2+MoY2f05fuOTGMHx7t0re2NweHo6VELcGWjEdS/QNQmgN1gL3k5FjbK3sM6ApY33NDzNFW3ccAG1QD2Lc4q8ANQeHXkuSsa6GYq+QkB0NBsttUeYegoQ/jFKpqR+IhEjtTPjgUkfACCOZCCpUIy8XPFYDt4REQ2ITVUg0RiIenpEuEDsCmgZqYvcjuEi4eVREXGOGFNxG3dUT+7vqQhw+GXq9qoDBR7N1VNoPrx7yLIsCfQZJRix8BLJjP5zD/qHagnuwq2hkRjug+CBYTuJsi5PVLBHgdSQwaXEn2pN4knjTa8nqRz8V2cHo5PuXMHBJwFIhaXJnUtehKNn5bNATl4Zl48z+/q2bVtU07Q8OMzDT6nCTSAinDze/FMFdPUfU/1siUcX33AC9Gz2ZoOGXbV9SyYgtWpPKhwz4m0rodxotozdgwg2jQQi5Ecl+aPRlKcybF7jpGYTdJ75gsPHsTbDIqbTcCeYehwTATjphiDjwaSqv0VJh0meZ00o3E+xr7QolBkp8PJR0XnlsuiFdyLeddAk 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:(346002)(136003)(39860400002)(366004)(376002)(396003)(26005)(83380400001)(53546011)(71200400001)(9686003)(110136005)(52536014)(86362001)(55016002)(6506007)(478600001)(33656002)(8676002)(5660300002)(2906002)(186003)(76116006)(4326008)(66446008)(8936002)(316002)(66476007)(66946007)(64756008)(66556008)(7696005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?gz24A2vXoBIvBjq9J1oCQoB9gbYx8zX1sjs6lCWTtO0dBi17jFGsENfuTFA3?= =?us-ascii?Q?pVj6pk64bxZjY7Lfa4GJuwiULmqHSTXyAUyrMFHFv2Rw7+6T0DwpOA3q1Z8W?= =?us-ascii?Q?mIV4bsan6Hosp/dCKt0PQZnIc6eDqpqnsln1sDasu37tkSo5DjNSSqr5IKpM?= =?us-ascii?Q?43gbgj2i+8smiWfgdXKOAQYzc/Iham6cpLsVbM+oTqfLqSNg03iVBxsq1RyY?= =?us-ascii?Q?5PUqbhyaUQjWqpL0Ys8ikPy3CHdJM6CUqrtLdTmbordY5ZKTHO6SV3+cq4BA?= =?us-ascii?Q?Jtn2tsdOhpAZnFOVihMHt1E0xayO40fnpq/ifJfxCzxGTrnHigTFPCEerY5D?= =?us-ascii?Q?sQj6iXAaZbDACKE44GvIVY7mnN9uXb6kq8GpAe95JrmDJE20f/1wrfJOQUpC?= =?us-ascii?Q?U9E+gdpYuqUeW2m4rR2W/pDJiqqUoOwGTx9dZqJoIUhjH7g8hNlCVwItH7HU?= =?us-ascii?Q?v9BYB4J3ncy6JNvc2PJ8NKysBopX00xsMtQDqXwl9JNqoqy1HchFgk7xFxbK?= =?us-ascii?Q?hZc0upxNtZqdhhF2+hqjHjkqiqZgDWbzp8Qnjqi6md4aawNzAWusglQMYBds?= =?us-ascii?Q?Mp3qxsOZtfcIarvoaeYoAqtUq319jPwEZgDKf+WEEUobTOaj9NnIKUJ4W3yJ?= =?us-ascii?Q?hw+ghzW13sMSkO5ZJN7JDPKx+CMHWIaPCksAPGR110d74QWCwF6xGzCiObtu?= =?us-ascii?Q?eRQL1vcwyiMGb9Qj17M850h+xTEA7fo+5FJfGfc8B6peLcLzv7bhW6BHMAZZ?= =?us-ascii?Q?K7fDZq9+0d6I+vBcVNjGxVMhjQbVEn6mXGS42IN/buz3xLwuxGxj7IOP43oJ?= =?us-ascii?Q?18DR2uN4YWPTujgtF67APYCvlMSNt0cT5A8wcEecpYyXcL4tL921RhzaNLj9?= =?us-ascii?Q?njT7d34tizcUB/76pjHhmbuS9vanXA0nyOGDrPHo5Vz1bZxVq4rOkRsCCbht?= =?us-ascii?Q?W3s7y1Yc/TDqbG3NI9JqUbZP4xuCjam+yWXaD1j5zp0pdK1gGcREL9FYwpRi?= =?us-ascii?Q?P2BwzAq2AW/uA4taDaOASqxH4g0v6iiqyU9+a63FYzE8B6uBnG5Vct8PO8gz?= =?us-ascii?Q?MLk/AS7U+ps0rJf7Lk73lcb2IqUUASWFfCry5P+j0ASlFAJwCHt/C3qsnLyn?= =?us-ascii?Q?GxxlXbpZQBv/8QSBLODC7HbOFyAq26f/l/i+JuL4Aapst1/yZrf0s4t4Tbv6?= =?us-ascii?Q?OI7s1zoTHrrqi5ddKHrfPe1dhdtdNJZoi7LTeBsn1REXi6BLMbQfuOGMfHsk?= =?us-ascii?Q?YkaQEvTGqmqR7z1zO6bcIyelwInXZ9dCdJspgB19+v6Fnvx+5+C7EbW0y/Yv?= =?us-ascii?Q?yWg=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: 49072d2d-15db-447f-cbd5-08d8e76ba50d X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Mar 2021 04:34:38.7957 (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: wFtTg3MkboLSLJibasay6zNHe4aIk8LFo2UGuWC+vPq7GR5efFJ1LT03xs9A/gNqNVTMRUv6WMm33TYg8SjdrA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1101MB2108 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, Please use BaseTools\Scripts\PatchCheck.py to check this patch. There are s= ome lines code format invalid. The logic looks good to me. Yunhua, could you please double check, I remember you have concerns about t= he previous version of this patch. Thanks, Bob -----Original Message----- From: Yeh, GregX =20 Sent: Wednesday, March 10, 2021 10:05 AM 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 | 56 ++++++++++++++++++++++++++---------= ---- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/BaseTools/Source/C/FMMT/FmmtLib.c b/BaseTools/Source/C/FMMT/Fm= mtLib.c index b945e9b63d..26df0181c7 100644 --- a/BaseTools/Source/C/FMMT/FmmtLib.c +++ b/BaseTools/Source/C/FMMT/FmmtLib.c @@ -494,7 +494,7 @@ LibReadFvHeader ( if ((FvLevel -1) =3D=3D 0) { printf ("\n%s :\n", FvName); } else { - printf ("%sChild FV named FV%d of %s\n", BlankSpace, FvCount, FvName= ); + printf ("\n%sChild FV named FV%d of %s\n", BlankSpace, FvCount,=20 + FvName); } } =20 @@ -502,7 +502,7 @@ LibReadFvHeader ( // Print FV header information // if (ViewFlag) { - printf ("\n%sAttributes: %X\n", BlankSpace, (unsigned) Volu= meHeader->Attributes); + printf ("%sAttributes: %X\n", BlankSpace, (unsigned) Volume= Header->Attributes); printf ("%sTotal Volume Size: 0x%08X\n", BlankSpace, (unsigned) Vo= lumeHeader->FvLength); printf ("%sFree Volume Size: 0x%08X\n", BlankSpace, (unsigned) (V= olumeHeader->FvLength - GetFreeOffset(InputFv))); } @@ -789,7 +789,8 @@ LibParseSection ( UINT8 *FvCount, BOOLEAN ViewFlag, BOOLEAN ErasePolarity, - BOOLEAN *IsFfsGenerated + BOOLEAN *IsFfsGenerated, + BOOLEAN IsFfs ) { UINT32 ParsedLength; @@ -997,8 +998,12 @@ LibParseSection ( break; =20 case EFI_SECTION_COMPRESSION: - if (FirstInFlag) { - Level ++; + if (IsFfs){ + Level ++; + } else { + if (FirstInFlag) { + Level ++; + } } NumberOfSections ++; =20 @@ -1159,7 +1164,9 @@ LibParseSection ( FvCount, ViewFlag, ErasePolarity, - IsFfsGenerated); + IsFfsGenerated, + FALSE + ); =20 if (CompressionType =3D=3D EFI_STANDARD_COMPRESSION) { // @@ -1181,8 +1188,12 @@ LibParseSection ( // looks up the appropriate tool to use for extracting // a GUID defined FV section. // - if (FirstInFlag) { + if (IsFfs) { Level ++; + } else { + if (FirstInFlag) { + Level ++; + } } NumberOfSections++; EncapDataNeedUpdata =3D TRUE; @@ -1216,7 +1227,8 @@ LibParseSection ( FvCount, ViewFlag, ErasePolarity, - IsFfsGenerated + IsFfsGenerated, + FALSE ); if (EFI_ERROR(Status)) { Error(NULL, 0, 0003, "parse of decoded GUIDED section failed", N= ULL); @@ -1471,7 +1483,8 @@ LibParseSection ( FvCount, ViewFlag, ErasePolarity, - IsFfsGenerated + IsFfsGenerated, + FALSE ); if (EFI_ERROR (Status)) { Error (NULL, 0, 0003, "parse of decoded GUIDED section failed", = NULL); @@ -1491,7 +1504,8 @@ LibParseSection ( FvCount, ViewFlag, ErasePolarity, - IsFfsGenerated + IsFfsGenerated, + FALSE ); if (ExtractionTool !=3D NULL) { free (ExtractionTool); @@ -2016,7 +2030,7 @@ LibGetFileInfo ( =20 LocalEncapData->Level =3D Level; LocalEncapData->Type =3D FMMT_ENCAP_TREE_FFS; - LocalEncapData->FvExtHeader =3D NULL; + LocalEncapData->FvExtHeader =3D NULL; LocalEncapData->Depex =3D NULL; LocalEncapData->DepexLen =3D 0; LocalEncapData->UiNameSize =3D 0; @@ -2099,7 +2113,8 @@ LibGetFileInfo ( FvCount, ViewFlag, ErasePolarity, - &IsGeneratedFfs + &IsGeneratedFfs, + TRUE ); } if (EFI_ERROR (Status)) { @@ -4198,10 +4213,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 +4242,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 +4279,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 +4295,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 += 4350,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; @@ -4818,= 6 +4839,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 +5099,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