From nobody Sat May 18 21:00:39 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+90051+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+90051+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1653572598; cv=none; d=zohomail.com; s=zohoarc; b=JQaLgoplTTTnruYeZchX+xu+PqQx63QWXuyOEiOB+izMnYWXZKv32l/fNGhu+XLe4HTUHz2S/OkENhtx9FVjpOpnF076rz1yV7BUEpnmkdmeSZj3j/ZWiA5fLUVRx8n0HE6/v9nq8KM4Hwwzl4IAgQOy8stbRD8nzodAT986pqc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1653572598; 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=6Eh1m0CCl5tVaRIU0+dT5XY7GvnES4v6f54nEjd9Hy0=; b=VXZApCFI4LqHh7c5IgFVloB6g0yslEWOEDpwzXTak7yejAwi19IiZ+X39Wcw5QeGG4BI6t4tp5DV5Je/UrXJyzkNGMHoBUMXEI1ilHTBvr3igTHmwXNVeh4sWWzpWEIvMO+GHA1d5yQQVkysoIHzK9TGcZ85prfFBJtAIHhk2k0= 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+90051+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 1653572598635629.3445813394881; Thu, 26 May 2022 06:43:18 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id NiBMYY1788612xUieNue784x; Thu, 26 May 2022 06:43:18 -0700 X-Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web12.17441.1653555114344984120 for ; Thu, 26 May 2022 01:51:55 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10358"; a="271661376" X-IronPort-AV: E=Sophos;i="5.91,252,1647327600"; d="scan'208";a="271661376" X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2022 01:51:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,252,1647327600"; d="scan'208";a="821153241" X-Received: from linjaso1-desk1.gar.corp.intel.com ([10.5.215.41]) by fmsmga006.fm.intel.com with ESMTP; 26 May 2022 01:51:51 -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 16:51:48 +0800 Message-Id: <20220526085148.423-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: f9o8ZbyxcuOqg48Kl8BjMS13x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1653572598; bh=Z5jW7rpKhGsn+rG9PVbvDdKVv6vnndV+udDmJukFglA=; h=Cc:Date:From:Reply-To:Subject:To; b=F16P9wjlNxwEyX4E65WRrFfSX6/eD8MeDjTGOxyCiQPZ2VeKKdyFRbj7SDTyYwgm4NW bE3yvoMZLTq95bvYGbKX3ERe3y4oWXG/xxE8ueB9AC1WazZWXsjE6vlCtzdMxTdSvhsAW hK9Q4xrB3woY+gF9e5fr2GNZWeYX1/F23kY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1653572599707100005 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 (#90051): https://edk2.groups.io/g/devel/message/90051 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-