From nobody Sat May 18 23:23:42 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+90050+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+90050+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1653572597; cv=none; d=zohomail.com; s=zohoarc; b=Bw002zyv8jBE63+gtsrQIwF9+B51WVulf81ttl1CIWdijtr1giFhNbY/Oud3EH8vdWLlkn9gq6SRhK01fYSYGX4QA4iACpPOIXS/0FwoQHOOjrrpJzIjzk2DpyGBBcLj+sGq+soadbi342LdyEjzMlHPmQ7QGvamPnR1ACeaMiA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653572597; 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=JI496MiXxb/HFC01CLDm+V5pSKWZe0aLX/MbfzuDELw=; b=lrI/bfMmL5+okKzs0u8KLaqmswEY82jc44ryf9NqMDO3HIBrBJFalMaDPrnk78OGTOaL+4FGlO/niCBuObm2gZEp2KJS9IfzzzkBsnDviAhvRgAE+m0fZL+SiYcT71sA/TKBJNr0N4CF5qQMchQoZRYmko4lc4IK49lGNo07QU8= 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+90050+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 1653572597692908.3944452482853; Thu, 26 May 2022 06:43:17 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 9oIeYY1788612xNjyEVbcPjw; Thu, 26 May 2022 06:43:17 -0700 X-Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web10.17165.1653550842117963391 for ; Thu, 26 May 2022 00:40:42 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10358"; a="261682595" X-IronPort-AV: E=Sophos;i="5.91,252,1647327600"; d="scan'208";a="261682595" X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2022 00:40:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,252,1647327600"; d="scan'208";a="718139475" X-Received: from gguo-desk.gar.corp.intel.com ([10.5.215.23]) by fmsmga001.fm.intel.com with ESMTP; 26 May 2022 00:40:30 -0700 From: jason1.lin@intel.com To: devel@edk2.groups.io Cc: Jason1 Lin , Bob Feng , Liming Gao , Yuwei Chen , Dakota Chiang , Vanessa Chuang Subject: [edk2-devel] [PATCH v1] [edk2-platforms] Silicon/Intel/FitGen: Fix CheckOverlap would do incorrect split BiosModule action in corner case Date: Thu, 26 May 2022 15:40:27 +0800 Message-Id: <20220526074027.218-1-jason1.lin@intel.com> 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,jason1.lin@intel.com X-Gm-Message-State: F8FKtf6D7zpndG1SVHceCvgux1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1653572597; bh=T6uwZEFme3e++DY+pun0DG0G3rf+xyoPP3DQpV8qiXA=; h=Cc:Date:From:Reply-To:Subject:To; b=M0lxuczdUJeHILPoZ7Ghe3jh9xwQ1Re9VgFApdu2ffWJPx/ck8x1svDjczuJo3B6J75 PXMGlPSQJRHZgOPdP8W4BUcjOCDcRhvOghYD1btsJZiRp33UlJy0bxusgwRpGs9FZWTgE 4wEMdMLrj3+YZTJrUHYFt22epZ8X2LLz3Bk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1653572599711100006 Content-Type: text/plain; charset="utf-8" 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/Intel/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: + + Check wheather the input address and size is overlap with any BiosModule. + If happen overlap, need to be deal with this case. + --- +--------------+ <------ BiosModule A Base +-----= ---------+ + | | | | = | + | | | Bio= sModule | + | | | = A | + | | | = | + BiosModule A +--------------+ <------ [Input] Address =3D=3D=3D=3D> = +--------------+ + Size | | | + | | | [Input] Size + +--------------+ ------ +-----= ---------+ + | | | Bio= sModule | + | | | | = B | + --- +--------------+ +-----= ---------+ + +Arguments: + + Address - The address of the buffer that required to check. + Size - The size of the buffer that required to check. + +Returns: + + None + +--*/ { INTN Index; =20 for (Index =3D 0; Index < (INTN)gFitTableContext.BiosModuleNumber; Index= ++) { if ((gFitTableContext.BiosModule[Index].Address <=3D Address) && - ((gFitTableContext.BiosModule[Index].Size - Size) >=3D (Address - = gFitTableContext.BiosModule[Index].Address))) { + ((INT64)((UINT64)gFitTableContext.BiosModule[Index].Size - (UINT64= )Size) >=3D (INT64)((UINT64)Address - (UINT64)gFitTableContext.BiosModule[I= ndex].Address))) { UINT32 TempSize; INT32 SubIndex; =20 diff --git a/Silicon/Intel/Tools/FitGen/FitGen.h b/Silicon/Intel/Tools/FitG= en/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_DATE __DATE__ =20 // --=20 2.36.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 (#90050): https://edk2.groups.io/g/devel/message/90050 Mute This Topic: https://groups.io/mt/91354490/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-