From nobody Tue May 14 01:40:02 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+107019+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+107019+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1689689822; cv=none; d=zohomail.com; s=zohoarc; b=FBa0p5kQitFv8DBBtVGCfA6Tm0pYqcb4dEFRx1vJ6n2faThKkZK8l3ct6wFL6He+nqz3lDqGXcU5aYhRQJr8OgSwsItAulJeTpSvgWRpdvGaj/3fYA9oMZTaQk/5D7UGXYdd/t0dtUpaVW7/2JGDQZbFGa8N97BjTPNaax1NL3E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689689822; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=2uCP4SbQxWg1nTpLSlY8JRWPbKg+r3bBJs1yK7zHcA4=; b=LudkRlvUIsGzB6jr/aCFAwJDffZqv8OA2oqmt+rTA28WSdl/PKHmuz6aDgNkqUeEoAspQ3LPZtOEXM7hw1gh5+phtgTbO9uFOhFjI0lsdJluszIGbM7cizV72Ed7C9sqNtvn9ijKwz9GEVwptC7vWxjaJBBkvSOS6mYIBgq+4Kw= 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+107019+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16896898229661014.6492776589056; Tue, 18 Jul 2023 07:17:02 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=zzRujUhlKoFdVsgnw0KEQo8DXxpw+lJnh9DYnrrMa0Q=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:X-IronPort-AV:X-IronPort-AV:X-Received:X-ExtLoop1:X-IronPort-AV:X-IronPort-AV:X-Received:From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Unsubscribe:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:X-Gm-Message-State:Content-Transfer-Encoding; s=20140610; t=1689689822; v=1; b=XIwcStyO5HCYxKRC/2lWhsJdgjCI/iQMEEXBKLJtHx6X309fmX9NNunNq7a7lBMt6XUAnzqd bP5mKy3sBJvC44QGpBwJJEHUTpshEkgioOybsZlK+5PTvDDc3RbpTUDCRGnRoVFjpUwvTeuANlu k7d8NgVTYCBhQcom7AQ3pIHs= X-Received: by 127.0.0.2 with SMTP id 0sHqYY1788612xYS4YRyPw3G; Tue, 18 Jul 2023 07:17:02 -0700 X-Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web10.8826.1689689821653226847 for ; Tue, 18 Jul 2023 07:17:02 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10775"; a="356161639" X-IronPort-AV: E=Sophos;i="6.01,214,1684825200"; d="scan'208";a="356161639" X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2023 07:16:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10775"; a="837295882" X-IronPort-AV: E=Sophos;i="6.01,214,1684825200"; d="scan'208";a="837295882" X-Received: from tedkuo1-desk1.gar.corp.intel.com ([10.5.215.137]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2023 07:16:52 -0700 From: "Kuo, Ted" To: devel@edk2.groups.io Cc: Chasel Chiu , Nate DeSimone , Star Zeng , Ashraf Ali S , Chinni B Duggapu , Ray Han Lim Ng , Susovan Mohapatra Subject: [edk2-devel][PATCH v1] SplitFspBin.py cannot support FSP binary with child FV included Date: Tue, 18 Jul 2023 22:15:50 +0800 Message-Id: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,ted.kuo@intel.com X-Gm-Message-State: 7Mmoy3S7d8urVVClFPSOkvQmx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1689689847566100001 Content-Type: text/plain; charset="utf-8" https://bugzilla.tianocore.org/show_bug.cgi?id=3D4502 Update SplitFspBin.py to support child FV in FSP binary. Without the patch, the tool won't be able to rebase the images in child FV in FSP binary. Cc: Chasel Chiu Cc: Nate DeSimone Cc: Star Zeng Cc: Ashraf Ali S Cc: Chinni B Duggapu Cc: Ray Han Lim Ng Cc: Susovan Mohapatra Signed-off-by: Ted Kuo --- IntelFsp2Pkg/Tools/SplitFspBin.py | 32 ++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/IntelFsp2Pkg/Tools/SplitFspBin.py b/IntelFsp2Pkg/Tools/SplitFs= pBin.py index 419e5ba985..2e7550dbb2 100644 --- a/IntelFsp2Pkg/Tools/SplitFspBin.py +++ b/IntelFsp2Pkg/Tools/SplitFspBin.py @@ -469,6 +469,7 @@ class FirmwareVolume: else: self.FvExtHdr =3D None self.FfsList =3D [] + self.ChildFvList =3D [] =20 def ParseFv(self): fvsize =3D len(self.FvData) @@ -483,8 +484,18 @@ class FirmwareVolume: offset =3D fvsize else: ffs =3D FirmwareFile (offset, self.FvData[offset:offset + = int(ffshdr.Size)]) - ffs.ParseFfs() - self.FfsList.append(ffs) + csoffset =3D offset + sizeof (EFI_FFS_FILE_HEADER) + cshdr =3D EFI_COMMON_SECTION_HEADER.from_buffer (self.FvDa= ta, csoffset) + # check if there is child fv + if (ffs.FfsHdr.Type =3D=3D EFI_FV_FILETYPE.FIRMWARE_VOLUME= _IMAGE and cshdr.Type =3D=3D EFI_SECTION_TYPE.RAW): + childfvoffset =3D csoffset + sizeof (EFI_COMMON_SECTIO= N_HEADER) + int(cshdr.Size) + childfvhdr =3D EFI_FIRMWARE_VOLUME_HEADER.from_buffer = (self.FvData, childfvoffset) + childfv =3D FirmwareVolume (childfvoffset, self.FvData= [childfvoffset:childfvoffset + int(childfvhdr.FvLength)]) + childfv.ParseFv () + self.ChildFvList.append(childfv) + else: + ffs.ParseFfs() + self.FfsList.append(ffs) offset +=3D int(ffshdr.Size) offset =3D AlignPtr(offset) =20 @@ -789,6 +800,13 @@ def SplitFspBin (fspfile, outdir, nametemplate): hfsp.write(fv.FvData) hfsp.close() =20 +def GetImageFromFv (fd, parentfvoffset, fv, imglist): + for ffs in fv.FfsList: + for sec in ffs.SecList: + if sec.SecHdr.Type in [EFI_SECTION_TYPE.TE, EFI_SECTION_TYPE.P= E32]: # TE or PE32 + offset =3D fd.Offset + parentfvoffset + fv.Offset + ffs.Of= fset + sec.Offset + sizeof(sec.SecHdr) + imglist.append ((offset, len(sec.SecData) - sizeof(sec.Sec= Hdr))) + def RebaseFspBin (FspBinary, FspComponent, FspBase, OutputDir, OutputFile): fd =3D FirmwareDevice(0, FspBinary) fd.ParseFd () @@ -832,11 +850,11 @@ def RebaseFspBin (FspBinary, FspComponent, FspBase, O= utputDir, OutputFile): imglist =3D [] for fvidx in fsp.FvIdxList: fv =3D fd.FvList[fvidx] - for ffs in fv.FfsList: - for sec in ffs.SecList: - if sec.SecHdr.Type in [EFI_SECTION_TYPE.TE, EFI_SECTIO= N_TYPE.PE32]: # TE or PE32 - offset =3D fd.Offset + fv.Offset + ffs.Offset + se= c.Offset + sizeof(sec.SecHdr) - imglist.append ((offset, len(sec.SecData) - sizeof= (sec.SecHdr))) + GetImageFromFv (fd, 0, fv, imglist) + # get image from child fv + for childfv in fv.ChildFvList: + print ("Get image from child fv of fv%d, parent fv offset:= 0x%x" % (fvidx, fv.Offset)) + GetImageFromFv (fd, fv.Offset, childfv, imglist) =20 fcount =3D 0 pcount =3D 0 --=20 2.40.1.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 (#107019): https://edk2.groups.io/g/devel/message/107019 Mute This Topic: https://groups.io/mt/100216127/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-