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.web10.14058.1586956854417282849 for ; Wed, 15 Apr 2020 06:20:54 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=V53Nlrep; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: liming.gao@intel.com) IronPort-SDR: uvkqzrVPcVsyZuuEuAM9pAkcHnGkZGd0A1o4uP1yCTp/B6mjzg0ptcWcfffzXzh1JUoMDts6Ip slrpFkoGW+aQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2020 06:20:53 -0700 IronPort-SDR: 9dR62lSY7qKfwFNOVberT955oQ0GG2lgj6ULJK3WYQFnqUSwipac1nUEraeTGbyjA1fbaG/DF7 yJi0r2m9Eh3A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,387,1580803200"; d="scan'208";a="363668032" Received: from orsmsx103.amr.corp.intel.com ([10.22.225.130]) by fmsmga001.fm.intel.com with ESMTP; 15 Apr 2020 06:20:53 -0700 Received: from orsmsx156.amr.corp.intel.com (10.22.240.22) by ORSMSX103.amr.corp.intel.com (10.22.225.130) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 15 Apr 2020 06:20:53 -0700 Received: from ORSEDG002.ED.cps.intel.com (10.7.248.5) by ORSMSX156.amr.corp.intel.com (10.22.240.22) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 15 Apr 2020 06:20:52 -0700 Received: from NAM04-BN3-obe.outbound.protection.outlook.com (104.47.46.51) by edgegateway.intel.com (134.134.137.101) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 15 Apr 2020 06:20:52 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZRhomd+fp9FVdF94I3kchCK2ZnT1U6sJOVf39h4rb7UlCe2JJn05KLFNxwuE8DiefFzFhHUlgC4XRXIfqq1JDW3NBrzWA4+9mcsUFk8t1696ZthDJq+NrCacAMsN/u5jMTkZXVKPUedpZlgBy3Xgq/zpdRpx/k/zp5MKWivkWVPG2hqDyg5ympvpUu61evxrhz8L+CjNeb8hjEKinZRBxJskFfDV9gFEG1q5RYHRevYug+LtrP2itYIEv+FnhS3DukDbHU+ngGctBmKOGel0kSbbDn6mt/NqSlzShaFQEDxlmKV7VOJVkSAryjs/z+8nyOpKCpV2S9a8YU9utYkeZQ== 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=mCkOGctS/088WHfJoQKF9R+xBdVLlk2/1Ey81AH/Xzc=; b=CbUqQ8Oo8B8GxSZP8q0Hu/I5GDBfQwRX1jXNpwwDeHyoYWr9QTozvebeJwLJ8cYN+EHL2i03x6pQJ2xugMFwlhokfF//QyMQWSPiQJ261ZS5GxdZl6PcctKee9XiDhNCQdUXn09cuf3d5/e2h48ZjvDEULbpDO+K3wCTs0uwipx7JZ4KDl6Y6ClP8kGpAPihi8GH/Aq6N41Rh1fsu+iF8C1Yujd8WPibK/zA+EIdPnqcft0/SJF3L5N30RhLzTAa1vjL31UV7WFEfy7AQSdfqnKJsW5WByYFp/xOfNMwogkJ03LySQZA8M2UJFM03nxXzWDuSjtJ89gagngbdZHzIQ== 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=mCkOGctS/088WHfJoQKF9R+xBdVLlk2/1Ey81AH/Xzc=; b=V53NlrepizE5hm7GHm02gV94M1M5llONDv4q4qsv0SxatDaELcliFaFQQdPfouqs40WScjrGUgoZfE4EKr7QCJlFz48koSNiagFxksi7gI+sqGYZp2/iXTPFO/E2dqvEiipZ0xa2v66op6EFOVnV2LRPFd5n3z54mq6+qsAe50o= Received: from BN6PR11MB3972.namprd11.prod.outlook.com (2603:10b6:405:7f::11) by BN6PR11MB2051.namprd11.prod.outlook.com (2603:10b6:404:49::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2900.20; Wed, 15 Apr 2020 13:20:50 +0000 Received: from BN6PR11MB3972.namprd11.prod.outlook.com ([fe80::4dcc:bc5c:def:9ae9]) by BN6PR11MB3972.namprd11.prod.outlook.com ([fe80::4dcc:bc5c:def:9ae9%5]) with mapi id 15.20.2900.028; Wed, 15 Apr 2020 13:20:50 +0000 From: "Liming Gao" To: "Fan, ZhijuX" , "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/dA Date: Wed, 15 Apr 2020 13:20:50 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.2.0.6 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: spf=none (sender IP is ) smtp.mailfrom=liming.gao@intel.com; x-originating-ip: [192.55.52.201] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9045f5f3-d7db-4353-612a-08d7e13fd12d x-ms-traffictypediagnostic: BN6PR11MB2051: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3631; x-forefront-prvs: 0374433C81 x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN6PR11MB3972.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(10019020)(396003)(346002)(136003)(39860400002)(376002)(366004)(5660300002)(66556008)(71200400001)(7696005)(33656002)(53546011)(9686003)(316002)(110136005)(4326008)(186003)(66446008)(66476007)(76116006)(64756008)(8936002)(2906002)(86362001)(81156014)(6506007)(55016002)(8676002)(26005)(66946007)(52536014)(478600001)(107886003);DIR:OUT;SFP:1102; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 3qauC1ljuBBP4CC+arLk4Xp8Ja5aGiuzRyKEsJmZPyhUY9TWiHM2QHgbZtmh5IV9n7eQPw9BijnYSMhC1zQGMW4hM2ilJfq5U07ggRglTjUxK60/BRszU6JU6WKWm0PyPjqCOEMaktoHgDYcwm38GW+HymR/mhIKfoojmiG9bOJJiSeOxt2VPd6QONTD3hnjKDQSB42Plx52t31EUHpW/3pBR0nm/9phHhRNpMZnjLpDaZ13Yjxyb5PrWSQ2Rl8uUtWfHlmnvaD8yqVnp1QQyYlw2AX3IHu4QeDD9tUODHoGhfEGPS0tJcRs55/pGeukjUJR+lacjg4ZbUmRbJyDDkqx4U2oFccohJgolmJHEoxGIG2lME7/vcuIy66LsShCFSc4vOnfZXGNo69y00VsTeKyksgKcRUaDGJ2HMRVSuXyyiX2MyI9MkGN6VRScEniIC/1tb9lCGsRNriJnERii8033+zxMHqnYG19CJrmnZL1hT4n/5CrHVy0TRRadEnmIZKZjEBY0mFDcm8cjvEbjA== x-ms-exchange-antispam-messagedata: 4LnrFGuzfEjwm8BNdQp28ZlpxUzCtEUBgScM+ylabtmS1D9RuyPcnoDPQUPUZbpLGk8/V1NImJh57l1VUkYjrCkD5cnfkLs8+C+vTS6c4JXc74wkC1hI+zec6zK3zFoQHr2XOZgV7IgeN7e/Jm3vkg== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 9045f5f3-d7db-4353-612a-08d7e13fd12d X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Apr 2020 13:20:50.2807 (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: lv0i5WbPwU/ZfkIdQA1NsyZ0zOmlQ3CkcXRGyfvF+60WethlZd10kH9Fh9tD26/UCnGZH8bWdaw9dxyXw1hkbQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB2051 Return-Path: liming.gao@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Zhiju: Thanks for your update. The change is good to me. For the report error me= ssage, I suggest as below xx FV free space xxxx is not enough to meet with the required spare space x= xxx set by -D FV_SPARE_SPACE_THRESHOLD option. 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 >=20 > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2654 >=20 > 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. >=20 > 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. >=20 > Cc: Liming Gao > Cc: Bob Feng > Signed-off-by: Zhiju.Fan > --- > changed the error message >=20 > BaseTools/Source/Python/Common/BuildToolError.py | 2 + > BaseTools/Source/Python/build/build.py | 47 ++++++++++ > 2 files changed, 49 insertions(+) >=20 > 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 >=20 > PERMISSION_FAILURE =3D 0x8000 >=20 > +FV_FREESIZE_ERROR =3D 0x9000 > + > CODE_ERROR =3D 0xC0DE >=20 > AUTOGEN_ERROR =3D 0xF000 > diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Py= thon/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 >=20 > @@ -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.FvD= ir) > return True >=20 > # 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.Fv= Dir) >=20 > # > # Create MAP file for all platform FVs after Gen= Fds. > @@ -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_S= PACE_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_SP= ACE_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.Profi= le.FvDict if > FdfParserObject.Profile.FvDict[FvName].FvRegionInFD] > + for FvName in FdfParserObject.Profile.FvDict: > + if FvName in FvRegionNameList: > + FvSpaceInfoFileName =3D os.path.join(FvDir, FvName.upper= () + '.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].stri= p() =3D=3D 'EFI_FV_SPACE_SIZE': > + FreeSizeValue =3D int(NameValue[1].strip(), = 0) > + if FreeSizeValue < Threshold: > + EdkLogger.error("build", FV_FREESIZE_ERR= OR, > + 'the required spare spac= e in fv image size %d of %s FV exceeds the set spare space in fv image size= %d' % > ( > + FreeSizeValue, FvNam= e, Threshold)) > + break > + > ## Generate GuidedSectionTools.txt in the FV directories. > # > def CreateGuidedSectionToolsFile(self,Wa): > -- > 2.14.1.windows.1