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.web09.6919.1654315678603142173 for ; Fri, 03 Jun 2022 21:07:59 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=aNiOL7WD; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: bob.c.feng@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654315678; x=1685851678; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=J6eoTmzmmjXVmo2tMpAf3fONL36cDgnc84Pq7Akhadw=; b=aNiOL7WDgaJM/MR/Z2NAFiarTlHub8zzI/hyLWmX/N7L4s/fgV9WKpYX 1w6iw12NpJ8+3XSe2hQ5NECOgOHZzAnllge1R+0kE/cHPRzEsCKyHMeMv EpYYHFS0NX+vrfxFUZt5Pet3gsK5K/ATopTA5CcTlqKeR0ehn5O+Fl2lP ErlObp+wjQ1+FcvjVXGHcD5gFzCfeLqamC2Hb/xeIkPsNRMHToSMoARHj 5o1y2r9qOfIdPY7dJ2HQnFDLq7XxBDQwpATpTRaXsyJueMXFmOtXK9keN 1+JQi3PZ0faSO5nqOK0qwHMoN4JkXjRCA/3NeUpWCrY/WzXVdj1PfvEy5 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10367"; a="256256099" X-IronPort-AV: E=Sophos;i="5.91,276,1647327600"; d="scan'208";a="256256099" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2022 21:07:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,276,1647327600"; d="scan'208";a="681446653" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmsmga002.fm.intel.com with ESMTP; 03 Jun 2022 21:07:58 -0700 Received: from fmsmsx605.amr.corp.intel.com (10.18.126.85) 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.2308.27; Fri, 3 Jun 2022 21:07:57 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Fri, 3 Jun 2022 21:07:57 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.105) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Fri, 3 Jun 2022 21:07:56 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=luoCrpBZ2qEscnI1kTKi6RwH1sXfnVTdtCp4ILzYWmt52U3IEOq3FgOvSO0A3HGwn7YloHG8dm2TmNazkrMv76B7OJkcU3z34gKSC+Yap3IonnEIwV8ccJbnLGDip8MxGOpXrc+MxXE+YH9iP+sR3Tn8jJV5eVuE6MOpZqcIn0PhG74SvhqB/jOtQezoVOWpsScOdury3MlPlY1rDCqqjQUZwuW+WzEBOKvlNQ8sISONq6sB96n47kc84J3yVYox80Sk1xal/3iN5R2nAVDZ+AP1lKTNdnM0/jZCKLFgsfCBJVEH24pzYesc01HuHwyZoWsx+JOzjCF5Jb+XGm64JQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dBwEbGVHaQLSWS35H+2YMBwIeQl6jDOJ0syrMpDM50E=; b=FmQ9kp0bDa0l2rT3FFJmMnUIfh35sVXYE+ZUK0f5WRmGbrWqFH4B2ky1jKKGEAuoW04IgyIxWpMM2pxHc1tK9Ia8VSQpyy7re61pWDbu9HlKnZe5UbgfWVquJuWnpBqSjr0KMUdY6GCoJyy1cF28YYpEA55XEGZUwV8/1jqBMCG2dQPaCLMiJKV4r/IW9uEsNn2XTKmcItF1Om8DX8ov8n24fwrSEszfmBG8ly50eYqaZ2emSfOVKKdm7mbNngJbioq4nYsodqSagmRZn+y1XX9QSQGrivd4zfue8G1yp6MhztpsUIN1tj8QbfsigyNb8eO7We9K5AMJ1oqwUHh53g== 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 Received: from PH7PR11MB5863.namprd11.prod.outlook.com (2603:10b6:510:135::11) by PH0PR11MB5641.namprd11.prod.outlook.com (2603:10b6:510:d6::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.15; Sat, 4 Jun 2022 04:07:55 +0000 Received: from PH7PR11MB5863.namprd11.prod.outlook.com ([fe80::4d85:900e:e547:4ba0]) by PH7PR11MB5863.namprd11.prod.outlook.com ([fe80::4d85:900e:e547:4ba0%9]) with mapi id 15.20.5314.013; Sat, 4 Jun 2022 04:07:55 +0000 From: "Bob Feng" To: "Lin, Jason1" , "devel@edk2.groups.io" CC: "Gao, Liming" , "Chen, Christine" , "Chiang, Dakota" , "Chuang, Vanessa" Subject: Re: [PATCH v1] [edk2-platforms] Silicon/Intel/FitGen: Fix CheckOverlap would do incorrect split BiosModule action in corner case Thread-Topic: [PATCH v1] [edk2-platforms] Silicon/Intel/FitGen: Fix CheckOverlap would do incorrect split BiosModule action in corner case Thread-Index: AQHYcN3d71YkbYNoy0WoDM4HZnIESK0+rCRQ Date: Sat, 4 Jun 2022 04:07:55 +0000 Message-ID: References: <20220526085148.423-1-jason1.lin@intel.com> In-Reply-To: <20220526085148.423-1-jason1.lin@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.6.500.17 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 017a803a-7a98-4305-ba5a-08da45dfcd9d x-ms-traffictypediagnostic: PH0PR11MB5641:EE_ x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: qPt4EgaNMGcGyLn/wBPOgohFPCt6S4dlS4emXAA15alhfVO6rkQItsdK+SdQ8WiIbbwiasoyAnOIGjfo2Bviyp9HtmSbmUpX4itUEmXTkt0IWNGtmcdOv+ySl92fJ0wPEVt2dDIoA2V9LvX0TNrLQiOONOlNa7vvfr6IgnxBQcIRlo2p020FYOZMVTQ0oaTdt6RTM+l9zmymSDk2SFN1lfikvInbGh1mp1qR95Rp7p35TVekyXjx6cbpJgcfrbqkVuTkl8LrXZWrJLPWm5qUFg5lmpZ5xHVBtPPf28SCMpNzjNsE5hkCsImUunOAVKnYb1OdWMOtlUsuDVfMwwRnBe2o6+Yk9tWYULuUPI/hQTMDDdxo9es/6LcDH9ImHj6M09ULSVmkun1Bl1z++e8XMpTU/DFTEcq0Zo0fgJafo3QGQiwKiayKLYFLIMVQ4A+5jhfqgDDMZT5IbVKNDBTxbP0e4N+DL0HmQQTRyC3uUFCTh1w2MIWicB9nmBeQriH8AHF7J3O9eZpkGuQYGpDcbrjghRKy/v7YnaIfaWDPg1KJ/yqZjJTG6/aQ/QinUz96aZoYTPcpWIHwyQ/F+d8JMhy7WSoA5dp4AwjaRMdncgUqTjs9bwNGYz22D3apvgF38M1IC2fcZysK7j7JOAZXzQ6D/77/9txKYbHGBEj2F114hh9j7RqkidTlUxs1SKUOlHeT1u/afyYmCW6zZv8oY+aP4QXIUn6voUi6rpoP0HRp+OtbAOc+arSJ48ZoU4cu5GtVxoXN0ZTw2BHjo59hupLrQmjyycHisurPksUQkU8= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH7PR11MB5863.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(366004)(5660300002)(107886003)(966005)(26005)(55016003)(8936002)(508600001)(9686003)(86362001)(316002)(71200400001)(52536014)(6506007)(83380400001)(33656002)(2906002)(53546011)(7696005)(186003)(4326008)(38100700002)(66556008)(64756008)(66446008)(66946007)(66476007)(8676002)(38070700005)(110136005)(122000001)(54906003)(82960400001)(76116006);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?wz5cY7FDLfqLADweOp3YMhxQNb2sbQ6Q/EijXA7W/VRU+CSDuHRahH10+Se0?= =?us-ascii?Q?AMRLGQ5jApt398dkW6UP+oX5qolU8vjdW6Gjm9nuNvDryPkGOmooJMwt7QPH?= =?us-ascii?Q?BsfBT+yzBT1i+LzXsd1pP9TVdxklWUnbB/9ny11dOSo5oSvuLnajIJiW72c1?= =?us-ascii?Q?XNLpHumIB2o+jp2b4FbH2qeol+HlOkWunOHFFSjRUeBL+ir5GcXGH3Nzq2/+?= =?us-ascii?Q?OQrVy+VdBlpAso1mg+t/i9RnS5PB9wxK7wdxQvzKIxYhhMMRLISdPt/vgTC6?= =?us-ascii?Q?rIVTbk5RB8JJL6PRIw2vm0Sskrnr4YLVBXbgbHvmsvW0DSm1qjhvxp6RvX5K?= =?us-ascii?Q?x64PdwdamTAECvyLopZf371UZRRPp+WllUKqmTHWdwQZKAybAM7/3m4I4xMv?= =?us-ascii?Q?gtgFiHY1ujQaFj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ascii?Q?qrz2iQlvHQfZMOz10vmU9FvJ/172TTwIyW/W6G0WTpXvupgBiqhP7CTYARrM?= =?us-ascii?Q?0tyIrP9rELboKXXRLcmYz8xv5Hg95o2eyp3cKcLFFm2ELymJFeO4l4HZfvuu?= =?us-ascii?Q?K+/U6sc00mEnZ8qbxusbul/qbuYhrEb3rR6ZxHuSstIwY/DTSg2Y5LyY5sYa?= =?us-ascii?Q?ehQc2mFYh98hiS/Z0z7VB51p48C0/amHPKWk7Amw8q3ugG7doAoy8S7FgSq6?= =?us-ascii?Q?R49jkI5IiVX23d35P0Ue2OdV0NrrW4Ca1NWUl1CtVLEHuucdho8emmsG9nJS?= =?us-ascii?Q?LAUR/99JQgJ+l3tXcJO4hyPm3TGUOePH666DSbk0fG5pwV2Ysy/Sf4UTCner?= =?us-ascii?Q?2TwRRzmXaS1t/aA5gf7b7oYQz8FwZADlo25va+ke0HXeekYAjUGlzhNTkOfu?= =?us-ascii?Q?+pww1lIcRQ=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH7PR11MB5863.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 017a803a-7a98-4305-ba5a-08da45dfcd9d X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Jun 2022 04:07:55.5879 (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: x0flphPEsFvoVf9LCdogQZBVjTgiASZv/wC5AF5oWI4QiVteBDwRsVF+sZdl4eyt1haHHU7OJd8mBKR+4XCkfw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5641 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 Jason, Do you think the code could be more understandable if adding a check for th= e size?=20 if ((gFitTableContext.BiosModule[Index].Address <=3D Address) && (gFitTable= Context.BiosModule[Index].Size >=3D Size) && ((gFitTableContext.BiosModule[Index].Size - Size) >=3D (Address - g= FitTableContext.BiosModule[Index].Address))) Thanks, Bob -----Original Message----- From: Lin, Jason1 =20 Sent: Thursday, May 26, 2022 4:52 PM To: devel@edk2.groups.io Cc: Lin, Jason1 ; Feng, Bob C ;= Gao, Liming ; Chen, Christine ; Chiang, Dakota ; Chuang, Vanessa Subject: [PATCH v1] [edk2-platforms] Silicon/Intel/FitGen: Fix CheckOverlap= would do incorrect split BiosModule action in corner case From: Jason1 Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3922 [Description] CheckOverlap function would do incorrect split on the BiosModule which not = happen overlap. This would cause incorrect value locate in FIT entry record= . [Condition] - This BiosModule base address is lower than input address. - This BiosModule size is smaller than input size. [Resolution] - Do the type coversion to UINT64 to prevent overflow when the value shuld = be nagative. - Do the type coversion from UINT64 to INT64 to do the comparsion with poss= ible nagative value. Signed-off-by: Jason1 Lin Cc: Bob Feng Cc: Liming Gao Cc: Yuwei Chen Cc: Dakota Chiang Cc: Vanessa Chuang --- Silicon/Intel/Tools/FitGen/FitGen.c | 30 +++++++++++++++++++- Silicon/Int= el/Tools/FitGen/FitGen.h | 2 +- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c b/Silicon/Intel/Tools/FitG= en/FitGen.c index 290e688f6e..9d7185dc55 100644 --- a/Silicon/Intel/Tools/FitGen/FitGen.c +++ b/Silicon/Intel/Tools/FitGen/FitGen.c @@ -755,12 +755,40 @@ CheckOverlap ( IN UINT32 Address, IN UINT32 Size )+/*+++Routine Description:++ Che= ck wheather the input address and size is overlap with any BiosModule.+ If= happen overlap, need to be deal with this case.+ --- +----------= ----+ <------ BiosModule A Base +--------------++ | |= | | |+ = | | | BiosModule= |+ | | | = A |+ | | = | |+ BiosModule A +--------------+ <------ [Input] Add= ress =3D=3D=3D=3D> +--------------++ Size | | = |+ | | | [Input] Size+ +--= ------------+ ------ +--------------++ = | | | BiosModule = |+ | | | | = B |+ --- +--------------+ = +--------------+++Arguments:++ Address - The address of the buffe= r that required to check.+ Size - The size of the buffer that requi= red to check.++Returns:++ None++--*/ { INTN Index; for (Index =3D 0;= Index < (INTN)gFitTableContext.BiosModuleNumber; Index ++) { if ((gFit= TableContext.BiosModule[Index].Address <=3D Address) &&- ((gFitTable= Context.BiosModule[Index].Size - Size) >=3D (Address - gFitTableContext.Bio= sModule[Index].Address))) {+ ((INT64)((UINT64)gFitTableContext.BiosM= odule[Index].Size - (UINT64)Size) >=3D (INT64)((UINT64)Address - (UINT64)gF= itTableContext.BiosModule[Index].Address))) { UINT32 TempSize; = INT32 SubIndex; diff --git a/Silicon/Intel/Tools/FitGen/FitGen.h b/Silic= on/Intel/Tools/FitGen/FitGen.h index 5add6a8870..4943ee259c 100644 --- a/Silicon/Intel/Tools/FitGen/FitGen.h +++ b/Silicon/Intel/Tools/FitGen/FitGen.h @@ -31,7 +31,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // Utility version information // #define UTILITY_MAJOR_VERSION 0-#define = UTILITY_MINOR_VERSION 64+#define UTILITY_MINOR_VERSION 65 #define UTILITY_D= ATE __DATE__ //--=20 2.36.1.windows.1