From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.10436.1587345432767847196 for ; Sun, 19 Apr 2020 18:17:12 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=s0Djrz9V; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: zhijux.fan@intel.com) IronPort-SDR: K7ySxjnDW4U9kzy8kKe7XnLQawaXHpSqvt8fLOa3y5OPrHQrasnP5/lkhm+tn2Gp9i1CELhEBY aRhPpypfP9Eg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2020 18:17:11 -0700 IronPort-SDR: HPIJ8C8k43paetoWkLkGor1wiBPHJ38byM69RDrQa0FXUur/BcyS9jxmjmpnqzYdNFmkxSVNDz BPwGO0Q95eZQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,405,1580803200"; d="scan'208";a="428937454" Received: from orsmsx107.amr.corp.intel.com ([10.22.240.5]) by orsmga005.jf.intel.com with ESMTP; 19 Apr 2020 18:17:11 -0700 Received: from orsmsx116.amr.corp.intel.com (10.22.240.14) by ORSMSX107.amr.corp.intel.com (10.22.240.5) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 19 Apr 2020 18:17:11 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by ORSMSX116.amr.corp.intel.com (10.22.240.14) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 19 Apr 2020 18:17:11 -0700 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.44) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 19 Apr 2020 18:17:11 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k50CqYyNIkx4EwmWGk0hCfBWx42Q44vTPG7WUmDs1HioIi+eAxnKIqsKacHQxPszLiTVjuCWrwxEFCmH6O7KSo0V0ODqg24jMW2ZLco6WyupxwT05W7kIonIPOChIBUaw07ihSa2I+FuW1ZC8MeoNzxRLhpiLgkrsGzp8lr2NMkUb4VHbilJKl6bmJ/WWv0UGZfrjwBzIK6A+1RG4yuqQg+eNr4opaZJpZrQcI94w7pF4mQMZIg8ne6VGlCw6Z5jUg4K8rKrO4zrHiZfzF+jbd+TVVD4uEKe45NVCXhN4NQDWR4hr9w153DWRx6w9EBJ6E/xwt13YvLBVu0ynrOAOQ== 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=Z09b/lvjKgHYU2VR/IXJ9PjDaMkNbYS83TWoCkxdlDM=; b=QaokmTg61fWT60UUf+ZugleVu6vMjY+tjxZKSel+cnYZl545FgYdJZ4dRCFSOvUFNSw5IwCYqx7Xz2SVvz/UdPvlzuglBmS9+CUOpks+tYWvEfyQYYzAvtCUjMF4C0l88l1mVd6d+Uu5hlogM5f06PoPLV+J2vz18KLX2QucZPPLYJaW2pWDfHADXhiMFtcr5p8SLUQy2lHZph53+TP93++A+C6AXRQ6J6JiGxoavoouUbDY4hGvYefyb7K6S2Bgp0wF4NqN5GccgQg6yK84ZCDelfOxi5K/YnlmkuLdd7sq2fhI5/A/bUQcBBwqNZc4QnqIxUCeLQ8j/95VmCRWNg== 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=Z09b/lvjKgHYU2VR/IXJ9PjDaMkNbYS83TWoCkxdlDM=; b=s0Djrz9VhDpUd1UR8dSSSyfojzUHCsEkrqYyElzyPtS9RMqPe2D084jjhb/T9cR1lsOgay5w3KlyzrRiIuMGckg182jPZJRwj40mQ8xRZMaW6MFFjRQndcXDuo/nq8tfk/+Wq2pGgoDMxhRZkp+LFkKsqRVvRX3NtxmP/HiIqII= Received: from CY4PR11MB1479.namprd11.prod.outlook.com (2603:10b6:910:5::9) by CY4PR11MB1574.namprd11.prod.outlook.com (2603:10b6:910:f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.29; Mon, 20 Apr 2020 01:17:09 +0000 Received: from CY4PR11MB1479.namprd11.prod.outlook.com ([fe80::bc01:878b:fa1a:82e0]) by CY4PR11MB1479.namprd11.prod.outlook.com ([fe80::bc01:878b:fa1a:82e0%7]) with mapi id 15.20.2921.027; Mon, 20 Apr 2020 01:17:09 +0000 From: "Fan, ZhijuX" To: "Gao, Liming" , "devel@edk2.groups.io" CC: "Feng, Bob C" Subject: Re: [PATCH V6] BaseTools:Add the spare space FV image size checker Thread-Topic: [PATCH V6] BaseTools:Add the spare space FV image size checker Thread-Index: AdYTG+StwkWvx/K8QluZzoxQvzOdKwAC2/dAAOJo0PA= Date: Mon, 20 Apr 2020 01:17:09 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-reaction: no-action dlp-version: 11.2.0.6 dlp-product: dlpe-windows authentication-results: spf=none (sender IP is ) smtp.mailfrom=zhijux.fan@intel.com; x-originating-ip: [192.55.52.219] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6a64af5c-f414-462f-688f-08d7e4c88c79 x-ms-traffictypediagnostic: CY4PR11MB1574: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4941; x-forefront-prvs: 03793408BA x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR11MB1479.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(10019020)(346002)(366004)(396003)(39860400002)(136003)(376002)(5660300002)(107886003)(52536014)(4326008)(66556008)(66946007)(66476007)(66446008)(76116006)(33656002)(478600001)(9686003)(64756008)(55016002)(2906002)(71200400001)(110136005)(186003)(86362001)(316002)(53546011)(6506007)(8676002)(7696005)(81156014)(8936002)(26005);DIR:OUT;SFP:1102; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: weV57iiFFSE50oOFsacKbF9uPnV32QKqnyWi8D/X4/gUhvK7yC/gnjk6wNwULUSJPUKajHcLk0Ts4GbSNwmjjiGNsBKKsTgJnfxzxqlk2QkT2MU0qJYKNKk3f5lQ2+nyUr9qT85QsE1vhHu9QQvUxBiJ6gdQ/QDjI8r8XFTb7ToaKP7js46TMrxWMIgHPPWY7/jK8B0bgQSSI69TKWfQ3iWG46l+2WtJAEGE2NlsWg9L3uplmkuHwXaRlqQeE3hQt9YxYW2E0kn+6rw81EL82E9hsWzKX0L8JTUq+72wTUu5wL3crd4gYwjWiHOQPndr8fZA1+Iv4qHLr+woOhcxohAVQeqrjEED1GWKeXMeENTf0gOWDeB9v8VXhc8iiF64CLyehCoRl0YQCIwvFrPBD09GWfZdMJfhTf5JOrlcVVIU7gTAX8Zl1F4ELaGvxvChF7LHn8hcDvNnJMyeCxM9yKN2J1OiojrOlAokLRWz9uTNMphoc8fi0P+7MghhRnNnJa0hKqfHy9O/yR6Wm3u7Rw== x-ms-exchange-antispam-messagedata: z6AhtCBS23346MqFnPMKYRX6ZldISErqN6Dz8XbIiiN05+2pmewRGB8JdTC9w+v4ws2QH4Eb0WFmKOd+t0ZtTS25RW4KAyGtpUSnMInaVIrGRcpOvi16jcfnTD4ycs/R8NPmvj9lOGb+tAs3QkEAGA== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 6a64af5c-f414-462f-688f-08d7e4c88c79 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Apr 2020 01:17:09.6344 (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: +WDVebS2XxDJw7nI0W52SKeQ0RZXySwwml5B72K42O4uVWDonJ/GKaWGO8nwVLJNmo9R+Gb1RKWMK54Oxi56LQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB1574 Return-Path: zhijux.fan@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi LiMing, I agree with this change and will improve it Any question, please let me know. Thanks. Best Regards Fan Zhiju > -----Original Message----- > From: Gao, Liming > Sent: Wednesday, April 15, 2020 9:21 PM > To: Fan, ZhijuX ; devel@edk2.groups.io > Cc: Feng, Bob C > Subject: RE: [PATCH V6] BaseTools:Add the spare space FV image size check= er >=20 > Zhiju: > Thanks for your update. The change is good to me. For the report error > message, I suggest as below >=20 > xx FV free space xxxx is not enough to meet with the required spare space= xxxx > set by -D FV_SPARE_SPACE_THRESHOLD option. >=20 > Thanks > Liming > > -----Original Message----- > > From: Fan, ZhijuX > > Sent: Wednesday, April 15, 2020 7:49 PM > > To: devel@edk2.groups.io > > Cc: Gao, Liming ; Feng, Bob C > > > > Subject: [PATCH V6] BaseTools:Add the spare space FV image size > > checker > > > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2654 > > > > If FV is placed in FD region, its FV image size is fixed. > > When FV image size exceeds it, it will trig the build break. > > To alert the developer to adjust FV image size earlier, I request to > > add new checker for the the spare FV space. > > When the spare FV space is less than the specified threshold, build > > tool will report the error. > > > > This checker is the optional. > > It can be enabled by -D FV_SPARE_SPACE_THRESHOLD=3D10000. > > Macro is the value of the spare space threshold size. > > It can be decimal or hex format. If it is enabled, BaseTools will > > check every FV with the fixed size. > > If FV doesn't meet with the size requirement, Build tool will report > > error message to say there is no enough spare space. > > > > Cc: Liming Gao > > Cc: Bob Feng > > Signed-off-by: Zhiju.Fan > > --- > > changed the error message > > > > BaseTools/Source/Python/Common/BuildToolError.py | 2 + > > BaseTools/Source/Python/build/build.py | 47 ++++++++++ > > 2 files changed, 49 insertions(+) > > > > diff --git a/BaseTools/Source/Python/Common/BuildToolError.py > > b/BaseTools/Source/Python/Common/BuildToolError.py > > index ecc83d0f48bd..21549683cd19 100644 > > --- a/BaseTools/Source/Python/Common/BuildToolError.py > > +++ b/BaseTools/Source/Python/Common/BuildToolError.py > > @@ -64,6 +64,8 @@ COMMAND_FAILURE =3D 0x7000 > > > > PERMISSION_FAILURE =3D 0x8000 > > > > +FV_FREESIZE_ERROR =3D 0x9000 > > + > > CODE_ERROR =3D 0xC0DE > > > > AUTOGEN_ERROR =3D 0xF000 > > diff --git a/BaseTools/Source/Python/build/build.py > > b/BaseTools/Source/Python/build/build.py > > index bec848a7b2e3..68f5b8cabea3 100755 > > --- a/BaseTools/Source/Python/build/build.py > > +++ b/BaseTools/Source/Python/build/build.py > > @@ -25,6 +25,7 @@ import traceback > > import multiprocessing > > from threading import Thread,Event,BoundedSemaphore import threading > > +from linecache import getlines > > from subprocess import Popen,PIPE, STDOUT from collections import > > OrderedDict, defaultdict > > > > @@ -1413,6 +1414,9 @@ class Build(): > > if Target =3D=3D 'fds': > > if GenFdsApi(AutoGenObject.GenFdsCommandDict, self.Db): > > EdkLogger.error("build", COMMAND_FAILURE) > > + Threshold =3D self.GetFreeSizeThreshold() > > + if Threshold: > > + self.CheckFreeSizeThreshold(Threshold, > > + AutoGenObject.FvDir) > > return True > > > > # run > > @@ -2311,6 +2315,9 @@ class Build(): > > GenFdsStart =3D time.time() > > if GenFdsApi(Wa.GenFdsCommandDict, self.Db): > > EdkLogger.error("build", COMMAND_FAILURE) > > + Threshold =3D self.GetFreeSizeThreshold() > > + if Threshold: > > + self.CheckFreeSizeThreshold(Threshold, > > + Wa.FvDir) > > > > # > > # Create MAP file for all platform FVs after G= enFds. > > @@ -2322,6 +2329,46 @@ class Build(): > > # > > self._SaveMapFile(MapBuffer, Wa) > > self.CreateGuidedSectionToolsFile(Wa) > > + > > + ## GetFreeSizeThreshold() > > + # > > + # @retval int Threshold value > > + # > > + def GetFreeSizeThreshold(self): > > + Threshold =3D None > > + Threshold_Str =3D > GlobalData.gCommandLineDefines.get('FV_SPARE_SPACE_THRESHOLD') > > + if Threshold_Str: > > + try: > > + if Threshold_Str.lower().startswith('0x'): > > + Threshold =3D int(Threshold_Str, 16) > > + else: > > + Threshold =3D int(Threshold_Str) > > + except: > > + EdkLogger.warn("build", 'incorrect value for > > + FV_SPARE_SPACE_THRESHOLD %s.Only decimal or hex format is allowed.' > > + % > > Threshold_Str) > > + return Threshold > > + > > + def CheckFreeSizeThreshold(self, Threshold=3DNone, FvDir=3DNone): > > + if not isinstance(Threshold, int): > > + return > > + if not isinstance(FvDir, str) or not FvDir: > > + return > > + FdfParserObject =3D GlobalData.gFdfParser > > + FvRegionNameList =3D [FvName for FvName in > > + FdfParserObject.Profile.FvDict if > > FdfParserObject.Profile.FvDict[FvName].FvRegionInFD] > > + for FvName in FdfParserObject.Profile.FvDict: > > + if FvName in FvRegionNameList: > > + FvSpaceInfoFileName =3D os.path.join(FvDir, FvName.upp= er() + > '.Fv.map') > > + if os.path.exists(FvSpaceInfoFileName): > > + FileLinesList =3D getlines(FvSpaceInfoFileName) > > + for Line in FileLinesList: > > + NameValue =3D Line.split('=3D') > > + if len(NameValue) =3D=3D 2 and NameValue[0].st= rip() =3D=3D > 'EFI_FV_SPACE_SIZE': > > + FreeSizeValue =3D int(NameValue[1].strip()= , 0) > > + if FreeSizeValue < Threshold: > > + EdkLogger.error("build", FV_FREESIZE_E= RROR, > > + 'the required spare > > + space in fv image size %d of %s FV exceeds the set spare space in fv > > + image size %d' % > > ( > > + FreeSizeValue, FvN= ame, Threshold)) > > + break > > + > > ## Generate GuidedSectionTools.txt in the FV directories. > > # > > def CreateGuidedSectionToolsFile(self,Wa): > > -- > > 2.14.1.windows.1